diff options
Diffstat (limited to 'usr.bin/skeyaudit/skeyaudit.c')
-rw-r--r-- | usr.bin/skeyaudit/skeyaudit.c | 49 |
1 files changed, 23 insertions, 26 deletions
diff --git a/usr.bin/skeyaudit/skeyaudit.c b/usr.bin/skeyaudit/skeyaudit.c index 900d255cb6c..dd53d724a2a 100644 --- a/usr.bin/skeyaudit/skeyaudit.c +++ b/usr.bin/skeyaudit/skeyaudit.c @@ -1,4 +1,4 @@ -/* $OpenBSD: skeyaudit.c,v 1.13 2002/05/16 03:50:42 millert Exp $ */ +/* $OpenBSD: skeyaudit.c,v 1.14 2002/05/29 15:32:10 millert Exp $ */ /* * Copyright (c) 1997, 2000 Todd C. Miller <Todd.Miller@courtesan.com> @@ -42,28 +42,26 @@ #include <unistd.h> #include <skey.h> -extern char *__progname; - void notify(struct passwd *, int, int); FILE *runsendmail(struct passwd *, int *); -void usage(void); +__dead void usage(void); int -main(argc, argv) - int argc; - char **argv; +main(int argc, char **argv) { struct passwd *pw; struct skey key; - int ch, errs = 0, left = 0, aflag = 0, iflag = 0, limit = 12; char *name; + int ch, left, aflag, iflag, limit; + left = aflag = iflag = 0; + limit = 12; while ((ch = getopt(argc, argv, "ail:")) != -1) switch(ch) { case 'a': - aflag = 1; if (getuid() != 0) errx(1, "only root may use the -a flag"); + aflag = 1; break; case 'i': iflag = 1; @@ -107,35 +105,32 @@ main(argc, argv) err(1, "cannot allocate memory"); sevenbit(name); - errs = skeylookup(&key, name); - switch (errs) { + switch (skeylookup(&key, name)) { case 0: /* Success! */ left = key.n - 1; break; case -1: /* File error */ - errx(errs, "cannot open %s", _PATH_SKEYDIR); + errx(1, "cannot open %s/%s", _PATH_SKEYDIR, + name); break; case 1: /* Unknown user */ - warnx("%s is not listed in %s", name, + errx(1, "user %s is not listed in %s", name, _PATH_SKEYDIR); } (void)fclose(key.keyfile); - if (!errs && left < limit) + if (left < limit) notify(pw, left, iflag); } - exit(errs); + exit(0); } void -notify(pw, seq, interactive) - struct passwd *pw; - int seq; - int interactive; +notify(struct passwd *pw, int seq, int interactive) { static char hostname[MAXHOSTNAMELEN]; - int pid; + pid_t pid; FILE *out; /* Only set this once */ @@ -173,12 +168,11 @@ pw->pw_name, hostname); } FILE * -runsendmail(pw, pidp) - struct passwd *pw; - int *pidp; +runsendmail(struct passwd *pw, pid_t *pidp) { FILE *fp; - int pfd[2], pid; + int pfd[2]; + pid_t pid; if (pipe(pfd) < 0) return(NULL); @@ -211,9 +205,12 @@ runsendmail(pw, pidp) return(fp); } -void -usage() + +__dead void +usage(void) { + extern char *__progname; + (void)fprintf(stderr, "Usage: %s [-i] [-l limit]\n", __progname); exit(1); |