Skip to content

Commit 186f3b1

Browse files
committed
[_621] add functions to write .irodsA
1 parent afac630 commit 186f3b1

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

irods/client_init.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import irods.client_configuration as cfg
2+
import irods.password_obfuscation as obf
3+
import irods.helpers as h
4+
import getpass
5+
import sys
6+
7+
def write_credentials_with_native_password( password ):
8+
s = h.make_session()
9+
assert(not s.auth_file)
10+
open(s.pool.account.derived_auth_file,'w').write(obf.encode(password))
11+
return True
12+
13+
def write_credentials_with_pam_password( password ):
14+
s = h.make_session()
15+
assert(not s.auth_file)
16+
s.pool.account.password = password
17+
with cfg.loadlines( [dict(setting='legacy_auth.pam.password_for_auto_renew',value='')] ):
18+
to_encode = s.pam_pw_negotiated
19+
if to_encode:
20+
open(s.pool.account.derived_auth_file,'w').write(obf.encode(to_encode[0]))
21+
return True
22+
return False
23+
24+
if __name__ == '__main__':
25+
vector = {
26+
'pam': write_credentials_with_pam_password,
27+
'native': write_credentials_with_native_password,
28+
}
29+
30+
if sys.argv[1] in vector:
31+
vector[sys.argv[1]](getpass.getpass(prompt=f'{sys.argv[1]} password: '))
32+
else:
33+
print('did not recognize authentication scheme argument',file = sys.stderr)

0 commit comments

Comments
 (0)