diff options
-rw-r--r-- | src/core/dbus-manager.c | 52 | ||||
-rw-r--r-- | src/machine/machinectl.c | 4 | ||||
-rw-r--r-- | src/portable/portablectl.c | 4 | ||||
-rw-r--r-- | src/shared/bus-unit-util.c | 8 | ||||
-rw-r--r-- | src/shared/bus-unit-util.h | 2 | ||||
-rw-r--r-- | src/shared/install.c | 142 | ||||
-rw-r--r-- | src/shared/install.h | 38 | ||||
-rw-r--r-- | src/systemctl/systemctl-add-dependency.c | 6 | ||||
-rw-r--r-- | src/systemctl/systemctl-enable.c | 6 | ||||
-rw-r--r-- | src/systemctl/systemctl-is-enabled.c | 2 | ||||
-rw-r--r-- | src/systemctl/systemctl-preset-all.c | 6 | ||||
-rw-r--r-- | src/systemctl/systemctl-set-default.c | 6 | ||||
-rw-r--r-- | src/test/test-install-root.c | 114 | ||||
-rw-r--r-- | src/test/test-install.c | 34 | ||||
-rwxr-xr-x | test/test-exec-deserialization.py | 29 |
15 files changed, 226 insertions, 227 deletions
diff --git a/src/core/dbus-manager.c b/src/core/dbus-manager.c index 73f739b12d..73810833ca 100644 --- a/src/core/dbus-manager.c +++ b/src/core/dbus-manager.c @@ -2122,12 +2122,12 @@ static int send_unit_files_changed(sd_bus *bus, void *userdata) { * if possible, and fall back to generating an error from error code c. * The error message only describes the first error. * - * Coordinate with unit_file_dump_changes() in install.c. + * Coordinate with install_changes_dump() in install.c. */ static int install_error( sd_bus_error *error, int c, - UnitFileChange *changes, + InstallChange *changes, size_t n_changes) { int r; @@ -2186,15 +2186,15 @@ static int install_error( r = c < 0 ? c : -EINVAL; found: - unit_file_changes_free(changes, n_changes); + install_changes_free(changes, n_changes); return r; } -static int reply_unit_file_changes_and_free( +static int reply_install_changes_and_free( Manager *m, sd_bus_message *message, int carries_install_info, - UnitFileChange *changes, + InstallChange *changes, size_t n_changes, sd_bus_error *error) { @@ -2202,7 +2202,7 @@ static int reply_unit_file_changes_and_free( bool bad = false, good = false; int r; - if (unit_file_changes_have_modification(changes, n_changes)) { + if (install_changes_have_modification(changes, n_changes)) { r = bus_foreach_bus(m, NULL, send_unit_files_changed, NULL); if (r < 0) log_debug_errno(r, "Failed to send UnitFilesChanged signal: %m"); @@ -2249,23 +2249,23 @@ static int reply_unit_file_changes_and_free( if (r < 0) goto fail; - unit_file_changes_free(changes, n_changes); + install_changes_free(changes, n_changes); return sd_bus_send(NULL, reply, NULL); fail: - unit_file_changes_free(changes, n_changes); + install_changes_free(changes, n_changes); return r; } static int method_enable_unit_files_generic( sd_bus_message *message, Manager *m, - int (*call)(LookupScope 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[], InstallChange **changes, size_t *n_changes), bool carries_install_info, sd_bus_error *error) { _cleanup_strv_free_ char **l = NULL; - UnitFileChange *changes = NULL; + InstallChange *changes = NULL; size_t n_changes = 0; UnitFileFlags flags; int r; @@ -2305,7 +2305,7 @@ static int method_enable_unit_files_generic( if (r < 0) return install_error(error, r, changes, n_changes); - return reply_unit_file_changes_and_free(m, message, carries_install_info ? r : -1, changes, n_changes, error); + return reply_install_changes_and_free(m, message, carries_install_info ? r : -1, changes, n_changes, error); } static int method_enable_unit_files_with_flags(sd_bus_message *message, void *userdata, sd_bus_error *error) { @@ -2324,7 +2324,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(LookupScope 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, InstallChange **changes, size_t *n_changes) { return unit_file_preset(scope, flags, root_dir, files, UNIT_FILE_PRESET_FULL, changes, n_changes); } @@ -2339,7 +2339,7 @@ static int method_mask_unit_files(sd_bus_message *message, void *userdata, sd_bu static int method_preset_unit_files_with_mode(sd_bus_message *message, void *userdata, sd_bus_error *error) { _cleanup_strv_free_ char **l = NULL; - UnitFileChange *changes = NULL; + InstallChange *changes = NULL; size_t n_changes = 0; Manager *m = ASSERT_PTR(userdata); UnitFilePresetMode preset_mode; @@ -2377,17 +2377,17 @@ static int method_preset_unit_files_with_mode(sd_bus_message *message, void *use if (r < 0) return install_error(error, r, changes, n_changes); - return reply_unit_file_changes_and_free(m, message, r, changes, n_changes, error); + return reply_install_changes_and_free(m, message, r, changes, n_changes, error); } static int method_disable_unit_files_generic( sd_bus_message *message, Manager *m, - int (*call)(LookupScope 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[], InstallChange **changes, size_t *n_changes), sd_bus_error *error) { _cleanup_strv_free_ char **l = NULL; - UnitFileChange *changes = NULL; + InstallChange *changes = NULL; UnitFileFlags flags; size_t n_changes = 0; int r; @@ -2428,7 +2428,7 @@ static int method_disable_unit_files_generic( if (r < 0) return install_error(error, r, changes, n_changes); - return reply_unit_file_changes_and_free(m, message, -1, changes, n_changes, error); + return reply_install_changes_and_free(m, message, -1, changes, n_changes, error); } static int method_disable_unit_files_with_flags(sd_bus_message *message, void *userdata, sd_bus_error *error) { @@ -2445,7 +2445,7 @@ static int method_unmask_unit_files(sd_bus_message *message, void *userdata, sd_ static int method_revert_unit_files(sd_bus_message *message, void *userdata, sd_bus_error *error) { _cleanup_strv_free_ char **l = NULL; - UnitFileChange *changes = NULL; + InstallChange *changes = NULL; size_t n_changes = 0; Manager *m = ASSERT_PTR(userdata); int r; @@ -2466,11 +2466,11 @@ static int method_revert_unit_files(sd_bus_message *message, void *userdata, sd_ if (r < 0) return install_error(error, r, changes, n_changes); - return reply_unit_file_changes_and_free(m, message, -1, changes, n_changes, error); + return reply_install_changes_and_free(m, message, -1, changes, n_changes, error); } static int method_set_default_target(sd_bus_message *message, void *userdata, sd_bus_error *error) { - UnitFileChange *changes = NULL; + InstallChange *changes = NULL; size_t n_changes = 0; Manager *m = ASSERT_PTR(userdata); const char *name; @@ -2496,11 +2496,11 @@ static int method_set_default_target(sd_bus_message *message, void *userdata, sd if (r < 0) return install_error(error, r, changes, n_changes); - return reply_unit_file_changes_and_free(m, message, -1, changes, n_changes, error); + return reply_install_changes_and_free(m, message, -1, changes, n_changes, error); } static int method_preset_all_unit_files(sd_bus_message *message, void *userdata, sd_bus_error *error) { - UnitFileChange *changes = NULL; + InstallChange *changes = NULL; size_t n_changes = 0; Manager *m = ASSERT_PTR(userdata); UnitFilePresetMode preset_mode; @@ -2538,13 +2538,13 @@ static int method_preset_all_unit_files(sd_bus_message *message, void *userdata, if (r < 0) return install_error(error, r, changes, n_changes); - return reply_unit_file_changes_and_free(m, message, -1, changes, n_changes, error); + return reply_install_changes_and_free(m, message, -1, changes, n_changes, error); } static int method_add_dependency_unit_files(sd_bus_message *message, void *userdata, sd_bus_error *error) { _cleanup_strv_free_ char **l = NULL; Manager *m = ASSERT_PTR(userdata); - UnitFileChange *changes = NULL; + InstallChange *changes = NULL; size_t n_changes = 0; int runtime, force, r; char *target, *type; @@ -2577,12 +2577,12 @@ static int method_add_dependency_unit_files(sd_bus_message *message, void *userd if (r < 0) return install_error(error, r, changes, n_changes); - return reply_unit_file_changes_and_free(m, message, -1, changes, n_changes, error); + return reply_install_changes_and_free(m, message, -1, changes, n_changes, error); } static int method_get_unit_file_links(sd_bus_message *message, void *userdata, sd_bus_error *error) { _cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL; - UnitFileChange *changes = NULL; + InstallChange *changes = NULL; size_t n_changes = 0, i; UnitFileFlags flags; const char *name; diff --git a/src/machine/machinectl.c b/src/machine/machinectl.c index db29e3092b..eac26bc4d3 100644 --- a/src/machine/machinectl.c +++ b/src/machine/machinectl.c @@ -1599,7 +1599,7 @@ static int start_machine(int argc, char *argv[], void *userdata) { static int enable_machine(int argc, char *argv[], void *userdata) { _cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL, *reply = NULL; _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL; - UnitFileChange *changes = NULL; + InstallChange *changes = NULL; size_t n_changes = 0; const char *method = NULL; sd_bus *bus = ASSERT_PTR(userdata); @@ -1671,7 +1671,7 @@ static int enable_machine(int argc, char *argv[], void *userdata) { r = 0; finish: - unit_file_changes_free(changes, n_changes); + install_changes_free(changes, n_changes); return r; } diff --git a/src/portable/portablectl.c b/src/portable/portablectl.c index 6ee9ee8f43..341e70621f 100644 --- a/src/portable/portablectl.c +++ b/src/portable/portablectl.c @@ -540,7 +540,7 @@ static int maybe_enable_disable(sd_bus *bus, const char *path, bool enable) { _cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL, *reply = NULL; _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL; _cleanup_strv_free_ char **names = NULL; - UnitFileChange *changes = NULL; + InstallChange *changes = NULL; const uint64_t flags = UNIT_FILE_PORTABLE | (arg_runtime ? UNIT_FILE_RUNTIME : 0); size_t n_changes = 0; int r; @@ -582,7 +582,7 @@ static int maybe_enable_disable(sd_bus *bus, const char *path, bool enable) { } (void) bus_deserialize_and_dump_unit_file_changes(reply, arg_quiet, &changes, &n_changes); - unit_file_changes_free(changes, n_changes); + install_changes_free(changes, n_changes); return 0; } diff --git a/src/shared/bus-unit-util.c b/src/shared/bus-unit-util.c index 2bf0d855b1..9b46b732ff 100644 --- a/src/shared/bus-unit-util.c +++ b/src/shared/bus-unit-util.c @@ -2668,11 +2668,11 @@ int bus_append_unit_property_assignment_many(sd_bus_message *m, UnitType t, char return 0; } -int bus_deserialize_and_dump_unit_file_changes(sd_bus_message *m, bool quiet, UnitFileChange **changes, size_t *n_changes) { +int bus_deserialize_and_dump_unit_file_changes(sd_bus_message *m, bool quiet, InstallChange **changes, size_t *n_changes) { const char *type, *path, *source; int r; - /* changes is dereferenced when calling unit_file_dump_changes() later, + /* changes is dereferenced when calling install_changes_dump() later, * so we have to make sure this is not NULL. */ assert(changes); assert(n_changes); @@ -2691,7 +2691,7 @@ int bus_deserialize_and_dump_unit_file_changes(sd_bus_message *m, bool quiet, Un continue; } - r = unit_file_changes_add(changes, n_changes, ch, path, source); + r = install_changes_add(changes, n_changes, ch, path, source); if (r < 0) return r; } @@ -2702,7 +2702,7 @@ int bus_deserialize_and_dump_unit_file_changes(sd_bus_message *m, bool quiet, Un if (r < 0) return bus_log_parse_error(r); - unit_file_dump_changes(0, NULL, *changes, *n_changes, quiet); + install_changes_dump(0, NULL, *changes, *n_changes, quiet); return 0; } diff --git a/src/shared/bus-unit-util.h b/src/shared/bus-unit-util.h index 999caf65cd..789a142e1d 100644 --- a/src/shared/bus-unit-util.h +++ b/src/shared/bus-unit-util.h @@ -25,7 +25,7 @@ int bus_parse_unit_info(sd_bus_message *message, UnitInfo *u); int bus_append_unit_property_assignment(sd_bus_message *m, UnitType t, const char *assignment); int bus_append_unit_property_assignment_many(sd_bus_message *m, UnitType t, char **l); -int bus_deserialize_and_dump_unit_file_changes(sd_bus_message *m, bool quiet, UnitFileChange **changes, size_t *n_changes); +int bus_deserialize_and_dump_unit_file_changes(sd_bus_message *m, bool quiet, InstallChange **changes, size_t *n_changes); int unit_load_state(sd_bus *bus, const char *name, char **load_state); diff --git a/src/shared/install.c b/src/shared/install.c index 5da26eeb21..3d74a9ba79 100644 --- a/src/shared/install.c +++ b/src/shared/install.c @@ -265,15 +265,15 @@ static const char* config_path_from_flags(const LookupPaths *lp, UnitFileFlags f return FLAGS_SET(flags, UNIT_FILE_RUNTIME) ? lp->runtime_config : lp->persistent_config; } -int unit_file_changes_add( - UnitFileChange **changes, +int install_changes_add( + InstallChange **changes, size_t *n_changes, int type_or_errno, /* UNIT_FILE_SYMLINK, _UNLINK, _IS_MASKED, _IS_DANGLING if positive or errno if negative */ const char *path, const char *source) { _cleanup_free_ char *p = NULL, *s = NULL; - UnitFileChange *c; + InstallChange *c; assert(!changes == !n_changes); @@ -285,7 +285,7 @@ int unit_file_changes_add( if (!changes) return 0; - c = reallocarray(*changes, *n_changes + 1, sizeof(UnitFileChange)); + c = reallocarray(*changes, *n_changes + 1, sizeof(InstallChange)); if (!c) return -ENOMEM; *changes = c; @@ -306,7 +306,7 @@ int unit_file_changes_add( path_simplify(s); } - c[(*n_changes)++] = (UnitFileChange) { + c[(*n_changes)++] = (InstallChange) { .type_or_errno = type_or_errno, .path = TAKE_PTR(p), .source = TAKE_PTR(s), @@ -315,7 +315,7 @@ int unit_file_changes_add( return 0; } -void unit_file_changes_free(UnitFileChange *changes, size_t n_changes) { +void install_changes_free(InstallChange *changes, size_t n_changes) { assert(changes || n_changes == 0); for (size_t i = 0; i < n_changes; i++) { @@ -326,7 +326,7 @@ void unit_file_changes_free(UnitFileChange *changes, size_t n_changes) { free(changes); } -void unit_file_dump_changes(int r, const char *verb, const UnitFileChange *changes, size_t n_changes, bool quiet) { +void install_changes_dump(int r, const char *verb, const InstallChange *changes, size_t n_changes, bool quiet) { int err = 0; assert(changes || n_changes == 0); @@ -484,7 +484,7 @@ static int create_symlink( const char *old_path, const char *new_path, bool force, - UnitFileChange **changes, + InstallChange **changes, size_t *n_changes) { _cleanup_free_ char *dest = NULL; @@ -508,12 +508,12 @@ static int create_symlink( (void) mkdir_parents_label(new_path, 0755); if (symlink(old_path, new_path) >= 0) { - unit_file_changes_add(changes, n_changes, UNIT_FILE_SYMLINK, new_path, old_path); + install_changes_add(changes, n_changes, UNIT_FILE_SYMLINK, new_path, old_path); return 1; } if (errno != EEXIST) { - unit_file_changes_add(changes, n_changes, -errno, new_path, NULL); + install_changes_add(changes, n_changes, -errno, new_path, NULL); return -errno; } @@ -523,7 +523,7 @@ static int create_symlink( if (r == -EINVAL) r = -EEXIST; - unit_file_changes_add(changes, n_changes, r, new_path, NULL); + install_changes_add(changes, n_changes, r, new_path, NULL); return r; } @@ -534,18 +534,18 @@ static int create_symlink( } if (!force) { - unit_file_changes_add(changes, n_changes, -EEXIST, new_path, dest); + install_changes_add(changes, n_changes, -EEXIST, new_path, dest); return -EEXIST; } r = symlink_atomic(old_path, new_path); if (r < 0) { - unit_file_changes_add(changes, n_changes, r, new_path, NULL); + install_changes_add(changes, n_changes, r, new_path, NULL); return r; } - unit_file_changes_add(changes, n_changes, UNIT_FILE_UNLINK, new_path, NULL); - unit_file_changes_add(changes, n_changes, UNIT_FILE_SYMLINK, new_path, old_path); + install_changes_add(changes, n_changes, UNIT_FILE_UNLINK, new_path, NULL); + install_changes_add(changes, n_changes, UNIT_FILE_SYMLINK, new_path, old_path); return 1; } @@ -586,7 +586,7 @@ static int remove_marked_symlinks_fd( const LookupPaths *lp, bool dry_run, bool *restart, - UnitFileChange **changes, + InstallChange **changes, size_t *n_changes) { _cleanup_closedir_ DIR *d = NULL; @@ -671,7 +671,7 @@ static int remove_marked_symlinks_fd( continue; if (q < 0) { log_debug_errno(q, "Failed to resolve symlink \"%s\": %m", p); - unit_file_changes_add(changes, n_changes, q, p, NULL); + install_changes_add(changes, n_changes, q, p, NULL); if (r == 0) r = q; @@ -691,14 +691,14 @@ static int remove_marked_symlinks_fd( if (unlinkat(fd, de->d_name, 0) < 0 && errno != ENOENT) { if (r == 0) r = -errno; - unit_file_changes_add(changes, n_changes, -errno, p, NULL); + install_changes_add(changes, n_changes, -errno, p, NULL); continue; } (void) rmdir_parents(p, config_path); } - unit_file_changes_add(changes, n_changes, UNIT_FILE_UNLINK, p, NULL); + install_changes_add(changes, n_changes, UNIT_FILE_UNLINK, p, NULL); /* Now, remember the full path (but with the root prefix removed) of * the symlink we just removed, and remove any symlinks to it, too. */ @@ -719,7 +719,7 @@ static int remove_marked_symlinks( const char *config_path, const LookupPaths *lp, bool dry_run, - UnitFileChange **changes, + InstallChange **changes, size_t *n_changes) { _cleanup_close_ int fd = -1; @@ -1076,7 +1076,7 @@ static UnitFileInstallInfo *install_info_find(InstallContext *ctx, const char *n static int install_info_may_process( const UnitFileInstallInfo *i, const LookupPaths *lp, - UnitFileChange **changes, + InstallChange **changes, size_t *n_changes) { assert(i); assert(lp); @@ -1085,12 +1085,12 @@ static int install_info_may_process( * transient or generated and thus not subject to enable/disable operations. */ if (i->type == UNIT_FILE_TYPE_MASKED) { - unit_file_changes_add(changes, n_changes, -ERFKILL, i->path, NULL); + install_changes_add(changes, n_changes, -ERFKILL, i->path, NULL); return -ERFKILL; } if (path_is_generator(lp, i->path) || path_is_transient(lp, i->path)) { - unit_file_changes_add(changes, n_changes, -EADDRNOTAVAIL, i->path, NULL); + install_changes_add(changes, n_changes, -EADDRNOTAVAIL, i->path, NULL); return -EADDRNOTAVAIL; } @@ -1731,7 +1731,7 @@ static int install_info_discover( const char *name_or_path, SearchFlags flags, UnitFileInstallInfo **ret, - UnitFileChange **changes, + InstallChange **changes, size_t *n_changes) { UnitFileInstallInfo *info; @@ -1746,7 +1746,7 @@ static int install_info_discover( r = install_info_traverse(ctx, lp, info, flags, ret); if (r < 0) - unit_file_changes_add(changes, n_changes, r, name_or_path, NULL); + install_changes_add(changes, n_changes, r, name_or_path, NULL); return r; } @@ -1756,7 +1756,7 @@ static int install_info_discover_and_check( const char *name_or_path, SearchFlags flags, UnitFileInstallInfo **ret, - UnitFileChange **changes, + InstallChange **changes, size_t *n_changes) { int r; @@ -1772,7 +1772,7 @@ int unit_file_verify_alias( const UnitFileInstallInfo *info, const char *dst, char **ret_dst, - UnitFileChange **changes, + InstallChange **changes, size_t *n_changes) { _cleanup_free_ char *dst_updated = NULL; @@ -1807,7 +1807,7 @@ int unit_file_verify_alias( if (!p) p = endswith(dir, ".requires"); if (!p) { - unit_file_changes_add(changes, n_changes, -EXDEV, dst, NULL); + install_changes_add(changes, n_changes, -EXDEV, dst, NULL); return log_debug_errno(SYNTHETIC_ERRNO(EXDEV), "Invalid path \"%s\" in alias.", dir); } @@ -1815,7 +1815,7 @@ int unit_file_verify_alias( UnitNameFlags type = unit_name_classify(dir); if (type < 0) { - unit_file_changes_add(changes, n_changes, -EXDEV, dst, NULL); + install_changes_add(changes, n_changes, -EXDEV, dst, NULL); return log_debug_errno(SYNTHETIC_ERRNO(EXDEV), "Invalid unit name component \"%s\" in alias.", dir); } @@ -1827,7 +1827,7 @@ int unit_file_verify_alias( if (r < 0) return log_error_errno(r, "Failed to verify alias validity: %m"); if (r == 0) { - unit_file_changes_add(changes, n_changes, -EXDEV, dst, info->name); + install_changes_add(changes, n_changes, -EXDEV, dst, info->name); return log_debug_errno(SYNTHETIC_ERRNO(EXDEV), "Invalid unit \"%s\" symlink \"%s\".", info->name, dst); @@ -1841,7 +1841,7 @@ int unit_file_verify_alias( UnitNameFlags type = unit_name_to_instance(info->name, &inst); if (type < 0) { - unit_file_changes_add(changes, n_changes, -EUCLEAN, info->name, NULL); + install_changes_add(changes, n_changes, -EUCLEAN, info->name, NULL); return log_debug_errno(type, "Failed to extract instance name from \"%s\": %m", info->name); } @@ -1857,7 +1857,7 @@ int unit_file_verify_alias( if (r == -ELOOP) /* -ELOOP means self-alias, which we (quietly) ignore */ return r; if (r < 0) { - unit_file_changes_add(changes, n_changes, + install_changes_add(changes, n_changes, r == -EINVAL ? -EXDEV : r, dst_updated ?: dst, info->name); @@ -1875,7 +1875,7 @@ static int install_info_symlink_alias( const LookupPaths *lp, const char *config_path, bool force, - UnitFileChange **changes, + InstallChange **changes, size_t *n_changes) { int r = 0, q; @@ -1889,7 +1889,7 @@ static int install_info_symlink_alias( q = install_name_printf(scope, info, *s, &dst); if (q < 0) { - unit_file_changes_add(changes, n_changes, q, *s, NULL); + install_changes_add(changes, n_changes, q, *s, NULL); r = r < 0 ? r : q; continue; } @@ -1921,7 +1921,7 @@ static int install_info_symlink_wants( const char *config_path, char **list, const char *suffix, - UnitFileChange **changes, + InstallChange **changes, size_t *n_changes) { _cleanup_free_ char *buf = NULL; @@ -1960,7 +1960,7 @@ static int install_info_symlink_wants( path = TAKE_PTR(instance.path); if (instance.type == UNIT_FILE_TYPE_MASKED) { - unit_file_changes_add(changes, n_changes, -ERFKILL, path, NULL); + install_changes_add(changes, n_changes, -ERFKILL, path, NULL); return -ERFKILL; } @@ -1979,7 +1979,7 @@ static int install_info_symlink_wants( q = install_name_printf(scope, info, *s, &dst); if (q < 0) { - unit_file_changes_add(changes, n_changes, q, *s, NULL); + install_changes_add(changes, n_changes, q, *s, NULL); return q; } @@ -1995,10 +1995,10 @@ static int install_info_symlink_wants( continue; if (unit_name_is_valid(dst, UNIT_NAME_ANY)) { - unit_file_changes_add(changes, n_changes, -EIDRM, dst, n); + install_changes_add(changes, n_changes, -EIDRM, dst, n); r = -EIDRM; } else { - unit_file_changes_add(changes, n_changes, -EUCLEAN, dst, NULL); + install_changes_add(changes, n_changes, -EUCLEAN, dst, NULL); r = -EUCLEAN; } @@ -2014,7 +2014,7 @@ static int install_info_symlink_wants( r = q; if (unit_file_exists(scope, lp, dst) == 0) - unit_file_changes_add(changes, n_changes, UNIT_FILE_DESTINATION_NOT_PRESENT, dst, info->path); + install_changes_add(changes, n_changes, UNIT_FILE_DESTINATION_NOT_PRESENT, dst, info->path); } return r; @@ -2025,7 +2025,7 @@ static int install_info_symlink_link( const LookupPaths *lp, const char *config_path, bool force, - UnitFileChange **changes, + InstallChange **changes, size_t *n_changes) { _cleanup_free_ char *path = NULL; @@ -2055,7 +2055,7 @@ static int install_info_apply( UnitFileInstallInfo *info, const LookupPaths *lp, const char *config_path, - UnitFileChange **changes, + InstallChange **changes, size_t *n_changes) { int r, q; @@ -2095,7 +2095,7 @@ static int install_context_apply( UnitFileFlags file_flags, const char *config_path, SearchFlags flags, - UnitFileChange **changes, + InstallChange **changes, size_t *n_changes) { UnitFileInstallInfo *i; @@ -2123,20 +2123,20 @@ static int install_context_apply( q = install_info_traverse(ctx, lp, i, flags, NULL); if (q < 0) { if (i->auxiliary) { - q = unit_file_changes_add(changes, n_changes, UNIT_FILE_AUXILIARY_FAILED, NULL, i->name); + q = install_changes_add(changes, n_changes, UNIT_FILE_AUXILIARY_FAILED, NULL, i->name); if (q < 0) return q; continue; } - unit_file_changes_add(changes, n_changes, q, i->name, NULL); + install_changes_add(changes, n_changes, q, i->name, NULL); return q; } /* We can attempt to process a masked unit when a different unit * that we were processing specifies it in Also=. */ if (i->type == UNIT_FILE_TYPE_MASKED) { - unit_file_changes_add(changes, n_changes, UNIT_FILE_IS_MASKED, i->path, NULL); + install_changes_add(changes, n_changes, UNIT_FILE_IS_MASKED, i->path, NULL); if (r >= 0) /* Assume that something *could* have been enabled here, * avoid "empty [Install] section" warning. */ @@ -2164,7 +2164,7 @@ static int install_context_mark_for_removal( const LookupPaths *lp, Set **remove_symlinks_to, const char *config_path, - UnitFileChange **changes, + InstallChange **changes, size_t *n_changes) { UnitFileInstallInfo *i; @@ -2192,22 +2192,22 @@ static int install_context_mark_for_removal( r = install_info_traverse(ctx, lp, i, SEARCH_LOAD|SEARCH_FOLLOW_CONFIG_SYMLINKS, NULL); if (r == -ENOLINK) { log_debug_errno(r, "Name %s leads to a dangling symlink, removing name.", i->name); - unit_file_changes_add(changes, n_changes, UNIT_FILE_IS_DANGLING, i->path ?: i->name, NULL); + install_changes_add(changes, n_changes, UNIT_FILE_IS_DANGLING, i->path ?: i->name, NULL); } else if (r == -ENOENT) { if (i->auxiliary) /* some unit specified in Also= or similar is missing */ log_debug_errno(r, "Auxiliary unit of %s not found, removing name.", i->name); else { log_debug_errno(r, "Unit %s not found, removing name.", i->name); - unit_file_changes_add(changes, n_changes, r, i->path ?: i->name, NULL); + install_changes_add(changes, n_changes, r, i->path ?: i->name, NULL); } } else if (r < 0) { log_debug_errno(r, "Failed to find unit %s, removing name: %m", i->name); - unit_file_changes_add(changes, n_changes, r, i->path ?: i->name, NULL); + install_changes_add(changes, n_changes, r, i->path ?: i->name, NULL); } else if (i->type == UNIT_FILE_TYPE_MASKED) { log_debug("Unit file %s is masked, ignoring.", i->name); - unit_file_changes_add(changes, n_changes, UNIT_FILE_IS_MASKED, i->path ?: i->name, NULL); + install_changes_add(changes, n_changes, UNIT_FILE_IS_MASKED, i->path ?: i->name, NULL); continue; } else if (i->type != UNIT_FILE_TYPE_REGULAR) { log_debug("Unit %s has type %s, ignoring.", i->name, unit_file_type_to_string(i->type) ?: "invalid"); @@ -2227,7 +2227,7 @@ int unit_file_mask( UnitFileFlags flags, const char *root_dir, char **names, - UnitFileChange **changes, + InstallChange **changes, size_t *n_changes) { _cleanup_(lookup_paths_free) LookupPaths lp = {}; @@ -2272,7 +2272,7 @@ int unit_file_unmask( UnitFileFlags flags, const char *root_dir, char **names, - UnitFileChange **changes, + InstallChange **changes, size_t *n_changes) { _cleanup_(lookup_paths_free) LookupPaths lp = {}; @@ -2338,13 +2338,13 @@ int unit_file_unmask( if (errno != ENOENT) { if (r >= 0) r = -errno; - unit_file_changes_add(changes, n_changes, -errno, path, NULL); + install_changes_add(changes, n_changes, -errno, path, NULL); } continue; } - unit_file_changes_add(changes, n_changes, UNIT_FILE_UNLINK, path, NULL); + install_changes_add(changes, n_changes, UNIT_FILE_UNLINK, path, NULL); rp = skip_root(lp.root_dir, path); q = mark_symlink_for_removal(&remove_symlinks_to, rp ?: path); @@ -2364,7 +2364,7 @@ int unit_file_link( UnitFileFlags flags, const char *root_dir, char **files, - UnitFileChange **changes, + InstallChange **changes, size_t *n_changes) { _cleanup_(lookup_paths_free) LookupPaths lp = {}; @@ -2463,7 +2463,7 @@ int unit_file_revert( LookupScope scope, const char *root_dir, char **names, - UnitFileChange **changes, + InstallChange **changes, size_t *n_changes) { _cleanup_set_free_free_ Set *remove_symlinks_to = NULL; @@ -2589,10 +2589,10 @@ int unit_file_revert( if (!t) return -ENOMEM; - unit_file_changes_add(changes, n_changes, UNIT_FILE_UNLINK, t, NULL); + install_changes_add(changes, n_changes, UNIT_FILE_UNLINK, t, NULL); } - unit_file_changes_add(changes, n_changes, UNIT_FILE_UNLINK, *i, NULL); + install_changes_add(changes, n_changes, UNIT_FILE_UNLINK, *i, NULL); rp = skip_root(lp.root_dir, *i); q = mark_symlink_for_removal(&remove_symlinks_to, rp ?: *i); @@ -2618,7 +2618,7 @@ int unit_file_add_dependency( char **names, const char *target, UnitDependency dep, - UnitFileChange **changes, + InstallChange **changes, size_t *n_changes) { _cleanup_(lookup_paths_free) LookupPaths lp = {}; @@ -2688,7 +2688,7 @@ static int do_unit_file_enable( UnitFileFlags flags, const char *config_path, char **names_or_paths, - UnitFileChange **changes, + InstallChange **changes, size_t *n_changes) { _cleanup_(install_context_done) InstallContext ctx = { .scope = scope }; @@ -2719,7 +2719,7 @@ int unit_file_enable( UnitFileFlags flags, const char *root_dir, char **names_or_paths, - UnitFileChange **changes, + InstallChange **changes, size_t *n_changes) { _cleanup_(lookup_paths_free) LookupPaths lp = {}; @@ -2745,7 +2745,7 @@ static int do_unit_file_disable( UnitFileFlags flags, const char *config_path, char **names, - UnitFileChange **changes, + InstallChange **changes, size_t *n_changes) { _cleanup_(install_context_done) InstallContext ctx = { .scope = scope }; @@ -2774,7 +2774,7 @@ int unit_file_disable( UnitFileFlags flags, const char *root_dir, char **files, - UnitFileChange **changes, + InstallChange **changes, size_t *n_changes) { _cleanup_(lookup_paths_free) LookupPaths lp = {}; @@ -2857,7 +2857,7 @@ int unit_file_reenable( UnitFileFlags flags, const char *root_dir, char **names_or_paths, - UnitFileChange **changes, + InstallChange **changes, size_t *n_changes) { _cleanup_(lookup_paths_free) LookupPaths lp = {}; @@ -2893,7 +2893,7 @@ int unit_file_set_default( UnitFileFlags flags, const char *root_dir, const char *name, - UnitFileChange **changes, + InstallChange **changes, size_t *n_changes) { _cleanup_(lookup_paths_free) LookupPaths lp = {}; @@ -3349,7 +3349,7 @@ static int execute_preset( const char *config_path, char **files, UnitFilePresetMode mode, - UnitFileChange **changes, + InstallChange **changes, size_t *n_changes) { int r; @@ -3396,7 +3396,7 @@ static int preset_prepare_one( LookupPaths *lp, const char *name, const UnitFilePresets *presets, - UnitFileChange **changes, + InstallChange **changes, size_t *n_changes) { _cleanup_(install_context_done) InstallContext tmp = { .scope = scope }; @@ -3448,7 +3448,7 @@ int unit_file_preset( const char *root_dir, char **names, UnitFilePresetMode mode, - UnitFileChange **changes, + InstallChange **changes, size_t *n_changes) { _cleanup_(install_context_done) InstallContext plus = {}, minus = {}; @@ -3487,7 +3487,7 @@ int unit_file_preset_all( UnitFileFlags file_flags, const char *root_dir, UnitFilePresetMode mode, - UnitFileChange **changes, + InstallChange **changes, size_t *n_changes) { _cleanup_(install_context_done) InstallContext plus = {}, minus = {}; @@ -3535,7 +3535,7 @@ int unit_file_preset_all( if (r < 0 && !IN_SET(r, -EEXIST, -ERFKILL, -EADDRNOTAVAIL, -EBADSLT, -EIDRM, -EUCLEAN, -ELOOP, -ENOENT, -EUNATCH, -EXDEV)) /* Ignore generated/transient/missing/invalid units when applying preset, propagate other errors. - * Coordinate with unit_file_dump_changes() above. */ + * Coordinate with install_changes_dump() above. */ return r; } } diff --git a/src/shared/install.h b/src/shared/install.h index bc107e03ae..6e70e751e0 100644 --- a/src/shared/install.h +++ b/src/shared/install.h @@ -4,10 +4,10 @@ #include <stdbool.h> typedef enum UnitFilePresetMode UnitFilePresetMode; -typedef enum UnitFileChangeType UnitFileChangeType; +typedef enum InstallChangeType InstallChangeType; typedef enum UnitFileFlags UnitFileFlags; typedef enum UnitFileType UnitFileType; -typedef struct UnitFileChange UnitFileChange; +typedef struct InstallChange InstallChange; typedef struct UnitFileList UnitFileList; typedef struct UnitFileInstallInfo UnitFileInstallInfo; @@ -51,13 +51,13 @@ enum UnitFileFlags { /* type can either one of the UNIT_FILE_SYMLINK, UNIT_FILE_UNLINK, … listed above, or a negative errno value. * If source is specified, it should be the contents of the path symlink. In case of an error, source should * be the existing symlink contents or NULL. */ -struct UnitFileChange { +struct InstallChange { int type_or_errno; /* UNIT_FILE_SYMLINK, … if positive, errno if negative */ char *path; char *source; }; -static inline bool unit_file_changes_have_modification(const UnitFileChange* changes, size_t n_changes) { +static inline bool install_changes_have_modification(const InstallChange* changes, size_t n_changes) { for (size_t i = 0; i < n_changes; i++) if (IN_SET(changes[i].type_or_errno, UNIT_FILE_SYMLINK, UNIT_FILE_UNLINK)) return true; @@ -100,21 +100,21 @@ int unit_file_enable( UnitFileFlags flags, const char *root_dir, char **names_or_paths, - UnitFileChange **changes, + InstallChange **changes, size_t *n_changes); int unit_file_disable( LookupScope scope, UnitFileFlags flags, const char *root_dir, char **names, - UnitFileChange **changes, + InstallChange **changes, size_t *n_changes); int unit_file_reenable( LookupScope scope, UnitFileFlags flags, const char *root_dir, char **names_or_paths, - UnitFileChange **changes, + InstallChange **changes, size_t *n_changes); int unit_file_preset( LookupScope scope, @@ -122,48 +122,48 @@ int unit_file_preset( const char *root_dir, char **names, UnitFilePresetMode mode, - UnitFileChange **changes, + InstallChange **changes, size_t *n_changes); int unit_file_preset_all( LookupScope scope, UnitFileFlags flags, const char *root_dir, UnitFilePresetMode mode, - UnitFileChange **changes, + InstallChange **changes, size_t *n_changes); int unit_file_mask( LookupScope scope, UnitFileFlags flags, const char *root_dir, char **names, - UnitFileChange **changes, + InstallChange **changes, size_t *n_changes); int unit_file_unmask( LookupScope scope, UnitFileFlags flags, const char *root_dir, char **names, - UnitFileChange **changes, + InstallChange **changes, size_t *n_changes); int unit_file_link( LookupScope scope, UnitFileFlags flags, const char *root_dir, char **files, - UnitFileChange **changes, + InstallChange **changes, size_t *n_changes); int unit_file_revert( LookupScope scope, const char *root_dir, char **names, - UnitFileChange **changes, + InstallChange **changes, size_t *n_changes); int unit_file_set_default( LookupScope scope, UnitFileFlags flags, const char *root_dir, const char *name, - UnitFileChange **changes, + InstallChange **changes, size_t *n_changes); int unit_file_get_default( LookupScope scope, @@ -176,7 +176,7 @@ int unit_file_add_dependency( char **names, const char *target, UnitDependency dep, - UnitFileChange **changes, + InstallChange **changes, size_t *n_changes); int unit_file_lookup_state( @@ -191,15 +191,15 @@ int unit_file_exists(LookupScope scope, const LookupPaths *paths, const char *na int unit_file_get_list(LookupScope scope, const char *root_dir, Hashmap *h, char **states, char **patterns); Hashmap* unit_file_list_free(Hashmap *h); -int unit_file_changes_add(UnitFileChange **changes, size_t *n_changes, int type, const char *path, const char *source); -void unit_file_changes_free(UnitFileChange *changes, size_t n_changes); -void unit_file_dump_changes(int r, const char *verb, const UnitFileChange *changes, size_t n_changes, bool quiet); +int install_changes_add(InstallChange **changes, size_t *n_changes, int type, const char *path, const char *source); +void install_changes_free(InstallChange *changes, size_t n_changes); +void install_changes_dump(int r, const char *verb, const InstallChange *changes, size_t n_changes, bool quiet); int unit_file_verify_alias( const UnitFileInstallInfo *info, const char *dst, char **ret_dst, - UnitFileChange **changes, + InstallChange **changes, size_t *n_changes); typedef struct UnitFilePresetRule UnitFilePresetRule; diff --git a/src/systemctl/systemctl-add-dependency.c b/src/systemctl/systemctl-add-dependency.c index 120798b33f..68968a783c 100644 --- a/src/systemctl/systemctl-add-dependency.c +++ b/src/systemctl/systemctl-add-dependency.c @@ -11,7 +11,7 @@ int verb_add_dependency(int argc, char *argv[], void *userdata) { _cleanup_strv_free_ char **names = NULL; _cleanup_free_ char *target = NULL; const char *verb = argv[0]; - UnitFileChange *changes = NULL; + InstallChange *changes = NULL; size_t n_changes = 0; UnitDependency dep; int r; @@ -38,7 +38,7 @@ int verb_add_dependency(int argc, char *argv[], void *userdata) { if (install_client_side()) { r = unit_file_add_dependency(arg_scope, unit_file_flags_from_args(), arg_root, names, target, dep, &changes, &n_changes); - unit_file_dump_changes(r, "add dependency on", changes, n_changes, arg_quiet); + install_changes_dump(r, "add dependency on", changes, n_changes, arg_quiet); if (r > 0) r = 0; @@ -84,7 +84,7 @@ int verb_add_dependency(int argc, char *argv[], void *userdata) { } finish: - unit_file_changes_free(changes, n_changes); + install_changes_free(changes, n_changes); return r; } diff --git a/src/systemctl/systemctl-enable.c b/src/systemctl/systemctl-enable.c index 7014f92736..5be4c0c725 100644 --- a/src/systemctl/systemctl-enable.c +++ b/src/systemctl/systemctl-enable.c @@ -64,7 +64,7 @@ static int normalize_names(char **names) { int verb_enable(int argc, char *argv[], void *userdata) { _cleanup_strv_free_ char **names = NULL; const char *verb = argv[0]; - UnitFileChange *changes = NULL; + InstallChange *changes = NULL; size_t n_changes = 0; int carries_install_info = -1; bool ignore_carries_install_info = arg_quiet; @@ -127,7 +127,7 @@ int verb_enable(int argc, char *argv[], void *userdata) { else assert_not_reached(); - unit_file_dump_changes(r, verb, changes, n_changes, arg_quiet); + install_changes_dump(r, verb, changes, n_changes, arg_quiet); if (r < 0) goto finish; r = 0; @@ -280,7 +280,7 @@ int verb_enable(int argc, char *argv[], void *userdata) { } finish: - unit_file_changes_free(changes, n_changes); + install_changes_free(changes, n_changes); return r; } diff --git a/src/systemctl/systemctl-is-enabled.c b/src/systemctl/systemctl-is-enabled.c index 6f3d0b6eaa..074d5084f2 100644 --- a/src/systemctl/systemctl-is-enabled.c +++ b/src/systemctl/systemctl-is-enabled.c @@ -8,7 +8,7 @@ #include "systemctl.h" static int show_installation_targets_client_side(const char *name) { - UnitFileChange *changes = NULL; + InstallChange *changes = NULL; size_t n_changes = 0; UnitFileFlags flags; char **p; diff --git a/src/systemctl/systemctl-preset-all.c b/src/systemctl/systemctl-preset-all.c index 8e36ddc0c0..68dbff5048 100644 --- a/src/systemctl/systemctl-preset-all.c +++ b/src/systemctl/systemctl-preset-all.c @@ -8,13 +8,13 @@ #include "systemctl.h" int verb_preset_all(int argc, char *argv[], void *userdata) { - UnitFileChange *changes = NULL; + InstallChange *changes = NULL; size_t n_changes = 0; int r; if (install_client_side()) { r = unit_file_preset_all(arg_scope, unit_file_flags_from_args(), arg_root, arg_preset_mode, &changes, &n_changes); - unit_file_dump_changes(r, "preset", changes, n_changes, arg_quiet); + install_changes_dump(r, "preset", changes, n_changes, arg_quiet); if (r > 0) r = 0; @@ -57,7 +57,7 @@ int verb_preset_all(int argc, char *argv[], void *userdata) { } finish: - unit_file_changes_free(changes, n_changes); + install_changes_free(changes, n_changes); return r; } diff --git a/src/systemctl/systemctl-set-default.c b/src/systemctl/systemctl-set-default.c index 5f9186aa38..06845be401 100644 --- a/src/systemctl/systemctl-set-default.c +++ b/src/systemctl/systemctl-set-default.c @@ -93,7 +93,7 @@ int verb_get_default(int argc, char *argv[], void *userdata) { int verb_set_default(int argc, char *argv[], void *userdata) { _cleanup_free_ char *unit = NULL; - UnitFileChange *changes = NULL; + InstallChange *changes = NULL; size_t n_changes = 0; int r; @@ -108,7 +108,7 @@ int verb_set_default(int argc, char *argv[], void *userdata) { if (install_client_side()) { r = unit_file_set_default(arg_scope, UNIT_FILE_FORCE, arg_root, unit, &changes, &n_changes); - unit_file_dump_changes(r, "set default", changes, n_changes, arg_quiet); + install_changes_dump(r, "set default", changes, n_changes, arg_quiet); if (r > 0) r = 0; @@ -154,7 +154,7 @@ int verb_set_default(int argc, char *argv[], void *userdata) { } finish: - unit_file_changes_free(changes, n_changes); + install_changes_free(changes, n_changes); return r; } diff --git a/src/test/test-install-root.c b/src/test/test-install-root.c index c2980ccbbd..897061519f 100644 --- a/src/test/test-install-root.c +++ b/src/test/test-install-root.c @@ -20,7 +20,7 @@ STATIC_DESTRUCTOR_REGISTER(root, rm_rf_physical_and_freep); TEST(basic_mask_and_enable) { const char *p; UnitFileState state; - UnitFileChange *changes = NULL; + InstallChange *changes = NULL; size_t n_changes = 0; assert_se(unit_file_get_state(LOOKUP_SCOPE_SYSTEM, root, "a.service", NULL) == -ENOENT); @@ -64,7 +64,7 @@ TEST(basic_mask_and_enable) { p = strjoina(root, SYSTEM_CONFIG_UNIT_DIR"/a.service"); assert_se(streq(changes[0].path, p)); - unit_file_changes_free(changes, n_changes); + install_changes_free(changes, n_changes); changes = NULL; n_changes = 0; assert_se(unit_file_get_state(LOOKUP_SCOPE_SYSTEM, root, "a.service", &state) >= 0 && state == UNIT_FILE_MASKED); @@ -74,7 +74,7 @@ TEST(basic_mask_and_enable) { /* Enabling a masked unit should fail! */ assert_se(unit_file_enable(LOOKUP_SCOPE_SYSTEM, 0, root, STRV_MAKE("a.service"), &changes, &n_changes) == -ERFKILL); - unit_file_changes_free(changes, n_changes); + install_changes_free(changes, n_changes); changes = NULL; n_changes = 0; assert_se(unit_file_unmask(LOOKUP_SCOPE_SYSTEM, 0, root, STRV_MAKE("a.service"), &changes, &n_changes) >= 0); @@ -82,7 +82,7 @@ TEST(basic_mask_and_enable) { assert_se(changes[0].type_or_errno == UNIT_FILE_UNLINK); p = strjoina(root, SYSTEM_CONFIG_UNIT_DIR"/a.service"); assert_se(streq(changes[0].path, p)); - unit_file_changes_free(changes, n_changes); + install_changes_free(changes, n_changes); changes = NULL; n_changes = 0; assert_se(unit_file_enable(LOOKUP_SCOPE_SYSTEM, 0, root, STRV_MAKE("a.service"), &changes, &n_changes) == 1); @@ -91,7 +91,7 @@ TEST(basic_mask_and_enable) { assert_se(streq(changes[0].source, "/usr/lib/systemd/system/a.service")); p = strjoina(root, SYSTEM_CONFIG_UNIT_DIR"/multi-user.target.wants/a.service"); assert_se(streq(changes[0].path, p)); - unit_file_changes_free(changes, n_changes); + install_changes_free(changes, n_changes); changes = NULL; n_changes = 0; assert_se(unit_file_get_state(LOOKUP_SCOPE_SYSTEM, root, "a.service", &state) >= 0 && state == UNIT_FILE_ENABLED); @@ -102,7 +102,7 @@ TEST(basic_mask_and_enable) { /* Enabling it again should succeed but be a NOP */ assert_se(unit_file_enable(LOOKUP_SCOPE_SYSTEM, 0, root, STRV_MAKE("a.service"), &changes, &n_changes) >= 0); assert_se(n_changes == 0); - unit_file_changes_free(changes, n_changes); + install_changes_free(changes, n_changes); changes = NULL; n_changes = 0; assert_se(unit_file_disable(LOOKUP_SCOPE_SYSTEM, 0, root, STRV_MAKE("a.service"), &changes, &n_changes) >= 0); @@ -110,7 +110,7 @@ TEST(basic_mask_and_enable) { assert_se(changes[0].type_or_errno == UNIT_FILE_UNLINK); p = strjoina(root, SYSTEM_CONFIG_UNIT_DIR"/multi-user.target.wants/a.service"); assert_se(streq(changes[0].path, p)); - unit_file_changes_free(changes, n_changes); + install_changes_free(changes, n_changes); changes = NULL; n_changes = 0; assert_se(unit_file_get_state(LOOKUP_SCOPE_SYSTEM, root, "a.service", &state) >= 0 && state == UNIT_FILE_DISABLED); @@ -121,7 +121,7 @@ TEST(basic_mask_and_enable) { /* Disabling a disabled unit must succeed but be a NOP */ assert_se(unit_file_disable(LOOKUP_SCOPE_SYSTEM, 0, root, STRV_MAKE("a.service"), &changes, &n_changes) >= 0); assert_se(n_changes == 0); - unit_file_changes_free(changes, n_changes); + install_changes_free(changes, n_changes); changes = NULL; n_changes = 0; /* Let's enable this indirectly via a symlink */ @@ -131,7 +131,7 @@ TEST(basic_mask_and_enable) { assert_se(streq(changes[0].source, "/usr/lib/systemd/system/a.service")); p = strjoina(root, SYSTEM_CONFIG_UNIT_DIR"/multi-user.target.wants/a.service"); assert_se(streq(changes[0].path, p)); - unit_file_changes_free(changes, n_changes); + install_changes_free(changes, n_changes); changes = NULL; n_changes = 0; assert_se(unit_file_get_state(LOOKUP_SCOPE_SYSTEM, root, "a.service", &state) >= 0 && state == UNIT_FILE_ENABLED); @@ -149,7 +149,7 @@ TEST(basic_mask_and_enable) { assert_se(changes[1].type_or_errno == UNIT_FILE_SYMLINK); assert_se(streq(changes[1].source, "/usr/lib/systemd/system/a.service")); assert_se(streq(changes[1].path, p)); - unit_file_changes_free(changes, n_changes); + install_changes_free(changes, n_changes); changes = NULL; n_changes = 0; assert_se(unit_file_get_state(LOOKUP_SCOPE_SYSTEM, root, "a.service", &state) >= 0 && state == UNIT_FILE_ENABLED); @@ -193,7 +193,7 @@ TEST(basic_mask_and_enable) { p = strjoina(root, "/usr/lib/systemd/system/f.service"); assert_se(streq(changes[1].source, p)); assert_se(streq(changes[1].path, "x.target")); - unit_file_changes_free(changes, n_changes); + install_changes_free(changes, n_changes); changes = NULL; n_changes = 0; assert_se(unit_file_get_state(LOOKUP_SCOPE_SYSTEM, root, "f.service", &state) >= 0 && state == UNIT_FILE_ENABLED); @@ -202,7 +202,7 @@ TEST(basic_mask_and_enable) { TEST(linked_units) { const char *p, *q; UnitFileState state; - UnitFileChange *changes = NULL; + InstallChange *changes = NULL; size_t n_changes = 0, i; /* @@ -257,7 +257,7 @@ TEST(linked_units) { assert_se(streq(changes[0].source, "/opt/linked.service")); p = strjoina(root, SYSTEM_CONFIG_UNIT_DIR"/linked.service"); assert_se(streq(changes[0].path, p)); - unit_file_changes_free(changes, n_changes); + install_changes_free(changes, n_changes); changes = NULL; n_changes = 0; assert_se(unit_file_get_state(LOOKUP_SCOPE_SYSTEM, root, "linked.service", &state) >= 0 && state == UNIT_FILE_LINKED); @@ -268,7 +268,7 @@ TEST(linked_units) { assert_se(changes[0].type_or_errno == UNIT_FILE_UNLINK); p = strjoina(root, SYSTEM_CONFIG_UNIT_DIR"/linked.service"); assert_se(streq(changes[0].path, p)); - unit_file_changes_free(changes, n_changes); + install_changes_free(changes, n_changes); changes = NULL; n_changes = 0; assert_se(unit_file_get_state(LOOKUP_SCOPE_SYSTEM, root, "linked.service", NULL) == -ENOENT); @@ -290,7 +290,7 @@ TEST(linked_units) { assert_not_reached(); } assert_se(!p && !q); - unit_file_changes_free(changes, n_changes); + install_changes_free(changes, n_changes); changes = NULL; n_changes = 0; assert_se(unit_file_get_state(LOOKUP_SCOPE_SYSTEM, root, "linked.service", &state) >= 0 && state == UNIT_FILE_ENABLED); @@ -311,7 +311,7 @@ TEST(linked_units) { assert_not_reached(); } assert_se(!p && !q); - unit_file_changes_free(changes, n_changes); + install_changes_free(changes, n_changes); changes = NULL; n_changes = 0; assert_se(unit_file_get_state(LOOKUP_SCOPE_SYSTEM, root, "linked.service", NULL) == -ENOENT); @@ -332,7 +332,7 @@ TEST(linked_units) { assert_not_reached(); } assert_se(!p && !q); - unit_file_changes_free(changes, n_changes); + install_changes_free(changes, n_changes); changes = NULL; n_changes = 0; assert_se(unit_file_enable(LOOKUP_SCOPE_SYSTEM, 0, root, STRV_MAKE("linked3.service"), &changes, &n_changes) >= 0); @@ -341,13 +341,13 @@ TEST(linked_units) { assert_se(startswith(changes[0].path, root)); assert_se(endswith(changes[0].path, "linked3.service")); assert_se(streq(changes[0].source, "/opt/linked3.service")); - unit_file_changes_free(changes, n_changes); + install_changes_free(changes, n_changes); changes = NULL; n_changes = 0; } TEST(default) { _cleanup_free_ char *def = NULL; - UnitFileChange *changes = NULL; + InstallChange *changes = NULL; size_t n_changes = 0; const char *p; @@ -363,7 +363,7 @@ TEST(default) { assert_se(n_changes == 1); assert_se(changes[0].type_or_errno == -ENOENT); assert_se(streq_ptr(changes[0].path, "idontexist.target")); - unit_file_changes_free(changes, n_changes); + install_changes_free(changes, n_changes); changes = NULL; n_changes = 0; assert_se(unit_file_get_default(LOOKUP_SCOPE_SYSTEM, root, &def) == -ENOENT); @@ -374,7 +374,7 @@ TEST(default) { assert_se(streq(changes[0].source, "/usr/lib/systemd/system/test-default-real.target")); p = strjoina(root, SYSTEM_CONFIG_UNIT_DIR "/" SPECIAL_DEFAULT_TARGET); assert_se(streq(changes[0].path, p)); - unit_file_changes_free(changes, n_changes); + install_changes_free(changes, n_changes); changes = NULL; n_changes = 0; assert_se(unit_file_get_default(LOOKUP_SCOPE_SYSTEM, root, &def) >= 0); @@ -382,7 +382,7 @@ TEST(default) { } TEST(add_dependency) { - UnitFileChange *changes = NULL; + InstallChange *changes = NULL; size_t n_changes = 0; const char *p; @@ -404,12 +404,12 @@ TEST(add_dependency) { assert_se(streq(changes[0].source, "/usr/lib/systemd/system/real-add-dependency-test-service.service")); p = strjoina(root, SYSTEM_CONFIG_UNIT_DIR"/real-add-dependency-test-target.target.wants/real-add-dependency-test-service.service"); assert_se(streq(changes[0].path, p)); - unit_file_changes_free(changes, n_changes); + install_changes_free(changes, n_changes); changes = NULL; n_changes = 0; } TEST(template_enable) { - UnitFileChange *changes = NULL; + InstallChange *changes = NULL; size_t n_changes = 0; UnitFileState state; const char *p; @@ -445,7 +445,7 @@ TEST(template_enable) { assert_se(streq(changes[0].source, "/usr/lib/systemd/system/template@.service")); p = strjoina(root, SYSTEM_CONFIG_UNIT_DIR"/multi-user.target.wants/template@def.service"); assert_se(streq(changes[0].path, p)); - unit_file_changes_free(changes, n_changes); + install_changes_free(changes, n_changes); changes = NULL; n_changes = 0; assert_se(unit_file_get_state(LOOKUP_SCOPE_SYSTEM, root, "template@.service", &state) >= 0 && state == UNIT_FILE_ENABLED); @@ -459,7 +459,7 @@ TEST(template_enable) { assert_se(n_changes == 1); assert_se(changes[0].type_or_errno == UNIT_FILE_UNLINK); assert_se(streq(changes[0].path, p)); - unit_file_changes_free(changes, n_changes); + install_changes_free(changes, n_changes); changes = NULL; n_changes = 0; assert_se(unit_file_get_state(LOOKUP_SCOPE_SYSTEM, root, "template@.service", &state) >= 0 && state == UNIT_FILE_DISABLED); @@ -476,7 +476,7 @@ TEST(template_enable) { assert_se(streq(changes[0].source, "/usr/lib/systemd/system/template@.service")); p = strjoina(root, SYSTEM_CONFIG_UNIT_DIR"/multi-user.target.wants/template@foo.service"); assert_se(streq(changes[0].path, p)); - unit_file_changes_free(changes, n_changes); + install_changes_free(changes, n_changes); changes = NULL; n_changes = 0; assert_se(unit_file_get_state(LOOKUP_SCOPE_SYSTEM, root, "template@.service", &state) >= 0 && state == UNIT_FILE_INDIRECT); @@ -490,7 +490,7 @@ TEST(template_enable) { assert_se(n_changes == 1); assert_se(changes[0].type_or_errno == UNIT_FILE_UNLINK); assert_se(streq(changes[0].path, p)); - unit_file_changes_free(changes, n_changes); + install_changes_free(changes, n_changes); changes = NULL; n_changes = 0; assert_se(unit_file_get_state(LOOKUP_SCOPE_SYSTEM, root, "template@.service", &state) >= 0 && state == UNIT_FILE_DISABLED); @@ -509,7 +509,7 @@ TEST(template_enable) { assert_se(streq(changes[0].source, "/usr/lib/systemd/system/template@.service")); p = strjoina(root, SYSTEM_CONFIG_UNIT_DIR"/multi-user.target.wants/template@quux.service"); assert_se(streq(changes[0].path, p)); - unit_file_changes_free(changes, n_changes); + install_changes_free(changes, n_changes); changes = NULL; n_changes = 0; assert_se(unit_file_get_state(LOOKUP_SCOPE_SYSTEM, root, "template@.service", &state) >= 0 && state == UNIT_FILE_INDIRECT); @@ -523,7 +523,7 @@ TEST(template_enable) { } TEST(indirect) { - UnitFileChange *changes = NULL; + InstallChange *changes = NULL; size_t n_changes = 0; UnitFileState state; const char *p; @@ -555,7 +555,7 @@ TEST(indirect) { assert_se(streq(changes[0].source, "/usr/lib/systemd/system/indirectb.service")); p = strjoina(root, SYSTEM_CONFIG_UNIT_DIR"/multi-user.target.wants/indirectb.service"); assert_se(streq(changes[0].path, p)); - unit_file_changes_free(changes, n_changes); + install_changes_free(changes, n_changes); changes = NULL; n_changes = 0; assert_se(unit_file_get_state(LOOKUP_SCOPE_SYSTEM, root, "indirecta.service", &state) >= 0 && state == UNIT_FILE_INDIRECT); @@ -567,12 +567,12 @@ TEST(indirect) { assert_se(changes[0].type_or_errno == UNIT_FILE_UNLINK); p = strjoina(root, SYSTEM_CONFIG_UNIT_DIR"/multi-user.target.wants/indirectb.service"); assert_se(streq(changes[0].path, p)); - unit_file_changes_free(changes, n_changes); + install_changes_free(changes, n_changes); changes = NULL; n_changes = 0; } TEST(preset_and_list) { - UnitFileChange *changes = NULL; + InstallChange *changes = NULL; size_t n_changes = 0, i; const char *p, *q; UnitFileState state; @@ -607,7 +607,7 @@ TEST(preset_and_list) { assert_se(streq(changes[0].source, "/usr/lib/systemd/system/preset-yes.service")); p = strjoina(root, SYSTEM_CONFIG_UNIT_DIR"/multi-user.target.wants/preset-yes.service"); assert_se(streq(changes[0].path, p)); - unit_file_changes_free(changes, n_changes); + install_changes_free(changes, n_changes); changes = NULL; n_changes = 0; assert_se(unit_file_get_state(LOOKUP_SCOPE_SYSTEM, root, "preset-yes.service", &state) >= 0 && state == UNIT_FILE_ENABLED); @@ -618,7 +618,7 @@ TEST(preset_and_list) { assert_se(changes[0].type_or_errno == UNIT_FILE_UNLINK); p = strjoina(root, SYSTEM_CONFIG_UNIT_DIR"/multi-user.target.wants/preset-yes.service"); assert_se(streq(changes[0].path, p)); - unit_file_changes_free(changes, n_changes); + install_changes_free(changes, n_changes); changes = NULL; n_changes = 0; assert_se(unit_file_get_state(LOOKUP_SCOPE_SYSTEM, root, "preset-yes.service", &state) >= 0 && state == UNIT_FILE_DISABLED); @@ -626,7 +626,7 @@ TEST(preset_and_list) { assert_se(unit_file_preset(LOOKUP_SCOPE_SYSTEM, 0, root, STRV_MAKE("preset-no.service"), UNIT_FILE_PRESET_FULL, &changes, &n_changes) >= 0); assert_se(n_changes == 0); - unit_file_changes_free(changes, n_changes); + install_changes_free(changes, n_changes); changes = NULL; n_changes = 0; assert_se(unit_file_get_state(LOOKUP_SCOPE_SYSTEM, root, "preset-yes.service", &state) >= 0 && state == UNIT_FILE_DISABLED); @@ -647,7 +647,7 @@ TEST(preset_and_list) { assert_se(changes[i].type_or_errno == UNIT_FILE_UNLINK); } - unit_file_changes_free(changes, n_changes); + install_changes_free(changes, n_changes); changes = NULL; n_changes = 0; assert_se(unit_file_get_state(LOOKUP_SCOPE_SYSTEM, root, "preset-yes.service", &state) >= 0 && state == UNIT_FILE_ENABLED); @@ -681,7 +681,7 @@ TEST(preset_and_list) { TEST(revert) { const char *p; UnitFileState state; - UnitFileChange *changes = NULL; + InstallChange *changes = NULL; size_t n_changes = 0; assert_se(unit_file_get_state(LOOKUP_SCOPE_SYSTEM, root, "xx.service", NULL) == -ENOENT); @@ -696,7 +696,7 @@ TEST(revert) { /* Initially there's nothing to revert */ assert_se(unit_file_revert(LOOKUP_SCOPE_SYSTEM, root, STRV_MAKE("xx.service"), &changes, &n_changes) >= 0); assert_se(n_changes == 0); - unit_file_changes_free(changes, n_changes); + install_changes_free(changes, n_changes); changes = NULL; n_changes = 0; p = strjoina(root, SYSTEM_CONFIG_UNIT_DIR"/xx.service"); @@ -707,7 +707,7 @@ TEST(revert) { assert_se(n_changes == 1); assert_se(changes[0].type_or_errno == UNIT_FILE_UNLINK); assert_se(streq(changes[0].path, p)); - unit_file_changes_free(changes, n_changes); + install_changes_free(changes, n_changes); changes = NULL; n_changes = 0; p = strjoina(root, SYSTEM_CONFIG_UNIT_DIR"/xx.service.d/dropin.conf"); @@ -722,12 +722,12 @@ TEST(revert) { p = strjoina(root, SYSTEM_CONFIG_UNIT_DIR"/xx.service.d"); assert_se(changes[1].type_or_errno == UNIT_FILE_UNLINK); assert_se(streq(changes[1].path, p)); - unit_file_changes_free(changes, n_changes); + install_changes_free(changes, n_changes); changes = NULL; n_changes = 0; } TEST(preset_order) { - UnitFileChange *changes = NULL; + InstallChange *changes = NULL; size_t n_changes = 0; const char *p; UnitFileState state; @@ -760,7 +760,7 @@ TEST(preset_order) { assert_se(streq(changes[0].source, "/usr/lib/systemd/system/prefix-1.service")); p = strjoina(root, SYSTEM_CONFIG_UNIT_DIR"/multi-user.target.wants/prefix-1.service"); assert_se(streq(changes[0].path, p)); - unit_file_changes_free(changes, n_changes); + install_changes_free(changes, n_changes); changes = NULL; n_changes = 0; assert_se(unit_file_get_state(LOOKUP_SCOPE_SYSTEM, root, "prefix-1.service", &state) >= 0 && state == UNIT_FILE_ENABLED); @@ -798,7 +798,7 @@ TEST(static_instance) { TEST(with_dropin) { const char *p; UnitFileState state; - UnitFileChange *changes = NULL; + InstallChange *changes = NULL; size_t n_changes = 0; assert_se(unit_file_get_state(LOOKUP_SCOPE_SYSTEM, root, "with-dropin-1.service", &state) == -ENOENT); @@ -872,7 +872,7 @@ TEST(with_dropin) { assert_se(streq(changes[0].path, p)); p = strjoina(root, SYSTEM_CONFIG_UNIT_DIR"/graphical.target.wants/with-dropin-1.service"); assert_se(streq(changes[1].path, p)); - unit_file_changes_free(changes, n_changes); + install_changes_free(changes, n_changes); changes = NULL; n_changes = 0; assert_se(unit_file_enable(LOOKUP_SCOPE_SYSTEM, 0, root, STRV_MAKE("with-dropin-2.service"), &changes, &n_changes) == 1); @@ -886,7 +886,7 @@ TEST(with_dropin) { assert_se(streq(changes[0].path, p)); p = strjoina(root, SYSTEM_CONFIG_UNIT_DIR"/graphical.target.wants/with-dropin-2.service"); assert_se(streq(changes[1].path, p)); - unit_file_changes_free(changes, n_changes); + install_changes_free(changes, n_changes); changes = NULL; n_changes = 0; assert_se(unit_file_enable(LOOKUP_SCOPE_SYSTEM, 0, root, STRV_MAKE("with-dropin-3.service"), &changes, &n_changes) == 1); @@ -900,7 +900,7 @@ TEST(with_dropin) { assert_se(streq(changes[0].path, p)); p = strjoina(root, SYSTEM_CONFIG_UNIT_DIR"/graphical.target.wants/with-dropin-3.service"); assert_se(streq(changes[1].path, p)); - unit_file_changes_free(changes, n_changes); + install_changes_free(changes, n_changes); changes = NULL; n_changes = 0; assert_se(unit_file_enable(LOOKUP_SCOPE_SYSTEM, 0, root, STRV_MAKE("with-dropin-4a.service"), &changes, &n_changes) == 2); @@ -914,7 +914,7 @@ TEST(with_dropin) { assert_se(streq(changes[0].path, p)); p = strjoina(root, SYSTEM_CONFIG_UNIT_DIR"/multi-user.target.wants/with-dropin-4b.service"); assert_se(streq(changes[1].path, p)); - unit_file_changes_free(changes, n_changes); + install_changes_free(changes, n_changes); changes = NULL; n_changes = 0; assert_se(unit_file_get_state(LOOKUP_SCOPE_SYSTEM, root, "with-dropin-1.service", &state) >= 0 && state == UNIT_FILE_ENABLED); @@ -927,7 +927,7 @@ TEST(with_dropin) { TEST(with_dropin_template) { const char *p; UnitFileState state; - UnitFileChange *changes = NULL; + InstallChange *changes = NULL; size_t n_changes = 0; assert_se(unit_file_get_state(LOOKUP_SCOPE_SYSTEM, root, "with-dropin-1@.service", &state) == -ENOENT); @@ -981,7 +981,7 @@ TEST(with_dropin_template) { assert_se(streq(changes[0].path, p)); p = strjoina(root, SYSTEM_CONFIG_UNIT_DIR"/graphical.target.wants/with-dropin-1@instance-1.service"); assert_se(streq(changes[1].path, p)); - unit_file_changes_free(changes, n_changes); + install_changes_free(changes, n_changes); changes = NULL; n_changes = 0; assert_se(unit_file_enable(LOOKUP_SCOPE_SYSTEM, 0, root, STRV_MAKE("with-dropin-2@instance-1.service"), &changes, &n_changes) == 1); @@ -994,7 +994,7 @@ TEST(with_dropin_template) { assert_se(streq(changes[0].path, p)); p = strjoina(root, SYSTEM_CONFIG_UNIT_DIR"/graphical.target.wants/with-dropin-2@instance-1.service"); assert_se(streq(changes[1].path, p)); - unit_file_changes_free(changes, n_changes); + install_changes_free(changes, n_changes); changes = NULL; n_changes = 0; assert_se(unit_file_enable(LOOKUP_SCOPE_SYSTEM, 0, root, STRV_MAKE("with-dropin-2@instance-2.service"), &changes, &n_changes) == 1); @@ -1003,7 +1003,7 @@ TEST(with_dropin_template) { assert_se(streq(changes[0].source, "/usr/lib/systemd/system/with-dropin-2@.service")); p = strjoina(root, SYSTEM_CONFIG_UNIT_DIR"/multi-user.target.wants/with-dropin-2@instance-2.service"); assert_se(streq(changes[0].path, p)); - unit_file_changes_free(changes, n_changes); + install_changes_free(changes, n_changes); changes = NULL; n_changes = 0; assert_se(unit_file_enable(LOOKUP_SCOPE_SYSTEM, 0, root, STRV_MAKE("with-dropin-3@.service"), &changes, &n_changes) == 1); @@ -1012,7 +1012,7 @@ TEST(with_dropin_template) { assert_se(streq(changes[0].source, "/usr/lib/systemd/system/with-dropin-3@.service")); p = strjoina(root, SYSTEM_CONFIG_UNIT_DIR"/multi-user.target.wants/with-dropin-3@instance-2.service"); assert_se(streq(changes[0].path, p)); - unit_file_changes_free(changes, n_changes); + install_changes_free(changes, n_changes); changes = NULL; n_changes = 0; assert_se(unit_file_get_state(LOOKUP_SCOPE_SYSTEM, root, "with-dropin-1@instance-1.service", &state) >= 0 && state == UNIT_FILE_ENABLED); @@ -1023,7 +1023,7 @@ TEST(with_dropin_template) { } TEST(preset_multiple_instances) { - UnitFileChange *changes = NULL; + InstallChange *changes = NULL; size_t n_changes = 0; const char *p; UnitFileState state; @@ -1052,7 +1052,7 @@ TEST(preset_multiple_instances) { assert_se(changes[0].type_or_errno == UNIT_FILE_SYMLINK); p = strjoina(root, SYSTEM_CONFIG_UNIT_DIR"/multi-user.target.wants/foo@bar0.service"); assert_se(streq(changes[0].path, p)); - unit_file_changes_free(changes, n_changes); + install_changes_free(changes, n_changes); changes = NULL; n_changes = 0; assert_se(unit_file_disable(LOOKUP_SCOPE_SYSTEM, 0, root, STRV_MAKE("foo@bar0.service"), &changes, &n_changes) >= 0); @@ -1060,7 +1060,7 @@ TEST(preset_multiple_instances) { assert_se(changes[0].type_or_errno == UNIT_FILE_UNLINK); p = strjoina(root, SYSTEM_CONFIG_UNIT_DIR"/multi-user.target.wants/foo@bar0.service"); assert_se(streq(changes[0].path, p)); - unit_file_changes_free(changes, n_changes); + install_changes_free(changes, n_changes); changes = NULL; n_changes = 0; /* Check for preset-all case, only instances on the list should be enabled, not including the default instance */ @@ -1076,7 +1076,7 @@ TEST(preset_multiple_instances) { assert_se(unit_file_get_state(LOOKUP_SCOPE_SYSTEM, root, "foo@bar1.service", &state) >= 0 && state == UNIT_FILE_ENABLED); assert_se(unit_file_get_state(LOOKUP_SCOPE_SYSTEM, root, "foo@bartest.service", &state) >= 0 && state == UNIT_FILE_ENABLED); - unit_file_changes_free(changes, n_changes); + install_changes_free(changes, n_changes); } static void verify_one( diff --git a/src/test/test-install.c b/src/test/test-install.c index 6c5a036465..95aeb77183 100644 --- a/src/test/test-install.c +++ b/src/test/test-install.c @@ -6,7 +6,7 @@ #include "install.h" #include "tests.h" -static void dump_changes(UnitFileChange *c, unsigned n) { +static void dump_changes(InstallChange *c, unsigned n) { unsigned i; assert_se(n == 0 || c); @@ -25,7 +25,7 @@ int main(int argc, char* argv[]) { int r; const char *const files[] = { "avahi-daemon.service", NULL }; const char *const files2[] = { "/home/lennart/test.service", NULL }; - UnitFileChange *changes = NULL; + InstallChange *changes = NULL; size_t n_changes = 0; UnitFileState state = 0; @@ -61,7 +61,7 @@ int main(int argc, char* argv[]) { assert_se(r >= 0); dump_changes(changes, n_changes); - unit_file_changes_free(changes, n_changes); + install_changes_free(changes, n_changes); r = unit_file_get_state(LOOKUP_SCOPE_SYSTEM, NULL, files[0], &state); assert_se(r >= 0); @@ -75,7 +75,7 @@ int main(int argc, char* argv[]) { assert_se(r >= 0); dump_changes(changes, n_changes); - unit_file_changes_free(changes, n_changes); + install_changes_free(changes, n_changes); r = unit_file_get_state(LOOKUP_SCOPE_SYSTEM, NULL, files[0], &state); assert_se(r >= 0); @@ -92,7 +92,7 @@ int main(int argc, char* argv[]) { assert_se(r >= 0); dump_changes(changes, n_changes); - unit_file_changes_free(changes, n_changes); + install_changes_free(changes, n_changes); r = unit_file_get_state(LOOKUP_SCOPE_SYSTEM, NULL, files[0], &state); assert_se(r >= 0); @@ -109,7 +109,7 @@ int main(int argc, char* argv[]) { assert_se(r >= 0); dump_changes(changes, n_changes); - unit_file_changes_free(changes, n_changes); + install_changes_free(changes, n_changes); r = unit_file_get_state(LOOKUP_SCOPE_SYSTEM, NULL, files[0], &state); assert_se(r >= 0); @@ -123,7 +123,7 @@ int main(int argc, char* argv[]) { assert_se(r >= 0); dump_changes(changes, n_changes); - unit_file_changes_free(changes, n_changes); + install_changes_free(changes, n_changes); r = unit_file_get_state(LOOKUP_SCOPE_SYSTEM, NULL, files[0], &state); assert_se(r >= 0); @@ -140,7 +140,7 @@ int main(int argc, char* argv[]) { assert_se(r >= 0); dump_changes(changes, n_changes); - unit_file_changes_free(changes, n_changes); + install_changes_free(changes, n_changes); r = unit_file_get_state(LOOKUP_SCOPE_SYSTEM, NULL, files[0], &state); assert_se(r >= 0); @@ -154,7 +154,7 @@ int main(int argc, char* argv[]) { assert_se(r >= 0); dump_changes(changes, n_changes); - unit_file_changes_free(changes, n_changes); + install_changes_free(changes, n_changes); r = unit_file_get_state(LOOKUP_SCOPE_SYSTEM, NULL, files[0], &state); assert_se(r >= 0); @@ -168,7 +168,7 @@ int main(int argc, char* argv[]) { assert_se(r >= 0); dump_changes(changes, n_changes); - unit_file_changes_free(changes, n_changes); + install_changes_free(changes, n_changes); r = unit_file_get_state(LOOKUP_SCOPE_SYSTEM, NULL, basename(files2[0]), &state); assert_se(r >= 0); @@ -182,7 +182,7 @@ int main(int argc, char* argv[]) { assert_se(r >= 0); dump_changes(changes, n_changes); - unit_file_changes_free(changes, n_changes); + install_changes_free(changes, n_changes); r = unit_file_get_state(LOOKUP_SCOPE_SYSTEM, NULL, basename(files2[0]), &state); assert_se(r < 0); @@ -195,7 +195,7 @@ int main(int argc, char* argv[]) { assert_se(r >= 0); dump_changes(changes, n_changes); - unit_file_changes_free(changes, n_changes); + install_changes_free(changes, n_changes); r = unit_file_get_state(LOOKUP_SCOPE_SYSTEM, NULL, basename(files2[0]), &state); assert_se(r >= 0); @@ -209,7 +209,7 @@ int main(int argc, char* argv[]) { assert_se(r >= 0); dump_changes(changes, n_changes); - unit_file_changes_free(changes, n_changes); + install_changes_free(changes, n_changes); r = unit_file_get_state(LOOKUP_SCOPE_SYSTEM, NULL, basename(files2[0]), &state); assert_se(r < 0); @@ -222,7 +222,7 @@ int main(int argc, char* argv[]) { assert_se(r >= 0); dump_changes(changes, n_changes); - unit_file_changes_free(changes, n_changes); + install_changes_free(changes, n_changes); r = unit_file_get_state(LOOKUP_SCOPE_SYSTEM, NULL, basename(files2[0]), &state); assert_se(r >= 0); @@ -236,7 +236,7 @@ int main(int argc, char* argv[]) { assert_se(r >= 0); dump_changes(changes, n_changes); - unit_file_changes_free(changes, n_changes); + install_changes_free(changes, n_changes); r = unit_file_get_state(LOOKUP_SCOPE_SYSTEM, NULL, basename(files2[0]), &state); assert_se(r >= 0); @@ -250,7 +250,7 @@ int main(int argc, char* argv[]) { assert_se(r >= 0); dump_changes(changes, n_changes); - unit_file_changes_free(changes, n_changes); + install_changes_free(changes, n_changes); r = unit_file_get_state(LOOKUP_SCOPE_SYSTEM, NULL, basename(files2[0]), &state); assert_se(r < 0); @@ -262,7 +262,7 @@ int main(int argc, char* argv[]) { assert_se(r >= 0); dump_changes(changes, n_changes); - unit_file_changes_free(changes, n_changes); + install_changes_free(changes, n_changes); r = unit_file_get_state(LOOKUP_SCOPE_SYSTEM, NULL, basename(files[0]), &state); assert_se(r >= 0); diff --git a/test/test-exec-deserialization.py b/test/test-exec-deserialization.py index 08307b18d7..8ad343f73d 100755 --- a/test/test-exec-deserialization.py +++ b/test/test-exec-deserialization.py @@ -17,8 +17,7 @@ import unittest import uuid from enum import Enum - -class UnitFileChange(Enum): +class InstallChange(Enum): NO_CHANGE = 0 LINES_SWAPPED = 1 COMMAND_ADDED_BEFORE = 2 @@ -39,7 +38,7 @@ class ExecutionResumeTest(unittest.TestCase): ExecStart=/bin/sleep 3 ExecStart=/bin/bash -c "echo foo >> {self.output_file}" ''' - self.unit_files[UnitFileChange.NO_CHANGE] = unit_file_content + self.unit_files[InstallChange.NO_CHANGE] = unit_file_content unit_file_content = f''' [Service] @@ -47,7 +46,7 @@ class ExecutionResumeTest(unittest.TestCase): ExecStart=/bin/bash -c "echo foo >> {self.output_file}" ExecStart=/bin/sleep 3 ''' - self.unit_files[UnitFileChange.LINES_SWAPPED] = unit_file_content + self.unit_files[InstallChange.LINES_SWAPPED] = unit_file_content unit_file_content = f''' [Service] @@ -56,7 +55,7 @@ class ExecutionResumeTest(unittest.TestCase): ExecStart=/bin/sleep 3 ExecStart=/bin/bash -c "echo foo >> {self.output_file}" ''' - self.unit_files[UnitFileChange.COMMAND_ADDED_BEFORE] = unit_file_content + self.unit_files[InstallChange.COMMAND_ADDED_BEFORE] = unit_file_content unit_file_content = f''' [Service] @@ -65,7 +64,7 @@ class ExecutionResumeTest(unittest.TestCase): ExecStart=/bin/bash -c "echo foo >> {self.output_file}" ExecStart=/bin/bash -c "echo bar >> {self.output_file}" ''' - self.unit_files[UnitFileChange.COMMAND_ADDED_AFTER] = unit_file_content + self.unit_files[InstallChange.COMMAND_ADDED_AFTER] = unit_file_content unit_file_content = f''' [Service] @@ -75,7 +74,7 @@ class ExecutionResumeTest(unittest.TestCase): ExecStart=/bin/bash -c "echo foo >> {self.output_file}" ExecStart=/bin/bash -c "echo bar >> {self.output_file}" ''' - self.unit_files[UnitFileChange.COMMAND_INTERLEAVED] = unit_file_content + self.unit_files[InstallChange.COMMAND_INTERLEAVED] = unit_file_content unit_file_content = f''' [Service] @@ -83,13 +82,13 @@ class ExecutionResumeTest(unittest.TestCase): ExecStart=/bin/bash -c "echo bar >> {self.output_file}" ExecStart=/bin/bash -c "echo baz >> {self.output_file}" ''' - self.unit_files[UnitFileChange.REMOVAL] = unit_file_content + self.unit_files[InstallChange.REMOVAL] = unit_file_content def reload(self): subprocess.check_call(['systemctl', 'daemon-reload']) def write_unit_file(self, unit_file_change): - if not isinstance(unit_file_change, UnitFileChange): + if not isinstance(unit_file_change, InstallChange): raise ValueError('Unknown unit file change') content = self.unit_files[unit_file_change] @@ -118,7 +117,7 @@ class ExecutionResumeTest(unittest.TestCase): self.fail(f'Timed out while waiting for the output file {self.output_file} to appear') def setup_unit(self): - self.write_unit_file(UnitFileChange.NO_CHANGE) + self.write_unit_file(InstallChange.NO_CHANGE) subprocess.check_call(['systemctl', '--job-mode=replace', '--no-block', 'start', self.unit]) time.sleep(1) @@ -132,7 +131,7 @@ class ExecutionResumeTest(unittest.TestCase): def test_swapped(self): self.setup_unit() - self.write_unit_file(UnitFileChange.LINES_SWAPPED) + self.write_unit_file(InstallChange.LINES_SWAPPED) self.reload() self.assertTrue(not os.path.exists(self.output_file)) @@ -141,7 +140,7 @@ class ExecutionResumeTest(unittest.TestCase): expected_output = 'foo\n' self.setup_unit() - self.write_unit_file(UnitFileChange.COMMAND_ADDED_BEFORE) + self.write_unit_file(InstallChange.COMMAND_ADDED_BEFORE) self.reload() self.check_output(expected_output) @@ -150,7 +149,7 @@ class ExecutionResumeTest(unittest.TestCase): expected_output = 'foo\nbar\n' self.setup_unit() - self.write_unit_file(UnitFileChange.COMMAND_ADDED_AFTER) + self.write_unit_file(InstallChange.COMMAND_ADDED_AFTER) self.reload() self.check_output(expected_output) @@ -159,14 +158,14 @@ class ExecutionResumeTest(unittest.TestCase): expected_output = 'foo\nbar\n' self.setup_unit() - self.write_unit_file(UnitFileChange.COMMAND_INTERLEAVED) + self.write_unit_file(InstallChange.COMMAND_INTERLEAVED) self.reload() self.check_output(expected_output) def test_removal(self): self.setup_unit() - self.write_unit_file(UnitFileChange.REMOVAL) + self.write_unit_file(InstallChange.REMOVAL) self.reload() self.assertTrue(not os.path.exists(self.output_file)) |