[systemd-devel] [PATCH] Make upstart compatibility optional

Dave Reisner d at falconindy.com
Mon Sep 30 05:44:56 PDT 2013


On Sun, Sep 29, 2013 at 11:18:52PM -0300, Cristian Rodríguez wrote:
> El 29/09/13 15:11, Lennart Poettering escribió:
> > On Fri, 27.09.13 23:04, Kay Sievers (kay at vrfy.org) wrote:
> > 
> >> On Fri, Sep 27, 2013 at 9:24 PM, Cristian Rodríguez
> >> <crrodriguez at opensuse.org> wrote:
> >>> Distributions such as openSUSE and probably others never included
> >>> upstart, in that case there is no need to include this code.
> >>>
> >>> This introduces --disable-upstartcompat, however upstart compat is still
> >>> enabled by default.
> >>
> >> I think we should just remove it, and leave it to people who actually
> >> need it to patch it back in, I doubt there are any left, really.
> > 
> > I agree. We can't test this anyway anymore. I'd be happy to merge a
> > patch that removes any Upstart compat support.
> > 
> > Lennart
> > 
> 
> OK, here we go...patch attached..
> 

What about removing the TELINIT define in configure.ac and the
associated machinery in systemctl.c? You'd need to fabricate a new error
message for when systemd isn't running and systemctl is called as the
name "init".

I also notice there's a comment in src/shared/utmp-wtmp.c that mentions
upstart, but it's actually incorrect: sysvinit uses PREVLEVEL as well.

d

> 
> 
> -- 
> "If debugging is the process of removing bugs, then programming must be
> the process of putting them in." - Edsger Dijkstra

> From c6040aaa4914123774295336a51f0630f7903586 Mon Sep 17 00:00:00 2001
> From: =?UTF-8?q?Cristian=20Rodr=C3=ADguez?= <crrodriguez at opensuse.org>
> Date: Sun, 29 Sep 2013 23:17:42 -0300
> Subject: [PATCH] remove legacy upstart compatibility
> 
> ---
>  src/systemctl/systemctl.c | 93 -----------------------------------------------
>  1 file changed, 93 deletions(-)
> 
> diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
> index eede616..bb7ada9 100644
> --- a/src/systemctl/systemctl.c
> +++ b/src/systemctl/systemctl.c
> @@ -5678,94 +5678,6 @@ _pure_ static int action_to_runlevel(void) {
>          return table[arg_action];
>  }
>  
> -static int talk_upstart(void) {
> -        _cleanup_dbus_message_unref_ DBusMessage *m = NULL, *reply = NULL;
> -        _cleanup_dbus_error_free_ DBusError error;
> -        int previous, rl, r;
> -        char
> -                env1_buf[] = "RUNLEVEL=X",
> -                env2_buf[] = "PREVLEVEL=X";
> -        char *env1 = env1_buf, *env2 = env2_buf;
> -        const char *emit = "runlevel";
> -        dbus_bool_t b_false = FALSE;
> -        DBusMessageIter iter, sub;
> -        DBusConnection *bus;
> -
> -        dbus_error_init(&error);
> -
> -        if (!(rl = action_to_runlevel()))
> -                return 0;
> -
> -        if (utmp_get_runlevel(&previous, NULL) < 0)
> -                previous = 'N';
> -
> -        if (!(bus = dbus_connection_open_private("unix:abstract=/com/ubuntu/upstart", &error))) {
> -                if (dbus_error_has_name(&error, DBUS_ERROR_NO_SERVER)) {
> -                        r = 0;
> -                        goto finish;
> -                }
> -
> -                log_error("Failed to connect to Upstart bus: %s", bus_error_message(&error));
> -                r = -EIO;
> -                goto finish;
> -        }
> -
> -        if ((r = bus_check_peercred(bus)) < 0) {
> -                log_error("Failed to verify owner of bus.");
> -                goto finish;
> -        }
> -
> -        if (!(m = dbus_message_new_method_call(
> -                              "com.ubuntu.Upstart",
> -                              "/com/ubuntu/Upstart",
> -                              "com.ubuntu.Upstart0_6",
> -                              "EmitEvent"))) {
> -
> -                log_error("Could not allocate message.");
> -                r = -ENOMEM;
> -                goto finish;
> -        }
> -
> -        dbus_message_iter_init_append(m, &iter);
> -
> -        env1_buf[sizeof(env1_buf)-2] = rl;
> -        env2_buf[sizeof(env2_buf)-2] = previous;
> -
> -        if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &emit) ||
> -            !dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "s", &sub) ||
> -            !dbus_message_iter_append_basic(&sub, DBUS_TYPE_STRING, &env1) ||
> -            !dbus_message_iter_append_basic(&sub, DBUS_TYPE_STRING, &env2) ||
> -            !dbus_message_iter_close_container(&iter, &sub) ||
> -            !dbus_message_iter_append_basic(&iter, DBUS_TYPE_BOOLEAN, &b_false)) {
> -                log_error("Could not append arguments to message.");
> -                r = -ENOMEM;
> -                goto finish;
> -        }
> -
> -        if (!(reply = dbus_connection_send_with_reply_and_block(bus, m, -1, &error))) {
> -
> -                if (bus_error_is_no_service(&error)) {
> -                        r = -EADDRNOTAVAIL;
> -                        goto finish;
> -                }
> -
> -                log_error("Failed to issue method call: %s", bus_error_message(&error));
> -                r = -EIO;
> -                goto finish;
> -        }
> -
> -        r = 1;
> -
> -finish:
> -        if (bus) {
> -                dbus_connection_flush(bus);
> -                dbus_connection_close(bus);
> -                dbus_connection_unref(bus);
> -        }
> -
> -        return r;
> -}
> -
>  static int talk_initctl(void) {
>          struct init_request request = {};
>          int r;
> @@ -6037,11 +5949,6 @@ static int start_with_fallback(DBusConnection *bus) {
>                          goto done;
>          }
>  
> -        /* Hmm, talking to systemd via D-Bus didn't work. Then
> -         * let's try to talk to Upstart via D-Bus. */
> -        if (talk_upstart() > 0)
> -                goto done;
> -
>          /* Nothing else worked, so let's try
>           * /dev/initctl */
>          if (talk_initctl() > 0)
> -- 
> 1.8.4
> 

> _______________________________________________
> systemd-devel mailing list
> systemd-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/systemd-devel



More information about the systemd-devel mailing list