LATER s3:winbindd/idmap_util: improve DEBUG messages and lower the log level
authorStefan Metzmacher <metze@samba.org>
Thu, 24 May 2012 07:28:59 +0000 (09:28 +0200)
committerStefan Metzmacher <metze@samba.org>
Thu, 15 Nov 2012 08:15:19 +0000 (09:15 +0100)
Things like negative/expired cache entries should appear in the logs
without log level = 10...

metze

source3/winbindd/idmap_util.c

index a44aaf5fe4c698423cf9b413549c8bb6d4f381ac..68bdb7f7081b850d70607343b0388787001d677c 100644 (file)
@@ -48,11 +48,13 @@ NTSTATUS idmap_uid_to_sid(const char *domname, struct dom_sid *sid, uid_t uid)
                        (unsigned int)uid,
                           expired ? " (expired)": ""));
                if (expired && idmap_is_online()) {
-                       DEBUG(10, ("revalidating expired entry\n"));
+                       DEBUG(2, ("revalidating expired entry for uid %u => %s\n",
+                                 (unsigned int)uid, sid_string_dbg(sid)));
                        goto backend;
                }
                if (is_null_sid(sid)) {
-                       DEBUG(10, ("Returning negative cache entry\n"));
+                       DEBUG(2, ("Returning negative cache entry: for uid %u\n",
+                                 (unsigned int)uid));
                        return NT_STATUS_NONE_MAPPED;
                }
                DEBUG(10, ("Returning positive cache entry\n"));
@@ -66,7 +68,7 @@ backend:
 
        ret = idmap_backends_unixid_to_sid(domname, &map);
        if ( ! NT_STATUS_IS_OK(ret)) {
-               DEBUG(10, ("error mapping uid [%lu]\n", (unsigned long)uid));
+               DEBUG(1, ("error mapping uid [%lu]\n", (unsigned long)uid));
                return ret;
        }
 
@@ -76,7 +78,7 @@ backend:
                        ZERO_STRUCT(null_sid);
                        idmap_cache_set_sid2uid(&null_sid, uid);
                }
-               DEBUG(10, ("uid [%lu] not mapped\n", (unsigned long)uid));
+               DEBUG(1, ("uid [%lu] not mapped\n", (unsigned long)uid));
                return NT_STATUS_NONE_MAPPED;
        }
 
@@ -107,11 +109,13 @@ NTSTATUS idmap_gid_to_sid(const char *domname, struct dom_sid *sid, gid_t gid)
                        (unsigned int)gid,
                           expired ? " (expired)": ""));
                if (expired && idmap_is_online()) {
-                       DEBUG(10, ("revalidating expired entry\n"));
+                       DEBUG(2, ("revalidating expired entry gid %u => %s\n",
+                               (unsigned int)gid, sid_string_dbg(sid)));
                        goto backend;
                }
                if (is_null_sid(sid)) {
-                       DEBUG(10, ("Returning negative cache entry\n"));
+                       DEBUG(2, ("Returning negative cache entry gid %u\n",
+                               (unsigned int)gid));
                        return NT_STATUS_NONE_MAPPED;
                }
                DEBUG(10, ("Returning positive cache entry\n"));
@@ -125,7 +129,7 @@ backend:
 
        ret = idmap_backends_unixid_to_sid(domname, &map);
        if ( ! NT_STATUS_IS_OK(ret)) {
-               DEBUG(10, ("error mapping gid [%lu]\n", (unsigned long)gid));
+               DEBUG(1, ("error mapping gid [%lu]\n", (unsigned long)gid));
                return ret;
        }
 
@@ -135,7 +139,7 @@ backend:
                        ZERO_STRUCT(null_sid);
                        idmap_cache_set_sid2gid(&null_sid, gid);
                }
-               DEBUG(10, ("gid [%lu] not mapped\n", (unsigned long)gid));
+               DEBUG(1, ("gid [%lu] not mapped\n", (unsigned long)gid));
                return NT_STATUS_NONE_MAPPED;
        }
 
