Add comment explaining the previous fix.
[Samba.git] / source / utils / net_groupmap.c
blobb0e3d60a24d48609decb5e297036eb85be1a365f
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(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 (opt_verbose || 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(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 );
297 if (!NT_STATUS_IS_OK(add_initial_entry(gid, string_sid, sid_type, ntgroup, ntcomment))) {
298 d_fprintf(stderr, "adding entry for group %s failed!\n", ntgroup);
299 return -1;
302 d_printf("Successfully added group %s to the mapping db as a %s\n",
303 ntgroup, name_type);
304 return 0;
307 static int net_groupmap_modify(int argc, const char **argv)
309 DOM_SID sid;
310 GROUP_MAP map;
311 fstring ntcomment = "";
312 fstring type = "";
313 fstring ntgroup = "";
314 fstring unixgrp = "";
315 fstring sid_string = "";
316 enum lsa_SidType sid_type = SID_NAME_UNKNOWN;
317 int i;
318 gid_t gid;
320 /* get the options */
321 for ( i=0; i<argc; i++ ) {
322 if ( !StrnCaseCmp(argv[i], "ntgroup", strlen("ntgroup")) ) {
323 fstrcpy( ntgroup, get_string_param( argv[i] ) );
324 if ( !ntgroup[0] ) {
325 d_fprintf(stderr, "must supply a name\n");
326 return -1;
329 else if ( !StrnCaseCmp(argv[i], "sid", strlen("sid")) ) {
330 fstrcpy( sid_string, get_string_param( argv[i] ) );
331 if ( !sid_string[0] ) {
332 d_fprintf(stderr, "must supply a name\n");
333 return -1;
336 else if ( !StrnCaseCmp(argv[i], "comment", strlen("comment")) ) {
337 fstrcpy( ntcomment, get_string_param( argv[i] ) );
338 if ( !ntcomment[0] ) {
339 d_fprintf(stderr, "must supply a comment string\n");
340 return -1;
343 else if ( !StrnCaseCmp(argv[i], "unixgroup", strlen("unixgroup")) ) {
344 fstrcpy( unixgrp, get_string_param( argv[i] ) );
345 if ( !unixgrp[0] ) {
346 d_fprintf(stderr, "must supply a group name\n");
347 return -1;
350 else if ( !StrnCaseCmp(argv[i], "type", strlen("type")) ) {
351 fstrcpy( type, get_string_param( argv[i] ) );
352 switch ( type[0] ) {
353 case 'd':
354 case 'D':
355 sid_type = SID_NAME_DOM_GRP;
356 break;
357 case 'l':
358 case 'L':
359 sid_type = SID_NAME_ALIAS;
360 break;
363 else {
364 d_fprintf(stderr, "Bad option: %s\n", argv[i]);
365 return -1;
369 if ( !ntgroup[0] && !sid_string[0] ) {
370 d_printf("Usage: net groupmap modify {ntgroup=<string>|sid=<SID>} [comment=<string>] [unixgroup=<string>] [type=<domain|local>]\n");
371 return -1;
374 /* give preference to the SID; if both the ntgroup name and SID
375 are defined, use the SID and assume that the group name could be a
376 new name */
378 if ( sid_string[0] ) {
379 if (!get_sid_from_input(&sid, sid_string)) {
380 return -1;
383 else {
384 if (!get_sid_from_input(&sid, ntgroup)) {
385 return -1;
389 /* Get the current mapping from the database */
390 if(!pdb_getgrsid(&map, sid)) {
391 d_fprintf(stderr, "Failure to local group SID in the database\n");
392 return -1;
396 * Allow changing of group type only between domain and local
397 * We disallow changing Builtin groups !!! (SID problem)
399 if (sid_type == SID_NAME_UNKNOWN) {
400 d_fprintf(stderr, "Can't map to an unknown group type.\n");
401 return -1;
404 if (map.sid_name_use == SID_NAME_WKN_GRP) {
405 d_fprintf(stderr, "You can only change between domain and local groups.\n");
406 return -1;
409 map.sid_name_use=sid_type;
411 /* Change comment if new one */
412 if ( ntcomment[0] )
413 fstrcpy( map.comment, ntcomment );
415 if ( ntgroup[0] )
416 fstrcpy( map.nt_name, ntgroup );
418 if ( unixgrp[0] ) {
419 gid = nametogid( unixgrp );
420 if ( gid == -1 ) {
421 d_fprintf(stderr, "Unable to lookup UNIX group %s. Make sure the group exists.\n",
422 unixgrp);
423 return -1;
426 map.gid = gid;
429 if ( !NT_STATUS_IS_OK(pdb_update_group_mapping_entry(&map)) ) {
430 d_fprintf(stderr, "Could not update group database\n");
431 return -1;
434 d_printf("Updated mapping entry for %s\n", map.nt_name);
436 return 0;
439 static int net_groupmap_delete(int argc, const char **argv)
441 DOM_SID sid;
442 fstring ntgroup = "";
443 fstring sid_string = "";
444 int i;
446 /* get the options */
447 for ( i=0; i<argc; i++ ) {
448 if ( !StrnCaseCmp(argv[i], "ntgroup", strlen("ntgroup")) ) {
449 fstrcpy( ntgroup, get_string_param( argv[i] ) );
450 if ( !ntgroup[0] ) {
451 d_fprintf(stderr, "must supply a name\n");
452 return -1;
455 else if ( !StrnCaseCmp(argv[i], "sid", strlen("sid")) ) {
456 fstrcpy( sid_string, get_string_param( argv[i] ) );
457 if ( !sid_string[0] ) {
458 d_fprintf(stderr, "must supply a SID\n");
459 return -1;
462 else {
463 d_fprintf(stderr, "Bad option: %s\n", argv[i]);
464 return -1;
468 if ( !ntgroup[0] && !sid_string[0]) {
469 d_printf("Usage: net groupmap delete {ntgroup=<string>|sid=<SID>}\n");
470 return -1;
473 /* give preference to the SID if we have that */
475 if ( sid_string[0] )
476 fstrcpy( ntgroup, sid_string );
478 if ( !get_sid_from_input(&sid, ntgroup) ) {
479 d_fprintf(stderr, "Unable to resolve group %s to a SID\n", ntgroup);
480 return -1;
483 if ( !NT_STATUS_IS_OK(pdb_delete_group_mapping_entry(sid)) ) {
484 d_fprintf(stderr, "Failed to removing group %s from the mapping db!\n", ntgroup);
485 return -1;
488 d_printf("Sucessfully removed %s from the mapping db\n", ntgroup);
490 return 0;
493 static int net_groupmap_set(int argc, const char **argv)
495 const char *ntgroup = NULL;
496 struct group *grp = NULL;
497 GROUP_MAP map;
498 bool have_map = False;
500 if ((argc < 1) || (argc > 2)) {
501 d_printf("Usage: net groupmap set \"NT Group\" "
502 "[\"unix group\"] [-C \"comment\"] [-L] [-D]\n");
503 return -1;
506 if ( opt_localgroup && opt_domaingroup ) {
507 d_printf("Can only specify -L or -D, not both\n");
508 return -1;
511 ntgroup = argv[0];
513 if (argc == 2) {
514 grp = getgrnam(argv[1]);
516 if (grp == NULL) {
517 d_fprintf(stderr, "Could not find unix group %s\n", argv[1]);
518 return -1;
522 have_map = pdb_getgrnam(&map, ntgroup);
524 if (!have_map) {
525 DOM_SID sid;
526 have_map = ( (strncmp(ntgroup, "S-", 2) == 0) &&
527 string_to_sid(&sid, ntgroup) &&
528 pdb_getgrsid(&map, sid) );
531 if (!have_map) {
533 /* Ok, add it */
535 if (grp == NULL) {
536 d_fprintf(stderr, "Could not find group mapping for %s\n",
537 ntgroup);
538 return -1;
541 map.gid = grp->gr_gid;
543 if (opt_rid == 0) {
544 if ( pdb_rid_algorithm() )
545 opt_rid = algorithmic_pdb_gid_to_group_rid(map.gid);
546 else {
547 if ( !pdb_new_rid((uint32*)&opt_rid) ) {
548 d_fprintf( stderr, "Could not allocate new RID\n");
549 return -1;
554 sid_copy(&map.sid, get_global_sam_sid());
555 sid_append_rid(&map.sid, opt_rid);
557 map.sid_name_use = SID_NAME_DOM_GRP;
558 fstrcpy(map.nt_name, ntgroup);
559 fstrcpy(map.comment, "");
561 if (!NT_STATUS_IS_OK(pdb_add_group_mapping_entry(&map))) {
562 d_fprintf(stderr, "Could not add mapping entry for %s\n",
563 ntgroup);
564 return -1;
568 /* Now we have a mapping entry, update that stuff */
570 if ( opt_localgroup || opt_domaingroup ) {
571 if (map.sid_name_use == SID_NAME_WKN_GRP) {
572 d_fprintf(stderr, "Can't change type of the BUILTIN group %s\n",
573 map.nt_name);
574 return -1;
578 if (opt_localgroup)
579 map.sid_name_use = SID_NAME_ALIAS;
581 if (opt_domaingroup)
582 map.sid_name_use = SID_NAME_DOM_GRP;
584 /* The case (opt_domaingroup && opt_localgroup) was tested for above */
586 if (strlen(opt_comment) > 0)
587 fstrcpy(map.comment, opt_comment);
589 if (strlen(opt_newntname) > 0)
590 fstrcpy(map.nt_name, opt_newntname);
592 if (grp != NULL)
593 map.gid = grp->gr_gid;
595 if (!NT_STATUS_IS_OK(pdb_update_group_mapping_entry(&map))) {
596 d_fprintf(stderr, "Could not update group mapping for %s\n", ntgroup);
597 return -1;
600 return 0;
603 static int net_groupmap_cleanup(int argc, const char **argv)
605 GROUP_MAP *map = NULL;
606 size_t i, entries;
608 if (!pdb_enum_group_mapping(NULL, SID_NAME_UNKNOWN, &map, &entries,
609 ENUM_ALL_MAPPED)) {
610 d_fprintf(stderr, "Could not list group mappings\n");
611 return -1;
614 for (i=0; i<entries; i++) {
616 if (map[i].gid == -1)
617 printf("Group %s is not mapped\n", map[i].nt_name);
619 if (!sid_check_is_in_our_domain(&map[i].sid)) {
620 printf("Deleting mapping for NT Group %s, sid %s\n",
621 map[i].nt_name,
622 sid_string_tos(&map[i].sid));
623 pdb_delete_group_mapping_entry(map[i].sid);
627 SAFE_FREE(map);
629 return 0;
632 static int net_groupmap_addmem(int argc, const char **argv)
634 DOM_SID alias, member;
636 if ( (argc != 2) ||
637 !string_to_sid(&alias, argv[0]) ||
638 !string_to_sid(&member, argv[1]) ) {
639 d_printf("Usage: net groupmap addmem alias-sid member-sid\n");
640 return -1;
643 if (!NT_STATUS_IS_OK(pdb_add_aliasmem(&alias, &member))) {
644 d_fprintf(stderr, "Could not add sid %s to alias %s\n",
645 argv[1], argv[0]);
646 return -1;
649 return 0;
652 static int net_groupmap_delmem(int argc, const char **argv)
654 DOM_SID alias, member;
656 if ( (argc != 2) ||
657 !string_to_sid(&alias, argv[0]) ||
658 !string_to_sid(&member, argv[1]) ) {
659 d_printf("Usage: net groupmap delmem alias-sid member-sid\n");
660 return -1;
663 if (!NT_STATUS_IS_OK(pdb_del_aliasmem(&alias, &member))) {
664 d_fprintf(stderr, "Could not delete sid %s from alias %s\n",
665 argv[1], argv[0]);
666 return -1;
669 return 0;
672 static int net_groupmap_listmem(int argc, const char **argv)
674 DOM_SID alias;
675 DOM_SID *members;
676 size_t i, num;
678 if ( (argc != 1) ||
679 !string_to_sid(&alias, argv[0]) ) {
680 d_printf("Usage: net groupmap listmem alias-sid\n");
681 return -1;
684 members = NULL;
685 num = 0;
687 if (!NT_STATUS_IS_OK(pdb_enum_aliasmem(&alias, &members, &num))) {
688 d_fprintf(stderr, "Could not list members for sid %s\n", argv[0]);
689 return -1;
692 for (i = 0; i < num; i++) {
693 printf("%s\n", sid_string_tos(&(members[i])));
696 TALLOC_FREE(members);
698 return 0;
701 static bool print_alias_memberships(TALLOC_CTX *mem_ctx,
702 const DOM_SID *domain_sid,
703 const DOM_SID *member)
705 uint32 *alias_rids;
706 size_t i, num_alias_rids;
708 alias_rids = NULL;
709 num_alias_rids = 0;
711 if (!NT_STATUS_IS_OK(pdb_enum_alias_memberships(
712 mem_ctx, domain_sid, member, 1,
713 &alias_rids, &num_alias_rids))) {
714 d_fprintf(stderr, "Could not list memberships for sid %s\n",
715 sid_string_tos(member));
716 return False;
719 for (i = 0; i < num_alias_rids; i++) {
720 DOM_SID alias;
721 sid_copy(&alias, domain_sid);
722 sid_append_rid(&alias, alias_rids[i]);
723 printf("%s\n", sid_string_tos(&alias));
726 return True;
729 static int net_groupmap_memberships(int argc, const char **argv)
731 TALLOC_CTX *mem_ctx;
732 DOM_SID *domain_sid, *builtin_sid, member;
734 if ( (argc != 1) ||
735 !string_to_sid(&member, argv[0]) ) {
736 d_printf("Usage: net groupmap memberof sid\n");
737 return -1;
740 mem_ctx = talloc_init("net_groupmap_memberships");
741 if (mem_ctx == NULL) {
742 d_fprintf(stderr, "talloc_init failed\n");
743 return -1;
746 domain_sid = get_global_sam_sid();
747 builtin_sid = string_sid_talloc(mem_ctx, "S-1-5-32");
748 if ((domain_sid == NULL) || (builtin_sid == NULL)) {
749 d_fprintf(stderr, "Could not get domain sid\n");
750 return -1;
753 if (!print_alias_memberships(mem_ctx, domain_sid, &member) ||
754 !print_alias_memberships(mem_ctx, builtin_sid, &member))
755 return -1;
757 talloc_destroy(mem_ctx);
759 return 0;
762 int net_help_groupmap(int argc, const char **argv)
764 d_printf("net groupmap add"\
765 "\n Create a new group mapping\n");
766 d_printf("net groupmap modify"\
767 "\n Update a group mapping\n");
768 d_printf("net groupmap delete"\
769 "\n Remove a group mapping\n");
770 d_printf("net groupmap addmem"\
771 "\n Add a foreign alias member\n");
772 d_printf("net groupmap delmem"\
773 "\n Delete a foreign alias member\n");
774 d_printf("net groupmap listmem"\
775 "\n List foreign group members\n");
776 d_printf("net groupmap memberships"\
777 "\n List foreign group memberships\n");
778 d_printf("net groupmap list"\
779 "\n List current group map\n");
780 d_printf("net groupmap set"\
781 "\n Set group mapping\n");
782 d_printf("net groupmap cleanup"\
783 "\n Remove foreign group mapping entries\n");
785 return -1;
789 /***********************************************************
790 migrated functionality from smbgroupedit
791 **********************************************************/
792 int net_groupmap(int argc, const char **argv)
794 struct functable func[] = {
795 {"add", net_groupmap_add},
796 {"modify", net_groupmap_modify},
797 {"delete", net_groupmap_delete},
798 {"set", net_groupmap_set},
799 {"cleanup", net_groupmap_cleanup},
800 {"addmem", net_groupmap_addmem},
801 {"delmem", net_groupmap_delmem},
802 {"listmem", net_groupmap_listmem},
803 {"memberships", net_groupmap_memberships},
804 {"list", net_groupmap_list},
805 {"help", net_help_groupmap},
806 {NULL, NULL}
809 /* we shouldn't have silly checks like this */
810 if (getuid() != 0) {
811 d_fprintf(stderr, "You must be root to edit group mappings.\n");
812 return -1;
815 if ( argc )
816 return net_run_function(argc, argv, func, net_help_groupmap);
818 return net_help_groupmap( argc, argv );