diff options
author | Nikolai Kondrashov <Nikolai.Kondrashov@redhat.com> | 2014-02-12 10:12:59 -0500 |
---|---|---|
committer | Jakub Hrozek <jhrozek@redhat.com> | 2014-05-02 10:58:33 +0200 |
commit | 46c28ba3044c2121c2c0af4493ac655dcb41e0e6 (patch) | |
tree | 376633177afd84f0b46a8e2e5533f5337a38cf95 /src/db/sysdb.c | |
parent | dad68b3284228a38b4beb06946701e8795980966 (diff) | |
download | sssd-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/db/sysdb.c')
-rw-r--r-- | src/db/sysdb.c | 59 |
1 files changed, 35 insertions, 24 deletions
diff --git a/src/db/sysdb.c b/src/db/sysdb.c index ff60330e9..4dd32f307 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); } @@ -726,21 +726,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; @@ -828,7 +829,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); } @@ -839,7 +841,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); } @@ -850,7 +853,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); } @@ -1046,11 +1050,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; } @@ -1217,7 +1222,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; @@ -1229,7 +1235,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; @@ -1251,7 +1258,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: @@ -1328,7 +1335,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; } } @@ -1336,7 +1344,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; } @@ -1641,7 +1649,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) { @@ -1650,25 +1658,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; @@ -1690,7 +1699,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; } @@ -1699,7 +1709,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); @@ -1831,7 +1842,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; } @@ -1915,14 +1926,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; } |