Hi Harold,

harold felton wrote on Fri, Jul 05, 2019 at 11:16:01PM +0000:
> On Fri, Jul 05, 2019 at 10:39:55PM +0000, harold felton wrote:

>> boot -s

Did you mount(8) /usr between the above and the below?

>> # shutdown now

> shutdown: unveil: No such file or directory

If the answer to the above question is "no", then i suspect from
code inspection that the following patch may help (untested).

The point of the patch is tolerating unveil(2) failure if /usr/bin/
does not exist.  Later, trying to execle(3) _PATH_WALL will of
course fail, too, but that's harmless because it merely results in
the child dying with a syslog message.

All that said, in single user mode, it may be more reliable to
use halt(8) directly rather than trying to fire up a bloated
monster application suite like shutdown(8).

> ps - i would rather reinstall than try to debug

If the patch below helps, reinstalling is most likely not needed.

Does it help?
  Ingo

P.S.
If some crazy person deletes /etc or /sbin or runs shutdown(8)
from a directory that was deleted after changing into it,
similar failures look likely - but while that might want fixing,
too, and while printing the unveil argument in case of failure
might also make sense, the case of _PATH_WALL is probably the
most important one because not having /usr mounted wouldn't
seem all that unusual.


Index: shutdown.c
===================================================================
RCS file: /cvs/src/sbin/shutdown/shutdown.c,v
retrieving revision 1.52
diff -u -p -r1.52 shutdown.c
--- shutdown.c  3 Aug 2018 17:09:22 -0000       1.52
+++ shutdown.c  6 Jul 2019 14:32:10 -0000
@@ -169,7 +169,7 @@ main(int argc, char *argv[])
                err(1, "unveil");
        if (unveil(_PATH_RC, "r") == -1)
                err(1, "unveil");
-       if (unveil(_PATH_WALL, "x") == -1)
+       if (unveil(_PATH_WALL, "x") == -1 && errno != ENOENT)
                err(1, "unveil");
        if (unveil(_PATH_FASTBOOT, "wc") == -1)
                err(1, "unveil");

Reply via email to