- STRV_FOREACH(name, names) {
- _cleanup_free_ char *path = NULL;
- char *new_path, *tmp_path;
-
- r = unit_file_find_path(&lp, *name, &path);
- if (r < 0)
- return r;
- if (r == 0) {
- log_warning("%s ignored: not found", *name);
- continue;
- }
-
- if (arg_full)
- r = unit_file_create_copy(*name, path, user_home, user_runtime, &new_path, &tmp_path);
- else
- r = unit_file_create_drop_in(*name, user_home, user_runtime, &new_path, &tmp_path);
-
- if (r < 0)
- continue;
-
- r = strv_push(paths, new_path);
- if (r < 0)
- return log_oom();
-
- r = strv_push(paths, tmp_path);
- if (r < 0)
- return log_oom();
- }
- } else {
- STRV_FOREACH(name, names) {
- _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
- _cleanup_free_ char *fragment_path = NULL;
- _cleanup_free_ char *unit = NULL;
- char *new_path, *tmp_path;
-
- unit = unit_dbus_path_from_name(*name);
- if (!unit)
- return log_oom();
-
- if (need_daemon_reload(bus, *name) > 0) {
- log_warning("%s ignored: unit file changed on disk. Run 'systemctl%s daemon-reload'.",
- *name, arg_scope == UNIT_FILE_SYSTEM ? "" : " --user");
- continue;
- }
-
- r = sd_bus_get_property_string(
- bus,
- "org.freedesktop.systemd1",
- unit,
- "org.freedesktop.systemd1.Unit",
- "FragmentPath",
- &error,
- &fragment_path);
- if (r < 0) {
- log_warning("Failed to get FragmentPath: %s", bus_error_message(&error, r));
- continue;
- }
-
- if (isempty(fragment_path)) {
- log_warning("%s ignored: not found", *name);
- continue;
- }
-
- if (arg_full)
- r = unit_file_create_copy(*name, fragment_path, user_home, user_runtime, &new_path, &tmp_path);
- else
- r = unit_file_create_drop_in(*name, user_home, user_runtime, &new_path, &tmp_path);
- if (r < 0)
- continue;
-
- r = strv_push(paths, new_path);
- if (r < 0)
- return log_oom();