@@ -165,11 +169,11 @@ NTSTATUS idmap_sid_to_uid(const char *dom_name, struct dom_sid *sid, uid_t *uid)
                DEBUG(10, ("idmap_cache_find_sid2uid found %d%s\n",
                           (int)(*uid), expired ? " (expired)": ""));
                if (expired && idmap_is_online()) {
-                       DEBUG(10, ("revalidating expired entry\n"));
+                       DEBUG(2, ("revalidating expired entry\n"));
                        goto backend;
                }
                if ((*uid) == -1) {
-                       DEBUG(10, ("Returning negative cache entry\n"));
+                       DEBUG(2, ("Returning negative cache entry\n"));
                        return NT_STATUS_NONE_MAPPED;
                }
                DEBUG(10, ("Returning positive cache entry\n"));
@@ -192,7 +196,7 @@ backend:
        }
 
        if (map.status != ID_MAPPED) {
-               DEBUG(10, ("sid [%s] is not mapped\n", sid_string_dbg(sid)));
+               DEBUG(1, ("sid [%s] is not mapped\n", sid_string_dbg(sid)));
                if (winbindd_use_idmap_cache()) {
                        idmap_cache_set_sid2uid(sid, -1);
                }
@@ -200,7 +204,7 @@ backend:
        }
 
        if (map.xid.type != ID_TYPE_UID) {
-               DEBUG(10, ("sid [%s] not mapped to a uid "
+               DEBUG(1, ("sid [%s] not mapped to a uid "
                           "[%u,%u,%u]\n",
                           sid_string_dbg(sid),
                           map.status,
@@ -235,10 +239,11 @@ NTSTATUS idmap_sid_to_gid(const char *domname, struct dom_sid *sid, gid_t *gid)
 
        if (winbindd_use_idmap_cache()
            && idmap_cache_find_sid2gid(sid, gid, &expired)) {
-               DEBUG(10, ("idmap_cache_find_sid2gid found %d%s\n",
+               DEBUG(10, ("idmap_cache_find_sid2gid %s found %d%s\n",
+                          sid_string_dbg(sid),
                           (int)(*gid), expired ? " (expired)": ""));
                if (expired && idmap_is_online()) {
-                       DEBUG(10, ("revalidating expired entry\n"));
+                       DEBUG(2, ("revalidating expired entry\n"));
                        goto backend;
                }
                if ((*gid) == -1) {
@@ -256,8 +261,8 @@ backend:
        ret = idmap_backends_sid_to_unixid(domname, &map);
 
        if (!NT_STATUS_IS_OK(ret)) {
-               DEBUG(10, ("idmap_backends_sid_to_unixid failed: %s\n",
-                          nt_errstr(ret)));
+               DEBUG(1, ("idmap_backends_sid_to_unixid failed for %s as GID: %s\n",
+                          sid_string_dbg(sid), nt_errstr(ret)));
                if (winbindd_use_idmap_cache()) {
                        idmap_cache_set_sid2gid(sid, -1);
                }
@@ -265,7 +270,7 @@ backend:
        }
 
        if (map.status != ID_MAPPED) {
-               DEBUG(10, ("sid [%s] is not mapped\n", sid_string_dbg(sid)));
+               DEBUG(1, ("sid [%s] is not mapped as GID\n", sid_string_dbg(sid)));
                if (winbindd_use_idmap_cache()) {
                        idmap_cache_set_sid2gid(sid, -1);
                }
@@ -273,7 +278,7 @@ backend:
        }
 
        if (map.xid.type != ID_TYPE_GID) {
-               DEBUG(10, ("sid [%s] not mapped to a gid "
+               DEBUG(1, ("sid [%s] not mapped to a gid "
                           "[%u,%u,%u]\n",
                           sid_string_dbg(sid),
                           map.status,