idmap: return the correct id type to *id_to_sid methods
authorGarming Sam <garming@catalyst.net.nz>
Wed, 26 Nov 2014 02:33:35 +0000 (15:33 +1300)
committerGarming Sam <garming@samba.org>
Wed, 3 Dec 2014 03:21:09 +0000 (04:21 +0100)
We have a pointer to a unixid which is sent down instead of a uid or
gid. We can use this as an in-out variable so that pdb_samba_dsdb can be
returned ID_TYPE_BOTH to cache correctly instead of leaving it as
ID_TYPE_UID or ID_TYPE_GID.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=10720

Change-Id: I0cef2e419cbb337531244b7b41c708cf2ab883e3
Signed-off-by: Garming Sam <garming@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
selftest/knownfail
source4/winbind/idmap.c

index e9e62396d822c62f4bbd0c2297c1c00c0b7fb4c5..1c4f446129abb5fda04644528d5614a3f07d3c7e 100644 (file)
 ^samba3.rpc.spoolss.printer.addprinterex.driver_info_winreg # knownfail or flapping?
 ^samba3.rpc.spoolss.printer.*.publish_toggle\(.*\)$ # needs spoolss AD member env
 ^samba3.rpc.spoolss.printserver.*.add_processor\(.*\)$
-^samba.wbinfo_sids2xids.\(plugin_s4_dc:local\)
-^samba.wbinfo_sids2xids.\(s4member:local\)
 #
 # The following tests fail against plugin_s4_dc (aka s3fs) currently.
 # These need to be examined and either fixed or correctly categorised.
index 54fea18c7fe8aeea50b08b7c13d3f3f090636048..26a4664a4d9f4b8039fed78e275af67fc9d8da8a 100644 (file)
@@ -208,7 +208,7 @@ struct idmap_context *idmap_init(TALLOC_CTX *mem_ctx,
 
 static NTSTATUS idmap_xid_to_sid(struct idmap_context *idmap_ctx,
                                 TALLOC_CTX *mem_ctx,
-                                const struct unixid *unixid,
+                                struct unixid *unixid,
                                 struct dom_sid **sid)
 {
        int ret;
@@ -321,6 +321,9 @@ static NTSTATUS idmap_xid_to_sid(struct idmap_context *idmap_ctx,
        }
 
        if (res->count == 1) {
+               const char *type = ldb_msg_find_attr_as_string(res->msgs[0],
+                                                              "type", NULL);
+
                *sid = idmap_msg_get_dom_sid(mem_ctx, res->msgs[0],
                                             "objectSid");
                if (*sid == NULL) {
@@ -328,6 +331,21 @@ static NTSTATUS idmap_xid_to_sid(struct idmap_context *idmap_ctx,
                        status = NT_STATUS_NONE_MAPPED;
                        goto failed;
                }
+
+               if (type == NULL) {
+                       DEBUG(1, ("Invalid type for mapping entry.\n"));
+                       talloc_free(tmp_ctx);
+                       return NT_STATUS_NONE_MAPPED;
+               }
+
+               if (strcmp(type, "ID_TYPE_BOTH") == 0) {
+                       unixid->type = ID_TYPE_BOTH;
+               } else if (strcmp(type, "ID_TYPE_UID") == 0) {
+                       unixid->type = ID_TYPE_UID;
+               } else {
+                       unixid->type = ID_TYPE_GID;
+               }
+
                talloc_free(tmp_ctx);
                return NT_STATUS_OK;
        }