nisupdkeys.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-1995 Sun Microsystems, Inc.
* All Rights Reserved.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
*
* This function will read the list of servers from a directory object,
* update them with the proper public keys and write the directory object
* back.
*
*/
#include <stdio.h>
#include <netdb.h>
#include <netdir.h>
#include <netconfig.h>
#include <rpc/key_prot.h>
#include <rpcsvc/nis_dhext.h>
#include <string.h>
#include <stdlib.h>
extern int optind;
extern char *optarg;
extern char *inet_ntoa();
extern nis_server *__nis_host2nis_server_g();
static
int
{
return (1);
return (0);
}
void
char *cmd;
{
exit(1);
}
int
char *h; /* host to act on */
int ns; /* number of servers */
{
int i, is_modified;
for (i = 0, is_modified = 0; i < ns; i++) {
continue;
is_modified++;
} else {
printf("\tNo keys exist for the server \"%s\"\n",
}
}
return (is_modified);
}
void
{
}
int
char *h; /* host to act on */
int ns; /* number of servers */
{
int i, is_modified;
char netname[MAXNETNAMELEN];
int errcode;
for (i = 0, is_modified = 0; i < ns; i++) {
continue;
continue;
}
#ifdef DEBUG
printf("\tFetching Public key for server %s ...\n",
#endif
/*
* Basically let __nis_host2nis_server do the magic of
* determining what kind of nis_server should be
* storred in the directory object. All we need to do
* is preserve endpoint (address) information and
* print out the appropriate message.
*
* The new publickey should come from the master so
* that a stale key is not returned from a replica.
* However there is currently no way of doing this so
* replicas should be sync'd with the master.
*/
if (!(newserver =
&errcode))) {
exit(1);
}
continue;
case NIS_PK_NONE:
case NIS_PK_NONE:
break;
case NIS_PK_DH:
"\tInstalling %s's public key in this object\n",
break;
case NIS_PK_DHEXT:
"\tInstalling %s's public key(s) in this object\n",
break;
default:
"\tERROR! Unknown server type.\n");
continue;
}
break;
case NIS_PK_DH:
case NIS_PK_NONE:
"\tRemoving %s's public key in this object\n",
break;
case NIS_PK_DH:
"\tUpdating %s's public key in this object\n",
break;
case NIS_PK_DHEXT:
"\tUpdating %s's public key(s) in this object\n",
break;
default:
"\tERROR! Unknown server type.\n");
continue;
}
break;
case NIS_PK_DHEXT:
case NIS_PK_NONE:
"\tRemoving %s's public key in this object\n",
break;
case NIS_PK_DH:
"\tInstalling %s's public key in this object\n",
break;
case NIS_PK_DHEXT:
"\tUpdating %s's public key(s) in this object\n",
break;
default:
"\tERROR! Unknown server type.\n");
continue;
}
default:
case NIS_PK_NONE:
break;
case NIS_PK_DH:
"\tInstalling %s's public key in this object\n",
break;
case NIS_PK_DHEXT:
"\tInstalling %s's public key(s) in this object\n",
break;
default:
"\tERROR! Unknown server type.\n");
continue;
}
}
}
return (is_modified);
}
/*
* updaddrdata()
*
* For each server in the list, update its address information to be
* current. If h is non-null only update information for that host.
*/
int
char *h; /* host to act on */
int ns; /* number of servers */
{
register int i, j, k;
int nep; /* num of eps */
void *nch; /* netconfig structure handle */
for (i = 0; i < ns; i++) {
continue;
for (j = 0; j < nep; j++) {
}
/* setup params for netdir_getbyname() */
/* count how many server entries we need */
j = 0, nch = setnetconfig();
continue;
}
}
if (j == 0) {
"nisupdkeys: Can't get address information for "
"host \"%s\"\n",
exit(1);
}
/* got server count and allocate space */
return (0);
}
/* fill in new server address info */
j = 0, nch = setnetconfig();
/* keep going if we still have more interfaces */
continue;
/* if any of these returned NULL, bail */
return (0);
}
j++;
}
}
}
if (j == 0) {
"nisupdkeys: Can't get address information for "
"host \"%s\"\n",
exit(1);
}
}
return (1);
}
#define UPD_KEYS 0
#define CLR_KEYS 1
#define UPD_ADDR 2
int argc;
char *argv[];
{
char dname[NIS_MAXNAMELEN];
int ns, is_modified;
int c;
int i = 0;
char *hostname;
switch (c) {
case 'C' :
break;
case 'a' :
break;
case 'H' :
break;
case 's' :
hostupdate = TRUE;
break;
case '?' :
default :
break;
}
}
if (server)
else
hostname = nis_local_host();
if (hostupdate == TRUE) {
/*
* get the list of directories served by this server and
* update all those directory objects.
*/
"No directories allowed with -s option\n");
}
if (!(nisserver =
exit(1);
/* Get a list of directories served by this server */
if (status != NIS_SUCCESS) {
"nisupdkeys: Error talking to host \"%s\", "
exit(1);
}
"Attributes for the server \"%s\" cannot be "
"updated by \"nisupdkeys -s\"\n", hostname);
"Instead, use the following for all directories "
"served by \"%s\"\n",
hostname);
exit(1);
}
*t++ = NULL;
dirname = t;
}
} else {
if (i == 0) {
dirlist[0] = nis_local_directory();
i++;
}
}
is_modified = 0;
/* if res != NULL its been used before */
if (res)
"\tERROR: Unable to retrieve object.\n");
continue;
}
dname);
continue;
}
/* if a specific host has been specified */
if (server) {
for (i = 0; i < ns; ++i) {
break;
}
if (i == ns) {
"\tERROR: Host \"%s\" does not serve "
"\tDirectory \"%s\" is not being "
"modified\n", *curdir);
continue;
}
}
switch (op) {
case CLR_KEYS :
break;
case UPD_KEYS :
break;
case UPD_ADDR :
break;
default:
/* should not have happened */
exit(1);
}
if (is_modified) {
"\tERROR: Unable to modify directory "
"object \"%s\"\n", *curdir);
}
}
}
if (res)
return (0);
}