1010import irods .password_obfuscation as obf
1111from irods import MAX_NAME_LEN
1212from ast import literal_eval as safe_eval
13+ import re
14+
15+
16+ PAM_PW_ESC_PATTERN = re .compile (r'([@=&;])' )
1317
1418
1519from irods .message import (
@@ -425,8 +429,10 @@ def _login_pam(self):
425429
426430 time_to_live_in_seconds = 60
427431
432+ pam_password = PAM_PW_ESC_PATTERN .sub (lambda m : '\\ ' + m .group (1 ), self .account .password )
433+
428434 ctx_user = '%s=%s' % (AUTH_USER_KEY , self .account .client_user )
429- ctx_pwd = '%s=%s' % (AUTH_PWD_KEY , self . account . password )
435+ ctx_pwd = '%s=%s' % (AUTH_PWD_KEY , pam_password )
430436 ctx_ttl = '%s=%s' % (AUTH_TTL_KEY , str (time_to_live_in_seconds ))
431437
432438 ctx = ";" .join ([ctx_user , ctx_pwd , ctx_ttl ])
@@ -441,7 +447,7 @@ def _login_pam(self):
441447
442448 message_body = PamAuthRequest (
443449 pamUser = self .account .client_user ,
444- pamPassword = self . account . password ,
450+ pamPassword = pam_password ,
445451 timeToLive = time_to_live_in_seconds )
446452 else :
447453
@@ -546,6 +552,7 @@ def _login_native(self, password=None):
546552 encoded_pwd_array = bytearray (encoded_pwd )
547553 encoded_pwd = bytes (encoded_pwd_array .replace (b'\x00 ' , b'\x01 ' ))
548554
555+
549556 pwd_msg = AuthResponse (
550557 response = encoded_pwd , username = self .account .proxy_user )
551558 pwd_request = iRODSMessage (
0 commit comments