[systemd-commits] fixme Makefile.am src/main.c

Lennart Poettering lennart at kemper.freedesktop.org
Fri Jun 18 11:01:08 PDT 2010


 Makefile.am |    1 +
 fixme       |    2 --
 src/main.c  |   10 ++++++++++
 3 files changed, 11 insertions(+), 2 deletions(-)

New commits:
commit 2cb1a60d14f869023652482a380ca7b659dcf78f
Author: Lennart Poettering <lennart at poettering.net>
Date:   Fri Jun 18 20:01:01 2010 +0200

    init: call telinit in case we are run as init and not pid1

diff --git a/Makefile.am b/Makefile.am
index 0e7c489..76662b1 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -44,6 +44,7 @@ AM_CPPFLAGS = \
 	-DSESSION_DATA_UNIT_PATH=\"$(sessionunitdir)\" \
 	-DCGROUP_AGENT_PATH=\"$(rootlibexecdir)/systemd-cgroups-agent\" \
 	-DSYSTEMD_BINARY_PATH=\"$(rootbindir)/systemd\" \
+	-DSYSTEMCTL_BINARY_PATH=\"$(rootbindir)/systemctl\" \
 	-I $(top_srcdir)/src
 
 rootbin_PROGRAMS = \
diff --git a/fixme b/fixme
index 374ff41..23fda7e 100644
--- a/fixme
+++ b/fixme
@@ -73,8 +73,6 @@
 
 * /sbin/shutdown argv[2..] message
 
-* exec /sbin/telinit from init
-
 * discuss NOTIFY_SOCKET, make it configurable? security implications?
 
 Regularly:
diff --git a/src/main.c b/src/main.c
index 99f6bdd..8a7f18e 100644
--- a/src/main.c
+++ b/src/main.c
@@ -610,6 +610,16 @@ int main(int argc, char *argv[]) {
         FDSet *fds = NULL;
         bool reexecute = false;
 
+        if (getpid() != 1 && strstr(program_invocation_short_name, "init")) {
+                /* This is compatbility support for SysV, where
+                 * calling init as a user is identical to telinit. */
+
+                errno = -ENOENT;
+                execv(SYSTEMCTL_BINARY_PATH, argv);
+                log_error("Failed to exec " SYSTEMCTL_BINARY_PATH ": %m");
+                return 1;
+        }
+
         log_show_color(true);
         log_show_location(false);
         log_set_max_level(LOG_DEBUG);


More information about the systemd-commits mailing list