[systemd-devel] [PATCH] Try to start rescue.target if default.target is missing

Kok, Auke-jan H auke-jan.h.kok at intel.com
Wed Sep 12 15:15:15 PDT 2012


On Tue, Sep 11, 2012 at 3:06 AM, Tomasz Torcz <tomek at pipebreaker.pl> wrote:
> From 0a3f3b2a46607a94efd2936ae7094a9ef7421e76 Mon Sep 17 00:00:00 2001
> From: Tomasz Torcz <tomek at pipebreaker.pl>
> Date: Fri, 7 Sep 2012 14:14:44 +0200
> Subject: [PATCH] Try to start rescue.target if default.target is missing
>
> In rare cases when default.target symlink is missing, systemd fails
> instantly and gets into reboot loop.
> Noticed by XReaper on IRC.
> Be a bit more resilient, try to fallback to rescue.target first.
> ---
>  src/core/main.c | 12 +++++++++++-
>  1 file changed, 11 insertions(+), 1 deletion(-)
>
> diff --git a/src/core/main.c b/src/core/main.c
> index 7b5c861..60e213a 100644
> --- a/src/core/main.c
> +++ b/src/core/main.c
> @@ -1301,7 +1301,17 @@ int main(int argc, char *argv[]) {
>          r = set_default_unit(SPECIAL_DEFAULT_TARGET);
>          if (r < 0) {
>                  log_error("Failed to set default unit %s: %s", SPECIAL_DEFAULT_TARGET, strerror(-r));
> -                goto finish;
> +
> +               if (arg_running_as == MANAGER_USER)
> +                       goto finish;
> +               else {
> +                       /* Give administrator a chance to fix things */
> +                       r = set_default_unit(SPECIAL_RESCUE_TARGET);
> +                       if (r < 0) {
> +                               log_error("Failed to set %s: %s", SPECIAL_RESCUE_TARGET, strerror(-r));
> +                               goto finish;
> +                       }
> +               }
>          }
>
>          /* By default, mount "cpu" and "cpuacct" together */

hmm

I wonder why default.target goes missing - after all systemd itself
installs a "default.target" file (not symlink!) under
/usr/lib/systemd/user/ (which in itself is horrible, but that's
another story).

A better approach to me sounds that a missing default.target would
result in an empty user session, where systemd just sits idle and
never spawns jobs unless manually instructed.

I often create new empty users and start a
user-session@<newuid>.service, then go and work on services for that
user after. Having a systemd --user come up without any configuration
to an "empty" state would help.

Auke


More information about the systemd-devel mailing list