From 7ade282e6edeac865d0c7f817a4c74c0d5ebeee4 Mon Sep 17 00:00:00 2001 From: Marcus Huewe Date: Sun, 14 Nov 2010 13:08:26 +0100 Subject: [PATCH] - rewrite pass to passx if pass and passx mismatch - do_config: automatically reread (which may lead to a rewrite) config if an option was changed --- osc/commandline.py | 5 ++++- osc/conf.py | 9 ++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/osc/commandline.py b/osc/commandline.py index 9fdace47..acb3ea63 100644 --- a/osc/commandline.py +++ b/osc/commandline.py @@ -6048,7 +6048,7 @@ Please submit there instead, or use --nodevelproject to force direct submission. if not inp: raise oscerr.WrongArgs('error: no value was entered') val = [inp] - opt, newval = conf.config_set_option(section, opt, ' '.join(val), delete=opts.delete, update=False) + opt, newval = conf.config_set_option(section, opt, ' '.join(val), delete=opts.delete, update=True) if newval is None and opts.delete: print '\'%s\': \'%s\' got removed' % (section, opt) elif newval is None: @@ -6057,6 +6057,9 @@ Please submit there instead, or use --nodevelproject to force direct submission. if opts.no_echo: # supress value print '\'%s\': set \'%s\'' % (section, opt) + elif opt == 'pass' and not conf.config['plaintext_passwd'] and newval == 'your_password': + opt, newval = conf.config_set_option(section, 'passx') + print '\'%s\': \'pass\' was rewritten to \'passx\': \'%s\'' % (section, newval) else: print '\'%s\': \'%s\' is set to \'%s\'' % (section, opt, newval) diff --git a/osc/conf.py b/osc/conf.py index 07c6e7a7..22e6e86e 100644 --- a/osc/conf.py +++ b/osc/conf.py @@ -766,10 +766,13 @@ def get_config(override_conffile = None, except: print "%s: no credentials known" % url password = 'your_password' - else: + elif password != passwordx.decode('base64').decode('bz2'): if not passwordx: - print "%s: rewriting from plain pass to encoded pass\n" % url - add_section(conffile, url, user, password) + # passx not present + print '%s: rewriting from plain pass to encoded pass\n' % url + else: + print '%s: pass and passx mismatch (rewriting from plain pass to encoded pass)\n' % url + add_section(conffile, url, user, password) if cp.has_option(url, 'http_headers'): http_headers = cp.get(url, 'http_headers')