summaryrefslogtreecommitdiff
path: root/source3/groupdb/mapping.c
diff options
context:
space:
mode:
authorVolker Lendecke <vlendec@samba.org>2002-10-16 09:41:42 +0000
committerVolker Lendecke <vlendec@samba.org>2002-10-16 09:41:42 +0000
commit4f001512cdc5fdf27981ffee7e110a6818a978d7 (patch)
treee5de0ae93c073904821dc231227b7a9d80c03f0d /source3/groupdb/mapping.c
parentf55eb87af56b68b44e64a2dee5fcfe8248b718cf (diff)
downloadsamba-4f001512cdc5fdf27981ffee7e110a6818a978d7.tar.gz
samba-4f001512cdc5fdf27981ffee7e110a6818a978d7.tar.bz2
samba-4f001512cdc5fdf27981ffee7e110a6818a978d7.zip
Create group mappings on the fly.
Volker (This used to be commit e2fc1de34aaf875a7003f9d15d5f8ecf159130fb)
Diffstat (limited to 'source3/groupdb/mapping.c')
-rw-r--r--source3/groupdb/mapping.c40
1 files changed, 24 insertions, 16 deletions
diff --git a/source3/groupdb/mapping.c b/source3/groupdb/mapping.c
index 0f05316949..d78582e7e5 100644
--- a/source3/groupdb/mapping.c
+++ b/source3/groupdb/mapping.c
@@ -1048,34 +1048,42 @@ Returns a GROUP_MAP struct based on the gid.
BOOL get_group_from_gid(gid_t gid, GROUP_MAP *map, BOOL with_priv)
{
struct group *grp;
+ fstring name;
+ DOM_SID sid;
+ fstring string_sid;
+ PRIVILEGE_SET priv_set;
if(!init_group_mapping()) {
DEBUG(0,("failed to initialize group mapping"));
return(False);
}
- if ( (grp=getgrgid(gid)) == NULL)
- return False;
+ if (get_group_map_from_gid(gid, map, with_priv))
+ return True;
- /*
- * make a group map from scratch if doesn't exist.
- */
- if (!get_group_map_from_gid(gid, map, with_priv)) {
- map->gid=gid;
- map->sid_name_use=SID_NAME_ALIAS;
- map->systemaccount=PR_ACCESS_FROM_NETWORK;
- init_privilege(&map->priv_set);
+ /* There is no mapping, create one on the fly. This is just
+ interim, we need a RID allocator in the passdb backend. */
- /* interim solution until we have a last RID allocated */
+ if ((grp=getgrgid(gid)) != NULL) {
+ slprintf(name, sizeof(name), "Group %s", grp->gr_name);
+ } else {
+ slprintf(name, sizeof(name), "Group %d", gid);
+ }
- sid_copy(&map->sid, get_global_sam_sid());
- sid_append_rid(&map->sid, pdb_gid_to_group_rid(gid));
+ /* interim solution until we have a last RID allocated */
- fstrcpy(map->nt_name, grp->gr_name);
- fstrcpy(map->comment, "Local Unix Group");
+ sid_copy(&sid, get_global_sam_sid());
+ sid_append_rid(&sid, pdb_gid_to_group_rid(gid));
+ sid_to_string(string_sid, &sid);
+ init_privilege(&priv_set);
+
+ if (!add_initial_entry(gid, string_sid, SID_NAME_DOM_GRP,
+ name, "Local Unix Group",
+ priv_set, PR_ACCESS_FROM_NETWORK)) {
+ return False;
}
- return True;
+ return get_group_map_from_gid(gid, map, with_priv);
}