diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2001-02-05 16:58:12 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2001-02-05 16:58:12 +0000 |
commit | 2620f303fd511a9f7c02e75d19344ea7ad1a0b37 (patch) | |
tree | a1702d91fba6d92e5b0f21e0e33ca62ddac8c434 /usr.bin/skeyinfo/skeyinfo.c | |
parent | ed320d55756e4ca9ef489ff1c4579b3bdaaa5878 (diff) |
Don't bother checking username length, we trust pw_name
Call exit(1) not exit(-1) on stat/open error
Don't pass the username though sevenbit()
Diffstat (limited to 'usr.bin/skeyinfo/skeyinfo.c')
-rw-r--r-- | usr.bin/skeyinfo/skeyinfo.c | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/usr.bin/skeyinfo/skeyinfo.c b/usr.bin/skeyinfo/skeyinfo.c index bd9f004e178..38b3046fc9d 100644 --- a/usr.bin/skeyinfo/skeyinfo.c +++ b/usr.bin/skeyinfo/skeyinfo.c @@ -1,4 +1,4 @@ -/* $OpenBSD: skeyinfo.c,v 1.5 1998/06/21 22:14:03 millert Exp $ */ +/* $OpenBSD: skeyinfo.c,v 1.6 2001/02/05 16:58:11 millert Exp $ */ /* * Copyright (c) 1997 Todd C. Miller <Todd.Miller@courtesan.com> @@ -49,7 +49,7 @@ main(argc, argv) struct passwd *pw; struct skey key; char *name = NULL; - int errs, ch, verbose = 0; + int error, ch, verbose = 0; if (geteuid() != 0) errx(1, "must be setuid root"); @@ -74,8 +74,6 @@ main(argc, argv) errx(1, "only root may specify an alternate user"); if (name) { - if (strlen(name) > PASS_MAX) - errx(1, "username too long (%d chars max)", PASS_MAX); if ((pw = getpwnam(name)) == NULL) errx(1, "no passwd entry for %s", name); } else { @@ -85,24 +83,23 @@ main(argc, argv) if ((name = strdup(pw->pw_name)) == NULL) err(1, "cannot allocate memory"); - sevenbit(name); - errs = skeylookup(&key, name); - switch (errs) { + error = skeylookup(&key, name); + switch (error) { case 0: /* Success! */ if (verbose) (void)printf("otp-%s ", skey_get_algorithm()); (void)printf("%d %s\n", key.n - 1, key.seed); break; case -1: /* File error */ - warnx("cannot open %s", _PATH_SKEYKEYS); + warn("cannot open %s", _PATH_SKEYKEYS); break; case 1: /* Unknown user */ warnx("%s is not listed in %s", name, _PATH_SKEYKEYS); } (void)fclose(key.keyfile); - exit(errs); + exit(error ? 1 : 0); } void |