summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorVolker Lendecke <vlendec@samba.org>2006-08-08 20:50:35 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 11:38:36 -0500
commitd802774e02ed4a68d61b9fa3b95164221dd50112 (patch)
treef55d6fad5bee4140c7fe3dee938a71e40a3854e6 /source3
parent4fb4ef919827eb6ba9fdbfdbe9b2c0d4bb43170e (diff)
downloadsamba-d802774e02ed4a68d61b9fa3b95164221dd50112.tar.gz
samba-d802774e02ed4a68d61b9fa3b95164221dd50112.tar.bz2
samba-d802774e02ed4a68d61b9fa3b95164221dd50112.zip
r17465: Get rid of add_initial_entry. In the two places it was called in it seemed a
bit pointless to me. Volker (This used to be commit 244b25ae49d3c635fc54498dbee29f5b649ea1fa)
Diffstat (limited to 'source3')
-rw-r--r--source3/groupdb/mapping.c25
-rw-r--r--source3/passdb/pdb_interface.c12
-rw-r--r--source3/utils/net_groupmap.c66
3 files changed, 40 insertions, 63 deletions
diff --git a/source3/groupdb/mapping.c b/source3/groupdb/mapping.c
index 67b550680c..643c6e517c 100644
--- a/source3/groupdb/mapping.c
+++ b/source3/groupdb/mapping.c
@@ -134,31 +134,6 @@ static BOOL add_mapping_entry(GROUP_MAP *map, int flag)
}
/****************************************************************************
-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
****************************************************************************/
NTSTATUS map_unix_group(const struct group *grp, GROUP_MAP *pmap)
diff --git a/source3/passdb/pdb_interface.c b/source3/passdb/pdb_interface.c
index 6a9d072fbb..8d287cf2ec 100644
--- a/source3/passdb/pdb_interface.c
+++ b/source3/passdb/pdb_interface.c
@@ -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,
diff --git a/source3/utils/net_groupmap.c b/source3/utils/net_groupmap.c
index 10ea8cce2a..fc16bb8e49 100644
--- a/source3/utils/net_groupmap.c
+++ b/source3/utils/net_groupmap.c
@@ -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;
}