From 8f0b33382943b9e5e419dcbcf3cc7bb974b7eae2 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Tue, 22 Apr 2003 05:14:41 +0000 Subject: support referencing group by sid in all operations; allow group name to be changed (This used to be commit 00dfaa7c2c9227a082ca17ed14aefc19d9087a57) --- source3/utils/net_groupmap.c | 73 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 60 insertions(+), 13 deletions(-) diff --git a/source3/utils/net_groupmap.c b/source3/utils/net_groupmap.c index a9f47172fe..3cb132c2f9 100644 --- a/source3/utils/net_groupmap.c +++ b/source3/utils/net_groupmap.c @@ -176,6 +176,7 @@ int net_groupmap_add(int argc, const char **argv) PRIVILEGE_SET se_priv; DOM_SID sid; fstring ntgroup = ""; + fstring unixgrp = ""; fstring string_sid = ""; fstring type = ""; fstring ntcomment = ""; @@ -193,7 +194,14 @@ int net_groupmap_add(int argc, const char **argv) return -1; } } - else if ( !StrnCaseCmp(argv[i], "name", strlen("name")) ) { + else if ( !StrnCaseCmp(argv[i], "unixgroup", strlen("unixgroup")) ) { + fstrcpy( unixgrp, get_string_param( argv[i] ) ); + if ( !unixgrp[0] ) { + d_printf("must supply a name\n"); + return -1; + } + } + else if ( !StrnCaseCmp(argv[i], "ntgroup", strlen("ntgroup")) ) { fstrcpy( ntgroup, get_string_param( argv[i] ) ); if ( !ntgroup[0] ) { d_printf("must supply a name\n"); @@ -237,8 +245,8 @@ int net_groupmap_add(int argc, const char **argv) } } - if ( !ntgroup[0] || (!rid && !string_sid[0]) || sid_type==SID_NAME_UNKNOWN ) { - d_printf("Usage: net groupmap add {rid=|sid=} name=| type= [comment=]\n"); + if ( !unixgrp[0] || (!rid && !string_sid[0]) || sid_type==SID_NAME_UNKNOWN ) { + d_printf("Usage: net groupmap add {rid=|sid=} unixgroup= type= [ntgroup=] [comment=]\n"); return -1; } @@ -252,11 +260,15 @@ int net_groupmap_add(int argc, const char **argv) if (ntcomment[0]) fstrcpy(ntcomment, "Local Unix group"); - if ( !(gid = nametogid(ntgroup)) ) { + if ( !(gid = nametogid(unixgrp)) ) { d_printf("Can't lookup UNIX group %s\n", ntgroup); return -1; } + if ( !ntgroup[0] ) + fstrcpy( ntgroup, unixgrp ); + + init_privilege(&se_priv); #if 0 if (privilege!=NULL) @@ -282,18 +294,26 @@ int net_groupmap_modify(int argc, const char **argv) fstring ntcomment = ""; fstring type = ""; fstring ntgroup = ""; + fstring sid_string = ""; enum SID_NAME_USE sid_type = SID_NAME_UNKNOWN; int i; /* get the options */ for ( i=0; i [comment=] [type=\n"); + if ( !ntgroup[0] && !sid_string[0] ) { + d_printf("Usage: net groupmap modify {ntgroup=|sid=} [comment=] [type=\n"); return -1; } - - if (!get_sid_from_input(&sid, ntgroup)) { - return -1; + + /* give preference to the SID; if both the ntgroup name and SID + are defined, use the SID and assume that the group name could be a + new name */ + + if ( sid_string[0] ) { + if (!get_sid_from_input(&sid, sid_string)) { + return -1; + } } + else { + if (!get_sid_from_input(&sid, ntgroup)) { + return -1; + } + } /* Get the current mapping from the database */ if(!pdb_getgrsid(&map, sid, MAPPING_WITH_PRIV)) { @@ -358,6 +389,9 @@ int net_groupmap_modify(int argc, const char **argv) /* Change comment if new one */ if ( ntcomment[0] ) fstrcpy( map.comment, ntcomment ); + + if ( ntgroup[0] ) + fstrcpy( map.nt_name, ntgroup ); #if 0 /* Change the privilege if new one */ @@ -382,28 +416,41 @@ int net_groupmap_delete(int argc, const char **argv) { DOM_SID sid; fstring ntgroup = ""; + fstring sid_string = ""; int i; /* get the options */ for ( i=0; i\n"); + if ( !ntgroup[0] && !sid_string[0]) { + d_printf("Usage: net groupmap delete {ntgroup=|sid=}\n"); return -1; } + /* give preference to the SID if we have that */ + + if ( sid_string[0] ) + fstrcpy( ntgroup, sid_string ); + if ( !get_sid_from_input(&sid, ntgroup) ) { d_printf("Unable to resolve group %s to a SID\n", ntgroup); return -1; -- cgit