diff options
author | charnier <charnier@FreeBSD.org> | 1997-07-29 06:54:16 +0000 |
---|---|---|
committer | charnier <charnier@FreeBSD.org> | 1997-07-29 06:54:16 +0000 |
commit | 7711e701aa1f4f9d39e5cb307997bfa18a733136 (patch) | |
tree | aa6e652d97672aab7685f3a8895f647b750a6401 | |
parent | e97a8f1bb5fbb72a7aba41985727d01d65f488c2 (diff) | |
download | FreeBSD-src-7711e701aa1f4f9d39e5cb307997bfa18a733136.zip FreeBSD-src-7711e701aa1f4f9d39e5cb307997bfa18a733136.tar.gz |
Add usage(), use err(3).
Rewrote man page in mdoc format.
-rw-r--r-- | usr.bin/newkey/generic.c | 5 | ||||
-rw-r--r-- | usr.bin/newkey/newkey.8 | 65 | ||||
-rw-r--r-- | usr.bin/newkey/newkey.c | 70 | ||||
-rw-r--r-- | usr.bin/newkey/update.c | 8 |
4 files changed, 76 insertions, 72 deletions
diff --git a/usr.bin/newkey/generic.c b/usr.bin/newkey/generic.c index 4d15185..2c3ec1e 100644 --- a/usr.bin/newkey/generic.c +++ b/usr.bin/newkey/generic.c @@ -28,14 +28,19 @@ * Mountain View, California 94043 */ #if !defined(lint) && defined(SCCSIDS) +#if 0 static char sccsid[] = "@(#)generic.c 1.2 91/03/11 Copyr 1986 Sun Micro"; #endif +static const char rcsid[] = + "$Id$"; +#endif /* * Copyright (C) 1986, Sun Microsystems, Inc. */ #include <stdio.h> +#include <stdlib.h> #include <rpc/rpc.h> #include <sys/file.h> #include <mp.h> diff --git a/usr.bin/newkey/newkey.8 b/usr.bin/newkey/newkey.8 index 8029751..c32fe9e 100644 --- a/usr.bin/newkey/newkey.8 +++ b/usr.bin/newkey/newkey.8 @@ -1,54 +1,53 @@ .\" @(#)newkey.8 1.3 91/03/11 TIRPC 1.0; from 1.12 90/02/03 SMI; -.TH NEWKEY 8 "12 October 1987" -.SH NAME -newkey \- create a new key in the publickey database -.SH SYNOPSIS -.B "newkey \-h" -.I hostname -.br -.B "newkey \-u" -.I username -.SH DESCRIPTION -.IX "newkey command" "" "\fLnewkey\fP command" -.LP -.B newkey +.Dd October 12, 1987 +.Dt NEWKEY 8 +.Os +.Sh NAME +.Nm newkey +.Nd create a new key in the publickey database +.Sh SYNOPSIS +.Nm newkey +.Fl h Ar hostname +.Nm newkey +.Fl u Ar username +.Sh DESCRIPTION +.Nm Newkey is normally run by the network administrator on the Network Interface Service (\s-1NIS\s0) master machine in order to establish public keys for users and super-users on the network. These keys are needed for using secure -.SM RPC +RPC or secure -.SM NFS\s0. -.LP -.B newkey +NFS\s0. +.Pp +.Nm Newkey will prompt for the login password of the given username and then create a new public/secret key pair in -.B /etc/publickey +.Pa /etc/publickey encrypted with the login password of the given user. -.LP +.Pp Use of this program is not required: users may create their own keys using -.BR chkey (1). -.SH OPTIONS -.TP 12 -.BI \-h " hostname" +.Xr chkey 1 . +.Sh OPTIONS +.Bl -tag -width indent +.It Fl h Ar hostname Create a new public key for the super-user at the given hostname. Prompts for the root password of the given hostname. -.TP -.BI \-u " username" +.It Fl u Ar username Create a new public key for the given username. Prompts for the -.SM NIS +NIS password of the given username. -.SH "SEE ALSO" -.BR chkey (1), -.BR keylogin (1), -.BR publickey (5), -.BR keyserv (8C) -.SH NOTES -.LP +.El +.Sh SEE ALSO +.Xr chkey 1 , +.Xr keylogin 1 , +.Xr publickey 5 , +.Xr keyserv 8 +.Sh NOTES The Network Information Service (\s-1NIS\s0) was formerly known as Sun Yellow Pages diff --git a/usr.bin/newkey/newkey.c b/usr.bin/newkey/newkey.c index 489324d..dcf14ec 100644 --- a/usr.bin/newkey/newkey.c +++ b/usr.bin/newkey/newkey.c @@ -28,8 +28,12 @@ * Mountain View, California 94043 */ #if !defined(lint) && defined(SCCSIDS) +#if 0 static char sccsid[] = "@(#)newkey.c 1.8 91/03/11 Copyr 1986 Sun Micro"; #endif +static const char rcsid[] = + "$Id$"; +#endif /* * Copyright (C) 1986, Sun Microsystems, Inc. @@ -38,6 +42,7 @@ static char sccsid[] = "@(#)newkey.c 1.8 91/03/11 Copyr 1986 Sun Micro"; /* * Administrative tool to add a new user to the publickey database */ +#include <err.h> #include <stdio.h> #include <rpc/rpc.h> #include <rpc/key_prot.h> @@ -49,6 +54,7 @@ static char sccsid[] = "@(#)newkey.c 1.8 91/03/11 Copyr 1986 Sun Micro"; #endif /* YP */ #include <pwd.h> #include <string.h> +#include <unistd.h> #include <sys/resource.h> #ifdef YP @@ -66,9 +72,6 @@ static char sccsid[] = "@(#)newkey.c 1.8 91/03/11 Copyr 1986 Sun Micro"; #define ERR_KEY 6 #endif -extern char *getpass(); -extern char *malloc(); - #ifdef YP static char *basename(); static char SHELL[] = "/bin/sh"; @@ -80,6 +83,9 @@ static char PKFILE[] = "/etc/publickey"; static char *err_string(); #endif /* YP */ +static void usage __P((void)); + +int main(argc, argv) int argc; char *argv[]; @@ -98,37 +104,25 @@ main(argc, argv) if (argc != 3 || !(strcmp(argv[1], "-u") == 0 || strcmp(argv[1], "-h") == 0)) { - (void)fprintf(stderr, "usage: %s [-u username]\n", - argv[0]); - (void)fprintf(stderr, "usage: %s [-h hostname]\n", - argv[0]); - exit(1); - } - if (geteuid() != 0) { - (void)fprintf(stderr, "must be superuser to run %s\n", argv[0]); - exit(1); + usage(); } + if (geteuid() != 0) + errx(1, "must be superuser"); #ifdef YP - if (chdir(YPDBPATH) < 0) { - (void)fprintf(stderr, "cannot chdir to "); - perror(YPDBPATH); - } + if (chdir(YPDBPATH) < 0) + warn("cannot chdir to %s", YPDBPATH); #endif /* YP */ if (strcmp(argv[1], "-u") == 0) { pw = getpwnam(argv[2]); - if (pw == NULL) { - (void)fprintf(stderr, "unknown user: %s\n", argv[2]); - exit(1); - } + if (pw == NULL) + errx(1, "unknown user: %s", argv[2]); (void)user2netname(name, (int)pw->pw_uid, (char *)NULL); } else { #ifdef undef h = gethostbyname(argv[2]); - if (h == NULL) { - (void)fprintf(stderr, "unknown host: %s\n", argv[1]); - exit(1); - } + if (h == NULL) + errx(1, "unknown host: %s", argv[1]); (void)host2netname(name, h->h_name, (char *)NULL); #else (void)host2netname(name, argv[2], (char *)NULL); @@ -147,31 +141,35 @@ main(argc, argv) memcpy(crypt2, crypt1, HEXKEYBYTES + KEYCHECKSUMSIZE + 1); xdecrypt(crypt2, getpass("Retype password:")); if (memcmp(crypt2, crypt2 + HEXKEYBYTES, KEYCHECKSUMSIZE) != 0 || - memcmp(crypt2, secret, HEXKEYBYTES) != 0) { - (void)fprintf(stderr, "Password incorrect.\n"); - exit(1); - } + memcmp(crypt2, secret, HEXKEYBYTES) != 0) + errx(1, "password incorrect"); #ifdef YP (void)printf("Please wait for the database to get updated...\n"); #endif - if (status = setpublicmap(name, public, crypt1)) { + if ((status = setpublicmap(name, public, crypt1))) { #ifdef YP - (void)fprintf(stderr, - "%s: unable to update NIS database (%u): %s\n", - argv[0], status, yperr_string(status)); + errx(1, "unable to update NIS database (%u): %s", + status, yperr_string(status)); #else - (void)fprintf(stderr, - "%s: unable to update publickey database (%u): %s\n", - argv[0], status, err_string(status)); + errx(1, "unable to update publickey database (%u): %s", + status, err_string(status)); #endif - exit(1); } (void)printf("Your new key has been successfully stored away.\n"); exit(0); /* NOTREACHED */ } +static void +usage() +{ + (void)fprintf(stderr, "%s\n%s\n", + "usage: newkey [-u username]", + " newkey [-h hostname]"); + exit(1); +} + /* * Set the entry in the public key file */ diff --git a/usr.bin/newkey/update.c b/usr.bin/newkey/update.c index e6bc9a6..c6b663d 100644 --- a/usr.bin/newkey/update.c +++ b/usr.bin/newkey/update.c @@ -28,8 +28,12 @@ * Mountain View, California 94043 */ #ifndef lint +#if 0 static char sccsid[] = "@(#)update.c 1.2 91/03/11 Copyr 1986 Sun Micro"; #endif +static const char rcsid[] = + "$Id$"; +#endif /* * Copyright (C) 1986, 1989, Sun Microsystems, Inc. @@ -49,6 +53,7 @@ static char sccsid[] = "@(#)update.c 1.2 91/03/11 Copyr 1986 Sun Micro"; #endif /* YP */ #include <pwd.h> #include <string.h> +#include <unistd.h> #include <sys/resource.h> #ifdef YP @@ -60,9 +65,6 @@ static char sccsid[] = "@(#)update.c 1.2 91/03/11 Copyr 1986 Sun Micro"; #define YPOP_STORE 4 /* add, or change */ #endif -extern char *getpass(); -extern char *malloc(); - #ifdef YP static char *basename(); static char SHELL[] = "/bin/sh"; |