From 97c57a650febc37e6d1dd4ec0c0a0d39c8173125 Mon Sep 17 00:00:00 2001 From: charnier Date: Wed, 16 Jul 1997 06:51:12 +0000 Subject: [PATCH] Use err(3). Rewrote man page in mdoc format. --- usr.bin/key/key.1 | 59 +++++++++++++++++++++++----------------------- usr.bin/key/skey.c | 43 +++++++++++++-------------------- 2 files changed, 46 insertions(+), 56 deletions(-) diff --git a/usr.bin/key/key.1 b/usr.bin/key/key.1 index 73992337c4c..aaeadd8dfe7 100644 --- a/usr.bin/key/key.1 +++ b/usr.bin/key/key.1 @@ -1,24 +1,26 @@ -.ll 6i -.pl 10.5i -.\" @(#)key.1 1.0 (Bellcore) 12/2/91 +.\" from: @(#)key.1 1.0 (Bellcore) 12/2/91 +.\" $Id$ .\" -.lt 6.0i -.TH KEY 1 "2 December 1991" -.AT 3 -.SH NAME -key \- Stand\-alone program for computing responses to S/Key challenges. -.SH SYNOPSIS -.B key [\-n ] -.SH DESCRIPTION -.I key -Takes the optional count of the number of one time access +.Dd December 2, 1991 +.Dt KEY 1 +.Os +.Sh NAME +.Nm key +.Nd stand\-alone program for computing responses to S/Key challenges +.Sh SYNOPSIS +.Nm +.Op Fl n Ar count +.Ar sequence +.Ar key +.Sh DESCRIPTION +.Nm Key +takes the optional count of the number of one time access passwords to print along with a (maximum) sequence number and key as command line args, it prompts for the user's secret password, and produces both word and hex format responses. -.SH EXAMPLE -.sh - Usage example: +.Sh EXAMPLE +Usage example: .sp 0 >key \-n 5 99 th91334 .sp 0 @@ -29,21 +31,18 @@ and hex format responses. .... 4 more passwords. .sp 0 > -.LP -.SH OPTIONS -.LP -.B \-n -the number of one time access passwords to print. +.Sh OPTIONS +.Bl -tag -width indent +.It Fl n Ar count +The number of one time access passwords to print. The default is one. -.SH DIAGNOSTICS -.SH BUGS -.LP -.SH SEE ALSO -.BR skey(1), -.BR keyinit(1), +.El +.Sh SEE ALSO +.Xr keyinfo 1 , +.Xr keyinit 1 , +.Xr skey 1 .\" .BR keysu(1), -.BR keyinfo(1) -.SH AUTHOR +.Sh AUTHOR Command by Phil Karn, Neil M. Haller, John S. Walden -.SH CONTACT +.Sh CONTACT staff@thumper.bellcore.com diff --git a/usr.bin/key/skey.c b/usr.bin/key/skey.c index 0196ebe62f7..42ef6c5e79f 100644 --- a/usr.bin/key/skey.c +++ b/usr.bin/key/skey.c @@ -9,9 +9,12 @@ * C848 666B 6435 0A93 * > */ + +#include #include #include #include +#include #ifdef __MSDOS__ #include @@ -21,11 +24,7 @@ #include -char *readpass(); -void usage(); -int getopt(); -extern int optind; -extern char *optarg; +static void usage __P((void)); int main(argc,argv) @@ -33,7 +32,7 @@ int argc; char *argv[]; { int n,cnt,i; - char passwd[256],passwd2[256]; + char passwd[256] /* ,passwd2[256] */; char key[8]; char *seed; char buf[33]; @@ -50,31 +49,25 @@ char *argv[]; /* could be in the form / */ if(argc <= optind + 1){ /*look for / in it */ - if(argc <= optind){ - usage(argv[0]); - return 1; - } + if(argc <= optind) + usage(); slash = strchr(argv[optind], '/'); - if(slash == NULL){ - usage(argv[0]); - return 1; - } + if(slash == NULL) + usage(); *slash++ = '\0'; seed = slash; if((n = atoi(argv[optind])) < 0){ fprintf(stderr,"%s not positive\n",argv[optind]); - usage(argv[0]); - return 1; + usage(); } } else { if((n = atoi(argv[optind])) < 0){ fprintf(stderr,"%s not positive\n",argv[optind]); - usage(argv[0]); - return 1; + usage(); } seed = argv[++optind]; } @@ -95,10 +88,8 @@ char *argv[]; } /* Crunch seed and password into starting key */ - if(keycrunch(key,seed,passwd) != 0){ - fprintf(stderr,"%s: key crunch failed\n",argv[0]); - return 1; - } + if(keycrunch(key,seed,passwd) != 0) + errx(1, "key crunch failed"); if(cnt == 1){ while(n-- != 0) f(key); @@ -121,9 +112,9 @@ char *argv[]; return 0; } -void -usage(s) -char *s; +static void +usage() { - fprintf(stderr,"Usage: %s [-n count] [/] \n",s); + fprintf(stderr,"usage: key [-n count] [/] \n"); + exit(1); } -- 2.45.2