X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fsystemctl.c;h=671745b7d001500ac5bfcf45d126960b88cdbee2;hb=b9080b03a98252ccccb332d0c892403b8b841916;hp=4beec0fca594d950e6af805d4e1aabad85b64aec;hpb=00dc5d769ac4a4019d6b6fe22e8383ec8b030a96;p=elogind.git diff --git a/src/systemctl.c b/src/systemctl.c index 4beec0fca..671745b7d 100644 --- a/src/systemctl.c +++ b/src/systemctl.c @@ -1568,6 +1568,7 @@ typedef struct UnitStatusInfo { const char *sub_state; const char *description; + const char *following; const char *path; const char *default_control_group; @@ -1629,6 +1630,9 @@ static void print_status_info(UnitStatusInfo *i) { printf("\n"); + if (i->following) + printf("\t Follow: unit currently follows state of %s\n", i->following); + if (streq_ptr(i->load_state, "failed") || streq_ptr(i->load_state, "banned")) { on = ansi_highlight(true); @@ -1675,9 +1679,9 @@ static void print_status_info(UnitStatusInfo *i) { s2 = format_timestamp(since2, sizeof(since2), timestamp); if (s1) - printf(" since [%s; %s]\n", s2, s1); + printf(" since %s; %s\n", s2, s1); else if (s2) - printf(" since [%s]\n", s2); + printf(" since %s\n", s2); else printf("\n"); @@ -1841,6 +1845,8 @@ static int status_property(const char *name, DBusMessageIter *iter, UnitStatusIn i->where = s; else if (streq(name, "What")) i->what = s; + else if (streq(name, "Following")) + i->following = s; } break; @@ -3221,6 +3227,7 @@ typedef struct { static Hashmap *will_install = NULL, *have_installed = NULL; static Set *remove_symlinks_to = NULL; +static unsigned n_symlinks = 0; static void install_info_free(InstallInfo *i) { assert(i); @@ -3247,7 +3254,7 @@ static int install_info_add(const char *name) { assert(will_install); - if (!unit_name_is_valid_no_type(name)) { + if (!unit_name_is_valid_no_type(name, true)) { log_warning("Unit name %s is not a valid unit name.", name); return -EINVAL; } @@ -3633,12 +3640,6 @@ static int install_info_symlink_alias(const char *verb, InstallInfo *i, const ch STRV_FOREACH(s, i->aliases) { - if (!unit_name_is_valid_no_type(*s)) { - log_error("Invalid name %s.", *s); - r = -EINVAL; - goto finish; - } - free(alias_path); if (!(alias_path = path_make_absolute(*s, config_path))) { log_error("Out of memory"); @@ -3670,7 +3671,7 @@ static int install_info_symlink_wants(const char *verb, InstallInfo *i, const ch assert(config_path); STRV_FOREACH(s, i->wanted_by) { - if (!unit_name_is_valid_no_type(*s)) { + if (!unit_name_is_valid_no_type(*s, true)) { log_error("Invalid name %s.", *s); r = -EINVAL; goto finish; @@ -3759,6 +3760,9 @@ static int install_info_apply(const char *verb, LookupPaths *paths, InstallInfo return r; } + n_symlinks += strv_length(i->aliases); + n_symlinks += strv_length(i->wanted_by); + fclose(f); if ((r = install_info_symlink_alias(verb, i, config_path)) != 0) @@ -3859,19 +3863,24 @@ static int enable_unit(DBusConnection *bus, char **args, unsigned n) { if (streq(verb, "is-enabled")) r = r > 0 ? 0 : -ENOENT; - else if (bus && - /* Don't try to reload anything if the user asked us to not do this */ - !arg_no_reload && - /* Don't try to reload anything when updating a unit globally */ - !arg_global && - /* Don't try to reload anything if we are called for system changes but the system wasn't booted with systemd */ - (arg_session || sd_booted() > 0) && - /* Don't try to reload anything if we are running in a chroot environment */ - (arg_session || running_in_chroot() <= 0) ) { - int q; + else { + if (n_symlinks <= 0) + log_warning("Unit files contain no applicable installation information. Ignoring."); + + if (bus && + /* Don't try to reload anything if the user asked us to not do this */ + !arg_no_reload && + /* Don't try to reload anything when updating a unit globally */ + !arg_global && + /* Don't try to reload anything if we are called for system changes but the system wasn't booted with systemd */ + (arg_session || sd_booted() > 0) && + /* Don't try to reload anything if we are running in a chroot environment */ + (arg_session || running_in_chroot() <= 0) ) { + int q; - if ((q = daemon_reload(bus, args, n)) < 0) - r = q; + if ((q = daemon_reload(bus, args, n)) < 0) + r = q; + } } finish: