From 51d2436023fafe0c9dadaa23d85ed4fe4d506fe7 Mon Sep 17 00:00:00 2001 From: Brandon Philips Date: Fri, 17 Dec 2010 17:17:40 -0800 Subject: [PATCH] conf: detect and handle blank usernames Fix situation where osc has added a blank username to the keyring and update the config parse script to do the right thing and not allow blank usernames. I was in a very confusing situation where my keyring ended up with two entries: - @api.suse.de - philipsb@api.suse.de And I was getting 401s because of it. Signed-off-by: Brandon Philips --- osc/conf.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/osc/conf.py b/osc/conf.py index e1d74b34..35c2c7de 100644 --- a/osc/conf.py +++ b/osc/conf.py @@ -769,6 +769,13 @@ def get_config(override_conffile = None, except gnomekeyring.NoMatchError: # Fallback to file based auth. pass + + if not user is None and len(user) == 0: + user = None + print >>sys.stderr, "Warning: blank user in the keyring for the "\ + "api url %s.\nRun seahorse to fix the "\ + "entry.\n" % (url) + # Read credentials from config if user is None: #FIXME: this could actually be the ideal spot to take defaults @@ -776,6 +783,10 @@ def get_config(override_conffile = None, user = cp.get(url, 'user', raw=True) # need to set raw to prevent '%' expansion password = cp.get(url, 'pass', raw=True) # especially on password! passwordx = cp.get(url, 'passx', raw=True) # especially on password! + if user is None or len(user) == 0: + raise oscerr.ConfigError("user is blank for %s" % apiurl, + config['conffile']) + if password is None or password == 'your_password': try: password = passwordx.decode('base64').decode('bz2')