Skip to content

Commit da490fc

Browse files
committed
force PAM api call; write .irodsA only in free func
1 parent 34e76f2 commit da490fc

2 files changed

Lines changed: 5 additions & 6 deletions

File tree

irods/client_init.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@ def write_credentials_with_native_password( password ):
1212

1313
def write_credentials_with_pam_password( password ):
1414
s = h.make_session()
15-
assert(not s.auth_file)
1615
s.pool.account.password = password
17-
with cfg.loadlines( [dict(setting='legacy_auth.pam.password_for_auto_renew',value='')] ):
16+
with cfg.loadlines( [dict(setting='legacy_auth.pam.password_for_auto_renew',value=None),
17+
dict(setting='legacy_auth.pam.store_password_to_environment',value=False)] ):
1818
to_encode = s.pam_pw_negotiated
19+
assert(not s.auth_file)
1920
if to_encode:
2021
open(s.pool.account.derived_auth_file,'w').write(obf.encode(to_encode[0]))
2122
return True

irods/connection.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -461,16 +461,14 @@ def _login_pam(self):
461461

462462
import irods.client_configuration as cfg
463463
inline_password = (self.account.authentication_scheme == self.account._original_authentication_scheme)
464-
# By default, let server determine the TTL.
465-
time_to_live_in_hours = 0
464+
time_to_live_in_hours = cfg.legacy_auth.pam.time_to_live_in_hours
466465
# For certain characters in the pam password, if they need escaping with '\' then do so.
467466
new_pam_password = PAM_PW_ESC_PATTERN.sub(lambda m: '\\'+m.group(1), self.account.password)
468-
if not inline_password:
467+
if not inline_password and cfg.legacy_auth.pam.password_for_auto_renew is not None:
469468
# Login using PAM password from .irodsA
470469
try:
471470
self._login_native()
472471
except (ex.CAT_PASSWORD_EXPIRED, ex.CAT_INVALID_USER, ex.CAT_INVALID_AUTHENTICATION) as exc:
473-
time_to_live_in_hours = cfg.legacy_auth.pam.time_to_live_in_hours
474472
if cfg.legacy_auth.pam.password_for_auto_renew:
475473
new_pam_password = cfg.legacy_auth.pam.password_for_auto_renew
476474
# Fall through and retry the native login later, after creating a new PAM password

0 commit comments

Comments
 (0)