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.
This commit is contained in:
Jesse Smith 2018-02-20 19:29:08 -04:00
parent efa6fefa8e
commit 80dbcf3de3
5 changed files with 14 additions and 18 deletions

View File

@ -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.

View File

@ -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

View File

@ -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) {

View File

@ -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 <sys/param.h>
#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

View File

@ -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;