r17465: Get rid of add_initial_entry. In the two places it was called in it seemed a
authorVolker Lendecke <vlendec@samba.org>
Tue, 8 Aug 2006 20:50:35 +0000 (20:50 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 16:38:36 +0000 (11:38 -0500)
bit pointless to me.

Volker
(This used to be commit 244b25ae49d3c635fc54498dbee29f5b649ea1fa)

source3/groupdb/mapping.c
source3/passdb/pdb_interface.c
source3/utils/net_groupmap.c

index 67b550680cb07b44673da4e56c997f641fcc7056..643c6e517c1c84a9c2b2322eb463356b73d002e4 100644 (file)
@@ -133,31 +133,6 @@ static BOOL add_mapping_entry(GROUP_MAP *map, int flag)
        return True;
 }
 
-/****************************************************************************
-initialise first time the mapping list
-****************************************************************************/
-NTSTATUS add_initial_entry(gid_t gid, const char *sid, enum SID_NAME_USE sid_name_use, const char *nt_name, const char *comment)
-{
-       GROUP_MAP map;
-
-       if(!init_group_mapping()) {
-               DEBUG(0,("failed to initialize group mapping\n"));
-               return NT_STATUS_UNSUCCESSFUL;
-       }
-       
-       map.gid=gid;
-       if (!string_to_sid(&map.sid, sid)) {
-               DEBUG(0, ("string_to_sid failed: %s", sid));
-               return NT_STATUS_UNSUCCESSFUL;
-       }
-       
-       map.sid_name_use=sid_name_use;
-       fstrcpy(map.nt_name, nt_name);
-       fstrcpy(map.comment, comment);
-
-       return pdb_add_group_mapping_entry(&map);
-}
-
 /****************************************************************************
  Map a unix group to a newly created mapping
 ****************************************************************************/
index 6a9d072fbb1c572870d3fc4839adad39883a596d..8d287cf2ec9e3403ab410eb170d74aaedc8dc53e 100644 (file)
@@ -584,7 +584,7 @@ static NTSTATUS pdb_default_create_dom_group(struct pdb_methods *methods,
                                             const char *name,
                                             uint32 *rid)
 {
-       DOM_SID group_sid;
+       GROUP_MAP map;
        struct group *grp;
 
        grp = getgrnam(name);
@@ -611,10 +611,12 @@ static NTSTATUS pdb_default_create_dom_group(struct pdb_methods *methods,
                }
        }
 
