From 13ac0cdca35c5f4ea1e0c7535ef489ff021f71c8 Mon Sep 17 00:00:00 2001 From: Mark Murray Date: Sun, 2 Dec 2001 12:17:20 +0000 Subject: [PATCH] WARNS=2 fixup. Turn on YP (NIS) while I'm about it. --- usr.bin/newkey/Makefile | 5 ++--- usr.bin/newkey/extern.h | 46 ++++++++++++++++++++++++++++++++++++++++ usr.bin/newkey/generic.c | 21 +++++++++++------- usr.bin/newkey/newkey.c | 16 ++++++++------ usr.bin/newkey/update.c | 29 +++++++++++-------------- 5 files changed, 82 insertions(+), 35 deletions(-) create mode 100644 usr.bin/newkey/extern.h diff --git a/usr.bin/newkey/Makefile b/usr.bin/newkey/Makefile index fbe8e3b176ef..a083a072f494 100644 --- a/usr.bin/newkey/Makefile +++ b/usr.bin/newkey/Makefile @@ -1,10 +1,9 @@ # $FreeBSD$ PROG= newkey -SRCS= generic.c newkey.c update.c +SRCS= newkey.c generic.c update.c MAN= newkey.8 -# For later: -#CFLAGS+= -DYP +CFLAGS+= -DYP DPADD= ${LIBRPCSVC} ${LIBMP} ${LIBCRYPTO} LDADD= -lrpcsvc -lmp -lcrypto diff --git a/usr.bin/newkey/extern.h b/usr.bin/newkey/extern.h new file mode 100644 index 000000000000..d39baa0fff66 --- /dev/null +++ b/usr.bin/newkey/extern.h @@ -0,0 +1,46 @@ +/* + * 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 or with the express written consent of + * Sun Microsystems, Inc. + * + * 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 + * + * $FreeBSD$ + */ + +#ifdef YP +#define MAXMAPNAMELEN 256 +#else +#define YPOP_CHANGE 1 /* change, do not add */ +#define YPOP_INSERT 2 /* add, do not change */ +#define YPOP_DELETE 3 /* delete this entry */ +#define YPOP_STORE 4 /* add, or change */ +#endif + +void genkeys(char *, char *, char *); +int setpublicmap(char *, char *, char *); +int mapupdate(char *, char *, u_int, u_int, char *, u_int, char *); +void xencrypt(char *, char *); +void xdecrypt(char *, char *); diff --git a/usr.bin/newkey/generic.c b/usr.bin/newkey/generic.c index 39e40f03859a..223dcf41e7b3 100644 --- a/usr.bin/newkey/generic.c +++ b/usr.bin/newkey/generic.c @@ -39,18 +39,22 @@ static const char rcsid[] = * Copyright (C) 1986, Sun Microsystems, Inc. */ +#include +#include +#include +#include #include #include -#include -#include -#include -#include -static int adjust __P(( char[], char * )); +#include "extern.h" + +static void adjust __P((char[], char *)); +static void getseed __P((char *, int, unsigned char *)); + /* * Generate a seed */ -static +static void getseed(seed, seedsize, pass) char *seed; int seedsize; @@ -66,12 +70,13 @@ getseed(seed, seedsize, pass) /* * Generate a random public/secret key pair */ +void genkeys(public, secret, pass) char *public; char *secret; char *pass; { - int i; + unsigned int i; # define BASEBITS (8*sizeof (short) - 1) # define BASE (1 << BASEBITS) @@ -112,7 +117,7 @@ genkeys(public, secret, pass) /* * Adjust the input key so that it is 0-filled on the left */ -static +static void adjust(keyout, keyin) char keyout[HEXKEYBYTES+1]; char *keyin; diff --git a/usr.bin/newkey/newkey.c b/usr.bin/newkey/newkey.c index 141614ee088d..6b98709676b4 100644 --- a/usr.bin/newkey/newkey.c +++ b/usr.bin/newkey/newkey.c @@ -42,20 +42,24 @@ static const char rcsid[] = /* * Administrative tool to add a new user to the publickey database */ -#include -#include +#include +#include +#include #include #include #ifdef YP +#include #include #include -#include #include #endif /* YP */ +#include #include +#include #include #include -#include + +#include "extern.h" #ifdef YP #define MAXMAPNAMELEN 256 @@ -73,11 +77,8 @@ static const char rcsid[] = #endif #ifdef YP -static char *basename(); -static char SHELL[] = "/bin/sh"; static char YPDBPATH[]="/var/yp"; static char PKMAP[] = "publickey.byname"; -static char UPDATEFILE[] = "updaters"; #else static char PKFILE[] = "/etc/publickey"; static char *err_string(); @@ -173,6 +174,7 @@ usage() /* * Set the entry in the public key file */ +int setpublicmap(name, public, secret) char *name; char *public; diff --git a/usr.bin/newkey/update.c b/usr.bin/newkey/update.c index 23248efa9928..972c0e396bfa 100644 --- a/usr.bin/newkey/update.c +++ b/usr.bin/newkey/update.c @@ -42,48 +42,43 @@ static const char rcsid[] = /* * Administrative tool to add a new user to the publickey database */ -#include -#include +#include +#include +#include #include #include #ifdef YP +#include #include #include -#include #include #endif /* YP */ +#include +#include #include #include #include -#include + +#include "extern.h" #ifdef YP -#define MAXMAPNAMELEN 256 -#else -#define YPOP_CHANGE 1 /* change, do not add */ -#define YPOP_INSERT 2 /* add, do not change */ -#define YPOP_DELETE 3 /* delete this entry */ -#define YPOP_STORE 4 /* add, or change */ -#endif - -#ifdef YP -static char *basename(); static char SHELL[] = "/bin/sh"; static char YPDBPATH[]="/var/yp"; /* This is defined but not used! */ -static char PKMAP[] = "publickey.byname"; static char UPDATEFILE[] = "updaters"; #else static char PKFILE[] = "/etc/publickey"; #endif /* YP */ #ifdef YP -static int _openchild __P(( char *, FILE **, FILE ** )); +static int _openchild __P((char *, FILE **, FILE **)); +static char *basename __P((char *path)); /* * Determine if requester is allowed to update the given map, * and update it if so. Returns the yp status, which is zero * if there is no access violation. */ +int mapupdate(requester, mapname, op, keylen, key, datalen, data) char *requester; char *mapname; @@ -148,7 +143,7 @@ mapupdate(requester, mapname, op, keylen, key, datalen, data) /* * returns pid, or -1 for failure */ -static +static pid_t _openchild(command, fto, ffrom) char *command; FILE **fto;