[csw-devel] [PATCH] Add support for reading password from a file by default
Ben Walton
bwalton at opencsw.org
Fri Apr 22 18:31:48 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 if there is any IOError while reading from the file.
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..6396182 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, e:
+ logging.warning("Error reading %s: %s", authfile, e)
+ 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