summaryrefslogtreecommitdiffstats
path: root/usr.sbin/bootparamd/bootparamd
diff options
context:
space:
mode:
authorcharnier <charnier@FreeBSD.org>1997-09-04 11:50:37 +0000
committercharnier <charnier@FreeBSD.org>1997-09-04 11:50:37 +0000
commit6440762ef4221fe3a3ca0949c8fc4e60a42d0a06 (patch)
treee063a80fc6c19a14600672243a47d18568458494 /usr.sbin/bootparamd/bootparamd
parent4bf7bce8d80e50305a5779f4390af7856250d18e (diff)
downloadFreeBSD-src-6440762ef4221fe3a3ca0949c8fc4e60a42d0a06.zip
FreeBSD-src-6440762ef4221fe3a3ca0949c8fc4e60a42d0a06.tar.gz
Use err(3). Add usage and prototypes. Remove Xref: Diskless(8) does not
exist. Use An/Aq macros for Author.
Diffstat (limited to 'usr.sbin/bootparamd/bootparamd')
-rw-r--r--usr.sbin/bootparamd/bootparamd/bootparamd.87
-rw-r--r--usr.sbin/bootparamd/bootparamd/bootparamd.c52
-rw-r--r--usr.sbin/bootparamd/bootparamd/bootparams.513
-rw-r--r--usr.sbin/bootparamd/bootparamd/main.c87
4 files changed, 77 insertions, 82 deletions
diff --git a/usr.sbin/bootparamd/bootparamd/bootparamd.8 b/usr.sbin/bootparamd/bootparamd/bootparamd.8
index e859b77..3573137 100644
--- a/usr.sbin/bootparamd/bootparamd/bootparamd.8
+++ b/usr.sbin/bootparamd/bootparamd/bootparamd.8
@@ -9,9 +9,9 @@
.Nm
.Op Fl ds
.Op Fl r Ar router
-.Op Fl f file
+.Op Fl f Ar file
.Sh DESCRIPTION
-.Nm bootparamd
+.Nm Bootparamd
is a server process that provides information to diskless clients
necessary for booting. It consults the
.Pa /etc/bootparams
@@ -44,4 +44,5 @@ The file to use as boot parameter file instead of
.Sh BUGS
You may find the syslog loggings to be verbose.
.Sh AUTHOR
-Written by Klas Heggemann <klas@nada.kth.se>
+Written by
+.An Klas Heggemann Aq klas@nada.kth.se
diff --git a/usr.sbin/bootparamd/bootparamd/bootparamd.c b/usr.sbin/bootparamd/bootparamd/bootparamd.c
index 3148814..327e2bb 100644
--- a/usr.sbin/bootparamd/bootparamd/bootparamd.c
+++ b/usr.sbin/bootparamd/bootparamd/bootparamd.c
@@ -5,22 +5,26 @@ use and modify. Please send modifications and/or suggestions + bug fixes to
Klas Heggemann <klas@nada.kth.se>
- $Id$
-
*/
+#ifndef lint
+static const char rcsid[] =
+ "$Id$";
+#endif /* not lint */
#include <rpc/rpc.h>
#include <rpcsvc/yp_prot.h>
#include <rpcsvc/ypclnt.h>
#include "bootparam_prot.h"
+#include <ctype.h>
+#include <err.h>
+#include <netdb.h>
#include <stdio.h>
#include <string.h>
+#include <syslog.h>
+#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
-#include <netdb.h>
-#include <ctype.h>
-#include <syslog.h>
extern int debug, dolog;
extern unsigned long route_addr;
extern char *bootpfile;
@@ -34,6 +38,8 @@ static char askname[MAX_MACHINE_NAME];
static char path[MAX_PATH_LEN];
static char domain_name[MAX_MACHINE_NAME];
+int getthefile __P((char *, char *, char *));
+int checkhost __P((char *, char *));
bp_whoami_res *
bootparamproc_whoami_1(whoami)
@@ -59,7 +65,7 @@ bp_whoami_arg *whoami;
he = gethostbyaddr((char *)&haddr,sizeof(haddr),AF_INET);
if ( ! he ) goto failed;
- if (debug) fprintf(stderr,"This is host %s\n", he->h_name);
+ if (debug) warnx("this is host %s", he->h_name);
if (dolog) syslog(LOG_NOTICE,"This is host %s\n", he->h_name);
strcpy(askname, he->h_name);
@@ -92,7 +98,7 @@ bp_whoami_arg *whoami;
return(&res);
}
failed:
- if (debug) fprintf(stderr,"whoami failed\n");
+ if (debug) warnx("whoami failed");
if (dolog) syslog(LOG_NOTICE,"whoami failed\n");
return(NULL);
}
@@ -106,7 +112,7 @@ bp_getfile_arg *getfile;
static bp_getfile_res res;
if (debug)
- fprintf(stderr,"getfile got question for \"%s\" and file \"%s\"\n",
+ warnx("getfile got question for \"%s\" and file \"%s\"",
getfile->client_name, getfile->file_id);
if (dolog)
@@ -119,7 +125,7 @@ bp_getfile_arg *getfile;
strcpy(askname,he->h_name);
if (getthefile(askname, getfile->file_id,buffer)) {
- if ( where = index(buffer,':')) {
+ if ( (where = index(buffer,':')) ) {
/* buffer is re-written to contain the name of the info of file */
strncpy(hostname, buffer, where - buffer);
hostname[where - buffer] = '\0';
@@ -157,7 +163,7 @@ bp_getfile_arg *getfile;
return(&res);
}
failed:
- if (debug) fprintf(stderr, "getfile failed for %s\n", getfile->client_name);
+ if (debug) warnx("getfile failed for %s", getfile->client_name);
if (dolog) syslog(LOG_NOTICE,
"getfile failed for %s\n", getfile->client_name);
return(NULL);
@@ -169,6 +175,7 @@ bp_getfile_arg *getfile;
will be empty. (This makes it possible to give the special
empty answer for the file "dump") */
+int
getthefile(askname,fileid,buffer)
char *askname;
char *fileid, *buffer;
@@ -184,10 +191,8 @@ char *fileid, *buffer;
char info[MAX_FILEID + MAX_PATH_LEN+MAX_MACHINE_NAME + 3];
bpf = fopen(bootpfile, "r");
- if ( ! bpf ) {
- fprintf(stderr, "No %s\n", bootpfile);
- exit(1);
- }
+ if ( ! bpf )
+ errx(1, "no %s", bootpfile);
while ( fscanf(bpf, "%s", hostname) > 0 && !match ) {
if ( *hostname != '#' ) { /* comment */
@@ -200,7 +205,7 @@ char *fileid, *buffer;
}
if (*hostname == '+' ) { /* NIS */
if (yp_get_default_domain(&yp_domain)) {
- if (debug) perror("NIS");
+ if (debug) warn("NIS");
return(0);
}
if (yp_match(yp_domain, "bootparams", askname, strlen(askname),
@@ -214,7 +219,7 @@ char *fileid, *buffer;
*(char *)(strchr(buffer, ' ')) = '\0';
}
if (fclose(bpf))
- fprintf(stderr,"Could not close %s\n", bootpfile);
+ warnx("could not close %s", bootpfile);
return(1);
}
/* skip to next entry */
@@ -254,7 +259,7 @@ char *fileid, *buffer;
} else break; /* a commented rest-of-line */
}
}
- if (fclose(bpf)) { fprintf(stderr,"Could not close %s\n", bootpfile); }
+ if (fclose(bpf)) { warnx("could not close %s", bootpfile); }
if ( res == -1) buffer[0] = '\0'; /* host found, file not */
return(match);
}
@@ -263,6 +268,7 @@ char *fileid, *buffer;
the hostname-variable and returns 1, if askname is a valid
name for a host in the database */
+int
checkhost(askname, hostname)
char *askname;
char *hostname;
@@ -277,10 +283,8 @@ char *hostname;
/* struct hostent *cmp_he;*/
bpf = fopen(bootpfile, "r");
- if ( ! bpf ) {
- fprintf(stderr, "No %s\n", bootpfile);
- exit(1);
- }
+ if ( ! bpf )
+ errx(1, "no %s", bootpfile);
while ( fscanf(bpf, "%s", hostname) > 0 ) {
if ( *hostname != '#' ) { /* comment */
@@ -300,7 +304,7 @@ char *hostname;
}
if (*hostname == '+' ) { /* NIS */
if (yp_get_default_domain(&yp_domain)) {
- if (debug) perror("NIS");
+ if (debug) warn("NIS");
return(0);
}
if (!yp_match(yp_domain, "bootparams", askname, strlen(askname),
@@ -314,7 +318,7 @@ char *hostname;
}
}
if (fclose(bpf))
- fprintf(stderr,"Could not close %s\n", bootpfile);
+ warnx("could not close %s", bootpfile);
return(res);
}
/* skip to next entry */
@@ -323,6 +327,6 @@ char *hostname;
pch = ch; ch = getc(bpf);
}
}
- if (fclose(bpf)) { fprintf(stderr,"Could not close %s\n", bootpfile); }
+ if (fclose(bpf)) { warnx("could not close %s", bootpfile); }
return(res);
}
diff --git a/usr.sbin/bootparamd/bootparamd/bootparams.5 b/usr.sbin/bootparamd/bootparamd/bootparams.5
index f5bcbea..844e71c 100644
--- a/usr.sbin/bootparamd/bootparamd/bootparams.5
+++ b/usr.sbin/bootparamd/bootparamd/bootparams.5
@@ -25,7 +25,7 @@
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
.\" from: Id: bootparams.5,v 1.2 1994/10/03 19:26:13 gwr Exp
-.\" $Id$
+.\" $Id: bootparams.5,v 1.6 1997/02/22 16:04:23 peter Exp $
.\"
.Dd October 2, 1994
.Dt BOOTPARAMS 5
@@ -37,12 +37,12 @@
.Nm /etc/bootparams
.Sh DESCRIPTION
The
-.Nm bootparams
+.Nm
file specifies the boot parameters that
-.Xr diskless
+diskless
clients may request when booting over the network.
Each client supported by this server must have an entry in the
-.Nm bootparams
+.Nm
file containing the pathnames for its
.Nm root
and (optionally)
@@ -74,6 +74,5 @@ request. The "host:" component must be supplied.
.It Pa /etc/bootparams
default configuration file
.El
-.Sh "SEE ALSO"
-.Xr bootparamd 8 ,
-.Xr diskless 8
+.Sh SEE ALSO
+.Xr bootparamd 8
diff --git a/usr.sbin/bootparamd/bootparamd/main.c b/usr.sbin/bootparamd/bootparamd/main.c
index 77bb76d..fb79060 100644
--- a/usr.sbin/bootparamd/bootparamd/main.c
+++ b/usr.sbin/bootparamd/bootparamd/main.c
@@ -5,35 +5,39 @@ use and modify. Please send modifications and/or suggestions + bug fixes to
Klas Heggemann <klas@nada.kth.se>
-
- $Id: main.c,v 1.5 1997/02/22 16:04:24 peter Exp $
-
*/
+#ifndef lint
+static const char rcsid[] =
+ "$Id$";
+#endif /* not lint */
+
+#include <ctype.h>
+#include <err.h>
+#include <netdb.h>
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include <syslog.h>
-#include <sys/ioctl.h>
+#include <unistd.h>
#include <rpc/rpc.h>
-#include "bootparam_prot.h"
-#include <sys/types.h>
-#include <sys/stat.h>
+#include <rpc/pmap_clnt.h>
+#include <sys/ioctl.h>
#include <sys/socket.h>
-#include <netdb.h>
-#include <ctype.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include "bootparam_prot.h"
int debug = 0;
int dolog = 0;
unsigned long route_addr = -1, inet_addr();
struct sockaddr_in my_addr;
-char *progname;
char *bootpfile = "/etc/bootparams";
extern void bootparamprog_1();
+static void usage __P((void));
-extern char *optarg;
-extern int optind;
-
+int
main(argc, argv)
int argc;
char **argv;
@@ -42,13 +46,8 @@ char **argv;
int i;
struct hostent *he;
struct stat buf;
- char *optstring;
char c;
- progname = rindex(argv[0],'/');
- if ( progname ) progname++;
- else progname = argv[0];
-
while ((c = getopt(argc, argv,"dsr:f:")) != -1)
switch (c) {
case 'd':
@@ -63,10 +62,9 @@ char **argv;
if (he) {
bcopy(he->h_addr, (char *)&route_addr, sizeof(route_addr));
break;
- } else {
- fprintf(stderr,"%s: No such host %s\n", progname, argv[i]);
- exit(1);
- }
+ } else {
+ errx(1, "no such host %s", argv[i]);
+ }
}
case 'f':
bootpfile = optarg;
@@ -74,24 +72,18 @@ char **argv;
case 's':
dolog = 1;
#ifndef LOG_DAEMON
- openlog(progname, 0 , 0);
+ openlog("bootparamd", 0 , 0);
#else
- openlog(progname, 0 , LOG_DAEMON);
+ openlog("bootparamd", 0 , LOG_DAEMON);
setlogmask(LOG_UPTO(LOG_NOTICE));
#endif
break;
default:
- fprintf(stderr,
- "Usage: %s [-d ] [ -s ] [ -r router ] [ -f bootparmsfile ]\n", progname);
- exit(1);
+ usage();
}
- if ( stat(bootpfile, &buf ) ) {
- fprintf(stderr,"%s: ", progname);
- perror(bootpfile);
- exit(1);
- }
-
+ if ( stat(bootpfile, &buf ) )
+ err(1, "%s", bootpfile);
if (route_addr == -1) {
get_myaddress(&my_addr);
@@ -99,28 +91,27 @@ char **argv;
}
if (!debug) {
- if (daemon(0,0)) {
- perror("bootparamd: fork");
- exit(1);
- }
+ if (daemon(0,0))
+ err(1, "fork");
}
(void)pmap_unset(BOOTPARAMPROG, BOOTPARAMVERS);
transp = svcudp_create(RPC_ANYSOCK);
- if (transp == NULL) {
- (void)fprintf(stderr, "cannot create udp service.\n");
- exit(1);
- }
- if (!svc_register(transp, BOOTPARAMPROG, BOOTPARAMVERS, bootparamprog_1, IPPROTO_UDP)) {
- (void)fprintf(stderr, "unable to register (BOOTPARAMPROG, BOOTPARAMVERS, udp).\n");
- exit(1);
- }
+ if (transp == NULL)
+ errx(1, "cannot create udp service");
+ if (!svc_register(transp, BOOTPARAMPROG, BOOTPARAMVERS, bootparamprog_1, IPPROTO_UDP))
+ errx(1, "unable to register (BOOTPARAMPROG, BOOTPARAMVERS, udp)");
svc_run();
- (void)fprintf(stderr, "svc_run returned\n");
- exit(1);
+ errx(1, "svc_run returned");
}
-
+static void
+usage()
+{
+ fprintf(stderr,
+ "usage: bootparamd [-d] [-s] [-r router] [-f bootparmsfile]\n");
+ exit(1);
+}
OpenPOWER on IntegriCloud