nisgrpadm.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
*
* Copyright (c) 1988-1992 Sun Microsystems Inc
* All Rights Reserved.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
*
* This program allows the system administrator to create and administer
* groups within the NIS+ namespace.
*
*/
#include <stdio.h>
#include <string.h>
extern char *optarg;
extern nis_object nis_default_obj;
extern nis_name __nis_map_group_r();
extern bool_t nis_verifycred();
nis_name n;
{
int err;
char dname[NIS_MAXNAMELEN];
return (err);
}
/*
* temp_nis_verifygroup(group)
*
* Verify the existence of the named group. This is a duplicate of
* nis_verifygroup API call.
* This duplication was necessitated by the fact that nis_verifygroup does not
* accept a 'flags' argument to force it to go to the master server.
* Refer to bugid 1092089 and rfe 1102245.
*
*/
{
char namebuf[NIS_MAXNAMELEN];
else
} else
return (result);
}
{
if (name[0] == '-')
name++;
if (name[0] == '@')
if (name[0] == '*') {
else
return (FALSE);
}
/*
* Only if a random NIS+ server does not know about this, do we
* force a connection to the Master server to avoid overloading it.
*/
}
void
usage()
{
"usage: nisgrpadm -a | -r | -t [-s] group princpal ...\n");
" nisgrpadm -d | -l [-M] [-s] group\n");
" nisgrpadm -c [ -D defaults] [-M] [-s] group\n");
exit(1);
}
int argc;
char *argv[];
{
char *defstr = 0;
int silent = 0;
int c;
switch (c) {
case 'D':
break;
case 'M':
break;
case 'd':
"c, d, a, r, t, and l options are mutually exclusive.\n");
usage();
}
break;
case 'c':
"c, d, a, r, t, and l options are mutually exclusive.\n");
usage();
}
break;
case 'a':
"c, d, a, r, t, and l options are mutually exclusive.\n");
usage();
}
break;
case 'r':
"c, d, a, r, t, and l options are mutually exclusive.\n");
usage();
}
break;
case 't':
"c, d, a, r, t, and l options are mutually exclusive.\n");
usage();
}
break;
case 'l':
"c, d, a, r, t, and l options are mutually exclusive.\n");
usage();
}
break;
case 's':
silent = 1;
break;
default:
usage();
}
}
usage();
usage();
}
if (!nis_defaults_init(defstr))
exit(1);
"Group name must be fully qualified.\n");
}
} else {
/*
* Get the group name using psuedo expand name magic
*/
}
for (p = grplist; *p; p++)
if (temp_nis_verifygroup(*p) == NIS_SUCCESS)
break;
if (*p == 0) {
if (!silent)
"Group \"%s\" not found.\n",
grpname);
}
grpname = *p;
}
switch (op) {
case DELETE:
s = nis_destroygroup(grpname);
if (!silent) {
if (s == NIS_SUCCESS)
printf("Group \"%s\" destroyed.\n",
grpname);
else {
"Unable to destroy group \"%s\": %s\n",
nis_sperrno(s));
}
}
exit(s);
case CREATE:
if (!silent) {
if (s == NIS_SUCCESS)
printf("Group \"%s\" created.\n",
grpname);
else {
"Unable to create group \"%s\": %s\n",
nis_sperrno(s));
}
}
exit(s);
case LIST:
if (!silent)
}
usage();
}
/*
* Get the group object so we can do prefix matching on partial
* principal names. temp_nis_verifygroup() has already read and
* verified the group (too bad we have to look it up again) so
* this shouldn't fail.
*/
if (!silent)
"Can't read group object");
}
}
/*
* If the principal name isn't fully qualified,
* look for a unique prefix match in the group
* membership list.
*/
if (strncasecmp(princp,
grpml[i],
"Principal \"%s\" not unique, please use full name.\n",
princp);
found = -2;
break;
} else
found = i;
}
}
if (found < 0) {
"Principal \"%s\" not found in group.\n",
princp);
continue;
}
}
} else {
/*
* Get the principal name using psuedo expand name
* magic
*/
if (plist)
}
for (p = plist; *p; p++)
if (verify_principal(*p))
break;
if (*p == 0) {
if (!silent)
"Principal \"%s\" not found.\n",
princp);
continue;
}
princp = *p;
}
switch (op) {
case ADD:
if (ostatus == NIS_SUCCESS)
ostatus = s;
if (!silent) {
if (s == NIS_SUCCESS)
"Added \"%s\" to group \"%s\".\n",
else {
"Unable to add \"%s\" to group \"%s\": %s\n",
nis_sperrno(s));
}
}
break;
case REMOVE:
if (ostatus == NIS_SUCCESS)
ostatus = s;
if (!silent) {
if (s == NIS_SUCCESS)
"Removed \"%s\" from group \"%s\".\n",
else {
"Unable to remove \"%s\" from group \"%s\": %s\n",
nis_sperrno(s));
}
}
break;
case TEST:
if (!s && ostatus == NIS_SUCCESS)
if (!silent) {
if (s)
"\"%s\" is a member of group \"%s\".\n",
else
"\"%s\" is not a member of group \"%s\".\n",
}
break;
}
}
if (ostatus == NIS_SUCCESS)
else
}