chiark / gitweb /
init: call telinit in case we are run as init and not pid1
authorLennart Poettering <lennart@poettering.net>
Fri, 18 Jun 2010 18:01:01 +0000 (20:01 +0200)
committerLennart Poettering <lennart@poettering.net>
Fri, 18 Jun 2010 18:01:01 +0000 (20:01 +0200)
Makefile.am
fixme
src/main.c

index 0e7c489ca0415a67370b36572b6d3deaa2e36b00..76662b18269fc00416dfd9aca3d70a70c27bbe30 100644 (file)
@@ -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 374ff4107e9c2211c234a409c456cd66daa176d1..23fda7e57ea56a5c8963d3cebf701a581ed995d7 100644 (file)
--- 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:
index 99f6bdd71212ac33010c381ce0678666f169e1cd..8a7f18ea9c38c2688b9f5ebe3f765fe9643d82df 100644 (file)
@@ -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);