Skip to content

Commit

Permalink
global: Replace "if(auth_debug){i_debug(...)}" with e_debug(event, ...)
Browse files Browse the repository at this point in the history
event is one of: global auth::auth_event,
auth_client_connection->event, auth_request->event,
login-common::event_auth. These event have category "auth".
  • Loading branch information
Sergey-Kitov authored and cmouse committed Aug 7, 2018
1 parent c0c8e87 commit aa509b9
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 42 deletions.
17 changes: 7 additions & 10 deletions src/auth/auth-client-connection.c
Expand Up @@ -79,11 +79,9 @@ static void auth_client_send(struct auth_client_connection *conn,
io_remove(&conn->io);
}

if (conn->auth->set->debug) {
i_debug("client passdb out: %s",
conn->auth->set->debug_passwords ?
cmd : reply_line_hide_pass(cmd));
}
e_debug(conn->event, "client passdb out: %s",
conn->auth->set->debug_passwords ?
cmd : reply_line_hide_pass(cmd));
}

static void auth_callback(const char *reply,
Expand Down Expand Up @@ -145,8 +143,7 @@ auth_client_input_cpid(struct auth_client_connection *conn, const char *args)
auth_request_handler_set(conn->request_handler, conn->connect_uid, pid);

conn->pid = pid;
if (conn->auth->set->debug)
i_debug("auth client connected (pid=%u)", conn->pid);
e_debug(conn->event, "auth client connected (pid=%u)", conn->pid);
return TRUE;
}

