@@ -34,8 +34,6 @@ static MQZ_TERM_AUTHORITY mqhtpass_terminate;
3434#define HTPASSWD_FILE "/etc/mqm/mq.htpasswd"
3535#define NAME "MQ Advanced for Developers custom authentication service"
3636
37- static char * trim (char * s );
38-
3937/**
4038 * Initialization and entrypoint for the dynamically loaded
4139 * authorization installable service. It registers the addresses of the
@@ -80,7 +78,7 @@ void MQENTRY MQStart(
8078 {
8179 log_infof ("Initializing %s" , NAME );
8280 }
83- log_debugf ("MQStart options=%s qmgr=%s" , ((Options == MQZIO_SECONDARY ) ? "Secondary" : "Primary" ), trim (QMgrName ) );
81+ log_debugf ("MQStart options=%s qmgr=%.* s" , ((Options == MQZIO_SECONDARY ) ? "Secondary" : "Primary" ), trimmed_len (QMgrName , MQ_Q_MGR_NAME_LENGTH ), QMgrName );
8482
8583 if (!htpass_valid_file (HTPASSWD_FILE ))
8684 {
@@ -176,11 +174,14 @@ static void MQENTRY mqhtpass_authenticate_user_csp(
176174 // Tell the queue manager to continue trying other authorization services, as they might have the user.
177175 * pContinuation = MQZCI_CONTINUE ;
178176 log_debugf (
179- "User authentication failed due to invalid user. user=%s effuser=%s applname=%s csp_user=%s cc=%d reason=%d" ,
180- trim (pIdentityContext -> UserIdentifier ),
181- trim (pApplicationContext -> EffectiveUserID ),
182- trim (pApplicationContext -> ApplName ),
183- trim (csp_user ),
177+ "User authentication failed due to invalid user. user=%.*s effuser=%.*s applname=%.*s csp_user=%s cc=%d reason=%d" ,
178+ trimmed_len (pIdentityContext -> UserIdentifier , MQ_USER_ID_LENGTH ),
179+ pIdentityContext -> UserIdentifier ,
180+ trimmed_len (pApplicationContext -> EffectiveUserID , MQ_USER_ID_LENGTH ),
181+ pApplicationContext -> EffectiveUserID ,
182+ trimmed_len (pApplicationContext -> ApplName , MQ_APPL_NAME_LENGTH ),
183+ pApplicationContext -> ApplName ,
184+ csp_user ,
184185 * pCompCode ,
185186 * pReason );
186187 }
@@ -192,11 +193,14 @@ static void MQENTRY mqhtpass_authenticate_user_csp(
192193 // Tell the queue manager to stop trying other authorization services.
193194 * pContinuation = MQZCI_STOP ;
194195 log_debugf (
195- "User authentication failed due to invalid password. user=%s effuser=%s applname=%s csp_user=%s cc=%d reason=%d" ,
196- trim (pIdentityContext -> UserIdentifier ),
197- trim (pApplicationContext -> EffectiveUserID ),
198- trim (pApplicationContext -> ApplName ),
199- trim (csp_user ),
196+ "User authentication failed due to invalid password. user=%.*s effuser=%.*s applname=%.*s csp_user=%s cc=%d reason=%d" ,
197+ trimmed_len (pIdentityContext -> UserIdentifier , MQ_USER_ID_LENGTH ),
198+ pIdentityContext -> UserIdentifier ,
199+ trimmed_len (pApplicationContext -> EffectiveUserID , MQ_USER_ID_LENGTH ),
200+ pApplicationContext -> EffectiveUserID ,
201+ trimmed_len (pApplicationContext -> ApplName , MQ_APPL_NAME_LENGTH ),
202+ pApplicationContext -> ApplName ,
203+ csp_user ,
200204 * pCompCode ,
201205 * pReason );
202206 }
@@ -275,11 +279,14 @@ static void MQENTRY mqhtpass_authenticate_user(
275279 else
276280 {
277281 log_debugf (
278- "User authentication failed user=%s effuser=%s applname=%s cspuser=%s cc=%d reason=%d" ,
279- trim (pIdentityContext -> UserIdentifier ),
280- trim (pApplicationContext -> EffectiveUserID ),
281- trim (pApplicationContext -> ApplName ),
282- trim (spuser ),
282+ "User authentication failed user=%.*s effuser=%.*s applname=%.*s cspuser=%s cc=%d reason=%d" ,
283+ trimmed_len (pIdentityContext -> UserIdentifier , MQ_USER_ID_LENGTH ),
284+ pIdentityContext -> UserIdentifier ,
285+ trimmed_len (pApplicationContext -> EffectiveUserID , MQ_USER_ID_LENGTH ),
286+ pApplicationContext -> EffectiveUserID ,
287+ trimmed_len (pApplicationContext -> ApplName , MQ_APPL_NAME_LENGTH ),
288+ pApplicationContext -> ApplName ,
289+ spuser ,
283290 * pCompCode ,
284291 * pReason );
285292 }
@@ -333,18 +340,3 @@ static void MQENTRY mqhtpass_terminate(
333340 * pReason = MQRC_NONE ;
334341}
335342
336- /**
337- * Remove trailing spaces from a string.
338- */
339- static char * trim (char * s )
340- {
341- int i ;
342- for (i = strlen (s ) - 1 ; i >= 0 ; i -- )
343- {
344- if (s [i ] == ' ' )
345- s [i ] = 0 ;
346- else
347- break ;
348- }
349- return s ;
350- }
0 commit comments