nisadm.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
*/
/*
* nisadm.c
*
* Copyright (c) 1988-1992 Sun Microsystems Inc
* All Rights Reserved.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* Ported from SCCS version :
* "@(#)nisadm.c 1.14 90/12/12 Copyr 1990 Sun Micro";
*
* nisadm.c
*
* This utility is a shell interface to the NIS name service.
*/
#include <stdio.h>
#include <string.h>
#include <ctype.h>
extern char *optarg;
#define nilstring(s) ((s) ? (s) : "(nil)")
struct obj_defaults {
};
{0L, NIS_BOGUS_OBJ}
};
typedef struct obj_defaults obj_defaults;
static obj_defaults *
{
if (obd)
return (obd);
return (obd);
return (obd);
}
static char *
char **buf;
int *buflen;
{
char *a, *s;
return (NULL);
a = *buf; /* Point a at the buffer */
exit(0); /* Exit on EOF */
return (NULL); /* return NULL on EOF */
s = a + strlen(a); /* Point s at the end of it */
*(s-1) = '\0'; /* Nul terminate the string */
*buf = s;
return (a);
}
static char *
char **buf;
int *len;
{
char *a, *s;
return (NULL);
a = *buf; /* Point a at the buffer */
return (NULL); /* return NULL on EOF */
s = a + strlen(a); /* Point s at the end of it */
*(s-1) = '\0'; /* Nul terminate the string */
if (*(s-2) != '.') {
if (strlen(a)) /* don't prepend a dot on a null name */
strcat(a, ".");
}
s = a + strlen(a) + 1;
*buf = s;
return (a);
}
/*
* Convert two hex digits to one unsigned char byte.
*/
static u_char
{
if (nyb >= 'a')
else
if (nyb > 15)
*bp);
if (nyb >= 'a')
else
if (nyb > 15)
*(bp+1));
return (val);
}
return (NULL); \
/*
* nis_get_object()
*
* This object will query the user for an object of the type specified
* in the 'type' variable. All of it's queries go to stdin.
*/
char *name;
char *group;
char *owner;
{
/*
* These variables define a string buffer array that is used
* while fetching the object, later the data is cloned so we
* can toss it. Yes, it's a giant hunk to put on the stack.
*/
#define BUFLENGTH 4096
char *t; /* temporary */
int np, i, j;
printf("Creating NIS object... \n");
if (! name) {
printf("Enter objects name : ");
if (!name)
return (NULL);
}
s = (char *) nis_leaf_of(name);
if (s)
else
if (owner)
else
if (group)
else
if (rights)
else
if (ttl)
else
/* name must be fully qualified */
if (type == NIS_BOGUS_OBJ) {
printf("Enter the objects type : ");
}
} else
case NIS_GROUP_OBJ :
printf("Enter flags value [IRN] ? ");
for (s = &tmpval[0]; *s; s++) {
if (LOWER(*s) == 'i')
else if (LOWER(*s) == 'r')
else if (LOWER(*s) == 'n')
else {
printf("Must be some combo of :\n");
printf("\tR = Recursive groups ok\n");
printf("\tN = Negative groups ok\n");
printf("\tI = Implicit groups ok\n");
exit(1);
}
}
do {
printf("Number of members in this group ? ");
printf("Illegal number of members.\n");
for (i = 0; i < np; i++) {
printf("\tMember #%d name :\n", i);
}
break;
case NIS_LINK_OBJ :
while (type == NIS_BOGUS_OBJ) {
else
}
do {
printf("Number of attributes in this name ? ");
"Illegal number of attributes.\n");
for (i = 0; i < np; i++) {
printf("Attribute #%d\n", i);
printf("\tAttribute Name : ");
printf("\tAttribute Value : ");
}
printf("Enter Linked name : ");
break;
case NIS_TABLE_OBJ :
printf("Enter table type : ");
do {
printf("Number of columns in this table ? ");
printf("Illegal number of columns.\n");
printf("Enter separator character : ");
printf("Enter Search path : ");
for (i = 0; i < np; i++) {
int tmplen;
printf("\tEnter Name : ");
printf("\tEnter Flags [S/C/B/X] : ");
flags |= TA_SEARCHABLE;
}
if ((flags & TA_SEARCHABLE) &&
"Can't have a searchable column with no name.\n");
return (NULL);
}
}
break;
case NIS_DIRECTORY_OBJ :
printf("This new directory's name : ");
do {
"Number of servers for this directory? ");
printf("Illegal number of servers.\n");
for (i = 0; i < np; i++) {
if (i == 0)
printf("Enter Master server name :");
else
printf("Enter replicate server name :");
printf("Enter Universal Address : ");
}
do {
printf("Enter ns type [Z/Y/D] :");
else
printf("Enter time to live value : ");
"Warning, ttl = 0 prohibits caching.\n");
break;
case NIS_ENTRY_OBJ :
/* Presumed to be the same. */
printf("Enter entry type : ");
return (NULL);
do {
printf("Number of columns for this entry ? ");
printf("Illegal number of columns.\n");
for (i = 0; i < np; i++) {
int len;
printf("\tEnter Flags [M/C/B/X] : ");
flags |= EN_MODIFIED;
else
printf("** Unknown flag '%c'\n",
tmpval[j]);
}
printf("\tValue : ");
for (j = 0; j < len; j += 2)
*(val + (j>>1)) =
}
}
break;
case NIS_PRIVATE_OBJ:
printf("Data length : ");
for (j = 0; j < i; j++) {
}
break;
}
return (obj);
}
void
char *nm;
{
"usage : %s -C|a|A|r|R|m|p|l|L [-t G|E|D|L|T] [-S] [-o file] name\n", nm);
}
char *nis_errors[] = {
"SUCCESS",
"S_SUCCESS",
"NOTFOUND",
"S_NOTFOUND",
"CACHEEXPIRED",
"NAMEUNREACHABLE",
"UNKNOWNOBJ",
"TRYAGAIN",
"SYSTEMERROR",
"CHAINBROKEN",
"PERMISSION",
"NOTOWNER",
"NOT_ME",
"NOMEMORY",
"NAMEEXISTS",
"NOTMASTER",
"INVALIDOBJ",
"BADNAME",
"NOCALLBACK",
"CBRESULTS",
"NOSUCHNAME",
"NOTUNIQUE",
"IBMODERROR",
"NOSUCHTABLE",
"TYPEMISMATCH",
"LINKNAMEERROR",
"PARTIAL",
"TOOMANYATTRS",
"RPCERROR",
"BADATTRIBUTE",
"NOTSEARCHABLE",
"CBERROR",
"FOREIGNNS",
"BADOBJECT",
"NOTSAMEOBJ",
"MODFAIL",
"BADREQUEST",
"NOTEMPTY"
};
static char *
text_of(s)
nis_error s;
{
static char *bg = "BOGUS_ERROR";
if (s > NIS_NOTEMPTY)
return (bg);
else
return (nis_errors[s]);
}
void
print_stats(r)
nis_result *r;
{
}
void
int f;
{
if (f)
else
}
int f;
{
char *s;
int stat;
if (f) {
} else {
if (! stat) {
} else if (name) {
/* We "rewrite" the name of the object. */
}
}
/* FIXUP for some old objects */
if (obj) {
}
return (obj); /* will be NULL if undecodable */
}
/*
* Attempt to actually create the directories for a particular
* dir object.
*/
{
int i, ms;
for (i = 0; i < ms; i++) {
}
}
/*
* Attempt to actually remove the directories for a particular
* dir object.
*/
{
int i, ms;
for (i = 0; i < ms; i++) {
}
}
/*
* Construct a legal NIS name from the object components.
* Uses static name buffer above.
*/
char *
{
if (domain[0] != '.')
return (name_buf);
}
/*
* Main code for the nisadm command
*/
int argc;
char *argv[];
{
err = 0; /* errors encountered */
char *s, /* Some temporaries */
*name, /* NIS name to look up */
*rname; /* name to look up */
int i, j; /* More temporaries */
int c;
prettyprint = TRUE;
}
switch (c) {
case 'a' :
break;
case 'A' :
break;
case 'R' :
op = REMOVE_OBJ;
break;
case 'r' :
break;
case 'm' :
break;
case 'L' :
break;
case 'l' :
break;
case 'p' :
prettyprint = TRUE;
break;
case 'i' :
break;
case 'S' :
break;
case 'C' :
op = CHECKPOINT;
break;
case 'F' :
for (s = optarg; *s; s++) {
switch (*s) {
case 'h' :
flags |= HARD_LOOKUP;
break;
case 'f' :
flags |= FOLLOW_LINKS;
break;
case 'p' :
flags |= FOLLOW_PATH;
break;
case 'c' :
break;
case 'a' :
flags |= ALL_RESULTS;
break;
case 'm' :
flags |= MASTER_ONLY;
break;
default :
err++;
}
}
break;
case 't':
switch (*optarg) {
case 'G' :
break;
case 'D' :
break;
case 'T' :
break;
case 'E' :
break;
case 'L' :
break;
default :
"unknown object type\n");
err++;
break;
}
break;
case '?' :
exit(1);
default :
err++;
break;
}
}
err++;
} else
}
exit(1);
}
exit(1);
}
}
if (! interact)
if (! prettyprint)
switch (op) {
case ADD :
case ADD_NS :
else
if (stats)
if (!stats)
break;
}
}
break;
case REMOVE_OBJ :
if (interact) {
"This option cannot use user typed in objects.\n");
break;
}
else
if (stats)
if (!stats)
}
}
break;
case REMOVE :
"Name required for remove operation.\n");
exit(1);
}
if (obj_type == NIS_DIRECTORY_OBJ) {
break;
}
NULL);
}
!= NIS_SUCCESS))
break;
}
else
break;
case MODIFY :
else
if (stats)
if (!stats)
}
}
break;
case LOOKUP :
case LIST :
"Name required for List or Lookup operation.\n");
exit(1);
}
else
if (stats)
}
}
if (stats)
if (!stats)
break;
}
break;
case PRINT :
}
break;
case CHECKPOINT :
if (! name) {
"Name required for Checkpoint operation.");
err++;
break;
}
if (stats)
if (!stats)
}
break;
default :
err = -1;
break;
}
if (! interact)
else
printf("\n");
if (! prettyprint)
}