summaryrefslogtreecommitdiff
path: root/usr.bin/skeyinit/skeyinit.c
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1995-12-20 09:48:25 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1995-12-20 09:48:25 +0000
commit00c1ae9c3963b23f1fe010fee051ffb1be1eb7ae (patch)
tree41165bc8303e615f82a515d8c272dfebc9f97595 /usr.bin/skeyinit/skeyinit.c
parentc482518380683ee38d14024c1e362a0d681cf967 (diff)
add ability to zero out entry; from millert@cs.colorado.edu; netbsd pr#1851
also add a prototype for skeyzero()
Diffstat (limited to 'usr.bin/skeyinit/skeyinit.c')
-rw-r--r--usr.bin/skeyinit/skeyinit.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/usr.bin/skeyinit/skeyinit.c b/usr.bin/skeyinit/skeyinit.c
index 684af16d9b8..b94327239f5 100644
--- a/usr.bin/skeyinit/skeyinit.c
+++ b/usr.bin/skeyinit/skeyinit.c
@@ -29,13 +29,14 @@
#define NAMELEN 2
int skeylookup __ARGS((struct skey * mp, char *name));
+int skeyzero __ARGS((struct skey * mp, char *name));
int
main(argc, argv)
int argc;
char *argv[];
{
- int rval, n, nn, i, defaultsetup, l;
+ int rval, n, nn, i, defaultsetup, l, zerokey = 0;
time_t now;
char hostname[MAXHOSTNAMELEN];
char seed[18], tmp[80], key[8], defaultseed[17];
@@ -63,14 +64,15 @@ main(argc, argv)
err(1, "Who are you?");
defaultsetup = 1;
- if (argc > 1) {
- if (strcmp("-s", argv[1]) == 0)
+ for (i=1; i < argc; i++) {
+ if (strcmp("-s", argv[i]) == 0)
defaultsetup = 0;
- else
- pp = getpwnam(argv[1]);
-
- if (argc > 2)
- pp = getpwnam(argv[2]);
+ else if (strcmp("-z", argv[i]) == 0)
+ zerokey = 1;
+ else {
+ pp = getpwnam(argv[i]);
+ break;
+ }
}
if (pp == NULL) {
err(1, "User unknown");
@@ -104,6 +106,10 @@ main(argc, argv)
case -1:
err(1, "cannot open database");
case 0:
+ /* comment out user if asked to */
+ if (zerokey)
+ exit(skeyzero(&skey, pp->pw_name));
+
printf("[Updating %s]\n", pp->pw_name);
printf("Old key: %s\n", skey.seed);
@@ -127,6 +133,10 @@ main(argc, argv)
}
break;
case 1:
+ if (zerokey) {
+ printf("You have no entry to zero.\n");
+ exit(1);
+ }
printf("[Adding %s]\n", pp->pw_name);
break;
}