From: Mike Gilbert Date: Fri, 30 Mar 2018 15:04:57 +0000 (-0400) Subject: systemctl: try opening /run/initctl before /dev/initctl X-Git-Tag: v239~451^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=83c76e8c385cefa05f8177992ba8cb7b75950249;p=thirdparty%2Fsystemd.git systemctl: try opening /run/initctl before /dev/initctl This ensures compatability with old/new sysvinit. http://git.savannah.nongnu.org/cgit/sysvinit.git/commit/?id=80dbcf3de3c1b83aeaa713a8fe5b8d35d8649af2 --- diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c index 43ca19d014e..12fca4ef9ab 100644 --- a/src/systemctl/systemctl.c +++ b/src/systemctl/systemctl.c @@ -8213,6 +8213,7 @@ static int talk_initctl(void) { _cleanup_close_ int fd = -1; char rl; int r; + const char *p; rl = action_to_runlevel(); if (!rl) @@ -8220,17 +8221,21 @@ static int talk_initctl(void) { request.runlevel = rl; - fd = open(INIT_FIFO, O_WRONLY|O_NONBLOCK|O_CLOEXEC|O_NOCTTY); + FOREACH_STRING(p, "/run/initctl", "/dev/initctl") { + fd = open(p, O_WRONLY|O_NONBLOCK|O_CLOEXEC|O_NOCTTY); + if (fd >= 0 || errno != ENOENT) + break; + } if (fd < 0) { if (errno == ENOENT) return 0; - return log_error_errno(errno, "Failed to open "INIT_FIFO": %m"); + return log_error_errno(errno, "Failed to open initctl fifo: %m"); } r = loop_write(fd, &request, sizeof(request), false); if (r < 0) - return log_error_errno(r, "Failed to write to "INIT_FIFO": %m"); + return log_error_errno(r, "Failed to write to %s: %m", p); return 1; #else