2525from irods .message import (PamAuthRequest , PamAuthRequestOut )
2626
2727
28-
29- ALLOW_PAM_LONG_TOKENS = True # True to fix [#279]
3028# Message to be logged when the connection
3129# destructor is called. Used in a unit test
3230DESTRUCTOR_MSG = "connection __del__() called"
@@ -493,9 +491,10 @@ def _login_pam(self):
493491 if getattr (self ,'DISALLOWING_PAM_PLAINTEXT' ,True ):
494492 raise PlainTextPAMPasswordError
495493
496- Pam_Long_Tokens = (ALLOW_PAM_LONG_TOKENS and (len (ctx ) >= MAX_NAME_LEN ))
494+ use_dedicated_pam_api = len (ctx ) >= MAX_NAME_LEN or \
495+ {';' ,'=' }.intersection (set (new_pam_password ))
497496
498- if Pam_Long_Tokens :
497+ if use_dedicated_pam_api :
499498 message_body = PamAuthRequest ( pamUser = self .account .client_user ,
500499 pamPassword = new_pam_password ,
501500 timeToLive = time_to_live_in_hours )
@@ -505,7 +504,7 @@ def _login_pam(self):
505504 auth_req = iRODSMessage (
506505 msg_type = 'RODS_API_REQ' ,
507506 msg = message_body ,
508- int_info = ( 725 if Pam_Long_Tokens else 1201 )
507+ int_info = api_number [ 'PAM_AUTH_REQUEST_AN' if use_dedicated_pam_api else 'AUTH_PLUG_REQ_AN' ]
509508 )
510509
511510 self .send (auth_req )
@@ -516,8 +515,7 @@ def _login_pam(self):
516515 # TODO (#480): In Python3 will be able to do: 'raise RuntimeError(...) from exc' for more succinct error messages
517516 raise RuntimeError ('Client-configured TTL is outside server parameters (password min and max times)' )
518517
519- Pam_Response_Class = (PamAuthRequestOut if Pam_Long_Tokens
520- else AuthPluginOut )
518+ Pam_Response_Class = (PamAuthRequestOut if use_dedicated_pam_api else AuthPluginOut )
521519
522520 auth_out = output_message .get_main_message ( Pam_Response_Class )
523521
0 commit comments