Skip to content

Commit bf44c66

Browse files
auth: Remove debug logging from aka_authorize and aka_cdb_fetch_av functions
1 parent f6fa361 commit bf44c66

2 files changed

Lines changed: 0 additions & 54 deletions

File tree

modules/auth_aka/aka_av_mgm.c

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -301,26 +301,13 @@ struct aka_av *aka_cdb_fetch_av(str *impu, str *impi, str *nonce)
301301
LM_DBG("fetching AV key=%.*s\n", key.len, key.s);
302302
get_ret = aka_cdbf.get(aka_cdb, &key, &value);
303303

304-
// #region agent log H4-cdb-get
305-
{FILE *_df = fopen("/tmp/debug.log", "a"); if(_df){fprintf(_df, "{\"hypothesisId\":\"H4\",\"location\":\"aka_av_mgm.c:aka_cdb_fetch_av\",\"message\":\"cdb_get_result\",\"data\":{\"get_ret\":%d,\"value_s\":\"%p\",\"value_len\":%d,\"key\":\"%.*s\"}}\n", get_ret, (void*)value.s, value.len, key.len, key.s); fclose(_df);}}
306-
// #endregion
307-
308304
if (get_ret < 0 || value.s == NULL) {
309305
LM_DBG("AV not found in cachedb for key=%.*s\n", key.len, key.s);
310306
pkg_free(key.s);
311307
return NULL;
312308
}
313309

