From 80dbcf3de3c1b83aeaa713a8fe5b8d35d8649af2 Mon Sep 17 00:00:00 2001 From: Jesse Smith Date: Tue, 20 Feb 2018 19:29:08 -0400 Subject: [PATCH] Moved the named communication pipe from /dev/initctl to /run/initctl. This patch was supplied by Robert Millan from Debian. FreeBSD apparently does not like named piped in /dev, so we move it to /run for better cross-platform compatibility. --- doc/Install | 2 +- src/Makefile | 8 ++++---- src/init.c | 12 ++++++------ src/initreq.h | 8 ++------ src/shutdown.c | 2 +- 5 files changed, 14 insertions(+), 18 deletions(-) diff --git a/doc/Install b/doc/Install index 05f23a2..fdd25fc 100644 --- a/doc/Install +++ b/doc/Install @@ -48,7 +48,7 @@ You might want to create a file called "/etc/shutdown.allow". Read the manual page on shutdown to find out more about this. Running from a read-only file system (CDROM?): -o All communication to init goes through the FIFO /dev/initctl. +o All communication to init goes through the FIFO /run/initctl. There should be no problem using a read-only root file system IF you use a Linux kernel > 1.3.66. Older kernels don't allow writing to a FIFO on a read-only file system. diff --git a/src/Makefile b/src/Makefile index b6ecc13..3695b6c 100644 --- a/src/Makefile +++ b/src/Makefile @@ -217,8 +217,8 @@ ifeq ($(ROOT),) # # This part is skipped on Debian systems, the # debian.preinst script takes care of it. - @if [ ! -p /dev/initctl ]; then \ - echo "Creating /dev/initctl"; \ - rm -f /dev/initctl; \ - mknod -m 600 /dev/initctl p; fi + @if [ ! -p /run/initctl ]; then \ + echo "Creating /run/initctl"; \ + rm -f /run/initctl; \ + mknod -m 600 /run/initctl p; fi endif diff --git a/src/init.c b/src/init.c index da715d1..723c60a 100644 --- a/src/init.c +++ b/src/init.c @@ -131,7 +131,7 @@ char *argv0; /* First arguments; show up in ps listing */ int maxproclen; /* Maximal length of argv[0] with \0 */ struct utmp utproto; /* Only used for sizeof(utproto.ut_id) */ char *console_dev; /* Console device. */ -int pipe_fd = -1; /* /dev/initctl */ +int pipe_fd = -1; /* /run/initctl */ int did_boot = 0; /* Did we already do BOOT* stuff? */ int main(int, char **); @@ -2326,13 +2326,13 @@ void check_init_fifo(void) int quit = 0; /* - * First, try to create /dev/initctl if not present. + * First, try to create /run/initctl if not present. */ if (stat(INIT_FIFO, &st2) < 0 && errno == ENOENT) (void)mkfifo(INIT_FIFO, 0600); /* - * If /dev/initctl is open, stat the file to see if it + * If /run/initctl is open, stat the file to see if it * is still the _same_ inode. */ if (pipe_fd >= 0) { @@ -2346,7 +2346,7 @@ void check_init_fifo(void) } /* - * Now finally try to open /dev/initctl + * Now finally try to open /run/initctl */ if (pipe_fd < 0) { if ((pipe_fd = open(INIT_FIFO, O_RDWR|O_NONBLOCK)) >= 0) { @@ -2652,7 +2652,7 @@ void process_signals() } if (ISMEMBER(got_signals, SIGUSR1)) { /* - * SIGUSR1 means close and reopen /dev/initctl + * SIGUSR1 means close and reopen /run/initctl */ INITDBG(L_VB, "got SIGUSR1"); close(pipe_fd); @@ -2890,7 +2890,7 @@ int telinit(char *progname, int argc, char **argv) strerror(errno)); /* Open the fifo and write a command. */ - /* Make sure we don't hang on opening /dev/initctl */ + /* Make sure we don't hang on opening /run/initctl */ SETSIG(sa, SIGALRM, signal_handler, 0); alarm(3); if ((fd = open(INIT_FIFO, O_WRONLY)) >= 0) { diff --git a/src/initreq.h b/src/initreq.h index e234215..ee8a355 100644 --- a/src/initreq.h +++ b/src/initreq.h @@ -1,5 +1,5 @@ /* - * initreq.h Interface to talk to init through /dev/initctl. + * initreq.h Interface to talk to init through /run/initctl. * * Copyright (C) 1995-2004 Miquel van Smoorenburg * @@ -26,11 +26,7 @@ #include #ifndef INIT_FIFO -# if defined(__FreeBSD_kernel__) -# define INIT_FIFO "/etc/.initctl" -# else -# define INIT_FIFO "/dev/initctl" -# endif +#define INIT_FIFO "/run/initctl" #endif #define INIT_MAGIC 0x03091969 diff --git a/src/shutdown.c b/src/shutdown.c index 11c616f..d9ac9f4 100644 --- a/src/shutdown.c +++ b/src/shutdown.c @@ -173,7 +173,7 @@ int init_setenv(char *name, char *value) /* * Open the fifo and write the command. - * Make sure we don't hang on opening /dev/initctl + * Make sure we don't hang on opening /run/initctl */ memset(&sa, 0, sizeof(sa)); sa.sa_handler = alrm_handler;