net: The top level help function for net cmd is always net_cmd_usage
[Samba.git] / source / utils / net_groupmap.c
blob4b4ec45deaf4d272fe2d1619173a521bac2163e2
1 /*
2 * Unix SMB/CIFS implementation.
3 * RPC Pipe client / server routines
4 * Copyright (C) Andrew Tridgell 1992-2000,
5 * Copyright (C) Jean François Micouleau 1998-2001.
6 * Copyright (C) Gerald Carter 2003,
7 * Copyright (C) Volker Lendecke 2004
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 3 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, see <http://www.gnu.org/licenses/>.
24 #include "includes.h"
25 #include "utils/net.h"
27 /*********************************************************
28 Figure out if the input was an NT group or a SID string.
29 Return the SID.
30 **********************************************************/
31 static bool get_sid_from_input(DOM_SID *sid, char *input)
33 GROUP_MAP map;
35 if (StrnCaseCmp( input, "S-", 2)) {
36 /* Perhaps its the NT group name? */
37 if (!pdb_getgrnam(&map, input)) {
38 printf("NT Group %s doesn't exist in mapping DB\n", input);
39 return false;
40 } else {
41 *sid = map.sid;
43 } else {
44 if (!string_to_sid(sid, input)) {
45 printf("converting sid %s from a string failed!\n", input);
46 return false;
49 return true;
52 /*********************************************************
53 Dump a GROUP_MAP entry to stdout (long or short listing)
54 **********************************************************/
56 static void print_map_entry ( GROUP_MAP map, bool long_list )
58 if (!long_list)
59 d_printf("%s (%s) -> %s\n", map.nt_name,
60 sid_string_tos(&map.sid), gidtoname(map.gid));
61 else {
62 d_printf("%s\n", map.nt_name);
63 d_printf("\tSID : %s\n", sid_string_tos(&map.sid));
64 d_printf("\tUnix gid : %d\n", map.gid);
65 d_printf("\tUnix group: %s\n", gidtoname(map.gid));
66 d_printf("\tGroup type: %s\n",
67 sid_type_lookup(map.sid_name_use));
68 d_printf("\tComment : %s\n", map.comment);
72 /*********************************************************
73 List the groups.
74 **********************************************************/
75 static int net_groupmap_list(struct net_context *c, int argc, const char **argv)
77 size_t entries;
78 bool long_list = false;
79 size_t i;
80 fstring ntgroup = "";
81 fstring sid_string = "";
83 if (c->opt_verbose || c->opt_long_list_entries)
84 long_list = true;
86 /* get the options */
87 for ( i=0; i<argc; i++ ) {
88 if ( !StrCaseCmp(argv[i], "verbose")) {
89 long_list = true;
91 else if ( !StrnCaseCmp(argv[i], "ntgroup", strlen("ntgroup")) ) {
92 fstrcpy( ntgroup, get_string_param( argv[i] ) );
93 if ( !ntgroup[0] ) {
94 d_fprintf(stderr, "must supply a name\n");
95 return -1;
98 else if ( !StrnCaseCmp(argv[i], "sid", strlen("sid")) ) {
99 fstrcpy( sid_string, get_string_param( argv[i] ) );
100 if ( !sid_string[0] ) {
101 d_fprintf(stderr, "must supply a SID\n");
102 return -1;
105 else {
106 d_fprintf(stderr, "Bad option: %s\n", argv[i]);
107 return -1;
111 /* list a single group is given a name */
112 if ( ntgroup[0] || sid_string[0] ) {
113 DOM_SID sid;
114 GROUP_MAP map;
116 if ( sid_string[0] )
117 fstrcpy( ntgroup, sid_string);
119 if (!get_sid_from_input(&sid, ntgroup)) {
120 return -1;
123 /* Get the current mapping from the database */
124 if(!pdb_getgrsid(&map, sid)) {
125 d_fprintf(stderr, "Failure to local group SID in the database\n");
126 return -1;
129 print_map_entry( map, long_list );
131 else {
132 GROUP_MAP *map=NULL;
133 /* enumerate all group mappings */
134 if (!pdb_enum_group_mapping(NULL, SID_NAME_UNKNOWN, &map, &entries, ENUM_ALL_MAPPED))
135 return -1;
137 for (i=0; i<entries; i++) {
138 print_map_entry( map[i], long_list );
141 SAFE_FREE(map);
144 return 0;
147 /*********************************************************
148 Add a new group mapping entry
149 **********************************************************/
151 static int net_groupmap_add(struct net_context *c, int argc, const char **argv)
153 DOM_SID sid;
154 fstring ntgroup = "";
155 fstring unixgrp = "";
156 fstring string_sid = "";
157 fstring type = "";
158 fstring ntcomment = "";
159 enum lsa_SidType sid_type = SID_NAME_DOM_GRP;
160 uint32 rid = 0;
161 gid_t gid;
162 int i;
163 GROUP_MAP map;
165 const char *name_type;
167 ZERO_STRUCT(map);
169 /* Default is domain group. */
170 map.sid_name_use = SID_NAME_DOM_GRP;
171 name_type = "domain group";
173 /* get the options */
174 for ( i=0; i<argc; i++ ) {
175 if ( !StrnCaseCmp(argv[i], "rid", strlen("rid")) ) {
176 rid = get_int_param(argv[i]);
177 if ( rid < DOMAIN_GROUP_RID_ADMINS ) {
178 d_fprintf(stderr, "RID must be greater than %d\n", (uint32)DOMAIN_GROUP_RID_ADMINS-1);
179 return -1;
182 else if ( !StrnCaseCmp(argv[i], "unixgroup", strlen("unixgroup")) ) {
183 fstrcpy( unixgrp, get_string_param( argv[i] ) );
184 if ( !unixgrp[0] ) {
185 d_fprintf(stderr, "must supply a name\n");
186 return -1;
189 else if ( !StrnCaseCmp(argv[i], "ntgroup", strlen("ntgroup")) ) {
190 fstrcpy( ntgroup, get_string_param( argv[i] ) );
191 if ( !ntgroup[0] ) {
192 d_fprintf(stderr, "must supply a name\n");
193 return -1;
196 else if ( !StrnCaseCmp(argv[i], "sid", strlen("sid")) ) {
197 fstrcpy( string_sid, get_string_param( argv[i] ) );
198 if ( !string_sid[0] ) {
199 d_fprintf(stderr, "must supply a SID\n");
200 return -1;
203 else if ( !StrnCaseCmp(argv[i], "comment", strlen("comment")) ) {
204 fstrcpy( ntcomment, get_string_param( argv[i] ) );
205 if ( !ntcomment[0] ) {
206 d_fprintf(stderr, "must supply a comment string\n");
207 return -1;
210 else if ( !StrnCaseCmp(argv[i], "type", strlen("type")) ) {
211 fstrcpy( type, get_string_param( argv[i] ) );
212 switch ( type[0] ) {
213 case 'b':
214 case 'B':
215 sid_type = SID_NAME_WKN_GRP;
216 name_type = "wellknown group";
217 break;
218 case 'd':
219 case 'D':
220 sid_type = SID_NAME_DOM_GRP;
221 name_type = "domain group";
222 break;
223 case 'l':
224 case 'L':
225 sid_type = SID_NAME_ALIAS;
226 name_type = "alias (local) group";
227 break;
228 default:
229 d_fprintf(stderr, "unknown group type %s\n", type);
230 return -1;
233 else {
234 d_fprintf(stderr, "Bad option: %s\n", argv[i]);
235 return -1;
239 if ( !unixgrp[0] ) {
240 d_printf("Usage: net groupmap add {rid=<int>|sid=<string>} unixgroup=<string> [type=<domain|local|builtin>] [ntgroup=<string>] [comment=<string>]\n");
241 return -1;
244 if ( (gid = nametogid(unixgrp)) == (gid_t)-1 ) {
245 d_fprintf(stderr, "Can't lookup UNIX group %s\n", unixgrp);
246 return -1;
250 if (pdb_getgrgid(&map, gid)) {
251 d_printf("Unix group %s already mapped to SID %s\n",
252 unixgrp, sid_string_tos(&map.sid));
253 return -1;
257 if ( (rid == 0) && (string_sid[0] == '\0') ) {
258 d_printf("No rid or sid specified, choosing a RID\n");
259 if (pdb_rid_algorithm()) {
260 rid = algorithmic_pdb_gid_to_group_rid(gid);
261 } else {
262 if (!pdb_new_rid(&rid)) {
263 d_printf("Could not get new RID\n");
266 d_printf("Got RID %d\n", rid);
269 /* append the rid to our own domain/machine SID if we don't have a full SID */
270 if ( !string_sid[0] ) {
271 sid_copy(&sid, get_global_sam_sid());
272 sid_append_rid(&sid, rid);
273 sid_to_fstring(string_sid, &sid);
276 if (!ntcomment[0]) {
277 switch (sid_type) {
278 case SID_NAME_WKN_GRP:
279 fstrcpy(ntcomment, "Wellknown Unix group");
280 break;
281 case SID_NAME_DOM_GRP:
282 fstrcpy(ntcomment, "Domain Unix group");
283 break;
284 case SID_NAME_ALIAS:
285 fstrcpy(ntcomment, "Local Unix group");
286 break;
287 default:
288 fstrcpy(ntcomment, "Unix group");
289 break;
293 if (!ntgroup[0] )
294 fstrcpy( ntgroup, unixgrp );
296 if (!NT_STATUS_IS_OK(add_initial_entry(gid, string_sid, sid_type, ntgroup, ntcomment))) {
297 d_fprintf(stderr, "adding entry for group %s failed!\n", ntgroup);
298 return -1;
301 d_printf("Successfully added group %s to the mapping db as a %s\n",
302 ntgroup, name_type);
303 return 0;
306 static int net_groupmap_modify(struct net_context *c, int argc, const char **argv)
308 DOM_SID sid;
309 GROUP_MAP map;
310 fstring ntcomment = "";
311 fstring type = "";
312 fstring ntgroup = "";
313 fstring unixgrp = "";
314 fstring sid_string = "";
315 enum lsa_SidType sid_type = SID_NAME_UNKNOWN;
316 int i;
317 gid_t gid;
319 /* get the options */
320 for ( i=0; i<argc; i++ ) {
321 if ( !StrnCaseCmp(argv[i], "ntgroup", strlen("ntgroup")) ) {
322 fstrcpy( ntgroup, get_string_param( argv[i] ) );
323 if ( !ntgroup[0] ) {
324 d_fprintf(stderr, "must supply a name\n");
325 return -1;
328 else if ( !StrnCaseCmp(argv[i], "sid", strlen("sid")) ) {
329 fstrcpy( sid_string, get_string_param( argv[i] ) );
330 if ( !sid_string[0] ) {
331 d_fprintf(stderr, "must supply a name\n");
332 return -1;
335 else if ( !StrnCaseCmp(argv[i], "comment", strlen("comment")) ) {
336 fstrcpy( ntcomment, get_string_param( argv[i] ) );
337 if ( !ntcomment[0] ) {
338 d_fprintf(stderr, "must supply a comment string\n");
339 return -1;
342 else if ( !StrnCaseCmp(argv[i], "unixgroup", strlen("unixgroup")) ) {
343 fstrcpy( unixgrp, get_string_param( argv[i] ) );
344 if ( !unixgrp[0] ) {
345 d_fprintf(stderr, "must supply a group name\n");
346 return -1;
349 else if ( !StrnCaseCmp(argv[i], "type", strlen("type")) ) {
350 fstrcpy( type, get_string_param( argv[i] ) );
351 switch ( type[0] ) {
352 case 'd':
353 case 'D':
354 sid_type = SID_NAME_DOM_GRP;
355 break;
356 case 'l':
357 case 'L':
358 sid_type = SID_NAME_ALIAS;
359 break;
362 else {
363 d_fprintf(stderr, "Bad option: %s\n", argv[i]);
364 return -1;
368 if ( !ntgroup[0] && !sid_string[0] ) {
369 d_printf("Usage: net groupmap modify {ntgroup=<string>|sid=<SID>} [comment=<string>] [unixgroup=<string>] [type=<domain|local>]\n");
370 return -1;
373 /* give preference to the SID; if both the ntgroup name and SID
374 are defined, use the SID and assume that the group name could be a
375 new name */
377 if ( sid_string[0] ) {
378 if (!get_sid_from_input(&sid, sid_string)) {
379 return -1;
382 else {
383 if (!get_sid_from_input(&sid, ntgroup)) {
384 return -1;
388 /* Get the current mapping from the database */
389 if(!pdb_getgrsid(&map, sid)) {
390 d_fprintf(stderr, "Failure to local group SID in the database\n");
391 return -1;
395 * Allow changing of group type only between domain and local
396 * We disallow changing Builtin groups !!! (SID problem)
398 if (sid_type == SID_NAME_UNKNOWN) {
399 d_fprintf(stderr, "Can't map to an unknown group type.\n");
400 return -1;
403 if (map.sid_name_use == SID_NAME_WKN_GRP) {
404 d_fprintf(stderr, "You can only change between domain and local groups.\n");
405 return -1;
408 map.sid_name_use=sid_type;
410 /* Change comment if new one */
411 if ( ntcomment[0] )
412 fstrcpy( map.comment, ntcomment );
414 if ( ntgroup[0] )
415 fstrcpy( map.nt_name, ntgroup );
417 if ( unixgrp[0] ) {
418 gid = nametogid( unixgrp );
419 if ( gid == -1 ) {
420 d_fprintf(stderr, "Unable to lookup UNIX group %s. Make sure the group exists.\n",
421 unixgrp);
422 return -1;
425 map.gid = gid;
428 if ( !NT_STATUS_IS_OK(pdb_update_group_mapping_entry(&map)) ) {
429 d_fprintf(stderr, "Could not update group database\n");
430 return -1;
433 d_printf("Updated mapping entry for %s\n", map.nt_name);
435 return 0;
438 static int net_groupmap_delete(struct net_context *c, int argc, const char **argv)
440 DOM_SID sid;
441 fstring ntgroup = "";
442 fstring sid_string = "";
443 int i;
445 /* get the options */
446 for ( i=0; i<argc; i++ ) {
447 if ( !StrnCaseCmp(argv[i], "ntgroup", strlen("ntgroup")) ) {
448 fstrcpy( ntgroup, get_string_param( argv[i] ) );
449 if ( !ntgroup[0] ) {
450 d_fprintf(stderr, "must supply a name\n");
451 return -1;
454 else if ( !StrnCaseCmp(argv[i], "sid", strlen("sid")) ) {
455 fstrcpy( sid_string, get_string_param( argv[i] ) );
456 if ( !sid_string[0] ) {
457 d_fprintf(stderr, "must supply a SID\n");
458 return -1;
461 else {
462 d_fprintf(stderr, "Bad option: %s\n", argv[i]);
463 return -1;
467 if ( !ntgroup[0] && !sid_string[0]) {
468 d_printf("Usage: net groupmap delete {ntgroup=<string>|sid=<SID>}\n");
469 return -1;
472 /* give preference to the SID if we have that */
474 if ( sid_string[0] )
475 fstrcpy( ntgroup, sid_string );
477 if ( !get_sid_from_input(&sid, ntgroup) ) {
478 d_fprintf(stderr, "Unable to resolve group %s to a SID\n", ntgroup);
479 return -1;
482 if ( !NT_STATUS_IS_OK(pdb_delete_group_mapping_entry(sid)) ) {
483 d_fprintf(stderr, "Failed to removing group %s from the mapping db!\n", ntgroup);
484 return -1;
487 d_printf("Sucessfully removed %s from the mapping db\n", ntgroup);
489 return 0;
492 static int net_groupmap_set(struct net_context *c, int argc, const char **argv)
494 const char *ntgroup = NULL;
495 struct group *grp = NULL;
496 GROUP_MAP map;
497 bool have_map = false;
499 if ((argc < 1) || (argc > 2)) {
500 d_printf("Usage: net groupmap set \"NT Group\" "
501 "[\"unix group\"] [-C \"comment\"] [-L] [-D]\n");
502 return -1;
505 if ( c->opt_localgroup && c->opt_domaingroup ) {
506 d_printf("Can only specify -L or -D, not both\n");
507 return -1;
510 ntgroup = argv[0];
512 if (argc == 2) {
513 grp = getgrnam(argv[1]);
515 if (grp == NULL) {
516 d_fprintf(stderr, "Could not find unix group %s\n", argv[1]);
517 return -1;
521 have_map = pdb_getgrnam(&map, ntgroup);
523 if (!have_map) {
524 DOM_SID sid;
525 have_map = ( (strncmp(ntgroup, "S-", 2) == 0) &&
526 string_to_sid(&sid, ntgroup) &&
527 pdb_getgrsid(&map, sid) );
530 if (!have_map) {
532 /* Ok, add it */
534 if (grp == NULL) {
535 d_fprintf(stderr, "Could not find group mapping for %s\n",
536 ntgroup);
537 return -1;
540 map.gid = grp->gr_gid;
542 if (c->opt_rid == 0) {
543 if ( pdb_rid_algorithm() )
544 c->opt_rid = algorithmic_pdb_gid_to_group_rid(map.gid);
545 else {
546 if ( !pdb_new_rid((uint32*)&c->opt_rid) ) {
547 d_fprintf( stderr, "Could not allocate new RID\n");
548 return -1;
553 sid_copy(&map.sid, get_global_sam_sid());
554 sid_append_rid(&map.sid, c->opt_rid);
556 map.sid_name_use = SID_NAME_DOM_GRP;
557 fstrcpy(map.nt_name, ntgroup);
558 fstrcpy(map.comment, "");
560 if (!NT_STATUS_IS_OK(pdb_add_group_mapping_entry(&map))) {
561 d_fprintf(stderr, "Could not add mapping entry for %s\n",
562 ntgroup);
563 return -1;
567 /* Now we have a mapping entry, update that stuff */
569 if ( c->opt_localgroup || c->opt_domaingroup ) {
570 if (map.sid_name_use == SID_NAME_WKN_GRP) {
571 d_fprintf(stderr, "Can't change type of the BUILTIN group %s\n",
572 map.nt_name);
573 return -1;
577 if (c->opt_localgroup)
578 map.sid_name_use = SID_NAME_ALIAS;
580 if (c->opt_domaingroup)
581 map.sid_name_use = SID_NAME_DOM_GRP;
583 /* The case (opt_domaingroup && opt_localgroup) was tested for above */
585 if (strlen(c->opt_comment) > 0)
586 fstrcpy(map.comment, c->opt_comment);
588 if (strlen(c->opt_newntname) > 0)
589 fstrcpy(map.nt_name, c->opt_newntname);
591 if (grp != NULL)
592 map.gid = grp->gr_gid;
594 if (!NT_STATUS_IS_OK(pdb_update_group_mapping_entry(&map))) {
595 d_fprintf(stderr, "Could not update group mapping for %s\n", ntgroup);
596 return -1;
599 return 0;
602 static int net_groupmap_cleanup(struct net_context *c, int argc, const char **argv)
604 GROUP_MAP *map = NULL;
605 size_t i, entries;
607 if (!pdb_enum_group_mapping(NULL, SID_NAME_UNKNOWN, &map, &entries,
608 ENUM_ALL_MAPPED)) {
609 d_fprintf(stderr, "Could not list group mappings\n");
610 return -1;
613 for (i=0; i<entries; i++) {
615 if (map[i].gid == -1)
616 printf("Group %s is not mapped\n", map[i].nt_name);
618 if (!sid_check_is_in_our_domain(&map[i].sid)) {
619 printf("Deleting mapping for NT Group %s, sid %s\n",
620 map[i].nt_name,
621 sid_string_tos(&map[i].sid));
622 pdb_delete_group_mapping_entry(map[i].sid);
626 SAFE_FREE(map);
628 return 0;
631 static int net_groupmap_addmem(struct net_context *c, int argc, const char **argv)
633 DOM_SID alias, member;
635 if ( (argc != 2) ||
636 !string_to_sid(&alias, argv[0]) ||
637 !string_to_sid(&member, argv[1]) ) {
638 d_printf("Usage: net groupmap addmem alias-sid member-sid\n");
639 return -1;
642 if (!NT_STATUS_IS_OK(pdb_add_aliasmem(&alias, &member))) {
643 d_fprintf(stderr, "Could not add sid %s to alias %s\n",
644 argv[1], argv[0]);
645 return -1;
648 return 0;
651 static int net_groupmap_delmem(struct net_context *c, int argc, const char **argv)
653 DOM_SID alias, member;
655 if ( (argc != 2) ||
656 !string_to_sid(&alias, argv[0]) ||
657 !string_to_sid(&member, argv[1]) ) {
658 d_printf("Usage: net groupmap delmem alias-sid member-sid\n");
659 return -1;
662 if (!NT_STATUS_IS_OK(pdb_del_aliasmem(&alias, &member))) {
663 d_fprintf(stderr, "Could not delete sid %s from alias %s\n",
664 argv[1], argv[0]);
665 return -1;
668 return 0;
671 static int net_groupmap_listmem(struct net_context *c, int argc, const char **argv)
673 DOM_SID alias;
674 DOM_SID *members;
675 size_t i, num;
677 if ( (argc != 1) ||
678 !string_to_sid(&alias, argv[0]) ) {
679 d_printf("Usage: net groupmap listmem alias-sid\n");
680 return -1;
683 members = NULL;
684 num = 0;
686 if (!NT_STATUS_IS_OK(pdb_enum_aliasmem(&alias, &members, &num))) {
687 d_fprintf(stderr, "Could not list members for sid %s\n", argv[0]);
688 return -1;
691 for (i = 0; i < num; i++) {
692 printf("%s\n", sid_string_tos(&(members[i])));
695 TALLOC_FREE(members);
697 return 0;
700 static bool print_alias_memberships(TALLOC_CTX *mem_ctx,
701 const DOM_SID *domain_sid,
702 const DOM_SID *member)
704 uint32 *alias_rids;
705 size_t i, num_alias_rids;
707 alias_rids = NULL;
708 num_alias_rids = 0;
710 if (!NT_STATUS_IS_OK(pdb_enum_alias_memberships(
711 mem_ctx, domain_sid, member, 1,
712 &alias_rids, &num_alias_rids))) {
713 d_fprintf(stderr, "Could not list memberships for sid %s\n",
714 sid_string_tos(member));
715 return false;
718 for (i = 0; i < num_alias_rids; i++) {
719 DOM_SID alias;
720 sid_copy(&alias, domain_sid);
721 sid_append_rid(&alias, alias_rids[i]);
722 printf("%s\n", sid_string_tos(&alias));
725 return true;
728 static int net_groupmap_memberships(struct net_context *c, int argc, const char **argv)
730 TALLOC_CTX *mem_ctx;
731 DOM_SID *domain_sid, *builtin_sid, member;
733 if ( (argc != 1) ||
734 !string_to_sid(&member, argv[0]) ) {
735 d_printf("Usage: net groupmap memberof sid\n");
736 return -1;
739 mem_ctx = talloc_init("net_groupmap_memberships");
740 if (mem_ctx == NULL) {
741 d_fprintf(stderr, "talloc_init failed\n");
742 return -1;
745 domain_sid = get_global_sam_sid();
746 builtin_sid = string_sid_talloc(mem_ctx, "S-1-5-32");
747 if ((domain_sid == NULL) || (builtin_sid == NULL)) {
748 d_fprintf(stderr, "Could not get domain sid\n");
749 return -1;
752 if (!print_alias_memberships(mem_ctx, domain_sid, &member) ||
753 !print_alias_memberships(mem_ctx, builtin_sid, &member))
754 return -1;
756 talloc_destroy(mem_ctx);
758 return 0;
761 int net_groupmap_usage(struct net_context *c, int argc, const char **argv)
763 d_printf("net groupmap add"\
764 "\n Create a new group mapping\n");
765 d_printf("net groupmap modify"\
766 "\n Update a group mapping\n");
767 d_printf("net groupmap delete"\
768 "\n Remove a group mapping\n");
769 d_printf("net groupmap addmem"\
770 "\n Add a foreign alias member\n");
771 d_printf("net groupmap delmem"\
772 "\n Delete a foreign alias member\n");
773 d_printf("net groupmap listmem"\
774 "\n List foreign group members\n");
775 d_printf("net groupmap memberships"\
776 "\n List foreign group memberships\n");
777 d_printf("net groupmap list"\
778 "\n List current group map\n");
779 d_printf("net groupmap set"\
780 "\n Set group mapping\n");
781 d_printf("net groupmap cleanup"\
782 "\n Remove foreign group mapping entries\n");
784 return -1;
788 /***********************************************************
789 migrated functionality from smbgroupedit
790 **********************************************************/
791 int net_groupmap(struct net_context *c, int argc, const char **argv)
793 struct functable func[] = {
794 {"add", net_groupmap_add},
795 {"modify", net_groupmap_modify},
796 {"delete", net_groupmap_delete},
797 {"set", net_groupmap_set},
798 {"cleanup", net_groupmap_cleanup},
799 {"addmem", net_groupmap_addmem},
800 {"delmem", net_groupmap_delmem},
801 {"listmem", net_groupmap_listmem},
802 {"memberships", net_groupmap_memberships},
803 {"list", net_groupmap_list},
804 {"help", net_groupmap_usage},
805 {NULL, NULL}
808 /* we shouldn't have silly checks like this */
809 if (getuid() != 0) {
810 d_fprintf(stderr, "You must be root to edit group mappings.\n");
811 return -1;
814 if ( argc )
815 return net_run_function(c,argc, argv, func, net_groupmap_usage);
817 return net_groupmap_usage(c, argc, argv);