summaryrefslogtreecommitdiffstats
path: root/src/db/sysdb.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-02-12 22:31:02 +0100
commit83bf46f4066e3d5e838a32357c201de9bd6ecdfd (patch)
tree65f491f7661bd533398625e015f2b5e5bff3badf /src/db/sysdb.c
parent45a1d9d597df977354428440aeff11c6a0a947fe (diff)
downloadsssd-83bf46f4066e3d5e838a32357c201de9bd6ecdfd.tar.gz
sssd-83bf46f4066e3d5e838a32357c201de9bd6ecdfd.tar.xz
sssd-83bf46f4066e3d5e838a32357c201de9bd6ecdfd.zip
Update DEBUG* invocations to use new levels
Use a script 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 Reviewed-by: Jakub Hrozek <jhrozek@redhat.com> Reviewed-by: Stephen Gallagher <sgallagh@redhat.com> Reviewed-by: Simo Sorce <simo@redhat.com>
Diffstat (limited to 'src/db/sysdb.c')
-rw-r--r--src/db/sysdb.c59
1 files changed, 35 insertions, 24 deletions
diff --git a/src/db/sysdb.c b/src/db/sysdb.c
index 901417e81..12964189a 100644
--- a/src/db/sysdb.c
+++ b/src/db/sysdb.c
@@ -52,7 +52,7 @@ errno_t sysdb_ldb_connect(TALLOC_CTX *mem_ctx, const char *filename,
mod_path = getenv(LDB_MODULES_PATH);
if (mod_path != NULL) {
- DEBUG(9, "Setting ldb module path to [%s].\n", mod_path);
+ DEBUG(SSSDBG_TRACE_ALL, "Setting ldb module path to [%s].\n", mod_path);
ldb_set_modules_dir(ldb, mod_path);
}
@@ -724,21 +724,22 @@ int sysdb_attrs_users_from_str_list(struct sysdb_attrs *attrs,
}
el->values = vals;
- DEBUG(9, "Adding %d members to existing %d ones\n",
+ DEBUG(SSSDBG_TRACE_ALL, "Adding %d members to existing %d ones\n",
num, el->num_values);
for (i = 0, j = el->num_values; i < num; i++) {
member = sysdb_user_strdn(el->values, domain, list[i]);
if (!member) {
- DEBUG(4, "Failed to get user dn for [%s]\n", list[i]);
+ DEBUG(SSSDBG_CONF_SETTINGS,
+ "Failed to get user dn for [%s]\n", list[i]);
continue;
}
el->values[j].data = (uint8_t *)member;
el->values[j].length = strlen(member);
j++;
- DEBUG(7, " member #%d: [%s]\n", i, member);
+ DEBUG(SSSDBG_TRACE_LIBS, " member #%d: [%s]\n", i, member);
}
el->num_values = j;
@@ -826,7 +827,8 @@ int sysdb_transaction_start(struct sysdb_ctx *sysdb)
ret = ldb_transaction_start(sysdb->ldb);
if (ret != LDB_SUCCESS) {
- DEBUG(1, "Failed to start ldb transaction! (%d)\n", ret);
+ DEBUG(SSSDBG_CRIT_FAILURE,
+ "Failed to start ldb transaction! (%d)\n", ret);
}
return sysdb_error_to_errno(ret);
}
@@ -837,7 +839,8 @@ int sysdb_transaction_commit(struct sysdb_ctx *sysdb)
ret = ldb_transaction_commit(sysdb->ldb);
if (ret != LDB_SUCCESS) {
- DEBUG(1, "Failed to commit ldb transaction! (%d)\n", ret);
+ DEBUG(SSSDBG_CRIT_FAILURE,
+ "Failed to commit ldb transaction! (%d)\n", ret);
}
return sysdb_error_to_errno(ret);
}
@@ -848,7 +851,8 @@ int sysdb_transaction_cancel(struct sysdb_ctx *sysdb)
ret = ldb_transaction_cancel(sysdb->ldb);
if (ret != LDB_SUCCESS) {
- DEBUG(1, "Failed to cancel ldb transaction! (%d)\n", ret);
+ DEBUG(SSSDBG_CRIT_FAILURE,
+ "Failed to cancel ldb transaction! (%d)\n", ret);
}
return sysdb_error_to_errno(ret);
}
@@ -1044,11 +1048,12 @@ int sysdb_domain_init_internal(TALLOC_CTX *mem_ctx,
if (ret != EOK) {
goto done;
}
- DEBUG(5, "DB File for %s: %s\n", domain->name, sysdb->ldb_file);
+ DEBUG(SSSDBG_FUNC_DATA,
+ "DB File for %s: %s\n", domain->name, sysdb->ldb_file);
ret = sysdb_ldb_connect(sysdb, sysdb->ldb_file, &sysdb->ldb);
if (ret != EOK) {
- DEBUG(1, "sysdb_ldb_connect failed.\n");
+ DEBUG(SSSDBG_CRIT_FAILURE, "sysdb_ldb_connect failed.\n");
goto done;
}
@@ -1215,7 +1220,8 @@ int sysdb_domain_init_internal(TALLOC_CTX *mem_ctx,
goto done;
}
- DEBUG(0,"Unknown DB version [%s], expected [%s] for domain %s!\n",
+ DEBUG(SSSDBG_FATAL_FAILURE,
+ "Unknown DB version [%s], expected [%s] for domain %s!\n",
version?version:"not found", SYSDB_VERSION, domain->name);
ret = sysdb_version_check(SYSDB_VERSION, version);
goto done;
@@ -1227,7 +1233,8 @@ int sysdb_domain_init_internal(TALLOC_CTX *mem_ctx,
while ((ldif = ldb_ldif_read_string(sysdb->ldb, &base_ldif))) {
ret = ldb_add(sysdb->ldb, ldif->msg);
if (ret != LDB_SUCCESS) {
- DEBUG(0, "Failed to initialize DB (%d, [%s]) for domain %s!\n",
+ DEBUG(SSSDBG_FATAL_FAILURE,
+ "Failed to initialize DB (%d, [%s]) for domain %s!\n",
ret, ldb_errstring(sysdb->ldb), domain->name);
ret = EIO;
goto done;
@@ -1249,7 +1256,7 @@ int sysdb_domain_init_internal(TALLOC_CTX *mem_ctx,
talloc_zfree(sysdb->ldb);
ret = sysdb_ldb_connect(sysdb, sysdb->ldb_file, &sysdb->ldb);
if (ret != EOK) {
- DEBUG(1, "sysdb_ldb_connect failed.\n");
+ DEBUG(SSSDBG_CRIT_FAILURE, "sysdb_ldb_connect failed.\n");
}
done:
@@ -1326,7 +1333,8 @@ int sysdb_attrs_replace_name(struct sysdb_attrs *attrs, const char *oldname,
e = &(attrs->a[i]);
}
if (strcasecmp(newname, attrs->a[i].name) == 0) {
- DEBUG(3, "New attribute name [%s] already exists.\n", newname);
+ DEBUG(SSSDBG_MINOR_FAILURE,
+ "New attribute name [%s] already exists.\n", newname);
return EEXIST;
}
}
@@ -1334,7 +1342,7 @@ int sysdb_attrs_replace_name(struct sysdb_attrs *attrs, const char *oldname,
if (e != NULL) {
dummy = talloc_strdup(attrs, newname);
if (dummy == NULL) {
- DEBUG(1, "talloc_strdup failed.\n");
+ DEBUG(SSSDBG_CRIT_FAILURE, "talloc_strdup failed.\n");
return ENOMEM;
}
@@ -1640,7 +1648,7 @@ errno_t sysdb_attrs_primary_name(struct sysdb_ctx *sysdb,
goto done;
}
if (orig_dn_el->num_values == 0) {
- DEBUG(1, "Original DN is not available.\n");
+ DEBUG(SSSDBG_CRIT_FAILURE, "Original DN is not available.\n");
ret = EINVAL;
goto done;
} else if (orig_dn_el->num_values == 1) {
@@ -1649,25 +1657,26 @@ errno_t sysdb_attrs_primary_name(struct sysdb_ctx *sysdb,
&rdn_attr,
&rdn_val);
if (ret != EOK) {
- DEBUG(1, "Could not get rdn from [%s]\n",
+ DEBUG(SSSDBG_CRIT_FAILURE, "Could not get rdn from [%s]\n",
(const char *) orig_dn_el->values[0].data);
goto done;
}
} else {
- DEBUG(1, "Should not have more than one origDN\n");
+ DEBUG(SSSDBG_CRIT_FAILURE, "Should not have more than one origDN\n");
ret = EINVAL;
goto done;
}
/* First check whether the attribute name matches */
- DEBUG(8, "Comparing attribute names [%s] and [%s]\n",
+ DEBUG(SSSDBG_TRACE_INTERNAL, "Comparing attribute names [%s] and [%s]\n",
rdn_attr, ldap_attr);
if (strcasecmp(rdn_attr, ldap_attr) != 0) {
/* Multiple entries, and the RDN attribute doesn't match.
* We have no way of resolving this deterministically,
* so we'll use the first value as a fallback.
*/
- DEBUG(3, "The entry has multiple names and the RDN attribute does "
+ DEBUG(SSSDBG_MINOR_FAILURE,
+ "The entry has multiple names and the RDN attribute does "
"not match. Will use the first value as fallback.\n");
*_primary = (const char *)sysdb_name_el->values[0].data;
ret = EOK;
@@ -1689,7 +1698,8 @@ errno_t sysdb_attrs_primary_name(struct sysdb_ctx *sysdb,
* throw up our hands. There's no deterministic way to
* decide which name is correct.
*/
- DEBUG(1, "Cannot save entry. Unable to determine groupname\n");
+ DEBUG(SSSDBG_CRIT_FAILURE,
+ "Cannot save entry. Unable to determine groupname\n");
ret = EINVAL;
goto done;
}
@@ -1698,7 +1708,8 @@ errno_t sysdb_attrs_primary_name(struct sysdb_ctx *sysdb,
done:
if (ret != EOK) {
- DEBUG(1, "Could not determine primary name: [%d][%s]\n",
+ DEBUG(SSSDBG_CRIT_FAILURE,
+ "Could not determine primary name: [%d][%s]\n",
ret, strerror(ret));
}
talloc_free(tmp_ctx);
@@ -1830,7 +1841,7 @@ errno_t sysdb_attrs_primary_name_list(struct sysdb_ctx *sysdb,
ldap_attr,
&name);
if (ret != EOK) {
- DEBUG(1, "Could not determine primary name\n");
+ DEBUG(SSSDBG_CRIT_FAILURE, "Could not determine primary name\n");
/* Skip and continue. Don't advance 'j' */
continue;
}
@@ -1913,14 +1924,14 @@ errno_t sysdb_msg2attrs(TALLOC_CTX *mem_ctx, size_t count,
a = talloc_array(mem_ctx, struct sysdb_attrs *, count);
if (a == NULL) {
- DEBUG(1, "talloc_array failed.\n");
+ DEBUG(SSSDBG_CRIT_FAILURE, "talloc_array failed.\n");
return ENOMEM;
}
for (i = 0; i < count; i++) {
a[i] = talloc(a, struct sysdb_attrs);
if (a[i] == NULL) {
- DEBUG(1, "talloc failed.\n");
+ DEBUG(SSSDBG_CRIT_FAILURE, "talloc failed.\n");
talloc_free(a);
return ENOMEM;
}