[PATCH] winbindd: idmap_rid: error code for failing id-to-sid mappings

Ralph Böhme slow at samba.org
Mon Oct 9 12:12:58 UTC 2017


Hi!

Can we let wbinfo return a slightly more indicative message for failed id-to-sid
mappings? Example:

$ bin/wbinfo --unix-ids-to-sids=u200002,g300001,g200001
S-1-5-21-3630213715-3911067759-4130201097-2
S-0-0
S-1-5-21-3630213715-3911067759-4130201097-1


Currently it just prints "S-0-0" which I find a little ass backwards. Can we
print something like "NOT MAPPED" instead:

$ bin/wbinfo --unix-ids-to-sids=u200002,g300001,g200001
S-1-5-21-3630213715-3911067759-4130201097-2
NOT MAPPED
S-1-5-21-3630213715-3911067759-4130201097-1

Patch attached. Please review&push if happy.

Thanks!
-slow
-------------- next part --------------
From 06f97e4916d5f89230964b9400ee380231011136 Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow at samba.org>
Date: Mon, 9 Oct 2017 13:25:21 +0200
Subject: [PATCH] wbinfo: return "NOT MAPPED" instead of "S-0-0" for unmapped
 id-to-sid

Currently wbinfo --unix-ids-to-sids prints "S-0-0" for failed
mappings. Let it print "NOT MAPPED" instead.

Signed-off-by: Ralph Boehme <slow at samba.org>
---
 nsswitch/tests/test_idmap_rfc2307.sh | 2 +-
 nsswitch/wbinfo.c                    | 6 ++++++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/nsswitch/tests/test_idmap_rfc2307.sh b/nsswitch/tests/test_idmap_rfc2307.sh
index 35daa39a592..7dc697d67a2 100755
--- a/nsswitch/tests/test_idmap_rfc2307.sh
+++ b/nsswitch/tests/test_idmap_rfc2307.sh
@@ -179,7 +179,7 @@ while [ ${i} -lt ${NUMGROUPS} ] ; do
     GIDS="$GIDS g$(expr ${i} + ${GID_START})"
     i=$(expr "$i" + 1)
 done
-NUM_VALID_SIDS=$($wbinfo --unix-ids-to-sids="$GIDS" | grep -v ^S-0-0 | wc -l)
+NUM_VALID_SIDS=$($wbinfo --unix-ids-to-sids="$GIDS" | grep -v ^"NOT MAPPED" | wc -l)
 
 testit "Count number of valid sids found" \
        test ${NUM_VALID_SIDS} = ${NUMGROUPS} ||
diff --git a/nsswitch/wbinfo.c b/nsswitch/wbinfo.c
index 67a97b5bbc0..9cd299a2174 100644
--- a/nsswitch/wbinfo.c
+++ b/nsswitch/wbinfo.c
@@ -1105,6 +1105,12 @@ static bool wbinfo_xids_to_sids(const char *arg)
 
 	for (i=0; i<num_xids; i++) {
 		char str[WBC_SID_STRING_BUFLEN];
+		struct wbcDomainSid null_sid = { 0 };
+
+		if (memcmp(&null_sid, &sids[i], sizeof(struct wbcDomainSid)) == 0) {
+			d_printf("NOT MAPPED\n");
+			continue;
+		}
 		wbcSidToStringBuf(&sids[i], str, sizeof(str));
 		d_printf("%s\n", str);
 	}
-- 
2.13.5



More information about the samba-technical mailing list