Expand Down Expand Up @@ -217,23 +214,23 @@ auth_client_handle_line(struct auth_client_connection *conn, const char *line)
{
if (str_begins(line, "AUTH\t")) {
if (conn->auth->set->debug) {
i_debug("client in: %s",
e_debug(conn->event, "client in: %s",
auth_line_hide_pass(conn, line));
}
return auth_request_handler_auth_begin(conn->request_handler,
line + 5);
}
if (str_begins(line, "CONT\t")) {
if (conn->auth->set->debug) {
i_debug("client in: %s",
e_debug(conn->event, "client in: %s",
cont_line_hide_pass(conn, line));
}
return auth_request_handler_auth_continue(conn->request_handler,
line + 5);
}
if (str_begins(line, "CANCEL\t")) {
if (conn->auth->set->debug)
i_debug("client in: %s", line);
e_debug(conn->event, "client in: %s", line);
return auth_client_cancel(conn, line + 7);
}

Expand Down
18 changes: 6 additions & 12 deletions src/auth/auth-master-connection.c
Expand Up @@ -73,10 +73,8 @@ void auth_master_request_callback(const char *reply, struct auth_master_connecti
{
struct const_iovec iov[2];

if (conn->auth->set->debug) {
i_debug("master userdb out: %s",
auth_master_reply_hide_passwords(conn, reply));
}
e_debug(auth_event, "master userdb out: %s",
auth_master_reply_hide_passwords(conn, reply));

iov[0].iov_base = reply;
iov[0].iov_len = strlen(reply);
Expand Down Expand Up @@ -307,10 +305,8 @@ user_callback(enum userdb_result result,
break;
}

if (conn->auth->set->debug) {
i_debug("userdb out: %s",
auth_master_reply_hide_passwords(conn, str_c(str)));
}
e_debug(auth_event, "userdb out: %s",
auth_master_reply_hide_passwords(conn, str_c(str)));

str_append_c(str, '\n');
o_stream_nsend(conn->output, str_data(str), str_len(str));
Expand Down Expand Up @@ -377,8 +373,7 @@ static void pass_callback_finish(struct auth_request *auth_request,
break;
}

if (conn->auth->set->debug)
i_debug("passdb out: %s", str_c(str));
e_debug(auth_event, "passdb out: %s", str_c(str));

str_append_c(str, '\n');
o_stream_nsend(conn->output, str_data(str), str_len(str));
Expand Down Expand Up @@ -635,8 +630,7 @@ master_input_list(struct auth_master_connection *conn, const char *args)
static bool
auth_master_input_line(struct auth_master_connection *conn, const char *line)
{
if (conn->auth->set->debug)
i_debug("master in: %s", line);
e_debug(auth_event, "master in: %s", line);

if (str_begins(line, "USER\t"))
return master_input_user(conn, line + 5);
Expand Down
6 changes: 2 additions & 4 deletions src/auth/auth-postfix-connection.c
Expand Up @@ -90,8 +90,7 @@ user_callback(enum userdb_result result, struct auth_request *auth_request)
break;
}

if (conn->auth->set->debug)
i_debug("postfix out: %s", str_c(str));
e_debug(auth_event, "postfix out: %s", str_c(str));

str_append_c(str, '\n');
o_stream_nsend(conn->output, str_data(str), str_len(str));
Expand Down Expand Up @@ -125,8 +124,7 @@ postfix_input_user(struct auth_postfix_connection *conn, const char *username)
static bool
auth_postfix_input_line(struct auth_postfix_connection *conn, const char *line)
{
if (conn->auth->set->debug)
i_debug("postfix in: %s", line);
e_debug(auth_event, "postfix in: %s", line);

if (strncasecmp(line, "get ", 4) == 0)
return postfix_input_user(conn, line + 4);
Expand Down
5 changes: 1 addition & 4 deletions src/auth/auth-request.c
Expand Up @@ -2645,12 +2645,9 @@ void auth_request_log_debug(struct auth_request *auth_request,
{
va_list va;

if (!auth_request->debug)
return;

va_start(va, format);
T_BEGIN {
i_debug("%s", get_log_str(auth_request, subsystem, format, va));
e_debug(auth_request->event, "%s", get_log_str(auth_request, subsystem, format, va));
} T_END;
va_end(va);
}
Expand Down
6 changes: 2 additions & 4 deletions src/auth/auth-token.c
Expand Up @@ -90,8 +90,7 @@ auth_token_read_secret(const char *path,
if (close(fd) < 0)
i_error("close(%s) failed: %m", path);

if (global_auth_settings->debug)
i_debug("Read auth token secret from %s", path);
e_debug(auth_event, "Read auth token secret from %s", path);
return ret;
}

Expand Down Expand Up @@ -133,8 +132,7 @@ auth_token_write_secret(const char *path,
return -1;
}

if (global_auth_settings->debug)
i_debug("Wrote new auth token secret to %s", path);
e_debug(auth_event, "Wrote new auth token secret to %s", path);
return 0;
}

Expand Down
10 changes: 4 additions & 6 deletions src/auth/userdb-ldap.c
Expand Up @@ -241,12 +241,10 @@ userdb_ldap_iterate_init(struct auth_request *auth_request,
request->request.attributes = conn->iterate_attr_names;
request->request.multi_entry = TRUE;

if (global_auth_settings->debug) {
i_debug("ldap: iterate: base=%s scope=%s filter=%s fields=%s",
request->request.base, conn->set.scope,
request->request.filter, attr_names == NULL ? "(all)" :
t_strarray_join(attr_names, ","));
}
e_debug(auth_request->event, "ldap: iterate: base=%s scope=%s filter=%s fields=%s",
request->request.base, conn->set.scope,
request->request.filter, attr_names == NULL ? "(all)" :
t_strarray_join(attr_names, ","));
request->request.request.callback = userdb_ldap_iterate_callback;
db_ldap_request(conn, &request->request.request);
return &ctx->ctx;
Expand Down
4 changes: 2 additions & 2 deletions src/login-common/client-common-auth.c
Expand Up @@ -216,8 +216,8 @@ static void client_auth_parse_args(struct client *client, bool success,
}
} else if (str_begins(key, "forward_")) {
/* these are passed to upstream */
} else if (client->set->auth_debug)
i_debug("Ignoring unknown passdb extra field: %s", key);
} else
e_debug(event_auth, "Ignoring unknown passdb extra field: %s", key);
}
if (array_count(&alt_usernames) > 0) {
const char **alt;
Expand Down

0 comments on commit aa509b9

Please sign in to comment.