-       sid_compose(&group_sid, get_global_sam_sid(), *rid);
-               
-       return add_initial_entry(grp->gr_gid, sid_string_static(&group_sid),
-                                SID_NAME_DOM_GRP, name, NULL);
+       map.gid = grp->gr_gid;
+       map.sid_name_use = SID_NAME_DOM_GRP;
+       sid_compose(&map.sid, get_global_sam_sid(), *rid);
+       fstrcpy(map.nt_name, name);
+       map.comment[0] = '\0';
+       return pdb_add_group_mapping_entry(&map);
 }
 
 NTSTATUS pdb_create_dom_group(TALLOC_CTX *mem_ctx, const char *name,
index 10ea8cce2a07cb24e27a4e36e855f7eb1812482f..fc16bb8e495368e7c4e884dd8c2a73e8e142f11d 100644 (file)
@@ -182,16 +182,12 @@ static int net_groupmap_list(int argc, const char **argv)
 
 static int net_groupmap_add(int argc, const char **argv)
 {
-       DOM_SID sid;
-       fstring ntgroup = "";
        fstring unixgrp = "";
        fstring string_sid = "";
        fstring type = "";
-       fstring ntcomment = "";
-       enum SID_NAME_USE sid_type = SID_NAME_DOM_GRP;
        uint32 rid = 0; 
-       gid_t gid;
        int i;
+       GROUP_MAP map;
        
        /* get the options */
        for ( i=0; i<argc; i++ ) {
@@ -210,8 +206,8 @@ static int net_groupmap_add(int argc, const char **argv)
                        }               
                }
                else if ( !StrnCaseCmp(argv[i], "ntgroup", strlen("ntgroup")) ) {
-                       fstrcpy( ntgroup, get_string_param( argv[i] ) );
-                       if ( !ntgroup[0] ) {
+                       fstrcpy( map.nt_name, get_string_param( argv[i] ) );
+                       if ( !map.nt_name[0] ) {
                                d_fprintf(stderr, "must supply a name\n");
                                return -1;
                        }               
@@ -221,11 +217,16 @@ static int net_groupmap_add(int argc, const char **argv)
                        if ( !string_sid[0] ) {
                                d_fprintf(stderr, "must supply a SID\n");
                                return -1;
-                       }               
+                       }
+                       if (!string_to_sid(&map.sid, string_sid)) {
+                               d_fprintf(stderr, "%s is not a valid SID\n",
+                                         string_sid);
+                               return -1;
+                       }
                }
                else if ( !StrnCaseCmp(argv[i], "comment", strlen("comment")) ) {
-                       fstrcpy( ntcomment, get_string_param( argv[i] ) );
-                       if ( !ntcomment[0] ) {
+                       fstrcpy( map.comment, get_string_param( argv[i] ) );
+                       if ( !map.comment[0] ) {
                                d_fprintf(stderr, "must supply a comment string\n");
                                return -1;
                        }                               
@@ -235,15 +236,15 @@ static int net_groupmap_add(int argc, const char **argv)
                        switch ( type[0] ) {
                                case 'b':
                                case 'B':
-                                       sid_type = SID_NAME_WKN_GRP;
+                                       map.sid_name_use = SID_NAME_WKN_GRP;
                                        break;
                                case 'd':
                                case 'D':
-                                       sid_type = SID_NAME_DOM_GRP;
+                                       map.sid_name_use = SID_NAME_DOM_GRP;
                                        break;
                                case 'l':
                                case 'L':
-                                       sid_type = SID_NAME_ALIAS;
+                                       map.sid_name_use = SID_NAME_ALIAS;
                                        break;
                        }
                }
@@ -258,14 +259,13 @@ static int net_groupmap_add(int argc, const char **argv)
                return -1;
        }
        
-       if ( (gid = nametogid(unixgrp)) == (gid_t)-1 ) {
+       if ( (map.gid = nametogid(unixgrp)) == (gid_t)-1 ) {
                d_fprintf(stderr, "Can't lookup UNIX group %s\n", unixgrp);
                return -1;
        }
 
        {
-               GROUP_MAP map;
-               if (NT_STATUS_IS_OK(pdb_getgrgid(&map, gid))) {
+               if (NT_STATUS_IS_OK(pdb_getgrgid(&map, map.gid))) {
                        d_printf("Unix group %s already mapped to SID %s\n",
                                 unixgrp, sid_string_static(&map.sid));
                        return -1;
@@ -275,7 +275,7 @@ static int net_groupmap_add(int argc, const char **argv)
        if ( (rid == 0) && (string_sid[0] == '\0') ) {
                d_printf("No rid or sid specified, choosing a RID\n");
                if (pdb_rid_algorithm()) {
-                       rid = pdb_gid_to_group_rid(gid);
+                       rid = pdb_gid_to_group_rid(map.gid);
                } else {
                        if (!pdb_new_rid(&rid)) {
                                d_printf("Could not get new RID\n");
@@ -286,38 +286,38 @@ static int net_groupmap_add(int argc, const char **argv)
 
        /* append the rid to our own domain/machine SID if we don't have a full SID */
        if ( !string_sid[0] ) {
-               sid_copy(&sid, get_global_sam_sid());
-               sid_append_rid(&sid, rid);
-               sid_to_string(string_sid, &sid);
+               sid_copy(&map.sid, get_global_sam_sid());
+               sid_append_rid(&map.sid, rid);
        }
 
-       if (!ntcomment[0]) {
-               switch (sid_type) {
+       if (!map.comment[0]) {
+               switch (map.sid_name_use) {
                case SID_NAME_WKN_GRP:
-                       fstrcpy(ntcomment, "Wellknown Unix group");
+                       fstrcpy(map.comment, "Wellknown Unix group");
                        break;
                case SID_NAME_DOM_GRP:
-                       fstrcpy(ntcomment, "Domain Unix group");
+                       fstrcpy(map.comment, "Domain Unix group");
                        break;
                case SID_NAME_ALIAS:
-                       fstrcpy(ntcomment, "Local Unix group");
+                       fstrcpy(map.comment, "Local Unix group");
                        break;
                default:
-                       fstrcpy(ntcomment, "Unix group");
+                       fstrcpy(map.comment, "Unix group");
                        break;
                }
        }
                
-       if (!ntgroup[0] )
-               fstrcpy( ntgroup, unixgrp );
-               
-       
-       if (!NT_STATUS_IS_OK(add_initial_entry(gid, string_sid, sid_type, ntgroup, ntcomment))) {
-               d_fprintf(stderr, "adding entry for group %s failed!\n", ntgroup);
+       if (!map.nt_name[0] )
+               fstrcpy( map.nt_name, unixgrp );
+
+       if (!NT_STATUS_IS_OK(pdb_add_group_mapping_entry(&map))) {
+               d_fprintf(stderr, "adding entry for group %s failed!\n",
+                         map.nt_name);
                return -1;
        }
 
-       d_printf("Successfully added group %s to the mapping db\n", ntgroup);
+       d_printf("Successfully added group %s to the mapping db\n",
+                map.nt_name);
        return 0;
 }