diff options
author | Volker Lendecke <vlendec@samba.org> | 2006-08-15 14:07:15 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 11:38:38 -0500 |
commit | 03e3cd1d5a005ad5fd2bc97f9863abf675efd09f (patch) | |
tree | 183a66f7bb43c7a34f05511a1903a854d963e27d /source3/utils | |
parent | 81e501ad1587b4f75851bc39c826383b112b7cb3 (diff) | |
download | samba-03e3cd1d5a005ad5fd2bc97f9863abf675efd09f.tar.gz samba-03e3cd1d5a005ad5fd2bc97f9863abf675efd09f.tar.bz2 samba-03e3cd1d5a005ad5fd2bc97f9863abf675efd09f.zip |
r17554: Cleanup
(This used to be commit 761cbd52f0cff6b864c506ec03c94039b6101ef9)
Diffstat (limited to 'source3/utils')
-rw-r--r-- | source3/utils/net_groupmap.c | 85 | ||||
-rw-r--r-- | source3/utils/net_rpc_samsync.c | 10 | ||||
-rw-r--r-- | source3/utils/net_sam.c | 8 |
3 files changed, 53 insertions, 50 deletions
diff --git a/source3/utils/net_groupmap.c b/source3/utils/net_groupmap.c index b95e8c65e4..df13a93de6 100644 --- a/source3/utils/net_groupmap.c +++ b/source3/utils/net_groupmap.c @@ -66,7 +66,7 @@ static BOOL get_sid_from_input(DOM_SID *sid, char *input) if (StrnCaseCmp( input, "S-", 2)) { /* Perhaps its the NT group name? */ - if (!NT_STATUS_IS_OK(pdb_getgrnam(&map, input))) { + if (!pdb_getgrnam(&map, input)) { printf("NT Group %s doesn't exist in mapping DB\n", input); return False; } else { @@ -153,7 +153,7 @@ static int net_groupmap_list(int argc, const char **argv) } /* Get the current mapping from the database */ - if(!NT_STATUS_IS_OK(pdb_getgrsid(&map, &sid))) { + if(!pdb_getgrsid(&map, sid)) { d_fprintf(stderr, "Failure to local group SID in the database\n"); return -1; } @@ -163,7 +163,7 @@ static int net_groupmap_list(int argc, const char **argv) else { GROUP_MAP *map=NULL; /* enumerate all group mappings */ - if (!NT_STATUS_IS_OK(pdb_enum_group_mapping(NULL, SID_NAME_UNKNOWN, &map, &entries, ENUM_ALL_MAPPED))) + if (!pdb_enum_group_mapping(NULL, SID_NAME_UNKNOWN, &map, &entries, ENUM_ALL_MAPPED)) return -1; for (i=0; i<entries; i++) { @@ -182,12 +182,18 @@ 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; + const char *name_type; ZERO_STRUCT(map); @@ -213,8 +219,8 @@ static int net_groupmap_add(int argc, const char **argv) } } else if ( !StrnCaseCmp(argv[i], "ntgroup", strlen("ntgroup")) ) { - fstrcpy( map.nt_name, get_string_param( argv[i] ) ); - if ( !map.nt_name[0] ) { + fstrcpy( ntgroup, get_string_param( argv[i] ) ); + if ( !ntgroup[0] ) { d_fprintf(stderr, "must supply a name\n"); return -1; } @@ -224,16 +230,11 @@ 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( map.comment, get_string_param( argv[i] ) ); - if ( !map.comment[0] ) { + fstrcpy( ntcomment, get_string_param( argv[i] ) ); + if ( !ntcomment[0] ) { d_fprintf(stderr, "must supply a comment string\n"); return -1; } @@ -243,17 +244,17 @@ static int net_groupmap_add(int argc, const char **argv) switch ( type[0] ) { case 'b': case 'B': - map.sid_name_use = SID_NAME_WKN_GRP; + sid_type = SID_NAME_WKN_GRP; name_type = "wellknown group"; break; case 'd': case 'D': - map.sid_name_use = SID_NAME_DOM_GRP; + sid_type = SID_NAME_DOM_GRP; name_type = "domain group"; break; case 'l': case 'L': - map.sid_name_use = SID_NAME_ALIAS; + sid_type = SID_NAME_ALIAS; name_type = "alias (local) group"; break; default: @@ -272,13 +273,13 @@ static int net_groupmap_add(int argc, const char **argv) return -1; } - if ( (map.gid = nametogid(unixgrp)) == (gid_t)-1 ) { + if ( (gid = nametogid(unixgrp)) == (gid_t)-1 ) { d_fprintf(stderr, "Can't lookup UNIX group %s\n", unixgrp); return -1; } { - if (NT_STATUS_IS_OK(pdb_getgrgid(&map, map.gid))) { + if (pdb_getgrgid(&map, gid)) { d_printf("Unix group %s already mapped to SID %s\n", unixgrp, sid_string_static(&map.sid)); return -1; @@ -288,7 +289,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(map.gid); + rid = pdb_gid_to_group_rid(gid); } else { if (!pdb_new_rid(&rid)) { d_printf("Could not get new RID\n"); @@ -299,38 +300,39 @@ 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(&map.sid, get_global_sam_sid()); - sid_append_rid(&map.sid, rid); + sid_copy(&sid, get_global_sam_sid()); + sid_append_rid(&sid, rid); + sid_to_string(string_sid, &sid); } - if (!map.comment[0]) { - switch (map.sid_name_use) { + if (!ntcomment[0]) { + switch (sid_type) { case SID_NAME_WKN_GRP: - fstrcpy(map.comment, "Wellknown Unix group"); + fstrcpy(ntcomment, "Wellknown Unix group"); break; case SID_NAME_DOM_GRP: - fstrcpy(map.comment, "Domain Unix group"); + fstrcpy(ntcomment, "Domain Unix group"); break; case SID_NAME_ALIAS: - fstrcpy(map.comment, "Local Unix group"); + fstrcpy(ntcomment, "Local Unix group"); break; default: - fstrcpy(map.comment, "Unix group"); + fstrcpy(ntcomment, "Unix group"); break; } } - 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); + 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); return -1; } d_printf("Successfully added group %s to the mapping db as a %s\n", - map.nt_name, name_type); + ntgroup, name_type); return 0; } @@ -417,7 +419,7 @@ static int net_groupmap_modify(int argc, const char **argv) } /* Get the current mapping from the database */ - if(!NT_STATUS_IS_OK(pdb_getgrsid(&map, &sid))) { + if(!pdb_getgrsid(&map, sid)) { d_fprintf(stderr, "Failure to local group SID in the database\n"); return -1; } @@ -426,17 +428,16 @@ static int net_groupmap_modify(int argc, const char **argv) * Allow changing of group type only between domain and local * We disallow changing Builtin groups !!! (SID problem) */ - if (sid_type == SID_NAME_UNKNOWN) { d_fprintf(stderr, "Can't map to an unknown group type.\n"); return -1; - } + } if (map.sid_name_use == SID_NAME_WKN_GRP) { d_fprintf(stderr, "You can only change between domain and local groups.\n"); return -1; } - + map.sid_name_use=sid_type; /* Change comment if new one */ @@ -550,13 +551,13 @@ static int net_groupmap_set(int argc, const char **argv) } } - have_map = NT_STATUS_IS_OK(pdb_getgrnam(&map, ntgroup)); + have_map = pdb_getgrnam(&map, ntgroup); if (!have_map) { DOM_SID sid; have_map = ( (strncmp(ntgroup, "S-", 2) == 0) && string_to_sid(&sid, ntgroup) && - NT_STATUS_IS_OK(pdb_getgrsid(&map, &sid)) ); + pdb_getgrsid(&map, sid) ); } if (!have_map) { @@ -629,8 +630,8 @@ static int net_groupmap_cleanup(int argc, const char **argv) GROUP_MAP *map = NULL; size_t i, entries; - if (!NT_STATUS_IS_OK(pdb_enum_group_mapping(NULL, SID_NAME_UNKNOWN, &map, &entries, - ENUM_ALL_MAPPED))) { + if (!pdb_enum_group_mapping(NULL, SID_NAME_UNKNOWN, &map, &entries, + ENUM_ALL_MAPPED)) { d_fprintf(stderr, "Could not list group mappings\n"); return -1; } diff --git a/source3/utils/net_rpc_samsync.c b/source3/utils/net_rpc_samsync.c index 7cf3bb6e1d..bbe09a3b35 100644 --- a/source3/utils/net_rpc_samsync.c +++ b/source3/utils/net_rpc_samsync.c @@ -588,7 +588,7 @@ static NTSTATUS fetch_account_info(uint32 rid, SAM_ACCOUNT_INFO *delta) group_sid = *pdb_get_group_sid(sam_account); - if (!NT_STATUS_IS_OK(pdb_getgrsid(&map, &group_sid))) { + if (!pdb_getgrsid(&map, group_sid)) { DEBUG(0, ("Primary group of %s has no mapping!\n", pdb_get_username(sam_account))); } else { @@ -630,7 +630,7 @@ static NTSTATUS fetch_group_info(uint32 rid, SAM_GROUP_INFO *delta) sid_append_rid(&group_sid, rid); sid_to_string(sid_string, &group_sid); - if (NT_STATUS_IS_OK(pdb_getgrsid(&map, &group_sid))) { + if (pdb_getgrsid(&map, group_sid)) { if ( map.gid != -1 ) grp = getgrgid(map.gid); insert = False; @@ -689,7 +689,7 @@ static NTSTATUS fetch_group_mem_info(uint32 rid, SAM_GROUP_MEM_INFO *delta) sid_copy(&group_sid, get_global_sam_sid()); sid_append_rid(&group_sid, rid); - if (!NT_STATUS_IS_OK(get_domain_group_from_sid(&group_sid, &map))) { + if (!get_domain_group_from_sid(group_sid, &map)) { DEBUG(0, ("Could not find global group %d\n", rid)); return NT_STATUS_NO_SUCH_GROUP; } @@ -805,6 +805,7 @@ static NTSTATUS fetch_alias_info(uint32 rid, SAM_ALIAS_INFO *delta, fstring comment; struct group *grp = NULL; DOM_SID alias_sid; + fstring sid_string; GROUP_MAP map; BOOL insert = True; @@ -814,8 +815,9 @@ static NTSTATUS fetch_alias_info(uint32 rid, SAM_ALIAS_INFO *delta, /* Find out whether the group is already mapped */ sid_copy(&alias_sid, &dom_sid); sid_append_rid(&alias_sid, rid); + sid_to_string(sid_string, &alias_sid); - if (NT_STATUS_IS_OK(pdb_getgrsid(&map, &alias_sid))) { + if (pdb_getgrsid(&map, alias_sid)) { grp = getgrgid(map.gid); insert = False; } diff --git a/source3/utils/net_sam.c b/source3/utils/net_sam.c index 16f7b1b25b..654c9ec5b2 100644 --- a/source3/utils/net_sam.c +++ b/source3/utils/net_sam.c @@ -330,7 +330,7 @@ static int net_sam_set_comment(int argc, const char **argv) return -1; } - if (!NT_STATUS_IS_OK(pdb_getgrsid(&map, &sid))) { + if (!pdb_getgrsid(&map, sid)) { d_fprintf(stderr, "Could not load group %s\n", argv[0]); return -1; } @@ -882,7 +882,7 @@ static int net_sam_provision(int argc, const char **argv) sid_compose(&gsid, get_global_sam_sid(), DOMAIN_GROUP_RID_USERS); - if (!NT_STATUS_IS_OK(pdb_getgrsid(&gmap, &gsid))) { + if (!pdb_getgrsid(&gmap, gsid)) { LDAPMod **mods = NULL; char *dn; char *uname; @@ -935,7 +935,7 @@ domu_done: sid_compose(&gsid, get_global_sam_sid(), DOMAIN_GROUP_RID_ADMINS); - if (!NT_STATUS_IS_OK(pdb_getgrsid(&gmap, &gsid))) { + if (!pdb_getgrsid(&gmap, gsid)) { LDAPMod **mods = NULL; char *dn; char *uname; @@ -1153,7 +1153,7 @@ doma_done: goto done; } - if (!NT_STATUS_IS_OK(pdb_getgrgid(&gmap, pwd->pw_gid))) { + if (!pdb_getgrgid(&gmap, pwd->pw_gid)) { LDAPMod **mods = NULL; char *dn; char *uname; |