On Sat, Nov 26, 2022 at 07:33:40PM -0700, Theo de Raadt wrote:
> Yes, that is understandable and suggests "no need to panic".

Sure, I wasn't sure yet as to whether this is the only way open(2) can
yield EAGAIN (in this use case), but since you seem to agree..

Todd, do you want to commit this diff?
If not, OK?

> 
> > On Sat, 26 Nov 2022 11:09:58 -0700, "Theo de Raadt" wrote:
> > 
> > > But "Resource temporarily unavailable" has absolutely no meaning to
> > > anyone who will try to do this by hand, it is better for the message
> > > to interpret the situation so that someone can understand.
> > 
> > Agreed, it would be friendlier to fo something like:
> > 
> >     if (lockfd == -1) {
> >             if (errno == EAGAIN)
> >                     errx(1, "already running");
> >             err(1, "%s", _PATH_LOCKFILE);
> >     }
> > 
> >  - todd
> 


Index: sbin/resolvd/resolvd.c
===================================================================
RCS file: /cvs/src/sbin/resolvd/resolvd.c,v
retrieving revision 1.29
diff -u -p -r1.29 resolvd.c
--- sbin/resolvd/resolvd.c      14 Nov 2022 13:57:46 -0000      1.29
+++ sbin/resolvd/resolvd.c      27 Nov 2022 12:39:32 -0000
@@ -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);
Index: sbin/dhcpleased/dhcpleased.c
===================================================================
RCS file: /cvs/src/sbin/dhcpleased/dhcpleased.c,v
retrieving revision 1.26
diff -u -p -r1.26 dhcpleased.c
--- sbin/dhcpleased/dhcpleased.c        23 Jul 2022 09:33:18 -0000      1.26
+++ sbin/dhcpleased/dhcpleased.c        27 Nov 2022 12:40:01 -0000
@@ -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)
Index: sbin/slaacd/slaacd.c
===================================================================
RCS file: /cvs/src/sbin/slaacd/slaacd.c,v
retrieving revision 1.66
diff -u -p -r1.66 slaacd.c
--- sbin/slaacd/slaacd.c        15 Sep 2022 07:59:59 -0000      1.66
+++ sbin/slaacd/slaacd.c        27 Nov 2022 12:40:43 -0000
@@ -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)

Reply via email to