diff options
| author | LV-426 <lv-426@taproot.org.il> | 2015-01-13 16:57:09 +0200 |
|---|---|---|
| committer | LV-426 <lv-426@taproot.org.il> | 2015-01-13 16:57:09 +0200 |
| commit | a71427cfcefd9c92af7117153de3a6e055981677 (patch) | |
| tree | 484bfcce1e6ab3854d6854e9b651acd3990e06f2 /src/local | |
| parent | 6b7b3f9cce9428e86ea1ca4c8fbcd92c45286e7a (diff) | |
add_user_login(): refactoring out of cryp_util (not needed in production)
Diffstat (limited to 'src/local')
| -rw-r--r-- | src/local/rz_cli_tool.py | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/local/rz_cli_tool.py b/src/local/rz_cli_tool.py index 1dea8559..93cc132a 100644 --- a/src/local/rz_cli_tool.py +++ b/src/local/rz_cli_tool.py @@ -8,6 +8,18 @@ from rz_server import init_config def init_pw_db(cfg, user_pw_list_file): + + def add_user_login(htpasswd_path, salt, u, p): + with open(htpasswd_path, 'rb') as f: + data = f.read() + pw_db = pickle.loads(data) + + with open(htpasswd_path, 'wb') as f: + pw_db[u] = hash_pw(str(p), salt) + pickle.dump(pw_db, f) + + log.info('htpasswd db: added entry: user: %s, pw: %s...' % (u, pw_db[u][:5])) + htpasswd_path = cfg.htpasswd_path if os.path.exists(htpasswd_path): @@ -32,7 +44,7 @@ def init_pw_db(cfg, user_pw_list_file): raise Exception('failed to parse user,pw line: ' + line) user, pw = map(str.strip, kv_arr) - crypt_util.add_user_login(htpasswd_path, salt, user, pw) + add_user_login(htpasswd_path, salt, user, pw) print('added user: u: ' + user) u_count = u_count + 1 print('htpasswd generated: path: %s, user-count: %d' % (htpasswd_path, u_count)) |
