systemctl: add new enablement state "alias"
For units which are aliases of other units, reporting preset status as "enabled" is rather misleading. For example, dbus.service is an alias of dbus-broker.service. In list-unit-files we'd show both as "enabled". In particular, systemctl preset ignores aliases, so showing any preset status at all is always going to be misleading. Let's introduce a new state "alias" and use that for all aliases. I was trying to avoid adding a new state, to keep compatibility with previous behaviour, but for alias unit files it simply doesn't seem very useful to show any of the existing states. It seems that the clearly showing that those are aliases for other units will be easiest to understand for users.
This commit is contained in:
@@ -2767,6 +2767,12 @@ int unit_file_lookup_state(
|
||||
break;
|
||||
|
||||
case UNIT_FILE_TYPE_REGULAR:
|
||||
/* Check if the name we were querying is actually an alias */
|
||||
if (!streq(name, basename(i->path)) && !unit_name_is_valid(i->name, UNIT_NAME_INSTANCE)) {
|
||||
state = UNIT_FILE_ALIAS;
|
||||
break;
|
||||
}
|
||||
|
||||
r = path_is_generator(paths, i->path);
|
||||
if (r < 0)
|
||||
return r;
|
||||
@@ -3420,6 +3426,7 @@ static const char* const unit_file_state_table[_UNIT_FILE_STATE_MAX] = {
|
||||
[UNIT_FILE_ENABLED_RUNTIME] = "enabled-runtime",
|
||||
[UNIT_FILE_LINKED] = "linked",
|
||||
[UNIT_FILE_LINKED_RUNTIME] = "linked-runtime",
|
||||
[UNIT_FILE_ALIAS] = "alias",
|
||||
[UNIT_FILE_MASKED] = "masked",
|
||||
[UNIT_FILE_MASKED_RUNTIME] = "masked-runtime",
|
||||
[UNIT_FILE_STATIC] = "static",
|
||||
|
||||
@@ -16,6 +16,7 @@ enum UnitFileState {
|
||||
UNIT_FILE_ENABLED_RUNTIME,
|
||||
UNIT_FILE_LINKED,
|
||||
UNIT_FILE_LINKED_RUNTIME,
|
||||
UNIT_FILE_ALIAS,
|
||||
UNIT_FILE_MASKED,
|
||||
UNIT_FILE_MASKED_RUNTIME,
|
||||
UNIT_FILE_STATIC,
|
||||
|
||||
Reference in New Issue
Block a user