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

Maciej Bliziński maciej at opencsw.org
Sat Apr 23 01:02:36 CEST 2011


2011/4/22 Ben Walton <bwalton at opencsw.org>:
> 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
>
>

LGTM


More information about the devel mailing list