summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKlemens Nanni <kn@cvs.openbsd.org>2022-11-27 15:19:39 +0000
committerKlemens Nanni <kn@cvs.openbsd.org>2022-11-27 15:19:39 +0000
commit8d0f9599fd889f726d8e8a2cf788fb85818b8888 (patch)
tree86f233efda419cb68e7c52936aaf855a29634dab
parentef4a78476e49dfd51ff324e05d273504ab2bd492 (diff)
Provide more accurate lock error message
When started manuall from single-user mode (/ still read-only), the current error is misleading: # slaacd -dv slaacd: already running The lock was specifically added to prevent multiple instances in the installer, which discards the error message entirely anyway. Retain the useful EAGAIN/"already running" message, but otherwise print the real error reason: # slaacd -dv slaacd: /dev/slaacd.lock: Read-only file system Feedback OK deraadt millert
-rw-r--r--sbin/dhcpleased/dhcpleased.c9
-rw-r--r--sbin/resolvd/resolvd.c9
-rw-r--r--sbin/slaacd/slaacd.c9
3 files changed, 18 insertions, 9 deletions
diff --git a/sbin/dhcpleased/dhcpleased.c b/sbin/dhcpleased/dhcpleased.c
index ef6200d6bc0..cc9d98995d2 100644
--- a/sbin/dhcpleased/dhcpleased.c
+++ b/sbin/dhcpleased/dhcpleased.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dhcpleased.c,v 1.26 2022/07/23 09:33:18 florian Exp $ */
+/* $OpenBSD: dhcpleased.c,v 1.27 2022/11/27 15:19:38 kn Exp $ */
/*
* Copyright (c) 2017, 2021 Florian Obser <florian@openbsd.org>
@@ -221,8 +221,11 @@ main(int argc, char *argv[])
errx(1, "need root privileges");
lockfd = open(_PATH_LOCKFILE, O_CREAT|O_RDWR|O_EXLOCK|O_NONBLOCK, 0600);
- if (lockfd == -1)
- errx(1, "already running");
+ if (lockfd == -1) {
+ if (errno == EAGAIN)
+ errx(1, "already running");
+ err(1, "%s", _PATH_LOCKFILE);
+ }
/* Check for assigned daemon user */
if (getpwnam(DHCPLEASED_USER) == NULL)
diff --git a/sbin/resolvd/resolvd.c b/sbin/resolvd/resolvd.c
index 5fb9b39a1e3..9260a6254ab 100644
--- a/sbin/resolvd/resolvd.c
+++ b/sbin/resolvd/resolvd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: resolvd.c,v 1.29 2022/11/14 13:57:46 kn Exp $ */
+/* $OpenBSD: resolvd.c,v 1.30 2022/11/27 15:19:38 kn Exp $ */
/*
* Copyright (c) 2021 Florian Obser <florian@openbsd.org>
* Copyright (c) 2021 Theo de Raadt <deraadt@openbsd.org>
@@ -193,8 +193,11 @@ main(int argc, char *argv[])
errx(1, "need root privileges");
lockfd = open(_PATH_LOCKFILE, O_CREAT|O_RDWR|O_EXLOCK|O_NONBLOCK, 0600);
- if (lockfd == -1)
- errx(1, "already running");
+ if (lockfd == -1) {
+ if (errno == EAGAIN)
+ errx(1, "already running");
+ err(1, "%s", _PATH_LOCKFILE);
+ }
if (!debug)
daemon(0, 0);
diff --git a/sbin/slaacd/slaacd.c b/sbin/slaacd/slaacd.c
index 4326492c545..816afff65e9 100644
--- a/sbin/slaacd/slaacd.c
+++ b/sbin/slaacd/slaacd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: slaacd.c,v 1.66 2022/09/15 07:59:59 florian Exp $ */
+/* $OpenBSD: slaacd.c,v 1.67 2022/11/27 15:19:38 kn Exp $ */
/*
* Copyright (c) 2017 Florian Obser <florian@openbsd.org>
@@ -179,8 +179,11 @@ main(int argc, char *argv[])
errx(1, "need root privileges");
lockfd = open(_PATH_LOCKFILE, O_CREAT|O_RDWR|O_EXLOCK|O_NONBLOCK, 0600);
- if (lockfd == -1)
- errx(1, "already running");
+ if (lockfd == -1) {
+ if (errno == EAGAIN)
+ errx(1, "already running");
+ err(1, "%s", _PATH_LOCKFILE);
+ }
/* Check for assigned daemon user */
if (getpwnam(SLAACD_USER) == NULL)