mirror of
https://github.com/openSUSE/osc.git
synced 2025-02-25 19:52:12 +01:00
- use base64 module for base64 encoding (as suggested by Luke Imhoff)
This commit is contained in:
parent
7f9b4a37df
commit
97a6a9e63c
@ -391,11 +391,11 @@ def write_initial_config(conffile, entries, custom_template = ''):
|
|||||||
for the config file (e.g. { 'user' : 'username', 'pass' : 'password' } ).
|
for the config file (e.g. { 'user' : 'username', 'pass' : 'password' } ).
|
||||||
custom_template is an optional configuration template.
|
custom_template is an optional configuration template.
|
||||||
"""
|
"""
|
||||||
import StringIO, sys
|
import StringIO, sys, base64
|
||||||
conf_template = custom_template or new_conf_template
|
conf_template = custom_template or new_conf_template
|
||||||
config = DEFAULTS.copy()
|
config = DEFAULTS.copy()
|
||||||
config.update(entries)
|
config.update(entries)
|
||||||
config['passx'] = config['pass'].encode('bz2').encode('base64')
|
config['passx'] = base64.b64encode(config['pass'].encode('bz2'))
|
||||||
if config['use_keyring'] and GENERIC_KEYRING:
|
if config['use_keyring'] and GENERIC_KEYRING:
|
||||||
protocol, host = \
|
protocol, host = \
|
||||||
parse_apisrv_url(None, config['apiurl'])
|
parse_apisrv_url(None, config['apiurl'])
|
||||||
@ -437,6 +437,7 @@ def add_section(filename, url, user, passwd):
|
|||||||
"""
|
"""
|
||||||
Add a section to config file for new api url.
|
Add a section to config file for new api url.
|
||||||
"""
|
"""
|
||||||
|
import base64
|
||||||
global config
|
global config
|
||||||
cp = get_configParser(filename)
|
cp = get_configParser(filename)
|
||||||
try:
|
try:
|
||||||
@ -467,7 +468,7 @@ def add_section(filename, url, user, passwd):
|
|||||||
cp.set(url, 'user', user)
|
cp.set(url, 'user', user)
|
||||||
if not config['plaintext_passwd']:
|
if not config['plaintext_passwd']:
|
||||||
cp.remove_option(url, 'pass')
|
cp.remove_option(url, 'pass')
|
||||||
cp.set(url, 'passx', passwd.encode('bz2').encode('base64'))
|
cp.set(url, 'passx', base64.b64encode(passwd.encode('bz2')))
|
||||||
file = open(filename, 'w')
|
file = open(filename, 'w')
|
||||||
cp.write(file, True)
|
cp.write(file, True)
|
||||||
if file: file.close()
|
if file: file.close()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user