Skip to content

Commit

Permalink
global: Remove unnecessary checks for mail_debug and auth_request->debug
Browse files Browse the repository at this point in the history
These checks are performed before calling auth_request_log_debug() and
push_notification_driver_debug(), while the same checks are performed
inside of these functions, and they return without doing anything.
  • Loading branch information
Sergey-Kitov authored and cmouse committed Aug 7, 2018
1 parent 3bbc48e commit c0c8e87
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 42 deletions.
54 changes: 23 additions & 31 deletions src/auth/db-oauth2.c
Expand Up @@ -405,10 +405,9 @@ static void db_oauth2_fields_merge(struct db_oauth2_request *req,
req->fields = auth_fields_init(req->pool);

array_foreach(fields, field) {
if (req->auth_request->debug)
auth_request_log_debug(req->auth_request, AUTH_SUBSYS_DB,
"oauth2: Processing field %s",
field->name);
auth_request_log_debug(req->auth_request, AUTH_SUBSYS_DB,
"oauth2: Processing field %s",
field->name);
auth_fields_add(req->fields, field->name, field->value, 0);
}
}
Expand All @@ -422,10 +421,9 @@ static void db_oauth2_callback(struct db_oauth2_request *req,

i_assert(result == PASSDB_RESULT_OK || error != NULL);

if (req->auth_request->debug)
auth_request_log_debug(req->auth_request, AUTH_SUBSYS_DB,
"oauth2: callback(%d, %s)",
result, error);
auth_request_log_debug(req->auth_request, AUTH_SUBSYS_DB,
"oauth2: callback(%d, %s)",
result, error);

if (callback != NULL) {
DLLIST_REMOVE(&req->db->head, req);
Expand Down Expand Up @@ -500,10 +498,9 @@ db_oauth2_token_in_scope(struct db_oauth2_request *req,
if (*req->db->set.scope != '\0') {
bool found = FALSE;
const char *value = auth_fields_find(req->fields, "scope");
if (req->auth_request->debug)
auth_request_log_debug(req->auth_request, AUTH_SUBSYS_DB,
"oauth2: Token scope(s): %s",
value);
auth_request_log_debug(req->auth_request, AUTH_SUBSYS_DB,
"oauth2: Token scope(s): %s",
value);
if (value != NULL) {
const char **scopes = t_strsplit_spaces(value, " ");
found = str_array_find(scopes, req->db->set.scope);
Expand Down Expand Up @@ -543,10 +540,9 @@ db_oauth2_introspect_continue(struct oauth2_introspection_result *result,

req->req = NULL;

if (req->auth_request->debug)
auth_request_log_debug(req->auth_request, AUTH_SUBSYS_DB,
"oauth2: Introspection result: %s",
result->success ? "success" : "failed");
auth_request_log_debug(req->auth_request, AUTH_SUBSYS_DB,
"oauth2: Introspection result: %s",
result->success ? "success" : "failed");

if (!result->success) {
/* fail here */
Expand All @@ -564,10 +560,9 @@ static void db_oauth2_lookup_introspect(struct db_oauth2_request *req)
struct oauth2_request_input input;
i_zero(&input);

if (req->auth_request->debug)
auth_request_log_debug(req->auth_request, AUTH_SUBSYS_DB,
"oauth2: Making introspection request to %s",
req->db->set.introspection_url);
auth_request_log_debug(req->auth_request, AUTH_SUBSYS_DB,
"oauth2: Making introspection request to %s",
req->db->set.introspection_url);
input.token = req->token;
input.local_ip = req->auth_request->local_ip;
input.local_port = req->auth_request->local_port;
Expand Down Expand Up @@ -603,9 +598,8 @@ db_oauth2_lookup_continue(struct oauth2_token_validation_result *result,
if (*req->db->set.introspection_url != '\0' &&
(req->db->set.force_introspection ||
!db_oauth2_have_all_fields(req))) {
if (req->auth_request->debug)
auth_request_log_debug(req->auth_request, AUTH_SUBSYS_DB,
"oauth2: Introspection needed after token validation");
auth_request_log_debug(req->auth_request, AUTH_SUBSYS_DB,
"oauth2: Introspection needed after token validation");
db_oauth2_lookup_introspect(req);
return;
}
Expand Down Expand Up @@ -640,17 +634,15 @@ void db_oauth2_lookup(struct db_oauth2 *db, struct db_oauth2_request *req,
input.service = req->auth_request->service;

if (*db->oauth2_set.tokeninfo_url == '\0') {
if (req->auth_request->debug)
auth_request_log_debug(req->auth_request, AUTH_SUBSYS_DB,
"oauth2: Making introspection request to %s",
db->set.introspection_url);
auth_request_log_debug(req->auth_request, AUTH_SUBSYS_DB,
"oauth2: Making introspection request to %s",
db->set.introspection_url);
req->req = oauth2_introspection_start(&req->db->oauth2_set, &input,
db_oauth2_introspect_continue, req);
} else {
if (req->auth_request->debug)
auth_request_log_debug(req->auth_request, AUTH_SUBSYS_DB,
"oauth2: Making token validation lookup to %s",
db->oauth2_set.tokeninfo_url);
auth_request_log_debug(req->auth_request, AUTH_SUBSYS_DB,
"oauth2: Making token validation lookup to %s",
db->oauth2_set.tokeninfo_url);
req->req = oauth2_token_validation_start(&db->oauth2_set, &input,
db_oauth2_lookup_continue, req);
}
Expand Down
10 changes: 4 additions & 6 deletions src/auth/userdb-prefetch.c
Expand Up @@ -27,12 +27,10 @@ static void prefetch_lookup(struct auth_request *auth_request,
callback(USERDB_RESULT_INTERNAL_FAILURE, auth_request);
return;
}
if (!auth_request->userdb_lookup || auth_request->debug) {
/* more userdbs, they may know the user */
auth_request_log_debug(auth_request, AUTH_SUBSYS_DB,
"passdb didn't return userdb entries, "
"trying the next userdb");
}
/* more userdbs, they may know the user */
auth_request_log_debug(auth_request, AUTH_SUBSYS_DB,
"passdb didn't return userdb entries, "
"trying the next userdb");
callback(USERDB_RESULT_USER_UNKNOWN, auth_request);
return;
}
Expand Down
8 changes: 3 additions & 5 deletions src/plugins/push-notification/push-notification-driver-ox.c
Expand Up @@ -283,11 +283,9 @@ static void push_notification_driver_ox_http_callback
switch (response->status / 100) {
case 2:
// Success.
if (user->mail_debug) {
push_notification_driver_debug(OX_LOG_LABEL, user,
"Notification sent successfully: %s",
http_response_get_message(response));
}
push_notification_driver_debug(OX_LOG_LABEL, user,
"Notification sent successfully: %s",
http_response_get_message(response));
break;

default:
Expand Down

0 comments on commit c0c8e87

Please sign in to comment.