]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
libcli/security: SDDL accepts lowercase "s-" in SIDs
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>
Fri, 20 Oct 2023 23:47:33 +0000 (12:47 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Wed, 1 Nov 2023 20:10:45 +0000 (20:10 +0000)
This is what Windows does, and it removes a couple of knownfails.

We can change it here cheaply without affecting the core dom_sid code,
which is good because there seem to be other places where we need the
uppercase S (for example in ldap search <SID=> queries).

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
libcli/security/sddl.c
selftest/knownfail.d/sid-strings

index 5f8a01fbef8d34a630876a5a81e0128dd87b7f11..e973a0910053ac016c66e871aa3145236040fe7b 100644 (file)
@@ -208,7 +208,7 @@ static struct dom_sid *sddl_transition_decode_sid(TALLOC_CTX *mem_ctx, const cha
        size_t i;
 
        /* see if its in the numeric format */
-       if (strncmp(sddl, "S-", 2) == 0) {
+       if (strncasecmp(sddl, "S-", 2) == 0) {
                struct dom_sid *sid = NULL;
                char *sid_str = NULL;
                const char *end = NULL;
@@ -230,6 +230,13 @@ static struct dom_sid *sddl_transition_decode_sid(TALLOC_CTX *mem_ctx, const cha
                if (sid_str == NULL) {
                        return NULL;
                }
+               if (sid_str[0] == 's') {
+                       /*
+                        * In SDDL, but not in the dom_sid parsers, a
+                        * lowercase "s-1-1-0" is accepted.
+                        */
+                       sid_str[0] = 'S';
+               }
                sid = talloc(mem_ctx, struct dom_sid);
                if (sid == NULL) {
                        TALLOC_FREE(sid_str);
index 9acc2b51a5a23db57cc77d210d92ff03d27ae3b5..c64510e330b4af34b1ecf276b9f6e75bbe2f199f 100644 (file)
@@ -79,5 +79,3 @@
 ^samba.tests.sid_strings.+.SidStringsThatStartWithS.test_sid_string_internal_S-000000001-5-32-579.ad_dc
 ^samba.tests.sid_strings.+.SidStringsThatStartWithS.test_sid_string_internal_S-1-0.ad_dc
 ^samba.tests.sid_strings.+.SidStringsThatStartWithS.test_sid_string_internal_S-1-22.ad_dc
-^samba.tests.sid_strings.+.SidStringsThatStartWithS.test_sid_string_internal_s-1-5-32-579.ad_dc
-^samba.tests.sid_strings.+.SidStringsThatStartWithS.test_sid_string_s-1-5-32-579.ad_dc