summaryrefslogtreecommitdiff
path: root/usr.bin/skeyinit
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2002-05-17 00:55:55 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2002-05-17 00:55:55 +0000
commitbb70e9f17a9a6c1b27a23dc4d7efbbac98604a36 (patch)
tree20bb6108ac427b22fade27656e94cf77da2b0090 /usr.bin/skeyinit
parentdbcf0d0738a545e3ea42a08b342f4d40970adf57 (diff)
Call enable_db() from convert_db() so the dir creation as well as
mode/user/group setting is done in one place.
Diffstat (limited to 'usr.bin/skeyinit')
-rw-r--r--usr.bin/skeyinit/skeyinit.c20
1 files changed, 9 insertions, 11 deletions
diff --git a/usr.bin/skeyinit/skeyinit.c b/usr.bin/skeyinit/skeyinit.c
index fd86ba6523a..02286f4b357 100644
--- a/usr.bin/skeyinit/skeyinit.c
+++ b/usr.bin/skeyinit/skeyinit.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: skeyinit.c,v 1.33 2002/05/16 17:54:34 millert Exp $ */
+/* $OpenBSD: skeyinit.c,v 1.34 2002/05/17 00:55:54 millert Exp $ */
/* OpenBSD S/Key (skeyinit.c)
*
@@ -137,10 +137,13 @@ main(argc, argv)
usage(argv[0]);
/* Handle -C, -D, and -E */
- if (enable)
- enable_db(enable);
- if (convert)
- convert_db();
+ if (convert || enable) {
+ if (convert)
+ convert_db();
+ else
+ enable_db(enable);
+ exit(0);
+ }
/* Check for optional user string. */
if (argc == 1) {
@@ -438,7 +441,6 @@ enable_db(op)
if (chmod(_PATH_SKEYDIR, 0) != 0 && errno != ENOENT)
err(1, "can't chmod %s", _PATH_SKEYDIR);
}
- exit(0);
}
#define _PATH_SKEYKEYS "/etc/skeykeys"
@@ -457,10 +459,7 @@ convert_db(void)
err(1, "can't open %s", _PATH_SKEYKEYS);
if (flock(fileno(keyfile), LOCK_EX) != 0)
err(1, "can't lock %s", _PATH_SKEYKEYS);
- if (mkdir(_PATH_SKEYDIR, 01730) != 0 && errno != EEXIST)
- err(1, "can't mkdir %s", _PATH_SKEYDIR);
- if (chmod(_PATH_SKEYDIR, 01730) != 0)
- err(1, "can't chmod %s", _PATH_SKEYDIR);
+ enable_db(1);
/*
* Loop over each entry in _PATH_SKEYKEYS, creating a file
@@ -511,7 +510,6 @@ convert_db(void)
printf("%s has been populated. NOTE: %s has *not* been removed.\n"
"It should be removed once you have verified that the new keys "
"work.\n", _PATH_SKEYDIR, _PATH_SKEYKEYS);
- exit(0);
}
#define TIMEOUT_MSG "Timed out waiting for input.\n"