Re: [Freeipa-devel] [PATCH] 004 Log script options to logfile

2010-11-09 Thread Jakub Hrozek
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 11/09/2010 07:28 PM, Rob Crittenden wrote:
 Jakub Hrozek wrote:
 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1

 On 11/08/2010 09:12 PM, Jakub Hrozek wrote:
 This patch is fine as-is so I'll give you a choice:

 1. You can update this patch and log those things that will be queried
 if not provided on the CLI.
 I'd prefer this option. The patch really is incomplete.

 New patch attached.
 
 Ack, pushed to master
 
 rob

Are you sure you pushed the second patch (-02) ? Looking at what's in
master, it looks like the first version..

Jakub
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/

iEYEARECAAYFAkzZq1IACgkQHsardTLnvCVKJACcCKjrIyigJ7fg8ItTXWxFl+0V
ZMMAoKSfh0A0z1b2EJYLO33yWN8s1Jn5
=aI0u
-END PGP SIGNATURE-

___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel


Re: [Freeipa-devel] [PATCH] 004 Log script options to logfile

2010-11-08 Thread Rob Crittenden

Jakub Hrozek wrote:

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Uses a new subclass IPAOptionParser in scripts instead of OptionParser
from the standard python library. IPAOptionParser uses its own IPAOption
class to store options, which adds a new 'sensitive' attribute.

https://fedorahosted.org/freeipa/ticket/393


This is a good start and does what I requested, I just wasn't clear 
enough in the request.


I think we should log the interactive data as well.

This patch is fine as-is so I'll give you a choice:

1. You can update this patch and log those things that will be queried 
if not provided on the CLI.


2. I can ACK and push this and we can open a new ticket for additional 
enhancements.


rob

___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel


Re: [Freeipa-devel] [PATCH] 004 Log script options to logfile

2010-11-08 Thread Jakub Hrozek
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 11/08/2010 09:00 PM, Rob Crittenden wrote:
 Jakub Hrozek wrote:
 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1

 Uses a new subclass IPAOptionParser in scripts instead of OptionParser
 from the standard python library. IPAOptionParser uses its own IPAOption
 class to store options, which adds a new 'sensitive' attribute.

 https://fedorahosted.org/freeipa/ticket/393
 
 This is a good start and does what I requested, I just wasn't clear
 enough in the request.
 
 I think we should log the interactive data as well.
 

Oh, right..

 This patch is fine as-is so I'll give you a choice:
 
 1. You can update this patch and log those things that will be queried
 if not provided on the CLI.

I'd prefer this option. The patch really is incomplete.
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/

iEYEARECAAYFAkzYWaMACgkQHsardTLnvCW2owCdEn/QD9LiB0+4vZy/KTW8x1Et
CbAAoKoqq3GYGKaTKdwwZAjNuym0p6qq
=d3jn
-END PGP SIGNATURE-

___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel


[Freeipa-devel] [PATCH] 004 Log script options to logfile

2010-11-01 Thread Jakub Hrozek
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Uses a new subclass IPAOptionParser in scripts instead of OptionParser
from the standard python library. IPAOptionParser uses its own IPAOption
class to store options, which adds a new 'sensitive' attribute.

https://fedorahosted.org/freeipa/ticket/393
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/

iEYEARECAAYFAkzPFocACgkQHsardTLnvCXxagCg1tuQv+lSo+i2f02WSYncQrRi
zZoAoKHoB/6qO5atlxUdw8G9X4nUf/TL
=oZDX
-END PGP SIGNATURE-
From 1eabce20969622f02165d5a64da3444ac9c44278 Mon Sep 17 00:00:00 2001
From: Jakub Hrozek jhro...@redhat.com
Date: Fri, 29 Oct 2010 20:24:31 +0200
Subject: [PATCH] Log script options to logfile

Uses a new subclass IPAOptionParser in scripts instead of OptionParser
from the standard python library. IPAOptionParser uses its own IPAOption
class to store options, which adds a new 'sensitive' attribute.

