1999-08-23 05:09:42 +04:00
|
|
|
/* $NetBSD: bootparamd.c,v 1.21 1999/08/23 01:09:42 christos Exp $ */
|
1996-08-31 00:03:54 +04:00
|
|
|
|
1994-01-08 16:22:03 +03:00
|
|
|
/*
|
|
|
|
* This code is not copyright, and is placed in the public domain.
|
|
|
|
* Feel free to use and modify. Please send modifications and/or
|
|
|
|
* suggestions + bug fixes to Klas Heggemann <klas@nada.kth.se>
|
1994-01-10 17:04:44 +03:00
|
|
|
*
|
1994-01-08 16:22:03 +03:00
|
|
|
* Various small changes by Theo de Raadt <deraadt@fsa.ca>
|
1994-01-10 17:04:44 +03:00
|
|
|
* Parser rewritten (adding YP support) by Roland McGrath <roland@frob.com>
|
1994-01-08 16:22:03 +03:00
|
|
|
*/
|
|
|
|
|
1997-07-28 10:03:54 +04:00
|
|
|
#include <sys/cdefs.h>
|
|
|
|
#ifndef lint
|
1999-08-23 05:09:42 +04:00
|
|
|
__RCSID("$NetBSD: bootparamd.c,v 1.21 1999/08/23 01:09:42 christos Exp $");
|
1997-07-28 10:03:54 +04:00
|
|
|
#endif
|
|
|
|
|
1994-01-08 16:22:03 +03:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <sys/socket.h>
|
1996-12-08 16:44:26 +03:00
|
|
|
|
1994-01-08 16:22:03 +03:00
|
|
|
#include <ctype.h>
|
1999-08-23 05:09:42 +04:00
|
|
|
#include <errno.h>
|
1996-12-08 16:44:26 +03:00
|
|
|
#include <err.h>
|
|
|
|
#include <netdb.h>
|
1997-07-28 10:03:54 +04:00
|
|
|
#include <stdlib.h>
|
1996-12-08 16:44:26 +03:00
|
|
|
#include <stdio.h>
|
1994-01-10 17:04:44 +03:00
|
|
|
#include <string.h>
|
1996-12-08 16:44:26 +03:00
|
|
|
#include <syslog.h>
|
1997-07-28 10:03:54 +04:00
|
|
|
#include <unistd.h>
|
1999-06-06 06:38:00 +04:00
|
|
|
#include <util.h>
|
1996-12-08 16:44:26 +03:00
|
|
|
|
|
|
|
#include <netinet/in.h>
|
1996-10-14 23:28:09 +04:00
|
|
|
#include <arpa/inet.h>
|
1996-12-08 16:44:26 +03:00
|
|
|
|
|
|
|
#include <rpc/rpc.h>
|
1997-07-28 10:03:54 +04:00
|
|
|
#include <rpc/pmap_clnt.h>
|
1996-12-08 16:44:26 +03:00
|
|
|
#include <rpcsvc/bootparam_prot.h>
|
1997-07-28 10:03:54 +04:00
|
|
|
#include <rpcsvc/ypclnt.h>
|
1996-12-08 16:44:26 +03:00
|
|
|
|
1994-01-10 17:04:44 +03:00
|
|
|
#include "pathnames.h"
|
1994-01-08 16:22:03 +03:00
|
|
|
|
|
|
|
#define MAXLEN 800
|
|
|
|
|
|
|
|
static char hostname[MAX_MACHINE_NAME];
|
|
|
|
static char askname[MAX_MACHINE_NAME];
|
|
|
|
static char domain_name[MAX_MACHINE_NAME];
|
|
|
|
|
1995-06-24 19:03:49 +04:00
|
|
|
extern void bootparamprog_1 __P((struct svc_req *, SVCXPRT *));
|
1994-01-08 16:22:03 +03:00
|
|
|
|
1995-06-24 19:03:49 +04:00
|
|
|
int _rpcsvcdirty = 0;
|
|
|
|
int _rpcpmstart = 0;
|
1994-01-08 16:22:03 +03:00
|
|
|
int debug = 0;
|
|
|
|
int dolog = 0;
|
1997-07-28 10:03:54 +04:00
|
|
|
struct in_addr route_addr;
|
1994-01-08 16:22:03 +03:00
|
|
|
struct sockaddr_in my_addr;
|
1996-12-08 16:53:25 +03:00
|
|
|
extern char *__progname;
|
1994-01-10 17:04:44 +03:00
|
|
|
char *bootpfile = _PATH_BOOTPARAMS;
|
1994-01-08 16:22:03 +03:00
|
|
|
|
1997-07-28 10:03:54 +04:00
|
|
|
int main __P((int, char *[]));
|
|
|
|
int lookup_bootparam __P((char *, char *, char *, char **, char **));
|
|
|
|
void usage __P((void));
|
1994-01-08 16:22:03 +03:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ever familiar
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
main(argc, argv)
|
|
|
|
int argc;
|
1997-07-28 10:03:54 +04:00
|
|
|
char *argv[];
|
1994-01-08 16:22:03 +03:00
|
|
|
{
|
|
|
|
SVCXPRT *transp;
|
|
|
|
struct hostent *he;
|
|
|
|
struct stat buf;
|
1996-03-31 03:53:51 +04:00
|
|
|
int c;
|
1994-01-08 16:22:03 +03:00
|
|
|
|
1996-03-31 03:53:51 +04:00
|
|
|
while ((c = getopt(argc, argv, "dsr:f:")) != -1)
|
1994-01-08 16:22:03 +03:00
|
|
|
switch (c) {
|
|
|
|
case 'd':
|
|
|
|
debug = 1;
|
|
|
|
break;
|
|
|
|
case 'r':
|
|
|
|
if (isdigit(*optarg)) {
|
1997-07-28 10:03:54 +04:00
|
|
|
if (inet_aton(optarg, &route_addr) != 0)
|
|
|
|
break;
|
1994-01-08 16:22:03 +03:00
|
|
|
}
|
|
|
|
he = gethostbyname(optarg);
|
1997-07-28 10:03:54 +04:00
|
|
|
if (he == 0) {
|
1997-09-08 06:21:52 +04:00
|
|
|
warnx("no such host: %s", optarg);
|
1994-01-08 16:22:03 +03:00
|
|
|
usage();
|
|
|
|
}
|
1997-10-18 15:27:49 +04:00
|
|
|
memmove(&route_addr.s_addr, he->h_addr, he->h_length);
|
1994-01-08 16:22:03 +03:00
|
|
|
break;
|
|
|
|
case 'f':
|
|
|
|
bootpfile = optarg;
|
|
|
|
break;
|
|
|
|
case 's':
|
|
|
|
dolog = 1;
|
|
|
|
#ifndef LOG_DAEMON
|
1996-12-08 16:53:25 +03:00
|
|
|
openlog(__progname, 0, 0);
|
1994-01-08 16:22:03 +03:00
|
|
|
#else
|
1996-12-08 16:53:25 +03:00
|
|
|
openlog(__progname, 0, LOG_DAEMON);
|
1994-01-08 16:22:03 +03:00
|
|
|
setlogmask(LOG_UPTO(LOG_NOTICE));
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
usage();
|
|
|
|
}
|
|
|
|
|
1996-12-08 16:44:26 +03:00
|
|
|
if (stat(bootpfile, &buf))
|
|
|
|
err(1, "%s", bootpfile);
|
|
|
|
|
1997-07-28 10:03:54 +04:00
|
|
|
if (route_addr.s_addr == 0) {
|
1994-01-08 16:22:03 +03:00
|
|
|
get_myaddress(&my_addr);
|
1997-07-28 10:03:54 +04:00
|
|
|
route_addr.s_addr = my_addr.sin_addr.s_addr;
|
1994-01-08 16:22:03 +03:00
|
|
|
}
|
1996-12-08 16:44:26 +03:00
|
|
|
if (!debug) {
|
|
|
|
if (daemon(0, 0))
|
|
|
|
err(1, "can't detach from terminal");
|
|
|
|
}
|
1999-06-06 06:38:00 +04:00
|
|
|
pidfile(NULL);
|
1994-01-08 16:22:03 +03:00
|
|
|
|
|
|
|
(void) pmap_unset(BOOTPARAMPROG, BOOTPARAMVERS);
|
|
|
|
|
|
|
|
transp = svcudp_create(RPC_ANYSOCK);
|
1996-12-08 16:44:26 +03:00
|
|
|
if (transp == NULL)
|
|
|
|
errx(1, "can't create udp service");
|
|
|
|
|
|
|
|
if (!svc_register(transp, BOOTPARAMPROG, BOOTPARAMVERS, bootparamprog_1,
|
|
|
|
IPPROTO_UDP))
|
1998-02-12 06:32:51 +03:00
|
|
|
errx(1, "unable to register BOOTPARAMPROG version %ld, udp",
|
1994-01-08 16:22:03 +03:00
|
|
|
BOOTPARAMVERS);
|
1996-12-08 16:44:26 +03:00
|
|
|
|
1994-01-08 16:22:03 +03:00
|
|
|
svc_run();
|
1996-12-08 16:44:26 +03:00
|
|
|
errx(1, "svc_run returned");
|
1994-01-08 16:22:03 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
bp_whoami_res *
|
1995-06-24 19:03:49 +04:00
|
|
|
bootparamproc_whoami_1_svc(whoami, rqstp)
|
1994-01-08 16:22:03 +03:00
|
|
|
bp_whoami_arg *whoami;
|
1995-06-24 19:03:49 +04:00
|
|
|
struct svc_req *rqstp;
|
1994-01-08 16:22:03 +03:00
|
|
|
{
|
|
|
|
static bp_whoami_res res;
|
1996-10-14 23:28:09 +04:00
|
|
|
struct hostent *he;
|
1999-03-25 01:01:38 +03:00
|
|
|
struct in_addr haddr;
|
1999-08-23 05:09:42 +04:00
|
|
|
int e;
|
1994-01-10 17:04:44 +03:00
|
|
|
|
1994-01-08 16:22:03 +03:00
|
|
|
if (debug)
|
1997-09-08 06:21:52 +04:00
|
|
|
warnx("whoami got question for %d.%d.%d.%d",
|
1994-01-08 16:22:03 +03:00
|
|
|
255 & whoami->client_address.bp_address_u.ip_addr.net,
|
|
|
|
255 & whoami->client_address.bp_address_u.ip_addr.host,
|
|
|
|
255 & whoami->client_address.bp_address_u.ip_addr.lh,
|
|
|
|
255 & whoami->client_address.bp_address_u.ip_addr.impno);
|
|
|
|
if (dolog)
|
1997-09-08 06:21:52 +04:00
|
|
|
syslog(LOG_NOTICE, "whoami got question for %d.%d.%d.%d",
|
1994-01-08 16:22:03 +03:00
|
|
|
255 & whoami->client_address.bp_address_u.ip_addr.net,
|
|
|
|
255 & whoami->client_address.bp_address_u.ip_addr.host,
|
|
|
|
255 & whoami->client_address.bp_address_u.ip_addr.lh,
|
|
|
|
255 & whoami->client_address.bp_address_u.ip_addr.impno);
|
|
|
|
|
1997-10-18 15:27:49 +04:00
|
|
|
memmove((char *) &haddr,
|
|
|
|
(char *) &whoami->client_address.bp_address_u.ip_addr,
|
|
|
|
sizeof(haddr));
|
1994-01-08 16:22:03 +03:00
|
|
|
he = gethostbyaddr((char *) &haddr, sizeof(haddr), AF_INET);
|
1997-09-23 11:28:29 +04:00
|
|
|
if (he) {
|
|
|
|
strncpy(askname, he->h_name, sizeof(askname));
|
|
|
|
askname[sizeof(askname)-1] = 0;
|
|
|
|
} else {
|
1999-03-25 01:01:38 +03:00
|
|
|
strncpy(askname, inet_ntoa(haddr), sizeof(askname));
|
1997-09-23 11:28:29 +04:00
|
|
|
askname[sizeof(askname)-1] = 0;
|
1996-10-14 23:28:09 +04:00
|
|
|
}
|
1994-01-08 16:22:03 +03:00
|
|
|
|
|
|
|
if (debug)
|
1997-09-08 06:21:52 +04:00
|
|
|
warnx("This is host %s", askname);
|
1994-01-08 16:22:03 +03:00
|
|
|
if (dolog)
|
1997-09-08 06:21:52 +04:00
|
|
|
syslog(LOG_NOTICE, "This is host %s", askname);
|
1994-01-08 16:22:03 +03:00
|
|
|
|
1999-08-23 05:09:42 +04:00
|
|
|
if ((e = lookup_bootparam(askname, hostname, NULL, NULL, NULL)) == 0) {
|
1994-01-08 16:22:03 +03:00
|
|
|
res.client_name = hostname;
|
|
|
|
getdomainname(domain_name, MAX_MACHINE_NAME);
|
|
|
|
res.domain_name = domain_name;
|
|
|
|
|
|
|
|
if (res.router_address.address_type != IP_ADDR_TYPE) {
|
|
|
|
res.router_address.address_type = IP_ADDR_TYPE;
|
1997-10-18 15:27:49 +04:00
|
|
|
memmove(&res.router_address.bp_address_u.ip_addr,
|
|
|
|
&route_addr.s_addr,4);
|
1994-01-08 16:22:03 +03:00
|
|
|
}
|
|
|
|
if (debug)
|
1997-09-08 06:21:52 +04:00
|
|
|
warnx("Returning %s %s %d.%d.%d.%d",
|
1994-01-08 16:22:03 +03:00
|
|
|
res.client_name, res.domain_name,
|
|
|
|
255 & res.router_address.bp_address_u.ip_addr.net,
|
|
|
|
255 & res.router_address.bp_address_u.ip_addr.host,
|
|
|
|
255 & res.router_address.bp_address_u.ip_addr.lh,
|
1997-09-23 11:28:29 +04:00
|
|
|
255 &res.router_address.bp_address_u.ip_addr.impno);
|
1994-01-08 16:22:03 +03:00
|
|
|
if (dolog)
|
1997-09-08 06:21:52 +04:00
|
|
|
syslog(LOG_NOTICE, "Returning %s %s %d.%d.%d.%d",
|
1994-01-08 16:22:03 +03:00
|
|
|
res.client_name, res.domain_name,
|
|
|
|
255 & res.router_address.bp_address_u.ip_addr.net,
|
|
|
|
255 & res.router_address.bp_address_u.ip_addr.host,
|
|
|
|
255 & res.router_address.bp_address_u.ip_addr.lh,
|
1997-09-23 11:28:29 +04:00
|
|
|
255 &res.router_address.bp_address_u.ip_addr.impno);
|
1994-01-08 16:22:03 +03:00
|
|
|
|
|
|
|
return (&res);
|
|
|
|
}
|
1999-08-23 05:09:42 +04:00
|
|
|
errno = e;
|
1994-01-08 16:22:03 +03:00
|
|
|
if (debug)
|
1999-08-23 05:09:42 +04:00
|
|
|
warn("whoami failed");
|
1994-01-08 16:22:03 +03:00
|
|
|
if (dolog)
|
1999-08-23 05:09:42 +04:00
|
|
|
syslog(LOG_NOTICE, "whoami failed %m");
|
1994-01-08 16:22:03 +03:00
|
|
|
return (NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bp_getfile_res *
|
1995-06-24 19:03:49 +04:00
|
|
|
bootparamproc_getfile_1_svc(getfile, rqstp)
|
1994-01-08 16:22:03 +03:00
|
|
|
bp_getfile_arg *getfile;
|
1995-06-24 19:03:49 +04:00
|
|
|
struct svc_req *rqstp;
|
1994-01-08 16:22:03 +03:00
|
|
|
{
|
|
|
|
static bp_getfile_res res;
|
1996-10-14 23:28:09 +04:00
|
|
|
struct hostent *he;
|
1994-01-10 17:04:44 +03:00
|
|
|
int err;
|
1994-01-08 16:22:03 +03:00
|
|
|
|
|
|
|
if (debug)
|
1997-09-08 06:21:52 +04:00
|
|
|
warnx("getfile got question for \"%s\" and file \"%s\"",
|
1994-01-08 16:22:03 +03:00
|
|
|
getfile->client_name, getfile->file_id);
|
|
|
|
|
|
|
|
if (dolog)
|
1997-09-08 06:21:52 +04:00
|
|
|
syslog(LOG_NOTICE,
|
|
|
|
"getfile got question for \"%s\" and file \"%s\"",
|
1994-01-08 16:22:03 +03:00
|
|
|
getfile->client_name, getfile->file_id);
|
|
|
|
|
|
|
|
he = NULL;
|
|
|
|
he = gethostbyname(getfile->client_name);
|
|
|
|
if (!he)
|
|
|
|
goto failed;
|
|
|
|
|
1997-09-23 11:28:29 +04:00
|
|
|
strncpy(askname, he->h_name, sizeof(askname));
|
|
|
|
askname[sizeof(askname)-1] = 0;
|
1994-01-10 17:04:44 +03:00
|
|
|
err = lookup_bootparam(askname, NULL, getfile->file_id,
|
|
|
|
&res.server_name, &res.server_path);
|
|
|
|
if (err == 0) {
|
|
|
|
he = gethostbyname(res.server_name);
|
|
|
|
if (!he)
|
|
|
|
goto failed;
|
1997-10-18 15:27:49 +04:00
|
|
|
memmove(&res.server_address.bp_address_u.ip_addr,
|
|
|
|
he->h_addr, 4);
|
1994-01-10 17:04:44 +03:00
|
|
|
res.server_address.address_type = IP_ADDR_TYPE;
|
|
|
|
} else if (err == ENOENT && !strcmp(getfile->file_id, "dump")) {
|
|
|
|
/* Special for dump, answer with null strings. */
|
|
|
|
res.server_name[0] = '\0';
|
|
|
|
res.server_path[0] = '\0';
|
1997-10-18 15:27:49 +04:00
|
|
|
memset(&res.server_address.bp_address_u.ip_addr, 0, 4);
|
1994-01-10 17:04:44 +03:00
|
|
|
} else {
|
|
|
|
failed:
|
1994-01-08 16:22:03 +03:00
|
|
|
if (debug)
|
1997-09-08 06:21:52 +04:00
|
|
|
warnx("getfile failed for %s",
|
1994-01-10 17:04:44 +03:00
|
|
|
getfile->client_name);
|
1994-01-08 16:22:03 +03:00
|
|
|
if (dolog)
|
|
|
|
syslog(LOG_NOTICE,
|
1997-09-08 06:21:52 +04:00
|
|
|
"getfile failed for %s", getfile->client_name);
|
1994-01-10 17:04:44 +03:00
|
|
|
return (NULL);
|
1994-01-08 16:22:03 +03:00
|
|
|
}
|
1994-01-10 17:04:44 +03:00
|
|
|
|
1994-01-08 16:22:03 +03:00
|
|
|
if (debug)
|
1996-12-08 16:44:26 +03:00
|
|
|
warnx(
|
1997-09-08 06:21:52 +04:00
|
|
|
"returning server:%s path:%s address: %d.%d.%d.%d",
|
1994-01-10 17:04:44 +03:00
|
|
|
res.server_name, res.server_path,
|
|
|
|
255 & res.server_address.bp_address_u.ip_addr.net,
|
|
|
|
255 & res.server_address.bp_address_u.ip_addr.host,
|
|
|
|
255 & res.server_address.bp_address_u.ip_addr.lh,
|
|
|
|
255 & res.server_address.bp_address_u.ip_addr.impno);
|
1994-01-08 16:22:03 +03:00
|
|
|
if (dolog)
|
|
|
|
syslog(LOG_NOTICE,
|
1997-09-08 06:21:52 +04:00
|
|
|
"returning server:%s path:%s address: %d.%d.%d.%d",
|
1994-01-10 17:04:44 +03:00
|
|
|
res.server_name, res.server_path,
|
|
|
|
255 & res.server_address.bp_address_u.ip_addr.net,
|
|
|
|
255 & res.server_address.bp_address_u.ip_addr.host,
|
|
|
|
255 & res.server_address.bp_address_u.ip_addr.lh,
|
|
|
|
255 & res.server_address.bp_address_u.ip_addr.impno);
|
|
|
|
return (&res);
|
1994-01-08 16:22:03 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1994-01-10 17:04:44 +03:00
|
|
|
int
|
|
|
|
lookup_bootparam(client, client_canonical, id, server, path)
|
|
|
|
char *client;
|
|
|
|
char *client_canonical;
|
|
|
|
char *id;
|
|
|
|
char **server;
|
|
|
|
char **path;
|
1994-01-08 16:22:03 +03:00
|
|
|
{
|
1994-01-10 17:04:44 +03:00
|
|
|
FILE *f = fopen(bootpfile, "r");
|
|
|
|
#ifdef YP
|
|
|
|
static char *ypbuf = NULL;
|
|
|
|
static int ypbuflen = 0;
|
|
|
|
#endif
|
|
|
|
static char buf[BUFSIZ];
|
1997-07-28 10:03:54 +04:00
|
|
|
char *bp, *word = NULL;
|
1994-01-10 17:04:44 +03:00
|
|
|
size_t idlen = id == NULL ? 0 : strlen(id);
|
|
|
|
int contin = 0;
|
|
|
|
int found = 0;
|
|
|
|
|
|
|
|
if (f == NULL)
|
|
|
|
return EINVAL; /* ? */
|
|
|
|
|
|
|
|
while (fgets(buf, sizeof buf, f)) {
|
|
|
|
int wascontin = contin;
|
|
|
|
contin = buf[strlen(buf) - 2] == '\\';
|
|
|
|
bp = buf + strspn(buf, " \t\n");
|
|
|
|
|
|
|
|
switch (wascontin) {
|
|
|
|
case -1:
|
|
|
|
/* Continuation of uninteresting line */
|
|
|
|
contin *= -1;
|
|
|
|
continue;
|
|
|
|
case 0:
|
|
|
|
/* New line */
|
|
|
|
contin *= -1;
|
|
|
|
if (*bp == '#')
|
|
|
|
continue;
|
|
|
|
if ((word = strsep(&bp, " \t\n")) == NULL)
|
|
|
|
continue;
|
|
|
|
#ifdef YP
|
|
|
|
/* A + in the file means try YP now */
|
|
|
|
if (!strcmp(word, "+")) {
|
|
|
|
char *ypdom;
|
|
|
|
|
|
|
|
if (yp_get_default_domain(&ypdom) ||
|
|
|
|
yp_match(ypdom, "bootparams", client,
|
|
|
|
strlen(client), &ypbuf, &ypbuflen))
|
|
|
|
continue;
|
|
|
|
bp = ypbuf;
|
|
|
|
word = client;
|
|
|
|
contin *= -1;
|
|
|
|
break;
|
1994-01-08 16:22:03 +03:00
|
|
|
}
|
1994-01-10 17:04:44 +03:00
|
|
|
#endif
|
1999-08-23 05:09:42 +04:00
|
|
|
if (debug)
|
|
|
|
warnx("match %s with %s", word, client);
|
1994-01-10 17:04:44 +03:00
|
|
|
/* See if this line's client is the one we are
|
|
|
|
* looking for */
|
1996-10-04 23:00:31 +04:00
|
|
|
if (strcasecmp(word, client) != 0) {
|
1994-01-10 17:04:44 +03:00
|
|
|
/*
|
|
|
|
* If it didn't match, try getting the
|
|
|
|
* canonical host name of the client
|
|
|
|
* on this line and comparing that to
|
|
|
|
* the client we are looking for
|
|
|
|
*/
|
|
|
|
struct hostent *hp = gethostbyname(word);
|
1999-04-26 06:35:17 +04:00
|
|
|
if (hp == NULL ) {
|
|
|
|
if (debug)
|
|
|
|
warnx(
|
|
|
|
"Unknown bootparams host %s", word);
|
|
|
|
if (dolog)
|
|
|
|
syslog(LOG_NOTICE,
|
|
|
|
"Unknown bootparams host %s", word);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (strcasecmp(hp->h_name, client))
|
1994-01-10 17:04:44 +03:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
contin *= -1;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
/* Continued line we want to parse below */
|
1994-01-08 16:22:03 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
1994-01-10 17:04:44 +03:00
|
|
|
if (client_canonical)
|
|
|
|
strncpy(client_canonical, word, MAX_MACHINE_NAME);
|
|
|
|
|
|
|
|
/* We have found a line for CLIENT */
|
1994-11-29 18:03:13 +03:00
|
|
|
if (id == NULL) {
|
|
|
|
(void) fclose(f);
|
1994-01-10 17:04:44 +03:00
|
|
|
return 0;
|
1994-11-29 18:03:13 +03:00
|
|
|
}
|
1994-01-10 17:04:44 +03:00
|
|
|
|
|
|
|
/* Look for a value for the parameter named by ID */
|
|
|
|
while ((word = strsep(&bp, " \t\n")) != NULL) {
|
|
|
|
if (!strncmp(word, id, idlen) && word[idlen] == '=') {
|
|
|
|
/* We have found the entry we want */
|
|
|
|
*server = &word[idlen + 1];
|
|
|
|
*path = strchr(*server, ':');
|
|
|
|
if (*path == NULL)
|
|
|
|
/* Malformed entry */
|
|
|
|
continue;
|
|
|
|
*(*path)++ = '\0';
|
|
|
|
(void) fclose(f);
|
|
|
|
return 0;
|
1994-01-08 16:22:03 +03:00
|
|
|
}
|
|
|
|
}
|
1994-01-10 17:04:44 +03:00
|
|
|
|
|
|
|
found = 1;
|
1994-01-08 16:22:03 +03:00
|
|
|
}
|
1994-01-10 17:04:44 +03:00
|
|
|
|
|
|
|
(void) fclose(f);
|
|
|
|
return found ? ENOENT : EPERM;
|
1994-01-08 16:22:03 +03:00
|
|
|
}
|
1997-07-28 10:03:54 +04:00
|
|
|
|
|
|
|
void
|
|
|
|
usage()
|
|
|
|
{
|
|
|
|
fprintf(stderr,
|
|
|
|
"usage: %s [-d] [-s] [-r router] [-f bootparmsfile]\n", __progname);
|
|
|
|
exit(1);
|
|
|
|
}
|