summaryrefslogtreecommitdiffstats
path: root/usr.sbin/kvm_mkdb/kvm_mkdb.c
diff options
context:
space:
mode:
authormillert <millert@openbsd.org>1998-08-19 07:43:36 +0000
committermillert <millert@openbsd.org>1998-08-19 07:43:36 +0000
commitfeed01ec931d57c1a770ab1f9b8b73617d992ac4 (patch)
tree7e5bc10c30dc656c1b72af5f4b8fdff11a89f592 /usr.sbin/kvm_mkdb/kvm_mkdb.c
parenttags, formatting, ANSI-fication, prototypes, de-typos, and the occasional (diff)
downloadwireguard-openbsd-feed01ec931d57c1a770ab1f9b8b73617d992ac4.tar.xz
wireguard-openbsd-feed01ec931d57c1a770ab1f9b8b73617d992ac4.zip
clean up our temp files on failure
Diffstat (limited to 'usr.sbin/kvm_mkdb/kvm_mkdb.c')
-rw-r--r--usr.sbin/kvm_mkdb/kvm_mkdb.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/usr.sbin/kvm_mkdb/kvm_mkdb.c b/usr.sbin/kvm_mkdb/kvm_mkdb.c
index c98c3b1641f..f40ee17a593 100644
--- a/usr.sbin/kvm_mkdb/kvm_mkdb.c
+++ b/usr.sbin/kvm_mkdb/kvm_mkdb.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kvm_mkdb.c,v 1.3 1998/08/19 06:47:53 millert Exp $ */
+/* $OpenBSD: kvm_mkdb.c,v 1.4 1998/08/19 07:43:37 millert Exp $ */
/*-
* Copyright (c) 1990, 1993
@@ -43,7 +43,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "from: @(#)kvm_mkdb.c 8.3 (Berkeley) 5/4/95";
#else
-static char *rcsid = "$OpenBSD: kvm_mkdb.c,v 1.3 1998/08/19 06:47:53 millert Exp $";
+static char *rcsid = "$OpenBSD: kvm_mkdb.c,v 1.4 1998/08/19 07:43:37 millert Exp $";
#endif
#endif /* not lint */
@@ -116,10 +116,16 @@ main(argc, argv)
db = dbopen(dbtemp, O_CREAT | O_EXLOCK | O_TRUNC | O_RDWR,
S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH, DB_HASH, &openinfo);
if (db == NULL)
- err(1, "%s", dbtemp);
- create_knlist(nlistpath, db);
- if (db->close(db))
- err(1, "%s", dbtemp);
+ err(1, "can't dbopen %s", dbtemp);
+ if (create_knlist(nlistpath, db) != 0) {
+ (void)unlink(dbtemp);
+ errx(1, "cannot determine executable type of %s", nlistpath);
+ }
+ if (db->close(db)) {
+ warn("can't dbclose %s", dbtemp);
+ (void)unlink(dbtemp);
+ exit(1);
+ }
if (rename(dbtemp, dbname))
err(1, "rename %s to %s", dbtemp, dbname);
exit(0);