Merge pull request #22649 from keszybz/symlink-enablement-yet-again-punish-me-harder
Fixups to the unit enablement logic
This commit is contained in:
@@ -2288,7 +2288,7 @@ fail:
|
||||
static int method_enable_unit_files_generic(
|
||||
sd_bus_message *message,
|
||||
Manager *m,
|
||||
int (*call)(UnitFileScope scope, UnitFileFlags flags, const char *root_dir, char *files[], UnitFileChange **changes, size_t *n_changes),
|
||||
int (*call)(LookupScope scope, UnitFileFlags flags, const char *root_dir, char *files[], UnitFileChange **changes, size_t *n_changes),
|
||||
bool carries_install_info,
|
||||
sd_bus_error *error) {
|
||||
|
||||
@@ -2352,7 +2352,7 @@ static int method_link_unit_files(sd_bus_message *message, void *userdata, sd_bu
|
||||
return method_enable_unit_files_generic(message, userdata, unit_file_link, false, error);
|
||||
}
|
||||
|
||||
static int unit_file_preset_without_mode(UnitFileScope scope, UnitFileFlags flags, const char *root_dir, char **files, UnitFileChange **changes, size_t *n_changes) {
|
||||
static int unit_file_preset_without_mode(LookupScope scope, UnitFileFlags flags, const char *root_dir, char **files, UnitFileChange **changes, size_t *n_changes) {
|
||||
return unit_file_preset(scope, flags, root_dir, files, UNIT_FILE_PRESET_FULL, changes, n_changes);
|
||||
}
|
||||
|
||||
@@ -2412,7 +2412,7 @@ static int method_preset_unit_files_with_mode(sd_bus_message *message, void *use
|
||||
static int method_disable_unit_files_generic(
|
||||
sd_bus_message *message,
|
||||
Manager *m,
|
||||
int (*call)(UnitFileScope scope, UnitFileFlags flags, const char *root_dir, char *files[], UnitFileChange **changes, size_t *n_changes),
|
||||
int (*call)(LookupScope scope, UnitFileFlags flags, const char *root_dir, char *files[], UnitFileChange **changes, size_t *n_changes),
|
||||
sd_bus_error *error) {
|
||||
|
||||
_cleanup_strv_free_ char **l = NULL;
|
||||
@@ -2638,7 +2638,7 @@ static int method_get_unit_file_links(sd_bus_message *message, void *userdata, s
|
||||
flags = UNIT_FILE_DRY_RUN |
|
||||
(runtime ? UNIT_FILE_RUNTIME : 0);
|
||||
|
||||
r = unit_file_disable(UNIT_FILE_SYSTEM, flags, NULL, p, &changes, &n_changes);
|
||||
r = unit_file_disable(LOOKUP_SCOPE_SYSTEM, flags, NULL, p, &changes, &n_changes);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to get file links for %s: %m", name);
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
||||
if (!getenv("SYSTEMD_LOG_LEVEL"))
|
||||
log_set_max_level(LOG_CRIT);
|
||||
|
||||
assert_se(manager_new(UNIT_FILE_SYSTEM, MANAGER_TEST_RUN_MINIMAL, &m) >= 0);
|
||||
assert_se(manager_new(LOOKUP_SCOPE_SYSTEM, MANAGER_TEST_RUN_MINIMAL, &m) >= 0);
|
||||
|
||||
name = strjoina("a.", unit_type_to_string(t));
|
||||
assert_se(unit_new_for_name(m, unit_vtable[t]->object_size, name, &u) >= 0);
|
||||
|
||||
+1
-1
@@ -2885,7 +2885,7 @@ int main(int argc, char *argv[]) {
|
||||
if (r < 0)
|
||||
goto finish;
|
||||
|
||||
r = manager_new(arg_system ? UNIT_FILE_SYSTEM : UNIT_FILE_USER,
|
||||
r = manager_new(arg_system ? LOOKUP_SCOPE_SYSTEM : LOOKUP_SCOPE_USER,
|
||||
arg_action == ACTION_TEST ? MANAGER_TEST_FULL : 0,
|
||||
&m);
|
||||
if (r < 0) {
|
||||
|
||||
+9
-9
@@ -775,13 +775,13 @@ static int manager_setup_sigchld_event_source(Manager *m) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int manager_new(UnitFileScope scope, ManagerTestRunFlags test_run_flags, Manager **_m) {
|
||||
int manager_new(LookupScope scope, ManagerTestRunFlags test_run_flags, Manager **_m) {
|
||||
_cleanup_(manager_freep) Manager *m = NULL;
|
||||
const char *e;
|
||||
int r;
|
||||
|
||||
assert(_m);
|
||||
assert(IN_SET(scope, UNIT_FILE_SYSTEM, UNIT_FILE_USER));
|
||||
assert(IN_SET(scope, LOOKUP_SCOPE_SYSTEM, LOOKUP_SCOPE_USER));
|
||||
|
||||
m = new(Manager, 1);
|
||||
if (!m)
|
||||
@@ -1700,7 +1700,7 @@ static void manager_preset_all(Manager *m) {
|
||||
return;
|
||||
|
||||
/* If this is the first boot, and we are in the host system, then preset everything */
|
||||
r = unit_file_preset_all(UNIT_FILE_SYSTEM, 0, NULL, UNIT_FILE_PRESET_ENABLE_ONLY, NULL, 0);
|
||||
r = unit_file_preset_all(LOOKUP_SCOPE_SYSTEM, 0, NULL, UNIT_FILE_PRESET_ENABLE_ONLY, NULL, 0);
|
||||
if (r < 0)
|
||||
log_full_errno(r == -EEXIST ? LOG_NOTICE : LOG_WARNING, r,
|
||||
"Failed to populate /etc with preset unit settings, ignoring: %m");
|
||||
@@ -1751,11 +1751,11 @@ int manager_startup(Manager *m, FILE *serialization, FDSet *fds, const char *roo
|
||||
|
||||
/* If we are running in test mode, we still want to run the generators,
|
||||
* but we should not touch the real generator directories. */
|
||||
r = lookup_paths_init(&m->lookup_paths, m->unit_file_scope,
|
||||
MANAGER_IS_TEST_RUN(m) ? LOOKUP_PATHS_TEMPORARY_GENERATED : 0,
|
||||
root);
|
||||
r = lookup_paths_init_or_warn(&m->lookup_paths, m->unit_file_scope,
|
||||
MANAGER_IS_TEST_RUN(m) ? LOOKUP_PATHS_TEMPORARY_GENERATED : 0,
|
||||
root);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to initialize path lookup table: %m");
|
||||
return r;
|
||||
|
||||
dual_timestamp_get(m->timestamps + manager_timestamp_initrd_mangle(MANAGER_TIMESTAMP_GENERATORS_START));
|
||||
r = manager_run_environment_generators(m);
|
||||
@@ -3343,9 +3343,9 @@ int manager_reload(Manager *m) {
|
||||
m->uid_refs = hashmap_free(m->uid_refs);
|
||||
m->gid_refs = hashmap_free(m->gid_refs);
|
||||
|
||||
r = lookup_paths_init(&m->lookup_paths, m->unit_file_scope, 0, NULL);
|
||||
r = lookup_paths_init_or_warn(&m->lookup_paths, m->unit_file_scope, 0, NULL);
|
||||
if (r < 0)
|
||||
log_warning_errno(r, "Failed to initialize path lookup table, ignoring: %m");
|
||||
return r;
|
||||
|
||||
(void) manager_run_environment_generators(m);
|
||||
(void) manager_run_generators(m);
|
||||
|
||||
+4
-4
@@ -235,7 +235,7 @@ struct Manager {
|
||||
int user_lookup_fds[2];
|
||||
sd_event_source *user_lookup_event_source;
|
||||
|
||||
UnitFileScope unit_file_scope;
|
||||
LookupScope unit_file_scope;
|
||||
LookupPaths lookup_paths;
|
||||
Hashmap *unit_id_map;
|
||||
Hashmap *unit_name_map;
|
||||
@@ -463,8 +463,8 @@ static inline usec_t manager_default_timeout_abort_usec(Manager *m) {
|
||||
return m->default_timeout_abort_set ? m->default_timeout_abort_usec : m->default_timeout_stop_usec;
|
||||
}
|
||||
|
||||
#define MANAGER_IS_SYSTEM(m) ((m)->unit_file_scope == UNIT_FILE_SYSTEM)
|
||||
#define MANAGER_IS_USER(m) ((m)->unit_file_scope != UNIT_FILE_SYSTEM)
|
||||
#define MANAGER_IS_SYSTEM(m) ((m)->unit_file_scope == LOOKUP_SCOPE_SYSTEM)
|
||||
#define MANAGER_IS_USER(m) ((m)->unit_file_scope != LOOKUP_SCOPE_SYSTEM)
|
||||
|
||||
#define MANAGER_IS_RELOADING(m) ((m)->n_reloading > 0)
|
||||
|
||||
@@ -475,7 +475,7 @@ static inline usec_t manager_default_timeout_abort_usec(Manager *m) {
|
||||
|
||||
#define MANAGER_IS_TEST_RUN(m) ((m)->test_run_flags != 0)
|
||||
|
||||
int manager_new(UnitFileScope scope, ManagerTestRunFlags test_run_flags, Manager **m);
|
||||
int manager_new(LookupScope scope, ManagerTestRunFlags test_run_flags, Manager **m);
|
||||
Manager* manager_free(Manager *m);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(Manager*, manager_free);
|
||||
|
||||
|
||||
@@ -183,7 +183,7 @@ int unit_name_printf(const Unit *u, const char* format, char **ret) {
|
||||
|
||||
COMMON_SYSTEM_SPECIFIERS,
|
||||
|
||||
COMMON_CREDS_SPECIFIERS,
|
||||
COMMON_CREDS_SPECIFIERS(u->manager->unit_file_scope),
|
||||
{}
|
||||
};
|
||||
|
||||
@@ -253,7 +253,7 @@ int unit_full_printf_full(const Unit *u, const char *format, size_t max_length,
|
||||
|
||||
COMMON_SYSTEM_SPECIFIERS,
|
||||
|
||||
COMMON_CREDS_SPECIFIERS,
|
||||
COMMON_CREDS_SPECIFIERS(u->manager->unit_file_scope),
|
||||
|
||||
COMMON_TMP_SPECIFIERS,
|
||||
{}
|
||||
|
||||
Reference in New Issue
Block a user