[csw-devel] [PATCH] Add support for reading password from a file by default

Ben Walton bwalton at opencsw.org
Fri Apr 22 14:10:23 CEST 2011


Before asking the user for a password to submit their package, look
for it in /etc/opt/csw/releases/auth/$username.  Fall back to getpass
on any exception.

Signed-off-by: Ben Walton <bwalton at opencsw.org>
---
 gar/v2/lib/python/csw_upload_pkg.py |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/gar/v2/lib/python/csw_upload_pkg.py b/gar/v2/lib/python/csw_upload_pkg.py
index 822d69f..bfb4ece 100755
--- a/gar/v2/lib/python/csw_upload_pkg.py
+++ b/gar/v2/lib/python/csw_upload_pkg.py
@@ -570,8 +570,17 @@ if __name__ == '__main__':
     for error_tag in error_tags:
       print "*", error_tag
     sys.exit(1)
+
   username = os.environ["LOGNAME"]
-  password = getpass.getpass("{0}'s pkg release password> ".format(username))
+  authfile = os.path.join('/etc/opt/csw/releases/auth', username)
+
+  try:
+    with open(authfile, 'r') as af:
+      password = af.read().strip()
+  except IOError:
+    logging.warning("IOError while attempting to read password from {0}".format(authfile))
+    password = getpass.getpass("{0}'s pkg release password> ".format(username))
+
   uploader = Srv4Uploader(args,
                           options.rest_url,
                           os_release=os_release,
-- 
1.7.3.2



More information about the devel mailing list