summaryrefslogtreecommitdiffstats
path: root/src/responder/nss/nsssrv_netgroup.c
diff options
context:
space:
mode:
authorNikolai Kondrashov <Nikolai.Kondrashov@redhat.com>2014-02-12 10:12:59 -0500
committerJakub Hrozek <jhrozek@redhat.com>2014-05-02 10:58:33 +0200
commit46c28ba3044c2121c2c0af4493ac655dcb41e0e6 (patch)
tree376633177afd84f0b46a8e2e5533f5337a38cf95 /src/responder/nss/nsssrv_netgroup.c
parentdad68b3284228a38b4beb06946701e8795980966 (diff)
downloadsssd-46c28ba3044c2121c2c0af4493ac655dcb41e0e6.tar.gz
sssd-46c28ba3044c2121c2c0af4493ac655dcb41e0e6.tar.xz
sssd-46c28ba3044c2121c2c0af4493ac655dcb41e0e6.zip
Update DEBUG* invocations to use new levels
Use a script (identical to commit 83bf46f4066e3d5e838a32357c201de9bd6ecdfd) to update DEBUG* macro invocations, which use literal numbers for levels, to use bitmask macros instead: grep -rl --include '*.[hc]' DEBUG . | while read f; do mv "$f"{,.orig} perl -e 'use strict; use File::Slurp; my @map=qw" SSSDBG_FATAL_FAILURE SSSDBG_CRIT_FAILURE SSSDBG_OP_FAILURE SSSDBG_MINOR_FAILURE SSSDBG_CONF_SETTINGS SSSDBG_FUNC_DATA SSSDBG_TRACE_FUNC SSSDBG_TRACE_LIBS SSSDBG_TRACE_INTERNAL SSSDBG_TRACE_ALL "; my $text=read_file(\*STDIN); my $repl; $text=~s/ ^ ( .* \b (DEBUG|DEBUG_PAM_DATA|DEBUG_GR_MEM) \s* \(\s* )( [0-9] )( \s*, ) ( \s* ) ( .* ) $ / $repl = $1.$map[$3].$4.$5.$6, length($repl) <= 80 ? $repl : $1.$map[$3].$4."\n".(" " x length($1)).$6 /xmge; print $text; ' < "$f.orig" > "$f" rm "$f.orig" done
Diffstat (limited to 'src/responder/nss/nsssrv_netgroup.c')
-rw-r--r--src/responder/nss/nsssrv_netgroup.c94
1 files changed, 56 insertions, 38 deletions
diff --git a/src/responder/nss/nsssrv_netgroup.c b/src/responder/nss/nsssrv_netgroup.c
index 60c5f838b..566354c03 100644
--- a/src/responder/nss/nsssrv_netgroup.c
+++ b/src/responder/nss/nsssrv_netgroup.c
@@ -50,7 +50,8 @@ static errno_t get_netgroup_entry(struct nss_ctx *nctx,
return ENOENT;
}
- DEBUG(1, "Unexpected error reading from netgroup hash [%d][%s]\n",
+ DEBUG(SSSDBG_CRIT_FAILURE,
+ "Unexpected error reading from netgroup hash [%d][%s]\n",
hret, hash_error_string(hret));
return EIO;
}
@@ -64,7 +65,7 @@ static errno_t set_netgroup_entry(struct nss_ctx *nctx,
int hret;
if (netgr->name == NULL) {
- DEBUG(1, "Missing netgroup name.\n");
+ DEBUG(SSSDBG_CRIT_FAILURE, "Missing netgroup name.\n");
return EINVAL;
}
/* Add this entry to the hash table */
@@ -74,8 +75,10 @@ static errno_t set_netgroup_entry(struct nss_ctx *nctx,
value.ptr = netgr;
hret = hash_enter(nctx->netgroups, &key, &value);
if (hret != EOK) {
- DEBUG(0, "Unable to add hash table entry for [%s]", key.str);
- DEBUG(4, "Hash error [%d][%s]", hret, hash_error_string(hret));
+ DEBUG(SSSDBG_FATAL_FAILURE,
+ "Unable to add hash table entry for [%s]", key.str);
+ DEBUG(SSSDBG_CONF_SETTINGS,
+ "Hash error [%d][%s]", hret, hash_error_string(hret));
return EIO;
}
talloc_steal(nctx->netgroups, netgr);
@@ -125,7 +128,7 @@ int nss_cmd_setnetgrent(struct cli_ctx *client)
req = setnetgrent_send(cmdctx, rawname, cmdctx);
if (!req) {
- DEBUG(0, "Fatal error calling setnetgrent_send\n");
+ DEBUG(SSSDBG_FATAL_FAILURE, "Fatal error calling setnetgrent_send\n");
ret = EIO;
goto done;
}
@@ -154,7 +157,8 @@ static int netgr_hash_remove (TALLOC_CTX *ctx)
/* Remove the netgroup result object from the lookup table */
hret = hash_delete(netgr->lookup_table, &key);
if (hret != HASH_SUCCESS) {
- DEBUG(0, "Could not remove key [%s] from table! [%d][%s]\n",
+ DEBUG(SSSDBG_FATAL_FAILURE,
+ "Could not remove key [%s] from table! [%d][%s]\n",
netgr->name, hret, hash_error_string(hret));
return -1;
}
@@ -187,7 +191,8 @@ static struct tevent_req *setnetgrent_send(TALLOC_CTX *mem_ctx,
req = tevent_req_create(mem_ctx, &state, struct setnetgrent_ctx);
if (!req) {
- DEBUG(0, "Could not create tevent request for setnetgrent\n");
+ DEBUG(SSSDBG_FATAL_FAILURE,
+ "Could not create tevent request for setnetgrent\n");
return NULL;
}
@@ -207,11 +212,11 @@ static struct tevent_req *setnetgrent_send(TALLOC_CTX *mem_ctx,
client->rctx->default_domain, rawname,
&domname, &state->netgr_shortname);
if (ret != EOK) {
- DEBUG(2, "Invalid name received [%s]\n", rawname);
+ DEBUG(SSSDBG_OP_FAILURE, "Invalid name received [%s]\n", rawname);
goto error;
}
- DEBUG(4, "Requesting info for netgroup [%s] from [%s]\n",
+ DEBUG(SSSDBG_CONF_SETTINGS, "Requesting info for netgroup [%s] from [%s]\n",
state->netgr_shortname, domname?domname:"<ALL>");
if (domname) {
@@ -341,7 +346,7 @@ static errno_t setnetgrent_retry(struct tevent_req *req)
ret = set_netgroup_entry(nctx, state->netgr);
if (ret != EOK) {
- DEBUG(1, "set_netgroup_entry failed.\n");
+ DEBUG(SSSDBG_CRIT_FAILURE, "set_netgroup_entry failed.\n");
talloc_free(state->netgr);
goto done;
}
@@ -418,7 +423,8 @@ static void set_netgr_lifetime(uint32_t lifetime,
setnetgrent_result_timeout,
netgr);
if (!te) {
- DEBUG(0, "Could not set up life timer for setnetgrent result object. "
+ DEBUG(SSSDBG_FATAL_FAILURE,
+ "Could not set up life timer for setnetgrent result object. "
"Entries may become stale.\n");
}
}
@@ -459,11 +465,12 @@ static errno_t lookup_netgr_step(struct setent_step_ctx *step_ctx)
return ENOMEM;
}
- DEBUG(4, "Requesting info for [%s@%s]\n",
+ DEBUG(SSSDBG_CONF_SETTINGS, "Requesting info for [%s@%s]\n",
name, dom->name);
sysdb = dom->sysdb;
if (sysdb == NULL) {
- DEBUG(0, "Fatal: Sysdb CTX not found for this domain!\n");
+ DEBUG(SSSDBG_FATAL_FAILURE,
+ "Fatal: Sysdb CTX not found for this domain!\n");
return EIO;
}
@@ -488,7 +495,8 @@ static errno_t lookup_netgr_step(struct setent_step_ctx *step_ctx)
}
if (ret != EOK) {
- DEBUG(1, "Failed to make request to our cache!\n");
+ DEBUG(SSSDBG_CRIT_FAILURE,
+ "Failed to make request to our cache!\n");
return EIO;
}
@@ -496,7 +504,7 @@ static errno_t lookup_netgr_step(struct setent_step_ctx *step_ctx)
&netgr);
if (ret != EOK) {
/* Something really bad happened! */
- DEBUG(0, "Netgroup entry was lost!\n");
+ DEBUG(SSSDBG_FATAL_FAILURE, "Netgroup entry was lost!\n");
return ret;
}
@@ -505,7 +513,7 @@ static errno_t lookup_netgr_step(struct setent_step_ctx *step_ctx)
&netgr->entries);
if (ret == ENOENT) {
/* This netgroup was not found in this domain */
- DEBUG(2, "No results for netgroup %s (domain %s)\n",
+ DEBUG(SSSDBG_OP_FAILURE, "No results for netgroup %s (domain %s)\n",
name, dom->name);
if (!step_ctx->dctx->check_provider) {
@@ -519,7 +527,8 @@ static errno_t lookup_netgr_step(struct setent_step_ctx *step_ctx)
}
if (ret != EOK) {
- DEBUG(1, "Failed to convert results into entries\n");
+ DEBUG(SSSDBG_CRIT_FAILURE,
+ "Failed to convert results into entries\n");
netgr->ready = true;
netgr->found = false;
set_netgr_lifetime(step_ctx->nctx->neg_timeout, step_ctx, netgr);
@@ -545,7 +554,7 @@ static errno_t lookup_netgr_step(struct setent_step_ctx *step_ctx)
}
/* Results found */
- DEBUG(6, "Returning info for netgroup [%s@%s]\n",
+ DEBUG(SSSDBG_TRACE_FUNC, "Returning info for netgroup [%s@%s]\n",
name, dom->name);
netgr->ready = true;
netgr->found = true;
@@ -566,7 +575,7 @@ static errno_t lookup_netgr_step(struct setent_step_ctx *step_ctx)
netgr = talloc_zero(step_ctx->nctx, struct getent_ctx);
if (netgr == NULL) {
- DEBUG(1, "talloc_zero failed, ignored.\n");
+ DEBUG(SSSDBG_CRIT_FAILURE, "talloc_zero failed, ignored.\n");
} else {
netgr->ready = true;
netgr->found = false;
@@ -574,14 +583,14 @@ static errno_t lookup_netgr_step(struct setent_step_ctx *step_ctx)
netgr->lookup_table = step_ctx->nctx->netgroups;
netgr->name = talloc_strdup(netgr, step_ctx->name);
if (netgr->name == NULL) {
- DEBUG(1, "talloc_strdup failed.\n");
+ DEBUG(SSSDBG_CRIT_FAILURE, "talloc_strdup failed.\n");
talloc_free(netgr);
return ENOMEM;
}
ret = set_netgroup_entry(step_ctx->nctx, netgr);
if (ret != EOK) {
- DEBUG(1, "set_netgroup_entry failed, ignored.\n");
+ DEBUG(SSSDBG_CRIT_FAILURE, "set_netgroup_entry failed, ignored.\n");
}
set_netgr_lifetime(step_ctx->nctx->neg_timeout, step_ctx, netgr);
}
@@ -599,7 +608,8 @@ static void lookup_netgr_dp_callback(uint16_t err_maj, uint32_t err_min,
int ret;
if (err_maj) {
- DEBUG(2, "Unable to get information from Data Provider\n"
+ DEBUG(SSSDBG_OP_FAILURE,
+ "Unable to get information from Data Provider\n"
"Error: %u, %u, %s\n"
"Will try to return what we have in cache\n",
(unsigned int)err_maj, (unsigned int)err_min, err_msg);
@@ -661,7 +671,7 @@ static void nss_cmd_setnetgrent_done(struct tevent_req *req)
reqret = setnetgrent_recv(req);
talloc_zfree(req);
if (reqret != EOK && reqret != ENOENT) {
- DEBUG(1, "setnetgrent failed\n");
+ DEBUG(SSSDBG_CRIT_FAILURE, "setnetgrent failed\n");
nss_cmd_done(cmdctx, reqret);
return;
}
@@ -678,7 +688,7 @@ static void nss_cmd_setnetgrent_done(struct tevent_req *req)
packet = cmdctx->cctx->creq->out;
ret = sss_packet_grow(packet, 2*sizeof(uint32_t));
if (ret != EOK) {
- DEBUG(1, "Couldn't grow the packet\n");
+ DEBUG(SSSDBG_CRIT_FAILURE, "Couldn't grow the packet\n");
NSS_CMD_FATAL_ERROR(cmdctx);
}
@@ -691,7 +701,7 @@ static void nss_cmd_setnetgrent_done(struct tevent_req *req)
return;
}
- DEBUG(1, "Error creating packet\n");
+ DEBUG(SSSDBG_CRIT_FAILURE, "Error creating packet\n");
}
static void setnetgrent_implicit_done(struct tevent_req *req);
@@ -705,7 +715,7 @@ int nss_cmd_getnetgrent(struct cli_ctx *client)
struct getent_ctx *netgr;
struct tevent_req *req;
- DEBUG(4, "Requesting netgroup data\n");
+ DEBUG(SSSDBG_CONF_SETTINGS, "Requesting netgroup data\n");
cmdctx = talloc_zero(client, struct nss_cmd_ctx);
if (!cmdctx) {
@@ -738,7 +748,7 @@ int nss_cmd_getnetgrent(struct cli_ctx *client)
return EOK;
} else if (ret != EOK) {
- DEBUG(1, "An unexpected error occurred: [%d][%s]\n",
+ DEBUG(SSSDBG_CRIT_FAILURE, "An unexpected error occurred: [%d][%s]\n",
ret, strerror(ret));
return nss_cmd_done(cmdctx, ret);
@@ -757,16 +767,18 @@ int nss_cmd_getnetgrent(struct cli_ctx *client)
return EOK;
} else if (!netgr->found) {
- DEBUG(6, "Results for [%s] not found.\n", client->netgr_name);
+ DEBUG(SSSDBG_TRACE_FUNC,
+ "Results for [%s] not found.\n", client->netgr_name);
return ENOENT;
}
- DEBUG(6, "Returning results for [%s]\n", client->netgr_name);
+ DEBUG(SSSDBG_TRACE_FUNC,
+ "Returning results for [%s]\n", client->netgr_name);
/* Read the result strings */
ret = nss_cmd_getnetgrent_process(cmdctx, netgr);
if (ret != EOK) {
- DEBUG(1, "Failed: [%d][%s]\n", ret, strerror(ret));
+ DEBUG(SSSDBG_CRIT_FAILURE, "Failed: [%d][%s]\n", ret, strerror(ret));
}
return ret;
}
@@ -788,7 +800,8 @@ static void setnetgrent_implicit_done(struct tevent_req *req)
* nss_cmd_retnetgrent later
*/
if (ret != EOK && ret != ENOENT) {
- DEBUG(0, "Implicit setnetgrent failed with unexpected error "
+ DEBUG(SSSDBG_FATAL_FAILURE,
+ "Implicit setnetgrent failed with unexpected error "
"[%d][%s]\n", ret, strerror(ret));
NSS_CMD_FATAL_ERROR(cmdctx);
}
@@ -803,11 +816,12 @@ static void setnetgrent_implicit_done(struct tevent_req *req)
ret = get_netgroup_entry(nctx, cmdctx->cctx->netgr_name, &netgr);
if (ret == ENOENT) {
/* Critical error. This should never happen */
- DEBUG(0, "Implicit setnetgrent returned success without creating "
+ DEBUG(SSSDBG_FATAL_FAILURE,
+ "Implicit setnetgrent returned success without creating "
"result object.\n");
NSS_CMD_FATAL_ERROR(cmdctx);
} else if (ret != EOK) {
- DEBUG(1, "An unexpected error occurred: [%d][%s]\n",
+ DEBUG(SSSDBG_CRIT_FAILURE, "An unexpected error occurred: [%d][%s]\n",
ret, strerror(ret));
NSS_CMD_FATAL_ERROR(cmdctx);
@@ -815,14 +829,16 @@ static void setnetgrent_implicit_done(struct tevent_req *req)
if (!netgr->ready) {
/* Critical error. This should never happen */
- DEBUG(0, "Implicit setnetgrent returned success without creating "
+ DEBUG(SSSDBG_FATAL_FAILURE,
+ "Implicit setnetgrent returned success without creating "
"result object.\n");
NSS_CMD_FATAL_ERROR(cmdctx);
}
ret = nss_cmd_getnetgrent_process(cmdctx, netgr);
if (ret != EOK) {
- DEBUG(0, "Immediate retrieval failed with unexpected error "
+ DEBUG(SSSDBG_FATAL_FAILURE,
+ "Immediate retrieval failed with unexpected error "
"[%d][%s]\n", ret, strerror(ret));
NSS_CMD_FATAL_ERROR(cmdctx);
}
@@ -857,7 +873,7 @@ static errno_t nss_cmd_getnetgrent_process(struct nss_cmd_ctx *cmdctx,
if (!netgr->entries || netgr->entries[0] == NULL) {
/* No entries */
- DEBUG(5, "No entries found\n");
+ DEBUG(SSSDBG_FUNC_DATA, "No entries found\n");
ret = sss_cmd_empty_packet(client->creq->out);
if (ret != EOK) {
return nss_cmd_done(cmdctx, ret);
@@ -952,7 +968,8 @@ static errno_t nss_cmd_retnetgrent(struct cli_ctx *client,
} else if (entries[client->netgrent_cur]->type == SYSDB_NETGROUP_GROUP_VAL) {
if (entries[client->netgrent_cur]->value.groupname == NULL ||
entries[client->netgrent_cur]->value.groupname[0] == '\0') {
- DEBUG(1, "Empty netgroup member. Please check your cache.\n");
+ DEBUG(SSSDBG_CRIT_FAILURE,
+ "Empty netgroup member. Please check your cache.\n");
continue;
}
@@ -974,7 +991,8 @@ static errno_t nss_cmd_retnetgrent(struct cli_ctx *client,
grouplen);
rp += grouplen;
} else {
- DEBUG(1, "Unexpected value type for netgroup entry. "
+ DEBUG(SSSDBG_CRIT_FAILURE,
+ "Unexpected value type for netgroup entry. "
"Please check your cache.\n");
continue;
}