https://fedorahosted.org/freeipa/ticket/393
---
 install/tools/ipa-dns-install |   13 +---
 install/tools/ipa-ldap-updater|   10 ---
 install/tools/ipa-replica-install |   12 +---
 install/tools/ipa-server-install  |   23 +--
 ipa-client/ipa-install/ipa-client-install |   12 +---
 ipapython/config.py   |   42 -
 6 files changed, 83 insertions(+), 29 deletions(-)

diff --git a/install/tools/ipa-dns-install b/install/tools/ipa-dns-install
index ece77ec..8502e3b 100755
--- a/install/tools/ipa-dns-install
+++ b/install/tools/ipa-dns-install
@@ -19,7 +19,6 @@
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 #
 
-from optparse import OptionParser
 import traceback
 
 from ipaserver.plugins.ldap2 import ldap2
@@ -28,11 +27,12 @@ from ipaserver.install.installutils import *
 from ipapython import version
 from ipapython import ipautil, sysrestore
 from ipalib import api, errors, util
+from ipapython.config import IPAOptionParser
 
 def parse_options():
-parser = OptionParser(version=version.VERSION)
+parser = IPAOptionParser(version=version.VERSION)
 parser.add_option(-p, --ds-password, dest=dm_password,
-  help=admin password)
+  sensitive=True, help=admin password)
 parser.add_option(-d, --debug, dest=debug, action=store_true,
   default=False, help=print debugging information)
 parser.add_option(--ip-address, dest=ip_address, help=Master Server IP Address)
@@ -46,6 +46,7 @@ def parse_options():
   default=False, help=unattended installation never prompts the user)
 
 options, args = parser.parse_args()
+safe_options = parser.get_safe_opts(options)
 
 if options.forwarders and options.no_forwarders:
 parser.error(You cannot specify a --forwarder option together with --no-forwarders)
@@ -56,7 +57,7 @@ def parse_options():
 if not options.forwarders and not options.no_forwarders:
 parser.error(You must specify at least one --forwarder option or --no-forwarders option)
 
-return options
+return safe_options, options
 
 def resolve_host(host_name):
 ip = None
@@ -76,7 +77,7 @@ def resolve_host(host_name):
 return ip
 
 def main():
-options = parse_options()
+safe_options, options = parse_options()
 
 if os.getegid() != 0:
 print Must be root to setup server
@@ -85,6 +86,8 @@ def main():
 standard_logging_setup(/var/log/ipaserver-install.log, options.debug, filemode='a')
 print \nThe log file for this installation can be found in /var/log/ipaserver-install.log
 
+logging.debug('%s was invoked with options: %s' % (sys.argv[0], safe_options))
+
 global fstore
 fstore = sysrestore.FileStore('/var/lib/ipa/sysrestore')
 
diff --git a/install/tools/ipa-ldap-updater b/install/tools/ipa-ldap-updater
index f3b83ce..51db012 100755
--- a/install/tools/ipa-ldap-updater
+++ b/install/tools/ipa-ldap-updater
@@ -25,7 +25,7 @@
 
 import sys
 try:
-from optparse import OptionParser
+from ipapython.config import IPAOptionParser
 from ipapython import ipautil, config
 from ipaserver.install import installutils
 from ipaserver.install.ldapupdate import LDAPUpdate, BadSyntax, UPDATES_DIR
@@ -44,7 +44,7 @@ error was:
 def parse_options():
 usage = %prog [options] input_file(s)\n
 usage += %prog [options]\n
-parser = OptionParser(usage=usage, formatter=config.IPAFormatter())
+parser = IPAOptionParser(usage=usage, formatter=config.IPAFormatter())
 
 parser.add_option(-d, --debug, action=store_true, dest=debug,
   help=Display debugging information about the update(s))
@@ -59,10 +59,11 @@ def parse_options():
 
 config.add_standard_options(parser)
 options, args = parser.parse_args()
+safe_options = parser.get_safe_opts(options)
 
 config.init_config(options)
 
-return options, args