]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3:winbindd/autorid preallocate well-known SIDs
authorChristian Ambach <ambi@samba.org>
Fri, 4 May 2012 15:56:26 +0000 (17:56 +0200)
committerChristian Ambach <ambi@samba.org>
Tue, 8 May 2012 07:26:07 +0000 (09:26 +0200)
preallocate the list of well-known SIDs that Win2008R2 reports
to be groups and that are on the list in KB243330
This will allow for deterministic mapping of these SIDs, even if they
are stored in the allocation pool as this is the first thing that autorid
will allocate from the pool during module initialization

source3/winbindd/idmap_autorid.c

index ab84104a633aef65273f0c896d3851d1cc361560..554a033512d8fac1f80bb12ad4fb023badec658b 100644 (file)
@@ -684,6 +684,45 @@ static NTSTATUS idmap_autorid_saveconfig(struct autorid_global_config *cfg)
        return status;
 }
 
+static NTSTATUS idmap_autorid_preallocate_wellknown(struct idmap_domain *dom)
+{
+       const char *groups[] = { "S-1-1-0", "S-1-2-0", "S-1-2-1",
+               "S-1-3-0", "S-1-3-1", "S-1-3-2", "S-1-3-3", "S-1-3-4",
+               "S-1-5-1", "S-1-5-2", "S-1-5-3", "S-1-5-4", "S-1-5-6",
+               "S-1-5-7", "S-1-5-8", "S-1-5-9", "S-1-5-10", "S-1-5-11",
+               "S-1-5-12", "S-1-5-13", "S-1-5-14", "S-1-5-15",
+               "S-1-5-17", "S-1-5-18", "S-1-5-19", "S-1-5-20"
+       };
+
+       struct id_map **maps;
+       int i, num;
+       NTSTATUS status;
+
+       num = sizeof(groups)/sizeof(char*);
+
+       maps = talloc_zero_array(talloc_tos(), struct id_map*, num+1);
+       if (!maps) {
+               return NT_STATUS_NO_MEMORY;
+       }
+
+       for (i = 0; i < num; i++) {
+               maps[i] = talloc(maps, struct id_map);
+               maps[i]->xid.type = ID_TYPE_GID;
+               maps[i]->sid = dom_sid_parse_talloc(maps, groups[i]);
+       }
+
+       maps[num] = NULL;
+
+       status = idmap_autorid_sids_to_unixids(dom, maps);
+
+       DEBUG(10,("Preallocation run finished with status %s\n",
+                 nt_errstr(status)));
+
+       talloc_free(maps);
+
+       return NT_STATUS_IS_OK(status)?NT_STATUS_OK:NT_STATUS_UNSUCCESSFUL;
+}
+
 static NTSTATUS idmap_autorid_initialize(struct idmap_domain *dom)
 {
        struct idmap_tdb_common_context *commonconfig;
@@ -810,6 +849,9 @@ static NTSTATUS idmap_autorid_initialize(struct idmap_domain *dom)
 
        dom->private_data = commonconfig;
 
+       /* preallocate well-known SIDs in the pool */
+       status = idmap_autorid_preallocate_wellknown(dom);
+
        goto done;
 
 error: