nischmod.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 1988-2003 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
*
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
extern int optind;
extern char *optarg;
extern bool_t nis_verifycred();
#define CMD_CHMOD 0
#define CMD_CHOWN 1
#define CMD_CHGRP 2
#define CMD_CHTTL 3
int cmdnum;
char *cmdname;
void
usage()
{
char *str;
switch (cmdnum) {
case CMD_CHMOD:
str = "mode";
break;
case CMD_CHOWN:
str = "owner";
break;
case CMD_CHGRP:
str = "group";
break;
case CMD_CHTTL:
str = "ttl";
break;
}
exit(1);
}
void
void *udata;
{
switch (cmdnum) {
case CMD_CHMOD:
break;
case CMD_CHOWN:
break;
case CMD_CHGRP:
break;
case CMD_CHTTL:
break;
}
}
static char force = 0;
static int error = 0;
static int
void *udata;
{
if (!force) {
error = 1;
}
}
return (0);
}
int argc;
char *argv[];
{
int c;
char **plist, **p;
char *name;
void *udata;
uint_t x;
int bad_name;
char oname[NIS_MAXNAMELEN];
cmdname++;
else
else {
exit(1);
}
switch (c) {
case 'L':
break;
case 'P':
fpath = FOLLOW_PATH;
break;
case 'A':
break;
case 'f':
force = 1;
break;
default:
usage();
}
}
usage();
switch (cmdnum) {
case CMD_CHMOD:
/*
* attempt to parse the access rights first
*/
if (!parse_rights(&x, udata)) {
usage();
}
break;
case CMD_CHOWN:
/*
* get the principal name using psuedo expand name
* magic
*/
/* Could be either no mem or more likely bad name */
exit(1);
}
for (p = plist; *p; p++) {
/*
* First try to verify through regular means and only
* if that fails, then try the Master server.
*/
if (nis_verifycred(*p, flags) ||
break;
}
if (*p == 0) {
if (!force) {
"%s: principal not found\n",
udata);
exit(1);
} else if (
exit(0);
} else
udata = *p;
break;
case CMD_CHGRP:
/*
* get the group name using psuedo expand name magic
*/
/* Could be either no mem or more likely bad name */
exit(1);
}
for (p = plist; *p; p++)
if (nis_verifygroup(*p) == NIS_SUCCESS)
break;
if (*p == 0) {
if (!force) {
"%s: group not found\n",
udata);
exit(1);
} else if (
exit(0);
} else
udata = *p;
break;
case CMD_CHTTL:
usage();
}
udata = &x;
break;
}
/*
* Get the object using expand name magic.
*/
if (*name == '[') {
if (!force) {
error = 1;
}
}
} else {
if (!force) {
error = 1;
}
goto loop;
}
/*
* Construct the name for the object that we found.
*/
>= sizeof (oname));
if (!bad_name &&
if (bad_name) {
if (!force) {
"can't modify object");
error = 1;
}
goto loop;
}
/*
* Modify the object.
*/
if (!force) {
"can't modify object");
error = 1;
}
}
}
loop:
}
}