314-
// #region agent log H1-deserialize-input
315-
{FILE *_df = fopen("/tmp/debug.log", "a"); if(_df){fprintf(_df, "{\"hypothesisId\":\"H1\",\"location\":\"aka_av_mgm.c:aka_cdb_fetch_av\",\"message\":\"deserialize_input\",\"data\":{\"value_len\":%d,\"value\":\"%.*s\"}}\n", value.len, value.len > 200 ? 200 : value.len, value.s); fclose(_df);}}
316-
// #endregion
317-
318310
av = aka_cdb_deserialize_av(&value);
319-
320-
// #region agent log H1-deserialize-result
321-
{FILE *_df = fopen("/tmp/debug.log", "a"); if(_df){fprintf(_df, "{\"hypothesisId\":\"H1\",\"location\":\"aka_av_mgm.c:aka_cdb_fetch_av\",\"message\":\"deserialize_result\",\"data\":{\"av\":\"%p\",\"state\":%d,\"xres_len\":%d}}\n", (void*)av, av ? av->state : -1, av ? av->authorize.len : -1); fclose(_df);}}
322-
// #endregion
323-
324311
if (av) {
325312
LM_DBG("fetched AV from cachedb key=%.*s state=%d\n",
326313
key.len, key.s, av->state);

modules/auth_aka/auth_aka.c

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -902,57 +902,31 @@ static int aka_authorize(struct sip_msg *_msg, str *_realm,
902902
realm.len, realm.s, public_id->len, public_id->s,
903903
private_id->len, private_id->s);
904904

905-
// #region agent log H1-entry
906-
{FILE *_df = fopen("/tmp/debug.log", "a"); if(_df){fprintf(_df, "{\"hypothesisId\":\"H1\",\"location\":\"auth_aka.c:aka_authorize\",\"message\":\"entry\",\"data\":{\"aka_cdb\":\"%p\",\"nonce_len\":%d,\"nonce\":\"%.*s\"}}\n", (void*)aka_cdb, digest->nonce.len, digest->nonce.len, digest->nonce.s); fclose(_df);}}
907-
// #endregion
908-
909905
user = aka_user_find(public_id, private_id);
910906
if (user == NULL) {
911-
// #region agent log H2-user-null
912-
{FILE *_df = fopen("/tmp/debug.log", "a"); if(_df){fprintf(_df, "{\"hypothesisId\":\"H2\",\"location\":\"auth_aka.c:aka_authorize\",\"message\":\"user_not_found_locally\",\"data\":{\"checking_cdb\":%d}}\n", (aka_cdb && digest->nonce.len) ? 1 : 0); fclose(_df);}}
913-
// #endregion
914-
915907
/* User not found locally - check CacheDB if configured */
916908
if (aka_cdb && digest->nonce.len) {
917909
LM_DBG("user not found locally, checking CacheDB for %.*s/%.*s nonce %.*s\n",
918910
public_id->len, public_id->s, private_id->len, private_id->s,
919911
digest->nonce.len, digest->nonce.s);
920912
av = aka_cdb_fetch_av(public_id, private_id, &digest->nonce);
921-
922-
// #region agent log H1-fetch-result
923-
{FILE *_df = fopen("/tmp/debug.log", "a"); if(_df){fprintf(_df, "{\"hypothesisId\":\"H1\",\"location\":\"auth_aka.c:aka_authorize\",\"message\":\"cdb_fetch_result\",\"data\":{\"av\":\"%p\",\"state\":%d,\"algmask\":%d,\"alg\":%d}}\n", (void*)av, av ? av->state : -1, av ? av->algmask : -1, av ? av->alg : -1); fclose(_df);}}
924-
// #endregion
925-
926913
if (av) {
927914
LM_DBG("AV fetched from CacheDB: state=%d algmask=%d alg=%d\n",
928915
av->state, av->algmask, av->alg);
929916
/* Check state - only USING or USED states are valid */
930917
if (av->state != AKA_AV_USING && av->state != AKA_AV_USED) {
931-
// #region agent log H3-state-reject
932-
{FILE *_df = fopen("/tmp/debug.log", "a"); if(_df){fprintf(_df, "{\"hypothesisId\":\"H3\",\"location\":\"auth_aka.c:aka_authorize\",\"message\":\"state_rejected\",\"data\":{\"state\":%d,\"expected_using\":%d,\"expected_used\":%d}}\n", av->state, AKA_AV_USING, AKA_AV_USED); fclose(_df);}}
933-
// #endregion
934918
LM_WARN("AV from CacheDB has invalid state %d (expected USING=%d or USED=%d)\n",
935919
av->state, AKA_AV_USING, AKA_AV_USED);
936920
shm_free(av);
937921
return STALE_NONCE;
938922
}
939923
/* Create user locally and attach the AV */
940924
user = aka_user_get(public_id, private_id);
941-
942-
// #region agent log H2-user-create
943-
{FILE *_df = fopen("/tmp/debug.log", "a"); if(_df){fprintf(_df, "{\"hypothesisId\":\"H2\",\"location\":\"auth_aka.c:aka_authorize\",\"message\":\"user_create_result\",\"data\":{\"user\":\"%p\"}}\n", (void*)user); fclose(_df);}}
944-
// #endregion
945-
946925
if (user) {
947926
cond_lock(&user->cond);
948927
av->state = AKA_AV_USED;
949928
list_add_tail(&av->list, &user->avs);
950929
cond_unlock(&user->cond);
951-
952-
// #region agent log H3-av-attached
953-
{FILE *_df = fopen("/tmp/debug.log", "a"); if(_df){fprintf(_df, "{\"hypothesisId\":\"H3\",\"location\":\"auth_aka.c:aka_authorize\",\"message\":\"av_attached_to_user\",\"data\":{\"av_state\":%d}}\n", av->state); fclose(_df);}}
954-
// #endregion
955-
956930
LM_DBG("created local user from CacheDB AV\n");
957931
goto av_found;
958932
} else {
@@ -962,10 +936,6 @@ static int aka_authorize(struct sip_msg *_msg, str *_realm,
962936
}
963937
}
964938

965-
// #region agent log H4-failure
966-
{FILE *_df = fopen("/tmp/debug.log", "a"); if(_df){fprintf(_df, "{\"hypothesisId\":\"H4\",\"location\":\"auth_aka.c:aka_authorize\",\"message\":\"returning_stale_nonce\",\"data\":{\"nonce_len\":%d}}\n", digest->nonce.len); fclose(_df);}}
967-
// #endregion
968-
969939
if (digest->nonce.len)
970940
LM_ERR("could not get AKA user %.*s/%.*s with nonce %.*s\n",
971941
public_id->len, public_id->s, private_id->len, private_id->s,
@@ -984,11 +954,6 @@ static int aka_authorize(struct sip_msg *_msg, str *_realm,
984954
goto release;
985955
}
986956
av_found:
987-
988-
// #region agent log H5-av-found
989-
{FILE *_df = fopen("/tmp/debug.log", "a"); if(_df){fprintf(_df, "{\"hypothesisId\":\"H5\",\"location\":\"auth_aka.c:aka_authorize\",\"message\":\"av_found_reached\",\"data\":{\"av\":\"%p\",\"av_state\":%d,\"xres_len\":%d}}\n", (void*)av, av ? av->state : -1, av ? av->authorize.len : -1); fclose(_df);}}
990-
// #endregion
991-
992957
/* now that we are trusting the user, check whether it has an auts
993958
* parameter - if it does, we need to re-challenge him */
994959
if (digest->auts.len) {
@@ -1012,14 +977,8 @@ static int aka_authorize(struct sip_msg *_msg, str *_realm,
1012977

1013978
if (!auth_api.check_response(digest,
1014979
&_msg->first_line.u.request.method, &msg_body, &ha1)) {
1015-
// #region agent log H5-auth-success
1016-
{FILE *_df = fopen("/tmp/debug.log", "a"); if(_df){fprintf(_df, "{\"hypothesisId\":\"H5\",\"location\":\"auth_aka.c:aka_authorize\",\"message\":\"auth_success\",\"data\":{}}\n"); fclose(_df);}}
1017-
// #endregion
1018980
ret = auth_api.post_auth(_msg, h);
1019981
} else {
1020-
// #region agent log H5-auth-failure
1021-
{FILE *_df = fopen("/tmp/debug.log", "a"); if(_df){fprintf(_df, "{\"hypothesisId\":\"H5\",\"location\":\"auth_aka.c:aka_authorize\",\"message\":\"auth_failed_invalid_password\",\"data\":{\"xres_len\":%d}}\n", av ? av->authorize.len : -1); fclose(_df);}}
1022-
// #endregion
1023982
ret = INVALID_PASSWORD;
1024983
}
1025984

0 commit comments

Comments
 (0)