yppoll.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 1995 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
/*
* Portions of this source code were derived from Berkeley
* under license from the Regents of the University of
* California.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* This is a user command which asks a particular ypserv which version of a
* map it is using. Usage is:
*
* yppoll [-h <host>] [-d <domainname>] mapname
*
* If the host is ommitted, the local host will be used. If host is specified
* as an internet address, no yp services need to be locally available.
*
*/
#include <stdio.h>
#include <ctype.h>
#include <netdir.h>
#include "yp_b.h"
#ifdef NULL
#endif
#define NULL 0
static int status = 0; /* exit status */
static char default_domain_name[YPMAXDOMAIN];
static char default_host_name[256];
static char err_usage[] =
"Usage:\n\
yppoll [ -h host ] [ -d domainname ] mapname\n\n";
static char err_bad_args[] =
"Bad %s argument.\n";
static char err_cant_get_kname[] =
"Can't get %s back from system call.\n";
static char err_null_kname[] =
"%s hasn't been set on this machine.\n";
static char err_bad_hostname[] = "hostname";
static char err_bad_mapname[] = "mapname";
static char err_bad_domainname[] = "domainname";
static char err_bad_resp[] =
"Ill-formed response returned from ypserv on host %s.\n";
static void get_command_line_args();
static void getdomain();
static void getlochost();
static void getmapparms();
static void newresults();
static void getypserv();
extern void exit();
extern int getdomainname();
extern int gethostname();
extern unsigned int strlen();
extern int strcmp();
/*
* This is the mainline for the yppoll process.
*/
void
int argc;
char **argv;
{
if (!domain) {
getdomain();
}
if (!host) {
getypserv();
}
getmapparms();
/* NOTREACHED */
}
/*
* This does the command line argument processing.
*/
static void
int argc;
char **argv;
{
argv++;
while (--argc) {
if ((*argv)[0] == '-') {
switch ((*argv)[1]) {
case 'h':
if (argc > 1) {
argv++;
argc--;
argv++;
exit(1);
}
} else {
exit(1);
}
break;
case 'd':
if (argc > 1) {
argv++;
argc--;
argv++;
exit(1);
}
} else {
exit(1);
}
break;
default:
exit(1);
}
} else {
if (!map) {
exit(1);
}
} else {
exit(1);
}
}
}
if (!map) {
exit(1);
}
}
/*
* This gets the local default domainname, and makes sure that it's set
* to something reasonable. domain is set here.
*/
static void
{
} else {
exit(1);
}
exit(1);
}
}
/*
* This gets the local hostname back from the kernel
*/
static void
{
} else {
exit(1);
}
}
static void
{
struct ypresp_order oresp;
struct ypreq_nokey req;
struct ypresp_master mresp;
enum clnt_stat s;
"netpath")) == NULL) {
"Can't create connection to %s.\n", host);
clnt_pcreateerror("Reason");
exit(1);
}
if (s == RPC_SUCCESS) {
} else {
"Can't make YPPROC_ORDER call to ypserv at %s.\n ",
host);
exit(1);
}
} else {
}
}
static void
newresults(m, o)
struct ypresp_master *m;
struct ypresp_order *o;
{
char *s_domok = "Domain %s is supported.\n";
char *s_ook = "Map %s has order number %d.\n";
char *s_mok = "The master server is %s.\n";
char *s_mbad = "Can't get master for map %s.\n Reason: %s\n";
char *s_obad = "Can't get order number for map %s.\n Reason: %s\n";
status = 1;
status = 1;
} else {
"Can't get any map parameter information.\n");
status = 1;
}
}
static void
{
struct ypbind_resp response;
struct ypbind_domain ypdomain;
struct ypbind_binding *binding;
static char hostbuf[256];
getlochost();
(char *)&response, "netpath");
exit(1);
}
/*
* When ypbind is running in broadcast mode, it sets the
* servername to "". To get the real name of the server,
* we need to do a host lookup on the svcaddr. This code
* is similar to code in ypwhich.
*/
struct nd_hostservlist *nhs;
struct sockaddr_in *sa;
} else {
}
}
}