s3:passdb add a gid argument to pdb_create_builtin_alias
authorChristian Ambach <ambi@samba.org>
Tue, 18 Jun 2013 14:30:31 +0000 (16:30 +0200)
committerMichael Adam <obnox@samba.org>
Fri, 21 Jun 2013 08:44:24 +0000 (10:44 +0200)
make it possible to skip the allocation of a new gid from winbind
by specifying the gid to be used

Signed-off-by: Christian Ambach <ambi@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
source3/groupdb/mapping.c
source3/include/passdb.h
source3/passdb/ABI/pdb-0.sigs
source3/passdb/pdb_util.c

index c6fcc8aa711a8411c4f593319c4cfe7b57c9796e..e3d52b70fb21254203eea91f38bcfc0ad355054b 100644 (file)
@@ -790,15 +790,19 @@ NTSTATUS pdb_nop_enum_group_mapping(struct pdb_methods *methods,
        return NT_STATUS_UNSUCCESSFUL;
 }
 
-/********************************************************************
- Really just intended to be called by smbd
-********************************************************************/
-
-NTSTATUS pdb_create_builtin_alias(uint32 rid)
+/**
+* @brief Add a new group mapping
+*
+* @param[in] gid gid to use to store the mapping. If gid is 0,
+*                new gid will be allocated from winbind
+*
+* @return Normal NTSTATUS return
+*/
+NTSTATUS pdb_create_builtin_alias(uint32 rid, gid_t gid)
 {
        struct dom_sid sid;
        enum lsa_SidType type;
-       gid_t gid;
+       gid_t gidformap;
        GROUP_MAP *map;
        NTSTATUS status;
        const char *name = NULL;
@@ -820,15 +824,21 @@ NTSTATUS pdb_create_builtin_alias(uint32 rid)
                goto done;
        }
 
-       if (!winbind_allocate_gid(&gid)) {
-               DEBUG(3, ("pdb_create_builtin_alias: Could not get a gid out of winbind\n"));
-               status = NT_STATUS_ACCESS_DENIED;
-               goto done;
+       if (gid == 0) {
+               if (!winbind_allocate_gid(&gidformap)) {
+                       DEBUG(3, ("pdb_create_builtin_alias: Could not get a "
+                                 "gid out of winbind\n"));
+                       status = NT_STATUS_ACCESS_DENIED;
+                       goto done;
+               }
+       } else {
+               gidformap = gid;
        }
 
-       DEBUG(10, ("Creating alias %s with gid %u\n", name, (unsigned)gid));
+       DEBUG(10, ("Creating alias %s with gid %u\n", name,
+                  (unsigned) gidformap));
 
-       map->gid = gid;
+       map->gid = gidformap;
        sid_copy(&map->sid, &sid);
        map->sid_name_use = SID_NAME_ALIAS;
        map->nt_name = talloc_strdup(map, name);
index ae3a96846405ecea699027c78db7e2c607fdc862..637c55a8402e5a7707c1392547b66ab9e831aa2f 100644 (file)
@@ -123,7 +123,7 @@ NTSTATUS pdb_nop_enum_group_mapping(struct pdb_methods *methods,
                                           enum lsa_SidType sid_name_use,
                                           GROUP_MAP **rmap, size_t *num_entries,
                                           bool unix_only);
-NTSTATUS pdb_create_builtin_alias(uint32_t rid);
+NTSTATUS pdb_create_builtin_alias(uint32_t rid, gid_t gid);
 
 
 /* passdb headers */
index 9c5c773941fb46bfd040a5a9dae4492bda491e92..ccb371b207f7fbf011970024edd45051ce705d92 100644 (file)
@@ -74,7 +74,7 @@ pdb_build_fields_present: uint32_t (struct samu *)
 pdb_capabilities: uint32_t (void)
 pdb_copy_sam_account: bool (struct samu *, struct samu *)
 pdb_create_alias: NTSTATUS (const char *, uint32_t *)
-pdb_create_builtin_alias: NTSTATUS (uint32_t)
+pdb_create_builtin_alias: NTSTATUS (uint32_t, gid_t)
 pdb_create_dom_group: NTSTATUS (TALLOC_CTX *, const char *, uint32_t *)
 pdb_create_user: NTSTATUS (TALLOC_CTX *, const char *, uint32_t, uint32_t *)
 pdb_decode_acct_ctrl: uint32_t (const char *)
index 0ac6594d4cfdea8faaf4fa1a0503cf186c9fd228..31fd018e8c266447f9d6fc0e8eaa6bd620c79e20 100644 (file)
@@ -81,7 +81,7 @@ NTSTATUS pdb_create_builtin(uint32_t rid)
                if (!lp_winbind_nested_groups() || !winbind_ping()) {
                        return NT_STATUS_PROTOCOL_UNREACHABLE;
                }
-               status = pdb_create_builtin_alias(rid);
+               status = pdb_create_builtin_alias(rid, 0);
        }
        return status;
 }