netkit-bootparamd-0.17/ 40700 144 144 0 7141141777 14273 5ustar dhollandpeoplenetkit-bootparamd-0.17/.cvsignore100644 144 144 10 7024703547 16330 0ustar dhollandpeopleMCONFIG netkit-bootparamd-0.17/ChangeLog100644 144 144 1547 7136345456 16167 0ustar dhollandpeople22-Jul-2000: Some cleanup. New scanf-free parsing code for bootparams file. Add bootparams(5) page (swiped from FreeBSD 4.0-RELEASE). 14-Dec-1999: netkit-bootparamd-0.16 is released. 14-Sep-1999: Some minor cleanup. 1-Aug-1999: Complete y2k and y2038 audit. 31-Jul-1999: Redid makefiles/config stuff for new confgen version. 22-Sep-1997: Fix some potential buffer overflow problems arising from DNS spoofing. 12-Jun-1997: netkit-bootparamd-0.10 released. 19-May-1997: glibc fixes from Red Hat. 05-Apr-1997: Added configure script to generate MCONFIG. glibc fixes from HJ Lu. 08-Mar-1997: Split from full NetKit package. Generated this change log from NetKit's. 29-Dec-1996 NetKit-0.09 released. Hardened programs against DNS h_length spoofing attacks. Use inet_aton() everywhere instead of inet_addr(). Added bootparamd to NetKit package. netkit-bootparamd-0.17/MCONFIG.in100644 144 144 240 6767425373 16002 0ustar dhollandpeople# Dirs INSTALLROOT BINDIR SBINDIR MANDIR # Modes BINMODE DAEMONMODE MANMODE # Compiling ALLWARNINGS CC CFLAGS LDFLAGS LIBS # Features BSDSIGNAL FN(snprintf) netkit-bootparamd-0.17/MRULES100644 144 144 173 6310310272 15276 0ustar dhollandpeople# Standard compilation rules (don't use make builtins) %.o: %.c $(CC) $(CFLAGS) $< -c %.o: %.cc $(CC) $(CFLAGS) $< -c netkit-bootparamd-0.17/Makefile100644 144 144 751 7024720305 16013 0ustar dhollandpeople# You can do "make SUB=blah" to make only a few, or edit here, or both # You can also run make directly in the subdirs you want. SUB = rpc.bootparamd %.build: (cd $(patsubst %.build, %, $@) && $(MAKE)) %.install: (cd $(patsubst %.install, %, $@) && $(MAKE) install) %.clean: (cd $(patsubst %.clean, %, $@) && $(MAKE) clean) all: $(patsubst %, %.build, $(SUB)) install: $(patsubst %, %.install, $(SUB)) clean: $(patsubst %, %.clean, $(SUB)) distclean: clean rm -f MCONFIG netkit-bootparamd-0.17/README100644 144 144 6775 7141137757 15304 0ustar dhollandpeopleThis is netkit-bootparamd-0.17 for Linux. This package updates netkit-bootparamd-0.16. If you're reading this off a CD, go right away and check the net archives for later versions and security fixes. As of this writing the home site for NetKit is ftp://ftp.uk.linux.org/pub/linux/Networking/netkit Contents: rpc.bootparamd Net-boot support daemon. Requires: Working compiler, libc, and kernel. You must have rpcgen installed; these days it comes with glibc, so this should not be an issue. Security: This release contains no security fixes relative to the bootparamd from NetKit-0.09. Versions prior to NetKit-0.09, however, should not be used. Installation: Do "./configure --help" and decide what options you want. The defaults should be suitable for most Linux systems. Then run the configure script. Do "make" to compile. Then (as root) do "make install". Save a backup copy of any mission-critical program in case the new one doesn't work, and so forth. We warned you. If you get gcc warnings from files in /usr/include, they are due to problems in your libc, not netkit. (You may only see them when compiling netkit because netkit turns on a lot of compiler warnings.) DEC CC: The DEC compiler for the Alpha is now freely available. This is a much better compiler with gcc, that is, it generates much better code. If you have the DEC compiler, you can explicitly use the DEC compiler instead of gcc by configuring like this: ./configure --with-c-compiler=ccc It is known to generate spurious warnings on some files. Also, some headers from some versions of glibc confuse it; that may prevent netkit from working. Other problems should be reported as bugs. Bugs: Please make sure the header files in /usr/include match the libc version installed in /lib and /usr/lib. If you have weird problems this is the most likely culprit. Also, before reporting a bug, be sure you're working with the latest version. If something doesn't compile for you, fix it and send diffs. If you can't, send the compiler's error output. If it compiles but doesn't work, send as complete a bug report as you can. Patches and fixes are welcome, as long as you describe adequately what they're supposed to fix. Please, one patch per distinct fix. Please do NOT send the whole archive back or reindent the source. Be sure to send all correspondence in e-mail to the netkit address. Postings to netnews or mailing lists will not be seen due to the enormous volume. Also, anything that doesn't get filed in the bug database is quite likely to end up forgotten. Please don't report known bugs (see the BUGS file(s)) unless you are including fixes. :-) Mail should be sent to: netbug@ftp.uk.linux.org Early in April 2000, a hacker broke into the machine that was hosting the netkit bug database for me and trashed it. Unfortunately, it seems backups hadn't gotten done for a while, so three months of mail (since mid-January) was lost. So, if you sent something and didn't hear back, or you sent something, heard back, but the changes failed to appear in this release (unlikely but possible) - please resend. Please see http://www.hcs.harvard.edu/~dholland/computers/netkit.html if you are curious why it was so long between the 0.10 and 0.16 releases. Future plans for netkit maintenance are still up in the air, but in the meantime new releases will still appear from time to time. I don't have a whole lot of cycles to spare to work on netkit, so things are likely to continue to be fairly slow. David A. Holland 23 July 2000 netkit-bootparamd-0.17/configure100755 144 144 16170 7140615674 16337 0ustar dhollandpeople#!/bin/sh # # This file was generated by confgen version 2. # Do not edit. # PREFIX='/usr' #EXECPREFIX='$PREFIX' INSTALLROOT='' BINMODE='755' #DAEMONMODE='$BINMODE' MANMODE='644' while [ x$1 != x ]; do case $1 in --help) cat < __conftest.c int main() { int class=0; return class; } EOF if [ x"$CC" = x ]; then echo -n 'Looking for a C compiler... ' for TRY in egcs gcc g++ CC c++ cc; do ( $TRY __conftest.c -o __conftest || exit 1; ./__conftest || exit 1; ) >/dev/null 2>&1 || continue; CC=$TRY break; done if [ x"$CC" = x ]; then echo 'failed.' echo 'Cannot find a C compiler. Run configure with --with-c-compiler.' rm -f __conftest* exit fi echo "$CC" else echo -n 'Checking if C compiler works... ' if ( $CC __conftest.c -o __conftest || exit 1 ./__conftest || exit 1 ) >/dev/null 2>&1; then echo 'yes' else echo 'no' echo 'Compiler '"$CC"' does not exist or cannot compile C; try another.' rm -f __conftest* exit fi fi echo -n "Checking if $CC accepts gcc warnings... " if ( $CC $WARNINGS __conftest.c -o __conftest || exit 1 ) >/dev/null 2>&1; then echo 'yes' CC_WARNINGS=1 else echo 'no' fi if [ x$DEBUG = x ]; then echo -n "Checking if $CC accepts -O2... " if ( $CC -O2 __conftest.c -o __conftest ) >/dev/null 2>&1; then echo 'yes' CFLAGS="$CFLAGS -O2" else echo 'no' echo -n "Checking if $CC accepts -O... " if ( $CC -O __conftest.c -o __conftest ) >/dev/null 2>&1; then echo 'yes' CFLAGS="$CFLAGS -O" else echo 'no' fi fi else echo -n "Checking if $CC accepts -g... " if ( $CC -g __conftest.c -o __conftest ) >/dev/null 2>&1; then echo 'yes' CFLAGS="$CFLAGS -g" else echo 'no' fi fi LDFLAGS= LIBS= rm -f __conftest* ################################################## echo -n 'Checking for BSD signal semantics... ' cat <__conftest.c #include #include int count=0; void handle(int foo) { count++; } int main() { int pid=getpid(); signal(SIGINT, handle); kill(pid,SIGINT); kill(pid,SIGINT); kill(pid,SIGINT); if (count!=3) return 1; return 0; } EOF if ( $CC $CFLAGS __conftest.c -o __conftest || exit 1 ./__conftest || exit 1 ) >/dev/null 2>&1; then echo 'yes' else if ( $CC $CFLAGS -D__USE_BSD_SIGNAL __conftest.c -o __conftest || exit 1 ./__conftest || exit 1 ) >/dev/null 2>&1; then echo '-D__USE_BSD_SIGNAL' CFLAGS="$CFLAGS -D__USE_BSD_SIGNAL" else echo 'no' echo 'This package needs BSD signal semantics to run.' rm -f __conftest* exit fi fi rm -f __conftest* ################################################## echo -n 'Checking for snprintf declaration... ' cat <__conftest.c #include int main() { void *x = (void *)snprintf; printf("%lx", (long)x); return 0; } EOF if ( $CC $CFLAGS __conftest.c -o __conftest || exit 1 ) >/dev/null 2>&1; then echo 'ok' else if ( $CC $CFLAGS -D_GNU_SOURCE __conftest.c -o __conftest || exit 1 ./__conftest || exit 1 ) >/dev/null 2>&1; then echo '-D_GNU_SOURCE' CFLAGS="$CFLAGS -D_GNU_SOURCE" else echo 'manual' CFLAGS="$CFLAGS -DDECLARE_SNPRINTF" fi fi rm -f __conftest* echo -n 'Checking for snprintf implementation... ' cat <__conftest.c #include #include #ifdef DECLARE_SNPRINTF #ifdef __cplusplus extern "C" #endif /*__cplusplus*/ int snprintf(char *, int, const char *, ...); #endif /*DECLARE_SNPRINTF*/ int main() { char buf[32]; snprintf(buf, 8, "%s", "1234567890"); if (strlen(buf)!=7) return 1; return 0; } EOF if ( $CC $CFLAGS __conftest.c $LIBBSD -o __conftest || exit 1 ./__conftest || exit 1 ) >/dev/null 2>&1; then echo 'ok' else if ( $CC $CFLAGS __conftest.c -lsnprintf $LIBBSD -o __conftest || exit 1 ./__conftest || exit 1 ) >/dev/null 2>&1; then echo '-lsnprintf' LIBS="$LIBS -lsnprintf" else if ( $CC $CFLAGS __conftest.c -ldb $LIBBSD -o __conftest || exit 1 ./__conftest || exit 1 ) >/dev/null 2>&1; then echo '-ldb' LIBS="$LIBS -ldb" else echo 'missing' echo 'This package requires snprintf.' rm -f __conftest* exit fi fi fi rm -f __conftest* ################################################## ## libbsd should go last in case it's broken if [ "x$LIBBSD" != x ]; then LIBS="$LIBS $LIBBSD" fi echo 'Generating MCONFIG...' ( echo -n '# Generated by configure (confgen version 2) on ' date echo '#' echo echo "BINDIR=$BINDIR" echo "SBINDIR=$SBINDIR" echo "MANDIR=$MANDIR" echo "BINMODE=$BINMODE" echo "DAEMONMODE=$DAEMONMODE" echo "MANMODE=$MANMODE" echo "PREFIX=$PREFIX" echo "EXECPREFIX=$EXECPREFIX" echo "INSTALLROOT=$INSTALLROOT" echo "CC=$CC" if [ x$CC_WARNINGS != x ]; then CFLAGS="$CFLAGS $WARNINGS" fi echo "CFLAGS=$CFLAGS" | sed 's/= */=/' echo "LDFLAGS=$LDFLAGS" | sed 's/= */=/' echo "LIBS=$LIBS" | sed 's/= */=/' ) > MCONFIG netkit-bootparamd-0.17/version.h100644 144 144 153 7141140313 16200 0ustar dhollandpeople/* * String to embed in binaries to identify package */ char pkg[]="$NetKit: netkit-bootparamd-0.17 $"; netkit-bootparamd-0.17/rpc.bootparamd/ 40700 144 144 0 7141142000 17162 5ustar dhollandpeoplenetkit-bootparamd-0.17/rpc.bootparamd/.cvsignore100644 144 144 146 6767425634 21310 0ustar dhollandpeoplebootparamd callbootd bootparam_prot_svc.c bootparam_prot_clnt.c bootparam_prot_xdr.c bootparam_prot.h netkit-bootparamd-0.17/rpc.bootparamd/Makefile100644 144 144 3220 7024761713 20750 0ustar dhollandpeopleall: bootparamd include ../MCONFIG include ../MRULES RPCGEN=rpcgen # Warning, do NOT put this in the current directory under its own # name without updating things and particularly the clean target. #BOOTPARAMX = /usr/include/rpcsvc/bootparam_prot.x # Actually the one that comes with linux libc appears to be broken BOOTPARAMX = bootparam_prot.x.real HEADER=bootparam_prot.h DIST=README main.c rpc.bootparamd.c callbootd.c bootparamd.8 Makefile all: bootparamd callbootd bootparamd: bootparam_prot_svc.o bootparam_prot_xdr.o rpc.bootparamd.o main.o ${CC} $(LDFLAGS) $^ $(LIBS) -o $@ callbootd: callbootd.o bootparam_prot_clnt.o bootparam_prot_xdr.o ${CC} $(LDFLAGS) $^ $(LIBS) -o $@ install: bootparamd callbootd install -s -m $(DAEMONMODE) bootparamd \ $(INSTALLROOT)$(SBINDIR)/rpc.bootparamd install -s -m $(BINMODE) callbootd $(INSTALLROOT)$(BINDIR)/callbootd install -m $(MANMODE) bootparamd.8 \ $(INSTALLROOT)$(MANDIR)/man8/rpc.bootparamd.8 ln -sf rpc.bootparamd.8 $(INSTALLROOT)$(MANDIR)/man8/bootparamd.8 clean: rm -f *.o bootparamd callbootd rm -f bootparam_prot.h bootparam_prot_svc.c rm -f bootparam_prot_xdr.c bootparam_prot_clnt.c rm -f bootparam_prot.x bootparam_prot_clnt.o bootparam_prot_xdr.o: bootparam_prot.h bootparam_prot_svc.o: bootparam_prot.h callbootd.o rpc.bootparamd.o main.o: bootparam_prot.h ../version.h bootparam_prot.x: $(BOOTPARAMX) ln -s $(BOOTPARAMX) bootparam_prot.x bootparam_prot.h: bootparam_prot.x $(RPCGEN) -h $< -o $@ bootparam_prot_xdr.c: bootparam_prot.x $(RPCGEN) -c $< -o $@ bootparam_prot_clnt.c: bootparam_prot.x $(RPCGEN) -l $< -o $@ bootparam_prot_svc.c: bootparam_prot.x $(RPCGEN) -m $< -o $@ netkit-bootparamd-0.17/rpc.bootparamd/README100644 144 144 4270 6261540620 20170 0ustar dhollandpeople This directory contains a version of the rpc.bootparamd, which have been written using the Sun's RPC protocol for bootparamd. To use it you must have a copy of the bootparam_prot.x file which on Sun systems you find in /usr/include/rpcsvc/bootparam_prot.x (( This file was retrieved from the Sun-RPC source package )) 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 RPC.BOOTPARAMD The rpc.bootparamd program does NOT use the yellow pages for the bootparams database. This data should recide in /etc/bootparams on the local host, or another file given when the server is started. The default router is set to the address of the machine running the server. This may not be a good thing to do, so it can be modified using the -r option when startning the daemon. This program was written with the need to keep short hostnames in the /etc/bootparams file and long (canonical) names in the hosts database. It probably also will work in conjunction with a nameserver, since matching is done by comparing the canonical name of the booting machine with the canonical name of the hosts found in the bootparams database. It is kept simple, e g there is no caching of data, but the bootparameter file is read at each request. CALLBOOTD The debugging tool callbootd is used to check the response you get to a specific (booting) request. It can be used as callbootd server inet-adress or callbootd server hostname file where "server" is a machine running the rpc.bootparamd program, "inet-address" is the internet address of a booting machine, "hostname" is the name of a booting machine and "file" the requested file, typically "root", "swap" or "dump". You may also use "all" instead of a specific server, in which case a RPC broadcast is performed. The broadcast is performed 4 times and then the program times out, after printing all responses. TODO Cache the date, instead of rereading it. Maybe match by comparing the inet address instead. (But beware that caching will prevent the server from detecting that a machine has changed name or address.) netkit-bootparamd-0.17/rpc.bootparamd/bootparam_prot.x.real100644 144 144 5512 6261546715 23466 0ustar dhollandpeople/* @(#)bootparam_prot.x 2.1 88/08/01 4.0 RPCSRC */ /* @(#)bootparam_prot.x 1.2 87/06/24 Copyr 1987 Sun Micro */ /* * Sun RPC is a product of Sun Microsystems, Inc. and is provided for * unrestricted use provided that this legend is included on all tape * media and as a part of the software program in whole or part. Users * may copy or modify Sun RPC without charge, but are not authorized * to license or distribute it to anyone else except as part of a product or * program developed by the user. * * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. * * Sun RPC is provided with no support and without any obligation on the * part of Sun Microsystems, Inc. to assist in its use, correction, * modification or enhancement. * * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC * OR ANY PART THEREOF. * * In no event will Sun Microsystems, Inc. be liable for any lost revenue * or profits or other special, indirect and consequential damages, even if * Sun has been advised of the possibility of such damages. * * Sun Microsystems, Inc. * 2550 Garcia Avenue * Mountain View, California 94043 */ /* * RPC for bootparms service. * There are two procedures: * WHOAMI takes a net address and returns a client name and also a * likely net address for routing * GETFILE takes a client name and file identifier and returns the * server name, server net address and pathname for the file. * file identifiers typically include root, swap, pub and dump */ #ifdef RPC_HDR %#include %#include %#include %#include "linux/nfs.h" % %void bootparamprog_1(struct svc_req *, register SVCXPRT *); % #endif const MAX_MACHINE_NAME = 255; const MAX_PATH_LEN = 1024; const MAX_FILEID = 32; const IP_ADDR_TYPE = 1; typedef string bp_machine_name_t; typedef string bp_path_t; typedef string bp_fileid_t; struct ip_addr_t { char net; char host; char lh; char impno; }; union bp_address switch (int address_type) { case IP_ADDR_TYPE: ip_addr_t ip_addr; }; struct bp_whoami_arg { bp_address client_address; }; struct bp_whoami_res { bp_machine_name_t client_name; bp_machine_name_t domain_name; bp_address router_address; }; struct bp_getfile_arg { bp_machine_name_t client_name; bp_fileid_t file_id; }; struct bp_getfile_res { bp_machine_name_t server_name; bp_address server_address; bp_path_t server_path; }; program BOOTPARAMPROG { version BOOTPARAMVERS { bp_whoami_res BOOTPARAMPROC_WHOAMI(bp_whoami_arg) = 1; bp_getfile_res BOOTPARAMPROC_GETFILE(bp_getfile_arg) = 2; } = 1; } = 100026; netkit-bootparamd-0.17/rpc.bootparamd/bootparamd.8100644 144 144 2465 7141140313 21526 0ustar dhollandpeople.\" @(#)bootparamd.8 .\" .\" $Id: bootparamd.8,v 1.13 2000/07/30 23:56:59 dholland Exp $ .\" .Dd November 8, 1989 .Dt BOOTPARAMD 8 .Os "Linux NetKit (0.17)" .Sh NAME .Nm bootparamd .Nd boot parameter server .Sh SYNOPSIS .Nm rpc.bootparamd .Op Fl d .Op Fl s .Op Fl r Ar router .Op Fl f Ar file .Sh DESCRIPTION .Nm bootparamd is a server process that provides information to diskless clients necessary for booting. It consults the .Pa /etc/bootparams file to find the information it needs. .Pp This version will allow the use of aliases on the hostname in the .Pa /etc/bootparams file. The returned hostname to the whoami request done by the booting client will be the name that appears in .Pa /etc/bootparams and not the canonical name. In this way you can keep the answer short enough so that machines that cannot handle long hostnames won't fail during boot. .Sh OPTIONS .Bl -tag -width indent .It Fl d Display debugging information. .It Fl s Log the debugging information to syslog. .It Fl r Ar router The default router (a machine or an IP-address). This defaults to the machine running the server. .It Fl f Ar file The file to use as boot parameter file instead of /etc/bootparams. .Sh FILES .Pa /etc/bootparams .Sh BUGS You may find the syslog loggings too verbose. .Sh AUTHOR Written by Klas Heggemann netkit-bootparamd-0.17/rpc.bootparamd/bootparams.5100644 144 144 5575 7141140313 21547 0ustar dhollandpeople.\" .\" Copyright (c) 1994 Gordon W. Ross .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. The name of the author may not be used to endorse or promote products .\" derived from this software without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES .\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. .\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, .\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\" 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 .\" from: FreeBSD: bootparams.5,v 1.9 1999/08/28 01:15:39 peter Exp .\" $Id: bootparams.5,v 1.3 2000/07/30 23:56:59 dholland Exp $ .\" .Dd October 2, 1994 .Dt BOOTPARAMS 5 .Os "Linux NetKit (0.17)" .Sh NAME .Nm bootparams .Nd boot parameter database .Sh SYNOPSIS .Nm /etc/bootparams .Sh DESCRIPTION The .Nm file specifies the boot parameters that diskless clients may request when booting over the network. Each client supported by this server must have an entry in the .Nm file containing the pathnames for its .Nm root and (optionally) .Nm swap areas. .Pp Each line in the file (other than comment lines that begin with a #) specifies the client name followed by the pathnames that the client may request by their logical names. The components of the line are delimited with blank or tab, and may be continued onto multiple lines with a backslash. .Pp For example: .Bd -literal -offset indent dummy root=host:/export/dummy/root \\ swap=host:/export/dummy/swap \\ dump=host:/export/dummy/swap .Ed .Pp When the client named "dummy" requests the pathname for its logical "root" it will be given the pathname .Dq Pa "host:/export/dummy/root" as the response to its .Tn RPC request. The "host:" component must be supplied. .Sh FILES .Bl -tag -width /etc/bootparams -compact .It Pa /etc/bootparams default configuration file .El .Sh SEE ALSO .Xr bootparamd 8 .\" .Xr diskless 8 netkit-bootparamd-0.17/rpc.bootparamd/callbootd.c100644 144 144 10661 6411700076 21440 0ustar dhollandpeople#include #include #include #include #include #include #include #include "bootparam_prot.h" /* #define bp_address_u bp_address */ #include #include "../version.h" const char callbootd_rcsid[] = "$Id: callbootd.c,v 1.5 1997/09/23 08:39:26 dholland Exp $"; static int printgetfile(bp_getfile_res *res); static int printwhoami(bp_whoami_res *res); int broadcast; char cln[MAX_MACHINE_NAME+1]; char dmn[MAX_MACHINE_NAME+1]; char path[MAX_PATH_LEN+1]; static int eachres_whoami(bp_whoami_res *resultp, struct sockaddr_in *raddr) { struct hostent *he; he = gethostbyaddr((char*)&raddr->sin_addr.s_addr,4,AF_INET); printf("%s answered:\n", he ? he->h_name : inet_ntoa(raddr->sin_addr)); printwhoami(resultp); printf("\n"); return 0; } static int eachres_getfile(bp_getfile_res *resultp, struct sockaddr_in *raddr) { struct hostent *he; he = gethostbyaddr((char*)&raddr->sin_addr.s_addr,4,AF_INET); printf("%s answered:\n", he ? he->h_name : inet_ntoa(raddr->sin_addr)); printgetfile(resultp); printf("\n"); return 0; } int main(int argc, char **argv) { char *server; bp_whoami_arg whoami_arg; bp_whoami_res *whoami_res, stat_whoami_res; bp_getfile_arg getfile_arg; bp_getfile_res *getfile_res, stat_getfile_res; struct in_addr the_inet_addr; CLIENT *clnt = NULL; enum clnt_stat clnt_stat; stat_whoami_res.client_name = cln; stat_whoami_res.domain_name = dmn; stat_getfile_res.server_name = cln; stat_getfile_res.server_path = path; if (argc < 3) { fprintf(stderr, "Usage: %s server procnum (IP-addr | host fileid)\n", argv[0]); exit(1); } server = argv[1]; if (!strcmp(server , "all") ) broadcast = 1; if (!broadcast) { clnt = clnt_create(server,BOOTPARAMPROG, BOOTPARAMVERS, "udp"); } switch (argc) { case 3: whoami_arg.client_address.address_type = IP_ADDR_TYPE; if (!inet_aton(argv[2], &the_inet_addr)) { fprintf(stderr, "bogus addr %s\n", argv[2]); exit(1); } memcpy(&whoami_arg.client_address.bp_address_u.ip_addr, &the_inet_addr, 4); if (!broadcast) { whoami_res = bootparamproc_whoami_1(&whoami_arg, clnt); printf("Whoami returning:\n"); if (printwhoami(whoami_res)) { fprintf(stderr, "Bad answer returned from server %s\n", server); exit(1); } else exit(0); } else { clnt_stat=clnt_broadcast(BOOTPARAMPROG, BOOTPARAMVERS, BOOTPARAMPROC_WHOAMI, (xdrproc_t) xdr_bp_whoami_arg, (void *) &whoami_arg, (xdrproc_t) xdr_bp_whoami_res, (void *) &stat_whoami_res, (resultproc_t) eachres_whoami); exit(0); } case 4: getfile_arg.client_name = argv[2]; getfile_arg.file_id = argv[3]; if (!broadcast) { getfile_res = bootparamproc_getfile_1(&getfile_arg,clnt); printf("getfile returning:\n"); if (printgetfile(getfile_res)) { fprintf(stderr, "Bad answer returned from server %s\n", server); exit(1); } else exit(0); } else { clnt_stat=clnt_broadcast(BOOTPARAMPROG, BOOTPARAMVERS, BOOTPARAMPROC_GETFILE, (xdrproc_t) xdr_bp_getfile_arg, (void *) &getfile_arg, (xdrproc_t) xdr_bp_getfile_res, (void *) &stat_getfile_res, (resultproc_t) eachres_getfile); exit(0); } default: fprintf(stderr, "Usage: %s server procnum (IP-addr | host fileid)\n", argv[0]); exit(1); } } int printwhoami(bp_whoami_res *res) { if (res) { printf("client_name:\t%s\ndomain_name:\t%s\n", res->client_name, res->domain_name); printf("router:\t%d.%d.%d.%d\n", 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, 255 & res->router_address.bp_address_u.ip_addr.impno); return 0; } else { fprintf(stderr,"Null answer!!!\n"); return 1; } } static int printgetfile(bp_getfile_res *res) { if (res) { struct in_addr sia; memcpy(&sia, &res->server_address.bp_address_u.ip_addr, 4); printf("server_name:\t%s\nserver_address:\t%s\npath:\t%s\n", res->server_name, inet_ntoa(sia), res->server_path); return 0; } else { fprintf(stderr,"Null answer!!!\n"); return(1); } } netkit-bootparamd-0.17/rpc.bootparamd/main.c100644 144 144 5261 7136345234 20407 0ustar dhollandpeople#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "bootparam_prot.h" #ifdef __GLIBC__ /* quick fix */ void get_myaddress(struct sockaddr_in *); #endif int debug = 0; int dolog = 0; struct in_addr route_addr; const char *bootpfile = "/etc/bootparams"; static char *progname; static struct sockaddr_in my_addr; static int route_addr_ok; int main(int argc, char **argv) { SVCXPRT *transp; int s, pid; struct hostent *he; struct stat buf; char c; progname = rindex(argv[0],'/'); if (progname) progname++; else progname = argv[0]; while ((c = getopt(argc, argv,"dsr:f:")) != EOF) { switch (c) { case 'd': debug = 1; break; case 'r': if (isdigit(*optarg)) { route_addr_ok = inet_aton(optarg, &route_addr); break; } else { he = gethostbyname(optarg); if (he) { memcpy(&route_addr, he->h_addr, sizeof(route_addr)); route_addr_ok = 1; break; } else { fprintf(stderr,"%s: No such host %s\n", progname, optarg); exit(1); } } case 'f': bootpfile = optarg; break; case 's': dolog = 1; #ifndef LOG_DAEMON openlog(progname, 0 , 0); #else openlog(progname, 0 , LOG_DAEMON); setlogmask(LOG_UPTO(LOG_NOTICE)); #endif break; default: fprintf(stderr, "Usage: %s [-d] [-s] [-r router] [-f bootparmsfile]\n", argv[0]); exit(1); } } if (stat(bootpfile, &buf)) { fprintf(stderr,"%s: ", progname); perror(bootpfile); exit(1); } if (!route_addr_ok) { get_myaddress(&my_addr); memcpy(&route_addr, &my_addr.sin_addr.s_addr, sizeof(route_addr)); } if (!debug) { pid = fork(); if (pid < 0) { perror("bootparamd: fork"); exit(1); } if (pid) exit(0); /* parent */ /* child */ for (s=0; s<20; s++) close(s); open("/", 0); dup2(0, 1); dup2(0, 2); s = open("/dev/tty",2); if ( s >= 0 ) { ioctl(s, TIOCNOTTY, 0); close(s); } } (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)) { fprintf(stderr, "unable to register (BOOTPARAMPROG, BOOTPARAMVERS, udp).\n"); exit(1); } svc_run(); (void)fprintf(stderr, "svc_run returned\n"); exit(1); } netkit-bootparamd-0.17/rpc.bootparamd/rpc.bootparamd.c100644 144 144 17245 7136345234 22423 0ustar dhollandpeople#include #include "bootparam_prot.h" #include #include #include #include #include #include #include #include #include #include "../version.h" const char bootparamd_rcsid[] = "$Id: rpc.bootparamd.c,v 1.12 2000/07/22 16:23:56 dholland Exp $"; extern int debug, dolog; extern struct in_addr route_addr; extern const char *bootpfile; static int getthefile(const char *askname, const char *fileid, char *buf, size_t buflen); static int checkhost(const char *askname, char *hostname, size_t hostsize); #define MAXLEN 800 struct hostent *he; static char buffer[MAXLEN]; static char hostname[MAX_MACHINE_NAME]; static char askname[MAX_MACHINE_NAME]; static char path[MAX_PATH_LEN]; static char domain_name[MAX_MACHINE_NAME]; static const char * my_ntoa(struct ip_addr_t addr) { static char buf[20]; /* * This is the same order it used to print the fields in before I * combined all the printing, but I really wonder if it's right. */ snprintf(buf, sizeof(buf), "%d.%d.%d.%d", addr.net&255, addr.host&255, addr.lh&255, addr.impno&255); return buf; } bp_whoami_res * bootparamproc_whoami_1_svc(bp_whoami_arg *whoami, struct svc_req *svc_req) { static bp_whoami_res res; struct ip_addr_t addr; const char *addrname; (void)svc_req; addr = whoami->client_address.bp_address_u.ip_addr; addrname = my_ntoa(addr); if (debug) { fprintf(stderr, "bootparamd: whoami got question for %s\n", addrname); } if (dolog) { syslog(LOG_NOTICE, "whoami got question for %s\n", addrname); } he = gethostbyaddr((char *)&addr, sizeof(addr), AF_INET); if (!he) goto failed; if (debug) fprintf(stderr,"This is host %s\n", he->h_name); if (dolog) syslog(LOG_NOTICE,"This is host %s\n", he->h_name); strncpy(askname, he->h_name, sizeof(askname)); askname[sizeof(askname)-1] = 0; if (checkhost(askname, hostname, sizeof(hostname))) { res.client_name = hostname; getdomainname(domain_name, sizeof(domain_name)); res.domain_name = domain_name; if (res.router_address.address_type != IP_ADDR_TYPE) { res.router_address.address_type = IP_ADDR_TYPE; memcpy(&res.router_address.bp_address_u.ip_addr, &route_addr, sizeof(route_addr)); } if (debug) fprintf(stderr, "Returning %s %s %s\n", res.client_name, res.domain_name, my_ntoa(res.router_address.bp_address_u.ip_addr)); if (dolog) syslog(LOG_NOTICE, "Returning %s %s %s\n", res.client_name, res.domain_name, my_ntoa(res.router_address.bp_address_u.ip_addr)); return(&res); } failed: if (debug) fprintf(stderr,"whoami failed\n"); if (dolog) syslog(LOG_NOTICE,"whoami failed\n"); return NULL; } bp_getfile_res * bootparamproc_getfile_1_svc(bp_getfile_arg *getfile,struct svc_req *svc_req) { char *where; static bp_getfile_res res; (void)svc_req; if (debug) fprintf(stderr,"getfile got question for \"%s\" and file \"%s\"\n", getfile->client_name, getfile->file_id); if (dolog) syslog(LOG_NOTICE,"getfile got question for \"%s\" and file \"%s\"\n", getfile->client_name, getfile->file_id); he = gethostbyname(getfile->client_name); if (!he) goto failed; strncpy(askname, he->h_name, sizeof(askname)); askname[sizeof(askname)-1] = 0; if (getthefile(askname, getfile->file_id, buffer, sizeof(buffer))) { if ((where = strchr(buffer,':'))!=NULL) { /* buffer is re-written to contain the name of the info of file */ strncpy(hostname, buffer, where - buffer); hostname[where - buffer] = '\0'; where++; strncpy(path, where, sizeof(path)); path[sizeof(path)-1] = 0; he = gethostbyname(hostname); if (!he) goto failed; bcopy( he->h_addr, &res.server_address.bp_address_u.ip_addr, 4); res.server_name = hostname; res.server_path = path; res.server_address.address_type = IP_ADDR_TYPE; } else { /* special for dump, answer with null strings */ if (!strcmp(getfile->file_id, "dump")) { res.server_name[0] = '\0'; res.server_path[0] = '\0'; bzero(&res.server_address.bp_address_u.ip_addr,4); } else goto failed; } if (debug) fprintf(stderr, "returning server:%s path:%s address: %s\n", res.server_name, res.server_path, my_ntoa(res.server_address.bp_address_u.ip_addr)); if (dolog) syslog(LOG_NOTICE, "returning server:%s path:%s address: %s\n", res.server_name, res.server_path, my_ntoa(res.server_address.bp_address_u.ip_addr)); return(&res); } failed: if (debug) fprintf(stderr, "getfile failed for %s\n", getfile->client_name); if (dolog) syslog(LOG_NOTICE, "getfile failed for %s\n", getfile->client_name); return NULL; } static int get_bootparam_line(char *buf, size_t len, FILE *f) { size_t pos = 0, inc; while (fgets(buf+pos, len-pos, f)) { inc = strlen(buf+pos); pos += inc; if (inc < 2 || buf[pos-1]!='\n' || buf[pos-2]!='\\') { break; } /* remove the escaped newline */ pos -= 2; buf[pos] = 0; } return pos>0; } static int get_bootparam_entry(const char *askname, const char *capname, char *hostbuf, size_t hostbuflen, char *valbuf, size_t valbuflen, FILE *f) { char linebuf[8192]; char *words[16], *s; int nwords, i; int found; size_t caplen; while (get_bootparam_line(linebuf, sizeof(linebuf), f)) { if (*linebuf=='#') continue; /* comment */ nwords = 0; for (s=strtok(linebuf, " \t\n"); s; s=strtok(NULL, " \t\n")) { if (s[0]=='#') break; /* comment */ if (nwords < 16) words[nwords++] = s; } if (nwords==0) continue; /* blank line */ found = 0; if (!strcmp(askname, words[0])) { found = 1; } else { struct hostent *hp = gethostbyname(words[0]); if (hp && !strcmp(askname, hp->h_name)) found = 1; } if (!found) continue; if (hostbuf) { snprintf(hostbuf, hostbuflen, "%s", words[0]); } if (!capname) return 1; caplen = strlen(capname); if (valbuf) *valbuf = 0; for (i=1; i