summaryrefslogtreecommitdiff
path: root/usr.bin/skeyinit
diff options
context:
space:
mode:
authorPhilip Guenther <guenther@cvs.openbsd.org>2014-05-20 01:25:25 +0000
committerPhilip Guenther <guenther@cvs.openbsd.org>2014-05-20 01:25:25 +0000
commit597da3199199b14e2722a1ada9fccb3737814d7f (patch)
treeb475f359033bb4063109bd5404e3d5a943578b0d /usr.bin/skeyinit
parentf45d4774a3a08f1a090fecf301051d4c28ec94f6 (diff)
Use errc/warnc to simplify code.
Also, in 'ftp', always put the error message last, after the hostname/ipaddr. ok jsing@ krw@ millert@
Diffstat (limited to 'usr.bin/skeyinit')
-rw-r--r--usr.bin/skeyinit/skeyinit.c19
1 files changed, 8 insertions, 11 deletions
diff --git a/usr.bin/skeyinit/skeyinit.c b/usr.bin/skeyinit/skeyinit.c
index 6554261735a..d94d72e0e97 100644
--- a/usr.bin/skeyinit/skeyinit.c
+++ b/usr.bin/skeyinit/skeyinit.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: skeyinit.c,v 1.54 2014/04/23 18:24:23 ajacoutot Exp $ */
+/* $OpenBSD: skeyinit.c,v 1.55 2014/05/20 01:25:23 guenther Exp $ */
/* OpenBSD S/Key (skeyinit.c)
*
@@ -220,10 +220,9 @@ main(int argc, char **argv)
if (rmkey) {
if (snprintf(filename, sizeof(filename),
"%s/%s", _PATH_SKEYDIR, pp->pw_name)
- >= sizeof(filename)) {
- errno = ENAMETOOLONG;
- err(1, "Cannot remove S/Key entry");
- }
+ >= sizeof(filename))
+ errc(1, ENAMETOOLONG,
+ "Cannot remove S/Key entry");
if (unlink(filename) != 0)
err(1, "Cannot remove S/Key entry");
printf("S/Key entry for %s removed.\n",
@@ -275,10 +274,9 @@ main(int argc, char **argv)
(void)printf("[Adding %s with %s]\n", pp->pw_name,
ht ? ht : skey_get_algorithm());
if (snprintf(filename, sizeof(filename), "%s/%s",
- _PATH_SKEYDIR, pp->pw_name) >= sizeof(filename)) {
- errno = ENAMETOOLONG;
- err(1, "Cannot create S/Key entry");
- }
+ _PATH_SKEYDIR, pp->pw_name) >= sizeof(filename))
+ errc(1, ENAMETOOLONG,
+ "Cannot create S/Key entry");
if ((l = open(filename,
O_RDWR | O_NONBLOCK | O_CREAT | O_TRUNC |O_NOFOLLOW,
S_IRUSR | S_IWUSR)) == -1 ||
@@ -532,8 +530,7 @@ convert_db(void)
/* Now write the new-style record. */
if (snprintf(filename, sizeof(filename), "%s/%s", _PATH_SKEYDIR,
logname) >= sizeof(filename)) {
- errno = ENAMETOOLONG;
- warn("%s", logname);
+ warnc(ENAMETOOLONG, "%s", logname);
continue;
}
fd = open(filename, O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR);