|
|
a19bc6 |
From 111080b06c79e6bcbe9da4786f9c7229f1fb573e Mon Sep 17 00:00:00 2001
|
|
|
a19bc6 |
From: Jan Synacek <jsynacek@redhat.com>
|
|
|
a19bc6 |
Date: Thu, 20 Oct 2016 14:48:33 +0200
|
|
|
a19bc6 |
Subject: [PATCH] install: introduce UnitFileFlags
|
|
|
a19bc6 |
|
|
|
a19bc6 |
Introduce a new enum to get rid of some boolean arguments of unit_file_*
|
|
|
a19bc6 |
functions. It unifies the code, makes it a bit cleaner and extensible.
|
|
|
a19bc6 |
|
|
|
a19bc6 |
(cherry picked from commit b3796dd8349af4235143889e44522a730c1635c0)
|
|
|
a19bc6 |
Related: #1413041
|
|
|
a19bc6 |
---
|
|
|
a19bc6 |
src/core/dbus-manager.c | 36 ++++++++++++++++++--------
|
|
|
a19bc6 |
src/core/main.c | 2 +-
|
|
|
a19bc6 |
src/shared/install.c | 61 ++++++++++++++++++++------------------------
|
|
|
a19bc6 |
src/shared/install.h | 25 ++++++++++--------
|
|
|
a19bc6 |
src/systemctl/systemctl.c | 28 ++++++++++++--------
|
|
|
a19bc6 |
src/test/test-install-root.c | 58 ++++++++++++++++++++---------------------
|
|
|
a19bc6 |
src/test/test-install.c | 38 +++++++++++++--------------
|
|
|
a19bc6 |
7 files changed, 135 insertions(+), 113 deletions(-)
|
|
|
a19bc6 |
|
|
|
a19bc6 |
diff --git a/src/core/dbus-manager.c b/src/core/dbus-manager.c
|
|
|
181b3f |
index c2067c099..5b40aa20f 100644
|
|
|
a19bc6 |
--- a/src/core/dbus-manager.c
|
|
|
a19bc6 |
+++ b/src/core/dbus-manager.c
|
|
|
a19bc6 |
@@ -41,6 +41,11 @@
|
|
|
a19bc6 |
#include "dbus-execute.h"
|
|
|
a19bc6 |
#include "bus-common-errors.h"
|
|
|
a19bc6 |
|
|
|
a19bc6 |
+static UnitFileFlags unit_file_bools_to_flags(bool runtime, bool force) {
|
|
|
a19bc6 |
+ return (runtime ? UNIT_FILE_RUNTIME : 0) |
|
|
|
a19bc6 |
+ (force ? UNIT_FILE_FORCE : 0);
|
|
|
a19bc6 |
+}
|
|
|
a19bc6 |
+
|
|
|
a19bc6 |
static int property_get_version(
|
|
|
a19bc6 |
sd_bus *bus,
|
|
|
a19bc6 |
const char *path,
|
|
|
a19bc6 |
@@ -1647,7 +1652,7 @@ static int method_enable_unit_files_generic(
|
|
|
a19bc6 |
sd_bus_message *message,
|
|
|
a19bc6 |
Manager *m,
|
|
|
a19bc6 |
const char *verb,
|
|
|
a19bc6 |
- int (*call)(UnitFileScope scope, bool runtime, const char *root_dir, char *files[], bool force, UnitFileChange **changes, unsigned *n_changes),
|
|
|
a19bc6 |
+ int (*call)(UnitFileScope scope, UnitFileFlags flags, const char *root_dir, char *files[], UnitFileChange **changes, unsigned *n_changes),
|
|
|
a19bc6 |
bool carries_install_info,
|
|
|
a19bc6 |
sd_bus_error *error) {
|
|
|
a19bc6 |
|
|
|
a19bc6 |
@@ -1655,6 +1660,7 @@ static int method_enable_unit_files_generic(
|
|
|
a19bc6 |
UnitFileChange *changes = NULL;
|
|
|
a19bc6 |
unsigned n_changes = 0;
|
|
|
a19bc6 |
UnitFileScope scope;
|
|
|
a19bc6 |
+ UnitFileFlags flags;
|
|
|
a19bc6 |
int runtime, force, r;
|
|
|
a19bc6 |
|
|
|
a19bc6 |
assert(bus);
|
|
|
a19bc6 |
@@ -1676,12 +1682,13 @@ static int method_enable_unit_files_generic(
|
|
|
a19bc6 |
return r;
|
|
|
a19bc6 |
|
|
|
a19bc6 |
r = mac_selinux_unit_access_check_strv(l, message, m, verb, error);
|
|
|
a19bc6 |
+ flags = unit_file_bools_to_flags(runtime, force);
|
|
|
a19bc6 |
if (r < 0)
|
|
|
a19bc6 |
return r;
|
|
|
a19bc6 |
|
|
|
a19bc6 |
scope = m->running_as == SYSTEMD_SYSTEM ? UNIT_FILE_SYSTEM : UNIT_FILE_USER;
|
|
|
a19bc6 |
|
|
|
a19bc6 |
- r = call(scope, runtime, NULL, l, force, &changes, &n_changes);
|
|
|
a19bc6 |
+ r = call(scope, flags, NULL, l, &changes, &n_changes);
|
|
|
a19bc6 |
if (r < 0)
|
|
|
a19bc6 |
return r;
|
|
|
a19bc6 |
|
|
|
a19bc6 |
@@ -1700,8 +1707,8 @@ static int method_link_unit_files(sd_bus *bus, sd_bus_message *message, void *us
|
|
|
a19bc6 |
return method_enable_unit_files_generic(bus, message, userdata, "enable", unit_file_link, false, error);
|
|
|
a19bc6 |
}
|
|
|
a19bc6 |
|
|
|
a19bc6 |
-static int unit_file_preset_without_mode(UnitFileScope scope, bool runtime, const char *root_dir, char **files, bool force, UnitFileChange **changes, unsigned *n_changes) {
|
|
|
a19bc6 |
- return unit_file_preset(scope, runtime, root_dir, files, UNIT_FILE_PRESET_FULL, force, changes, n_changes);
|
|
|
a19bc6 |
+static int unit_file_preset_without_mode(UnitFileScope scope, UnitFileFlags flags, const char *root_dir, char **files, UnitFileChange **changes, unsigned *n_changes) {
|
|
|
a19bc6 |
+ return unit_file_preset(scope, flags, root_dir, files, UNIT_FILE_PRESET_FULL, changes, n_changes);
|
|
|
a19bc6 |
}
|
|
|
a19bc6 |
|
|
|
a19bc6 |
static int method_preset_unit_files(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
|
|
|
a19bc6 |
@@ -1721,6 +1728,7 @@ static int method_preset_unit_files_with_mode(sd_bus *bus, sd_bus_message *messa
|
|
|
a19bc6 |
UnitFilePresetMode mm;
|
|
|
a19bc6 |
UnitFileScope scope;
|
|
|
a19bc6 |
int runtime, force, r;
|
|
|
a19bc6 |
+ UnitFileFlags flags;
|
|
|
a19bc6 |
const char *mode;
|
|
|
a19bc6 |
|
|
|
a19bc6 |
assert(bus);
|
|
|
a19bc6 |
@@ -1741,6 +1749,8 @@ static int method_preset_unit_files_with_mode(sd_bus *bus, sd_bus_message *messa
|
|
|
a19bc6 |
if (r < 0)
|
|
|
a19bc6 |
return r;
|
|
|
a19bc6 |
|
|
|
a19bc6 |
+ flags = unit_file_bools_to_flags(runtime, force);
|
|
|
a19bc6 |
+
|
|
|
a19bc6 |
if (isempty(mode))
|
|
|
a19bc6 |
mm = UNIT_FILE_PRESET_FULL;
|
|
|
a19bc6 |
else {
|
|
|
a19bc6 |
@@ -1755,7 +1765,7 @@ static int method_preset_unit_files_with_mode(sd_bus *bus, sd_bus_message *messa
|
|
|
a19bc6 |
|
|
|
a19bc6 |
scope = m->running_as == SYSTEMD_SYSTEM ? UNIT_FILE_SYSTEM : UNIT_FILE_USER;
|
|
|
a19bc6 |
|
|
|
a19bc6 |
- r = unit_file_preset(scope, runtime, NULL, l, mm, force, &changes, &n_changes);
|
|
|
a19bc6 |
+ r = unit_file_preset(scope, flags, NULL, l, mm, &changes, &n_changes);
|
|
|
a19bc6 |
if (r < 0)
|
|
|
a19bc6 |
return r;
|
|
|
a19bc6 |
|
|
|
a19bc6 |
@@ -1767,7 +1777,7 @@ static int method_disable_unit_files_generic(
|
|
|
a19bc6 |
sd_bus_message *message,
|
|
|
a19bc6 |
Manager *m, const
|
|
|
a19bc6 |
char *verb,
|
|
|
a19bc6 |
- int (*call)(UnitFileScope scope, bool runtime, const char *root_dir, char *files[], UnitFileChange **changes, unsigned *n_changes),
|
|
|
a19bc6 |
+ int (*call)(UnitFileScope scope, UnitFileFlags flags, const char *root_dir, char *files[], UnitFileChange **changes, unsigned *n_changes),
|
|
|
a19bc6 |
sd_bus_error *error) {
|
|
|
a19bc6 |
|
|
|
a19bc6 |
_cleanup_strv_free_ char **l = NULL;
|
|
|
a19bc6 |
@@ -1800,7 +1810,7 @@ static int method_disable_unit_files_generic(
|
|
|
a19bc6 |
|
|
|
a19bc6 |
scope = m->running_as == SYSTEMD_SYSTEM ? UNIT_FILE_SYSTEM : UNIT_FILE_USER;
|
|
|
a19bc6 |
|
|
|
a19bc6 |
- r = call(scope, runtime, NULL, l, &changes, &n_changes);
|
|
|
a19bc6 |
+ r = call(scope, runtime ? UNIT_FILE_RUNTIME : 0, NULL, l, &changes, &n_changes);
|
|
|
a19bc6 |
if (r < 0)
|
|
|
a19bc6 |
return r;
|
|
|
a19bc6 |
|
|
|
a19bc6 |
@@ -1843,7 +1853,7 @@ static int method_set_default_target(sd_bus *bus, sd_bus_message *message, void
|
|
|
a19bc6 |
|
|
|
a19bc6 |
scope = m->running_as == SYSTEMD_SYSTEM ? UNIT_FILE_SYSTEM : UNIT_FILE_USER;
|
|
|
a19bc6 |
|
|
|
a19bc6 |
- r = unit_file_set_default(scope, NULL, name, force, &changes, &n_changes);
|
|
|
a19bc6 |
+ r = unit_file_set_default(scope, force ? UNIT_FILE_FORCE : 0, NULL, name, &changes, &n_changes);
|
|
|
a19bc6 |
if (r < 0)
|
|
|
a19bc6 |
return r;
|
|
|
a19bc6 |
|
|
|
a19bc6 |
@@ -1857,6 +1867,7 @@ static int method_preset_all_unit_files(sd_bus *bus, sd_bus_message *message, vo
|
|
|
a19bc6 |
UnitFilePresetMode mm;
|
|
|
a19bc6 |
UnitFileScope scope;
|
|
|
a19bc6 |
const char *mode;
|
|
|
a19bc6 |
+ UnitFileFlags flags;
|
|
|
a19bc6 |
int force, runtime, r;
|
|
|
a19bc6 |
|
|
|
a19bc6 |
assert(bus);
|
|
|
a19bc6 |
@@ -1877,6 +1888,8 @@ static int method_preset_all_unit_files(sd_bus *bus, sd_bus_message *message, vo
|
|
|
a19bc6 |
if (r < 0)
|
|
|
a19bc6 |
return r;
|
|
|
a19bc6 |
|
|
|
a19bc6 |
+ flags = unit_file_bools_to_flags(runtime, force);
|
|
|
a19bc6 |
+
|
|
|
a19bc6 |
if (isempty(mode))
|
|
|
a19bc6 |
mm = UNIT_FILE_PRESET_FULL;
|
|
|
a19bc6 |
else {
|
|
|
a19bc6 |
@@ -1887,7 +1900,7 @@ static int method_preset_all_unit_files(sd_bus *bus, sd_bus_message *message, vo
|
|
|
a19bc6 |
|
|
|
a19bc6 |
scope = m->running_as == SYSTEMD_SYSTEM ? UNIT_FILE_SYSTEM : UNIT_FILE_USER;
|
|
|
a19bc6 |
|
|
|
a19bc6 |
- r = unit_file_preset_all(scope, runtime, NULL, mm, force, &changes, &n_changes);
|
|
|
a19bc6 |
+ r = unit_file_preset_all(scope, flags, NULL, mm, &changes, &n_changes);
|
|
|
a19bc6 |
if (r < 0) {
|
|
|
a19bc6 |
unit_file_changes_free(changes, n_changes);
|
|
|
a19bc6 |
return r;
|
|
|
a19bc6 |
@@ -1906,6 +1919,7 @@ static int method_add_dependency_unit_files(sd_bus *bus, sd_bus_message *message
|
|
|
a19bc6 |
char *target;
|
|
|
a19bc6 |
char *type;
|
|
|
a19bc6 |
UnitDependency dep;
|
|
|
a19bc6 |
+ UnitFileFlags flags;
|
|
|
a19bc6 |
|
|
|
a19bc6 |
assert(bus);
|
|
|
a19bc6 |
assert(message);
|
|
|
a19bc6 |
@@ -1925,6 +1939,8 @@ static int method_add_dependency_unit_files(sd_bus *bus, sd_bus_message *message
|
|
|
a19bc6 |
if (r < 0)
|
|
|
a19bc6 |
return r;
|
|
|
a19bc6 |
|
|
|
a19bc6 |
+ flags = unit_file_bools_to_flags(runtime, force);
|
|
|
a19bc6 |
+
|
|
|
a19bc6 |
dep = unit_dependency_from_string(type);
|
|
|
a19bc6 |
if (dep < 0)
|
|
|
a19bc6 |
return -EINVAL;
|
|
|
a19bc6 |
@@ -1935,7 +1951,7 @@ static int method_add_dependency_unit_files(sd_bus *bus, sd_bus_message *message
|
|
|
a19bc6 |
|
|
|
a19bc6 |
scope = m->running_as == SYSTEMD_SYSTEM ? UNIT_FILE_SYSTEM : UNIT_FILE_USER;
|
|
|
a19bc6 |
|
|
|
a19bc6 |
- r = unit_file_add_dependency(scope, runtime, NULL, l, target, dep, force, &changes, &n_changes);
|
|
|
a19bc6 |
+ r = unit_file_add_dependency(scope, flags, NULL, l, target, dep, &changes, &n_changes);
|
|
|
a19bc6 |
if (r < 0)
|
|
|
a19bc6 |
return r;
|
|
|
a19bc6 |
|
|
|
a19bc6 |
diff --git a/src/core/main.c b/src/core/main.c
|
|
|
181b3f |
index 820cbc3e5..a0df1e5ce 100644
|
|
|
a19bc6 |
--- a/src/core/main.c
|
|
|
a19bc6 |
+++ b/src/core/main.c
|
|
|
a19bc6 |
@@ -1658,7 +1658,7 @@ int main(int argc, char *argv[]) {
|
|
|
a19bc6 |
bump_rlimit_nofile(&saved_rlimit_nofile);
|
|
|
a19bc6 |
|
|
|
a19bc6 |
if (empty_etc) {
|
|
|
a19bc6 |
- r = unit_file_preset_all(UNIT_FILE_SYSTEM, false, NULL, UNIT_FILE_PRESET_FULL, false, NULL, 0);
|
|
|
a19bc6 |
+ r = unit_file_preset_all(UNIT_FILE_SYSTEM, 0, NULL, UNIT_FILE_PRESET_FULL, NULL, 0);
|
|
|
a19bc6 |
if (r < 0)
|
|
|
a19bc6 |
log_warning_errno(r, "Failed to populate /etc with preset unit settings, ignoring: %m");
|
|
|
a19bc6 |
else
|
|
|
a19bc6 |
diff --git a/src/shared/install.c b/src/shared/install.c
|
|
|
181b3f |
index 62bdf674c..b3df6b35c 100644
|
|
|
a19bc6 |
--- a/src/shared/install.c
|
|
|
a19bc6 |
+++ b/src/shared/install.c
|
|
|
a19bc6 |
@@ -1549,10 +1549,9 @@ static int install_context_mark_for_removal(
|
|
|
a19bc6 |
|
|
|
a19bc6 |
int unit_file_mask(
|
|
|
a19bc6 |
UnitFileScope scope,
|
|
|
a19bc6 |
- bool runtime,
|
|
|
a19bc6 |
+ UnitFileFlags flags,
|
|
|
a19bc6 |
const char *root_dir,
|
|
|
a19bc6 |
char **files,
|
|
|
a19bc6 |
- bool force,
|
|
|
a19bc6 |
UnitFileChange **changes,
|
|
|
a19bc6 |
unsigned *n_changes) {
|
|
|
a19bc6 |
|
|
|
a19bc6 |
@@ -1567,7 +1566,7 @@ int unit_file_mask(
|
|
|
a19bc6 |
if (r < 0)
|
|
|
a19bc6 |
return r;
|
|
|
a19bc6 |
|
|
|
a19bc6 |
- r = get_config_path(scope, runtime, root_dir, &prefix);
|
|
|
a19bc6 |
+ r = get_config_path(scope, flags & UNIT_FILE_RUNTIME, root_dir, &prefix);
|
|
|
a19bc6 |
if (r < 0)
|
|
|
a19bc6 |
return r;
|
|
|
a19bc6 |
|
|
|
a19bc6 |
@@ -1584,7 +1583,7 @@ int unit_file_mask(
|
|
|
a19bc6 |
if (!path)
|
|
|
a19bc6 |
return -ENOMEM;
|
|
|
a19bc6 |
|
|
|
a19bc6 |
- q = create_symlink("/dev/null", path, force, changes, n_changes);
|
|
|
a19bc6 |
+ q = create_symlink("/dev/null", path, !!(flags & UNIT_FILE_FORCE), changes, n_changes);
|
|
|
a19bc6 |
if (q < 0 && r >= 0)
|
|
|
a19bc6 |
r = q;
|
|
|
a19bc6 |
}
|
|
|
a19bc6 |
@@ -1594,7 +1593,7 @@ int unit_file_mask(
|
|
|
a19bc6 |
|
|
|
a19bc6 |
int unit_file_unmask(
|
|
|
a19bc6 |
UnitFileScope scope,
|
|
|
a19bc6 |
- bool runtime,
|
|
|
a19bc6 |
+ UnitFileFlags flags,
|
|
|
a19bc6 |
const char *root_dir,
|
|
|
a19bc6 |
char **files,
|
|
|
a19bc6 |
UnitFileChange **changes,
|
|
|
a19bc6 |
@@ -1614,7 +1613,7 @@ int unit_file_unmask(
|
|
|
a19bc6 |
if (r < 0)
|
|
|
a19bc6 |
return r;
|
|
|
a19bc6 |
|
|
|
a19bc6 |
- r = get_config_path(scope, runtime, root_dir, &config_path);
|
|
|
a19bc6 |
+ r = get_config_path(scope, flags & UNIT_FILE_RUNTIME, root_dir, &config_path);
|
|
|
a19bc6 |
if (r < 0)
|
|
|
a19bc6 |
return r;
|
|
|
a19bc6 |
|
|
|
a19bc6 |
@@ -1677,10 +1676,9 @@ int unit_file_unmask(
|
|
|
a19bc6 |
|
|
|
a19bc6 |
int unit_file_link(
|
|
|
a19bc6 |
UnitFileScope scope,
|
|
|
a19bc6 |
- bool runtime,
|
|
|
a19bc6 |
+ UnitFileFlags flags,
|
|
|
a19bc6 |
const char *root_dir,
|
|
|
a19bc6 |
char **files,
|
|
|
a19bc6 |
- bool force,
|
|
|
a19bc6 |
UnitFileChange **changes,
|
|
|
a19bc6 |
unsigned *n_changes) {
|
|
|
a19bc6 |
|
|
|
a19bc6 |
@@ -1702,7 +1700,7 @@ int unit_file_link(
|
|
|
a19bc6 |
if (r < 0)
|
|
|
a19bc6 |
return r;
|
|
|
a19bc6 |
|
|
|
a19bc6 |
- r = get_config_path(scope, runtime, root_dir, &config_path);
|
|
|
a19bc6 |
+ r = get_config_path(scope, flags & UNIT_FILE_RUNTIME, root_dir, &config_path);
|
|
|
a19bc6 |
if (r < 0)
|
|
|
a19bc6 |
return r;
|
|
|
a19bc6 |
|
|
|
a19bc6 |
@@ -1757,7 +1755,7 @@ int unit_file_link(
|
|
|
a19bc6 |
if (!path)
|
|
|
a19bc6 |
return -ENOMEM;
|
|
|
a19bc6 |
|
|
|
a19bc6 |
- q = create_symlink(*i, path, force, changes, n_changes);
|
|
|
a19bc6 |
+ q = create_symlink(*i, path, !!(flags & UNIT_FILE_FORCE), changes, n_changes);
|
|
|
a19bc6 |
if (q < 0 && r >= 0)
|
|
|
a19bc6 |
r = q;
|
|
|
a19bc6 |
}
|
|
|
a19bc6 |
@@ -1767,12 +1765,11 @@ int unit_file_link(
|
|
|
a19bc6 |
|
|
|
a19bc6 |
int unit_file_add_dependency(
|
|
|
a19bc6 |
UnitFileScope scope,
|
|
|
a19bc6 |
- bool runtime,
|
|
|
a19bc6 |
+ UnitFileFlags flags,
|
|
|
a19bc6 |
const char *root_dir,
|
|
|
a19bc6 |
char **files,
|
|
|
a19bc6 |
const char *target,
|
|
|
a19bc6 |
UnitDependency dep,
|
|
|
a19bc6 |
- bool force,
|
|
|
a19bc6 |
UnitFileChange **changes,
|
|
|
a19bc6 |
unsigned *n_changes) {
|
|
|
a19bc6 |
|
|
|
a19bc6 |
@@ -1801,7 +1798,7 @@ int unit_file_add_dependency(
|
|
|
a19bc6 |
if (r < 0)
|
|
|
a19bc6 |
return r;
|
|
|
a19bc6 |
|
|
|
a19bc6 |
- r = get_config_path(scope, runtime, root_dir, &config_path);
|
|
|
a19bc6 |
+ r = get_config_path(scope, flags & UNIT_FILE_RUNTIME, root_dir, &config_path);
|
|
|
a19bc6 |
if (r < 0)
|
|
|
a19bc6 |
return r;
|
|
|
a19bc6 |
|
|
|
a19bc6 |
@@ -1839,16 +1836,15 @@ int unit_file_add_dependency(
|
|
|
a19bc6 |
return -ENOMEM;
|
|
|
a19bc6 |
}
|
|
|
a19bc6 |
|
|
|
a19bc6 |
- return install_context_apply(scope, &c, &paths, config_path, root_dir, force, SEARCH_FOLLOW_CONFIG_SYMLINKS, changes, n_changes);
|
|
|
a19bc6 |
+ return install_context_apply(scope, &c, &paths, config_path, root_dir, !!(flags & UNIT_FILE_FORCE), SEARCH_FOLLOW_CONFIG_SYMLINKS, changes, n_changes);
|
|
|
a19bc6 |
}
|
|
|
a19bc6 |
|
|
|
a19bc6 |
|
|
|
a19bc6 |
int unit_file_enable(
|
|
|
a19bc6 |
UnitFileScope scope,
|
|
|
a19bc6 |
- bool runtime,
|
|
|
a19bc6 |
+ UnitFileFlags flags,
|
|
|
a19bc6 |
const char *root_dir,
|
|
|
a19bc6 |
char **files,
|
|
|
a19bc6 |
- bool force,
|
|
|
a19bc6 |
UnitFileChange **changes,
|
|
|
a19bc6 |
unsigned *n_changes) {
|
|
|
a19bc6 |
|
|
|
a19bc6 |
@@ -1870,7 +1866,7 @@ int unit_file_enable(
|
|
|
a19bc6 |
if (r < 0)
|
|
|
a19bc6 |
return r;
|
|
|
a19bc6 |
|
|
|
a19bc6 |
- r = get_config_path(scope, runtime, root_dir, &config_path);
|
|
|
a19bc6 |
+ r = get_config_path(scope, flags & UNIT_FILE_RUNTIME, root_dir, &config_path);
|
|
|
a19bc6 |
if (r < 0)
|
|
|
a19bc6 |
return r;
|
|
|
a19bc6 |
|
|
|
a19bc6 |
@@ -1889,12 +1885,12 @@ int unit_file_enable(
|
|
|
a19bc6 |
useful to determine whether the passed files had any
|
|
|
a19bc6 |
installation data at all. */
|
|
|
a19bc6 |
|
|
|
a19bc6 |
- return install_context_apply(scope, &c, &paths, config_path, root_dir, force, SEARCH_LOAD, changes, n_changes);
|
|
|
a19bc6 |
+ return install_context_apply(scope, &c, &paths, config_path, root_dir, !!(flags & UNIT_FILE_FORCE), SEARCH_LOAD, changes, n_changes);
|
|
|
a19bc6 |
}
|
|
|
a19bc6 |
|
|
|
a19bc6 |
int unit_file_disable(
|
|
|
a19bc6 |
UnitFileScope scope,
|
|
|
a19bc6 |
- bool runtime,
|
|
|
a19bc6 |
+ UnitFileFlags flags,
|
|
|
a19bc6 |
const char *root_dir,
|
|
|
a19bc6 |
char **files,
|
|
|
a19bc6 |
UnitFileChange **changes,
|
|
|
a19bc6 |
@@ -1918,7 +1914,7 @@ int unit_file_disable(
|
|
|
a19bc6 |
if (r < 0)
|
|
|
a19bc6 |
return r;
|
|
|
a19bc6 |
|
|
|
a19bc6 |
- r = get_config_path(scope, runtime, root_dir, &config_path);
|
|
|
a19bc6 |
+ r = get_config_path(scope, flags & UNIT_FILE_RUNTIME, root_dir, &config_path);
|
|
|
a19bc6 |
if (r < 0)
|
|
|
a19bc6 |
return r;
|
|
|
a19bc6 |
|
|
|
a19bc6 |
@@ -1940,10 +1936,9 @@ int unit_file_disable(
|
|
|
a19bc6 |
|
|
|
a19bc6 |
int unit_file_reenable(
|
|
|
a19bc6 |
UnitFileScope scope,
|
|
|
a19bc6 |
- bool runtime,
|
|
|
a19bc6 |
+ UnitFileFlags flags,
|
|
|
a19bc6 |
const char *root_dir,
|
|
|
a19bc6 |
char **files,
|
|
|
a19bc6 |
- bool force,
|
|
|
a19bc6 |
UnitFileChange **changes,
|
|
|
a19bc6 |
unsigned *n_changes) {
|
|
|
a19bc6 |
|
|
|
a19bc6 |
@@ -1958,19 +1953,19 @@ int unit_file_reenable(
|
|
|
a19bc6 |
n[i] = basename(files[i]);
|
|
|
a19bc6 |
n[i] = NULL;
|
|
|
a19bc6 |
|
|
|
a19bc6 |
- r = unit_file_disable(scope, runtime, root_dir, n, changes, n_changes);
|
|
|
a19bc6 |
+ r = unit_file_disable(scope, flags, root_dir, n, changes, n_changes);
|
|
|
a19bc6 |
if (r < 0)
|
|
|
a19bc6 |
return r;
|
|
|
a19bc6 |
|
|
|
a19bc6 |
/* But the enable command with the full name */
|
|
|
a19bc6 |
- return unit_file_enable(scope, runtime, root_dir, files, force, changes, n_changes);
|
|
|
a19bc6 |
+ return unit_file_enable(scope, flags, root_dir, files, changes, n_changes);
|
|
|
a19bc6 |
}
|
|
|
a19bc6 |
|
|
|
a19bc6 |
int unit_file_set_default(
|
|
|
a19bc6 |
UnitFileScope scope,
|
|
|
a19bc6 |
+ UnitFileFlags flags,
|
|
|
a19bc6 |
const char *root_dir,
|
|
|
a19bc6 |
const char *name,
|
|
|
a19bc6 |
- bool force,
|
|
|
a19bc6 |
UnitFileChange **changes,
|
|
|
a19bc6 |
unsigned *n_changes) {
|
|
|
a19bc6 |
|
|
|
a19bc6 |
@@ -2010,7 +2005,7 @@ int unit_file_set_default(
|
|
|
a19bc6 |
|
|
|
a19bc6 |
path = strjoina(config_path, "/" SPECIAL_DEFAULT_TARGET);
|
|
|
a19bc6 |
|
|
|
a19bc6 |
- return create_symlink(i->path, path, force, changes, n_changes);
|
|
|
a19bc6 |
+ return create_symlink(i->path, path, !!(flags & UNIT_FILE_FORCE), changes, n_changes);
|
|
|
a19bc6 |
}
|
|
|
a19bc6 |
|
|
|
a19bc6 |
int unit_file_get_default(
|
|
|
a19bc6 |
@@ -2311,11 +2306,10 @@ static int preset_prepare_one(
|
|
|
a19bc6 |
|
|
|
a19bc6 |
int unit_file_preset(
|
|
|
a19bc6 |
UnitFileScope scope,
|
|
|
a19bc6 |
- bool runtime,
|
|
|
a19bc6 |
+ UnitFileFlags flags,
|
|
|
a19bc6 |
const char *root_dir,
|
|
|
a19bc6 |
char **files,
|
|
|
a19bc6 |
UnitFilePresetMode mode,
|
|
|
a19bc6 |
- bool force,
|
|
|
a19bc6 |
UnitFileChange **changes,
|
|
|
a19bc6 |
unsigned *n_changes) {
|
|
|
a19bc6 |
|
|
|
a19bc6 |
@@ -2337,7 +2331,7 @@ int unit_file_preset(
|
|
|
a19bc6 |
if (r < 0)
|
|
|
a19bc6 |
return r;
|
|
|
a19bc6 |
|
|
|
a19bc6 |
- r = get_config_path(scope, runtime, root_dir, &config_path);
|
|
|
a19bc6 |
+ r = get_config_path(scope, flags & UNIT_FILE_RUNTIME, root_dir, &config_path);
|
|
|
a19bc6 |
if (r < 0)
|
|
|
a19bc6 |
return r;
|
|
|
a19bc6 |
|
|
|
a19bc6 |
@@ -2350,15 +2344,14 @@ int unit_file_preset(
|
|
|
a19bc6 |
return r;
|
|
|
a19bc6 |
}
|
|
|
a19bc6 |
|
|
|
a19bc6 |
- return execute_preset(scope, &plus, &minus, &paths, config_path, root_dir, files, mode, force, changes, n_changes);
|
|
|
a19bc6 |
+ return execute_preset(scope, &plus, &minus, &paths, config_path, root_dir, files, mode, !!(flags & UNIT_FILE_FORCE), changes, n_changes);
|
|
|
a19bc6 |
}
|
|
|
a19bc6 |
|
|
|
a19bc6 |
int unit_file_preset_all(
|
|
|
a19bc6 |
UnitFileScope scope,
|
|
|
a19bc6 |
- bool runtime,
|
|
|
a19bc6 |
+ UnitFileFlags flags,
|
|
|
a19bc6 |
const char *root_dir,
|
|
|
a19bc6 |
UnitFilePresetMode mode,
|
|
|
a19bc6 |
- bool force,
|
|
|
a19bc6 |
UnitFileChange **changes,
|
|
|
a19bc6 |
unsigned *n_changes) {
|
|
|
a19bc6 |
|
|
|
a19bc6 |
@@ -2380,7 +2373,7 @@ int unit_file_preset_all(
|
|
|
a19bc6 |
if (r < 0)
|
|
|
a19bc6 |
return r;
|
|
|
a19bc6 |
|
|
|
a19bc6 |
- r = get_config_path(scope, runtime, root_dir, &config_path);
|
|
|
a19bc6 |
+ r = get_config_path(scope, flags & UNIT_FILE_RUNTIME, root_dir, &config_path);
|
|
|
a19bc6 |
if (r < 0)
|
|
|
a19bc6 |
return r;
|
|
|
a19bc6 |
|
|
|
a19bc6 |
@@ -2434,7 +2427,7 @@ int unit_file_preset_all(
|
|
|
a19bc6 |
}
|
|
|
a19bc6 |
}
|
|
|
a19bc6 |
|
|
|
a19bc6 |
- return execute_preset(scope, &plus, &minus, &paths, config_path, root_dir, NULL, mode, force, changes, n_changes);
|
|
|
a19bc6 |
+ return execute_preset(scope, &plus, &minus, &paths, config_path, root_dir, NULL, mode, !!(flags & UNIT_FILE_FORCE), changes, n_changes);
|
|
|
a19bc6 |
}
|
|
|
a19bc6 |
|
|
|
a19bc6 |
static void unit_file_list_free_one(UnitFileList *f) {
|
|
|
a19bc6 |
diff --git a/src/shared/install.h b/src/shared/install.h
|
|
|
181b3f |
index 7e40445d3..c961b53d0 100644
|
|
|
a19bc6 |
--- a/src/shared/install.h
|
|
|
a19bc6 |
+++ b/src/shared/install.h
|
|
|
a19bc6 |
@@ -66,6 +66,11 @@ typedef enum UnitFileChangeType {
|
|
|
a19bc6 |
_UNIT_FILE_CHANGE_TYPE_INVALID = -1
|
|
|
a19bc6 |
} UnitFileChangeType;
|
|
|
a19bc6 |
|
|
|
a19bc6 |
+typedef enum UnitFileFlags {
|
|
|
a19bc6 |
+ UNIT_FILE_RUNTIME = 1,
|
|
|
a19bc6 |
+ UNIT_FILE_FORCE = 1 << 1
|
|
|
a19bc6 |
+} UnitFileFlags;
|
|
|
a19bc6 |
+
|
|
|
a19bc6 |
static inline bool unit_file_change_is_modification(UnitFileChangeType type) {
|
|
|
a19bc6 |
return IN_SET(type, UNIT_FILE_SYMLINK, UNIT_FILE_UNLINK);
|
|
|
a19bc6 |
}
|
|
|
a19bc6 |
@@ -120,17 +125,17 @@ static inline bool UNIT_FILE_INSTALL_INFO_HAS_ALSO(InstallInfo *i) {
|
|
|
a19bc6 |
return !strv_isempty(i->also);
|
|
|
a19bc6 |
}
|
|
|
a19bc6 |
|
|
|
a19bc6 |
-int unit_file_enable(UnitFileScope scope, bool runtime, const char *root_dir, char **files, bool force, UnitFileChange **changes, unsigned *n_changes);
|
|
|
a19bc6 |
-int unit_file_disable(UnitFileScope scope, bool runtime, const char *root_dir, char **files, UnitFileChange **changes, unsigned *n_changes);
|
|
|
a19bc6 |
-int unit_file_reenable(UnitFileScope scope, bool runtime, const char *root_dir, char **files, bool force, UnitFileChange **changes, unsigned *n_changes);
|
|
|
a19bc6 |
-int unit_file_link(UnitFileScope scope, bool runtime, const char *root_dir, char **files, bool force, UnitFileChange **changes, unsigned *n_changes);
|
|
|
a19bc6 |
-int unit_file_preset(UnitFileScope scope, bool runtime, const char *root_dir, char **files, UnitFilePresetMode mode, bool force, UnitFileChange **changes, unsigned *n_changes);
|
|
|
a19bc6 |
-int unit_file_preset_all(UnitFileScope scope, bool runtime, const char *root_dir, UnitFilePresetMode mode, bool force, UnitFileChange **changes, unsigned *n_changes);
|
|
|
a19bc6 |
-int unit_file_mask(UnitFileScope scope, bool runtime, const char *root_dir, char **files, bool force, UnitFileChange **changes, unsigned *n_changes);
|
|
|
a19bc6 |
-int unit_file_unmask(UnitFileScope scope, bool runtime, const char *root_dir, char **files, UnitFileChange **changes, unsigned *n_changes);
|
|
|
a19bc6 |
-int unit_file_set_default(UnitFileScope scope, const char *root_dir, const char *file, bool force, UnitFileChange **changes, unsigned *n_changes);
|
|
|
a19bc6 |
+int unit_file_enable(UnitFileScope scope, UnitFileFlags flags, const char *root_dir, char **files, UnitFileChange **changes, unsigned *n_changes);
|
|
|
a19bc6 |
+int unit_file_disable(UnitFileScope scope, UnitFileFlags flags, const char *root_dir, char **files, UnitFileChange **changes, unsigned *n_changes);
|
|
|
a19bc6 |
+int unit_file_reenable(UnitFileScope scope, UnitFileFlags flags, const char *root_dir, char **files, UnitFileChange **changes, unsigned *n_changes);
|
|
|
a19bc6 |
+int unit_file_link(UnitFileScope scope, UnitFileFlags flags, const char *root_dir, char **files, UnitFileChange **changes, unsigned *n_changes);
|
|
|
a19bc6 |
+int unit_file_preset(UnitFileScope scope, UnitFileFlags flags, const char *root_dir, char **files, UnitFilePresetMode mode, UnitFileChange **changes, unsigned *n_changes);
|
|
|
a19bc6 |
+int unit_file_preset_all(UnitFileScope scope, UnitFileFlags flags, const char *root_dir, UnitFilePresetMode mode, UnitFileChange **changes, unsigned *n_changes);
|
|
|
a19bc6 |
+int unit_file_mask(UnitFileScope scope, UnitFileFlags flags, const char *root_dir, char **files, UnitFileChange **changes, unsigned *n_changes);
|
|
|
a19bc6 |
+int unit_file_unmask(UnitFileScope scope, UnitFileFlags flags, const char *root_dir, char **files, UnitFileChange **changes, unsigned *n_changes);
|
|
|
a19bc6 |
+int unit_file_set_default(UnitFileScope scope, UnitFileFlags flags, const char *root_dir, const char *file, UnitFileChange **changes, unsigned *n_changes);
|
|
|
a19bc6 |
int unit_file_get_default(UnitFileScope scope, const char *root_dir, char **name);
|
|
|
a19bc6 |
-int unit_file_add_dependency(UnitFileScope scope, bool runtime, const char *root_dir, char **files, const char *target, UnitDependency dep, bool force, UnitFileChange **changes, unsigned *n_changes);
|
|
|
a19bc6 |
+int unit_file_add_dependency(UnitFileScope scope, UnitFileFlags flags, const char *root_dir, char **files, const char *target, UnitDependency dep, UnitFileChange **changes, unsigned *n_changes);
|
|
|
a19bc6 |
|
|
|
a19bc6 |
int unit_file_lookup_state(UnitFileScope scope, const char *root_dir,const LookupPaths *paths, const char *name, UnitFileState *ret);
|
|
|
a19bc6 |
int unit_file_get_state(UnitFileScope scope, const char *root_dir, const char *filename, UnitFileState *ret);
|
|
|
a19bc6 |
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
|
|
|
181b3f |
index 1e1009f38..e0dbf0fda 100644
|
|
|
a19bc6 |
--- a/src/systemctl/systemctl.c
|
|
|
a19bc6 |
+++ b/src/systemctl/systemctl.c
|
|
|
a19bc6 |
@@ -165,6 +165,11 @@ static int daemon_reload(sd_bus *bus, char **args);
|
|
|
a19bc6 |
static int halt_now(enum action a);
|
|
|
a19bc6 |
static int check_one_unit(sd_bus *bus, const char *name, const char *good_states, bool quiet);
|
|
|
a19bc6 |
|
|
|
a19bc6 |
+static UnitFileFlags args_to_flags(void) {
|
|
|
a19bc6 |
+ return (arg_runtime ? UNIT_FILE_RUNTIME : 0) |
|
|
|
a19bc6 |
+ (arg_force ? UNIT_FILE_FORCE : 0);
|
|
|
a19bc6 |
+}
|
|
|
a19bc6 |
+
|
|
|
a19bc6 |
static char** strv_skip_first(char **strv) {
|
|
|
a19bc6 |
if (strv_length(strv) > 0)
|
|
|
a19bc6 |
return strv + 1;
|
|
|
a19bc6 |
@@ -1974,7 +1979,7 @@ static int set_default(sd_bus *bus, char **args) {
|
|
|
a19bc6 |
return log_oom();
|
|
|
a19bc6 |
|
|
|
a19bc6 |
if (!bus || avoid_bus()) {
|
|
|
a19bc6 |
- r = unit_file_set_default(arg_scope, arg_root, unit, true, &changes, &n_changes);
|
|
|
a19bc6 |
+ r = unit_file_set_default(arg_scope, UNIT_FILE_FORCE, arg_root, unit, &changes, &n_changes);
|
|
|
a19bc6 |
if (r < 0)
|
|
|
a19bc6 |
return log_error_errno(r, "Failed to set default target: %m");
|
|
|
a19bc6 |
|
|
|
a19bc6 |
@@ -5407,22 +5412,25 @@ static int enable_unit(sd_bus *bus, char **args) {
|
|
|
a19bc6 |
}
|
|
|
a19bc6 |
|
|
|
a19bc6 |
if (!bus || avoid_bus()) {
|
|
|
a19bc6 |
+ UnitFileFlags flags;
|
|
|
a19bc6 |
+
|
|
|
a19bc6 |
+ flags = args_to_flags();
|
|
|
a19bc6 |
if (streq(verb, "enable")) {
|
|
|
a19bc6 |
- r = unit_file_enable(arg_scope, arg_runtime, arg_root, names, arg_force, &changes, &n_changes);
|
|
|
a19bc6 |
+ r = unit_file_enable(arg_scope, flags, arg_root, names, &changes, &n_changes);
|
|
|
a19bc6 |
carries_install_info = r;
|
|
|
a19bc6 |
} else if (streq(verb, "disable"))
|
|
|
a19bc6 |
- r = unit_file_disable(arg_scope, arg_runtime, arg_root, names, &changes, &n_changes);
|
|
|
a19bc6 |
+ r = unit_file_disable(arg_scope, flags, arg_root, names, &changes, &n_changes);
|
|
|
a19bc6 |
else if (streq(verb, "reenable")) {
|
|
|
a19bc6 |
- r = unit_file_reenable(arg_scope, arg_runtime, arg_root, names, arg_force, &changes, &n_changes);
|
|
|
a19bc6 |
+ r = unit_file_reenable(arg_scope, flags, arg_root, names, &changes, &n_changes);
|
|
|
a19bc6 |
carries_install_info = r;
|
|
|
a19bc6 |
} else if (streq(verb, "link"))
|
|
|
a19bc6 |
- r = unit_file_link(arg_scope, arg_runtime, arg_root, names, arg_force, &changes, &n_changes);
|
|
|
a19bc6 |
+ r = unit_file_link(arg_scope, flags, arg_root, names, &changes, &n_changes);
|
|
|
a19bc6 |
else if (streq(verb, "preset")) {
|
|
|
a19bc6 |
- r = unit_file_preset(arg_scope, arg_runtime, arg_root, names, arg_preset_mode, arg_force, &changes, &n_changes);
|
|
|
a19bc6 |
+ r = unit_file_preset(arg_scope, flags, arg_root, names, arg_preset_mode, &changes, &n_changes);
|
|
|
a19bc6 |
} else if (streq(verb, "mask"))
|
|
|
a19bc6 |
- r = unit_file_mask(arg_scope, arg_runtime, arg_root, names, arg_force, &changes, &n_changes);
|
|
|
a19bc6 |
+ r = unit_file_mask(arg_scope, flags, arg_root, names, &changes, &n_changes);
|
|
|
a19bc6 |
else if (streq(verb, "unmask"))
|
|
|
a19bc6 |
- r = unit_file_unmask(arg_scope, arg_runtime, arg_root, names, &changes, &n_changes);
|
|
|
a19bc6 |
+ r = unit_file_unmask(arg_scope, flags, arg_root, names, &changes, &n_changes);
|
|
|
a19bc6 |
else
|
|
|
a19bc6 |
assert_not_reached("Unknown verb");
|
|
|
a19bc6 |
|
|
|
a19bc6 |
@@ -5588,7 +5596,7 @@ static int add_dependency(sd_bus *bus, char **args) {
|
|
|
a19bc6 |
UnitFileChange *changes = NULL;
|
|
|
a19bc6 |
unsigned n_changes = 0;
|
|
|
a19bc6 |
|
|
|
a19bc6 |
- r = unit_file_add_dependency(arg_scope, arg_runtime, arg_root, names, target, dep, arg_force, &changes, &n_changes);
|
|
|
a19bc6 |
+ r = unit_file_add_dependency(arg_scope, args_to_flags(), arg_root, names, target, dep, &changes, &n_changes);
|
|
|
a19bc6 |
|
|
|
a19bc6 |
if (r < 0)
|
|
|
a19bc6 |
return log_error_errno(r, "Can't add dependency: %m");
|
|
|
a19bc6 |
@@ -5652,7 +5660,7 @@ static int preset_all(sd_bus *bus, char **args) {
|
|
|
a19bc6 |
|
|
|
a19bc6 |
if (!bus || avoid_bus()) {
|
|
|
a19bc6 |
|
|
|
a19bc6 |
- r = unit_file_preset_all(arg_scope, arg_runtime, arg_root, arg_preset_mode, arg_force, &changes, &n_changes);
|
|
|
a19bc6 |
+ r = unit_file_preset_all(arg_scope, args_to_flags(), arg_root, arg_preset_mode, &changes, &n_changes);
|
|
|
a19bc6 |
if (r < 0) {
|
|
|
a19bc6 |
log_error_errno(r, "Operation failed: %m");
|
|
|
a19bc6 |
goto finish;
|
|
|
a19bc6 |
diff --git a/src/test/test-install-root.c b/src/test/test-install-root.c
|
|
|
181b3f |
index 667c3748c..cb417d4c1 100644
|
|
|
a19bc6 |
--- a/src/test/test-install-root.c
|
|
|
a19bc6 |
+++ b/src/test/test-install-root.c
|
|
|
a19bc6 |
@@ -62,7 +62,7 @@ static void test_basic_mask_and_enable(const char *root) {
|
|
|
a19bc6 |
assert_se(unit_file_get_state(UNIT_FILE_SYSTEM, root, "d.service", NULL) >= 0);
|
|
|
a19bc6 |
assert_se(unit_file_get_state(UNIT_FILE_SYSTEM, root, "d.service", &state) >= 0 && state == UNIT_FILE_DISABLED);
|
|
|
a19bc6 |
|
|
|
a19bc6 |
- assert_se(unit_file_mask(UNIT_FILE_SYSTEM, false, root, STRV_MAKE("a.service"), false, &changes, &n_changes) >= 0);
|
|
|
a19bc6 |
+ assert_se(unit_file_mask(UNIT_FILE_SYSTEM, 0, root, STRV_MAKE("a.service"), &changes, &n_changes) >= 0);
|
|
|
a19bc6 |
assert_se(n_changes == 1);
|
|
|
a19bc6 |
assert_se(changes[0].type == UNIT_FILE_SYMLINK);
|
|
|
a19bc6 |
assert_se(streq(changes[0].source, "/dev/null"));
|
|
|
a19bc6 |
@@ -78,11 +78,11 @@ static void test_basic_mask_and_enable(const char *root) {
|
|
|
a19bc6 |
assert_se(unit_file_get_state(UNIT_FILE_SYSTEM, root, "d.service", &state) >= 0 && state == UNIT_FILE_MASKED);
|
|
|
a19bc6 |
|
|
|
a19bc6 |
/* Enabling a masked unit should fail! */
|
|
|
a19bc6 |
- assert_se(unit_file_enable(UNIT_FILE_SYSTEM, false, root, STRV_MAKE("a.service"), false, &changes, &n_changes) == -ESHUTDOWN);
|
|
|
a19bc6 |
+ assert_se(unit_file_enable(UNIT_FILE_SYSTEM, 0, root, STRV_MAKE("a.service"), &changes, &n_changes) == -ESHUTDOWN);
|
|
|
a19bc6 |
unit_file_changes_free(changes, n_changes);
|
|
|
a19bc6 |
changes = NULL; n_changes = 0;
|
|
|
a19bc6 |
|
|
|
a19bc6 |
- assert_se(unit_file_unmask(UNIT_FILE_SYSTEM, false, root, STRV_MAKE("a.service"), &changes, &n_changes) >= 0);
|
|
|
a19bc6 |
+ assert_se(unit_file_unmask(UNIT_FILE_SYSTEM, 0, root, STRV_MAKE("a.service"), &changes, &n_changes) >= 0);
|
|
|
a19bc6 |
assert_se(n_changes == 1);
|
|
|
a19bc6 |
assert_se(changes[0].type == UNIT_FILE_UNLINK);
|
|
|
a19bc6 |
p = strjoina(root, SYSTEM_CONFIG_UNIT_PATH"/a.service");
|
|
|
a19bc6 |
@@ -90,7 +90,7 @@ static void test_basic_mask_and_enable(const char *root) {
|
|
|
a19bc6 |
unit_file_changes_free(changes, n_changes);
|
|
|
a19bc6 |
changes = NULL; n_changes = 0;
|
|
|
a19bc6 |
|
|
|
a19bc6 |
- assert_se(unit_file_enable(UNIT_FILE_SYSTEM, false, root, STRV_MAKE("a.service"), false, &changes, &n_changes) == 1);
|
|
|
a19bc6 |
+ assert_se(unit_file_enable(UNIT_FILE_SYSTEM, 0, root, STRV_MAKE("a.service"), &changes, &n_changes) == 1);
|
|
|
a19bc6 |
assert_se(n_changes == 1);
|
|
|
a19bc6 |
assert_se(changes[0].type == UNIT_FILE_SYMLINK);
|
|
|
a19bc6 |
assert_se(streq(changes[0].source, "/usr/lib/systemd/system/a.service"));
|
|
|
a19bc6 |
@@ -105,12 +105,12 @@ static void test_basic_mask_and_enable(const char *root) {
|
|
|
a19bc6 |
assert_se(unit_file_get_state(UNIT_FILE_SYSTEM, root, "d.service", &state) >= 0 && state == UNIT_FILE_ENABLED);
|
|
|
a19bc6 |
|
|
|
a19bc6 |
/* Enabling it again should succeed but be a NOP */
|
|
|
a19bc6 |
- assert_se(unit_file_enable(UNIT_FILE_SYSTEM, false, root, STRV_MAKE("a.service"), false, &changes, &n_changes) == 1);
|
|
|
a19bc6 |
+ assert_se(unit_file_enable(UNIT_FILE_SYSTEM, 0, root, STRV_MAKE("a.service"), &changes, &n_changes) == 1);
|
|
|
a19bc6 |
assert_se(n_changes == 0);
|
|
|
a19bc6 |
unit_file_changes_free(changes, n_changes);
|
|
|
a19bc6 |
changes = NULL; n_changes = 0;
|
|
|
a19bc6 |
|
|
|
a19bc6 |
- assert_se(unit_file_disable(UNIT_FILE_SYSTEM, false, root, STRV_MAKE("a.service"), &changes, &n_changes) >= 0);
|
|
|
a19bc6 |
+ assert_se(unit_file_disable(UNIT_FILE_SYSTEM, 0, root, STRV_MAKE("a.service"), &changes, &n_changes) >= 0);
|
|
|
a19bc6 |
assert_se(n_changes == 1);
|
|
|
a19bc6 |
assert_se(changes[0].type == UNIT_FILE_UNLINK);
|
|
|
a19bc6 |
p = strjoina(root, SYSTEM_CONFIG_UNIT_PATH"/multi-user.target.wants/a.service");
|
|
|
a19bc6 |
@@ -124,13 +124,13 @@ static void test_basic_mask_and_enable(const char *root) {
|
|
|
a19bc6 |
assert_se(unit_file_get_state(UNIT_FILE_SYSTEM, root, "d.service", &state) >= 0 && state == UNIT_FILE_DISABLED);
|
|
|
a19bc6 |
|
|
|
a19bc6 |
/* Disabling a disabled unit must suceed but be a NOP */
|
|
|
a19bc6 |
- assert_se(unit_file_disable(UNIT_FILE_SYSTEM, false, root, STRV_MAKE("a.service"), &changes, &n_changes) >= 0);
|
|
|
a19bc6 |
+ assert_se(unit_file_disable(UNIT_FILE_SYSTEM, 0, root, STRV_MAKE("a.service"), &changes, &n_changes) >= 0);
|
|
|
a19bc6 |
assert_se(n_changes == 0);
|
|
|
a19bc6 |
unit_file_changes_free(changes, n_changes);
|
|
|
a19bc6 |
changes = NULL; n_changes = 0;
|
|
|
a19bc6 |
|
|
|
a19bc6 |
/* Let's enable this indirectly via a symlink */
|
|
|
a19bc6 |
- assert_se(unit_file_enable(UNIT_FILE_SYSTEM, false, root, STRV_MAKE("d.service"), false, &changes, &n_changes) >= 0);
|
|
|
a19bc6 |
+ assert_se(unit_file_enable(UNIT_FILE_SYSTEM, 0, root, STRV_MAKE("d.service"), &changes, &n_changes) >= 0);
|
|
|
a19bc6 |
assert_se(n_changes == 1);
|
|
|
a19bc6 |
assert_se(changes[0].type == UNIT_FILE_SYMLINK);
|
|
|
a19bc6 |
assert_se(streq(changes[0].source, "/usr/lib/systemd/system/a.service"));
|
|
|
a19bc6 |
@@ -146,7 +146,7 @@ static void test_basic_mask_and_enable(const char *root) {
|
|
|
a19bc6 |
|
|
|
a19bc6 |
/* Let's try to reenable */
|
|
|
a19bc6 |
|
|
|
a19bc6 |
- assert_se(unit_file_reenable(UNIT_FILE_SYSTEM, false, root, STRV_MAKE("b.service"), false, &changes, &n_changes) >= 0);
|
|
|
a19bc6 |
+ assert_se(unit_file_reenable(UNIT_FILE_SYSTEM, 0, root, STRV_MAKE("b.service"), &changes, &n_changes) >= 0);
|
|
|
a19bc6 |
assert_se(n_changes == 2);
|
|
|
a19bc6 |
assert_se(changes[0].type == UNIT_FILE_UNLINK);
|
|
|
a19bc6 |
p = strjoina(root, SYSTEM_CONFIG_UNIT_PATH"/multi-user.target.wants/a.service");
|
|
|
a19bc6 |
@@ -215,7 +215,7 @@ static void test_linked_units(const char *root) {
|
|
|
a19bc6 |
assert_se(unit_file_get_state(UNIT_FILE_SYSTEM, root, "linked3.service", &state) >= 0 && state == UNIT_FILE_LINKED);
|
|
|
a19bc6 |
|
|
|
a19bc6 |
/* First, let's link the unit into the search path */
|
|
|
a19bc6 |
- assert_se(unit_file_link(UNIT_FILE_SYSTEM, false, root, STRV_MAKE("/opt/linked.service"), false, &changes, &n_changes) >= 0);
|
|
|
a19bc6 |
+ assert_se(unit_file_link(UNIT_FILE_SYSTEM, 0, root, STRV_MAKE("/opt/linked.service"), &changes, &n_changes) >= 0);
|
|
|
a19bc6 |
assert_se(n_changes == 1);
|
|
|
a19bc6 |
assert_se(changes[0].type == UNIT_FILE_SYMLINK);
|
|
|
a19bc6 |
assert_se(streq(changes[0].source, "/opt/linked.service"));
|
|
|
a19bc6 |
@@ -227,7 +227,7 @@ static void test_linked_units(const char *root) {
|
|
|
a19bc6 |
assert_se(unit_file_get_state(UNIT_FILE_SYSTEM, root, "linked.service", &state) >= 0 && state == UNIT_FILE_LINKED);
|
|
|
a19bc6 |
|
|
|
a19bc6 |
/* Let's unlink it from the search path again */
|
|
|
a19bc6 |
- assert_se(unit_file_disable(UNIT_FILE_SYSTEM, false, root, STRV_MAKE("linked.service"), &changes, &n_changes) >= 0);
|
|
|
a19bc6 |
+ assert_se(unit_file_disable(UNIT_FILE_SYSTEM, 0, root, STRV_MAKE("linked.service"), &changes, &n_changes) >= 0);
|
|
|
a19bc6 |
assert_se(n_changes == 1);
|
|
|
a19bc6 |
assert_se(changes[0].type == UNIT_FILE_UNLINK);
|
|
|
a19bc6 |
p = strjoina(root, SYSTEM_CONFIG_UNIT_PATH"/linked.service");
|
|
|
a19bc6 |
@@ -238,7 +238,7 @@ static void test_linked_units(const char *root) {
|
|
|
a19bc6 |
assert_se(unit_file_get_state(UNIT_FILE_SYSTEM, root, "linked.service", NULL) == -ENOENT);
|
|
|
a19bc6 |
|
|
|
a19bc6 |
/* Now, let's not just link it, but also enable it */
|
|
|
a19bc6 |
- assert_se(unit_file_enable(UNIT_FILE_SYSTEM, false, root, STRV_MAKE("/opt/linked.service"), false, &changes, &n_changes) >= 0);
|
|
|
a19bc6 |
+ assert_se(unit_file_enable(UNIT_FILE_SYSTEM, 0, root, STRV_MAKE("/opt/linked.service"), &changes, &n_changes) >= 0);
|
|
|
a19bc6 |
assert_se(n_changes == 2);
|
|
|
a19bc6 |
p = strjoina(root, SYSTEM_CONFIG_UNIT_PATH"/multi-user.target.wants/linked.service");
|
|
|
a19bc6 |
q = strjoina(root, SYSTEM_CONFIG_UNIT_PATH"/linked.service");
|
|
|
a19bc6 |
@@ -260,7 +260,7 @@ static void test_linked_units(const char *root) {
|
|
|
a19bc6 |
assert_se(unit_file_get_state(UNIT_FILE_SYSTEM, root, "linked.service", &state) >= 0 && state == UNIT_FILE_ENABLED);
|
|
|
a19bc6 |
|
|
|
a19bc6 |
/* And let's unlink it again */
|
|
|
a19bc6 |
- assert_se(unit_file_disable(UNIT_FILE_SYSTEM, false, root, STRV_MAKE("linked.service"), &changes, &n_changes) >= 0);
|
|
|
a19bc6 |
+ assert_se(unit_file_disable(UNIT_FILE_SYSTEM, 0, root, STRV_MAKE("linked.service"), &changes, &n_changes) >= 0);
|
|
|
a19bc6 |
assert_se(n_changes == 2);
|
|
|
a19bc6 |
p = strjoina(root, SYSTEM_CONFIG_UNIT_PATH"/multi-user.target.wants/linked.service");
|
|
|
a19bc6 |
q = strjoina(root, SYSTEM_CONFIG_UNIT_PATH"/linked.service");
|
|
|
a19bc6 |
@@ -280,7 +280,7 @@ static void test_linked_units(const char *root) {
|
|
|
a19bc6 |
|
|
|
a19bc6 |
assert_se(unit_file_get_state(UNIT_FILE_SYSTEM, root, "linked.service", NULL) == -ENOENT);
|
|
|
a19bc6 |
|
|
|
a19bc6 |
- assert_se(unit_file_enable(UNIT_FILE_SYSTEM, false, root, STRV_MAKE("linked2.service"), false, &changes, &n_changes) >= 0);
|
|
|
a19bc6 |
+ assert_se(unit_file_enable(UNIT_FILE_SYSTEM, 0, root, STRV_MAKE("linked2.service"), &changes, &n_changes) >= 0);
|
|
|
a19bc6 |
assert_se(n_changes == 2);
|
|
|
a19bc6 |
p = strjoina(root, SYSTEM_CONFIG_UNIT_PATH"/multi-user.target.wants/linked2.service");
|
|
|
a19bc6 |
q = strjoina(root, SYSTEM_CONFIG_UNIT_PATH"/linked2.service");
|
|
|
a19bc6 |
@@ -299,7 +299,7 @@ static void test_linked_units(const char *root) {
|
|
|
a19bc6 |
unit_file_changes_free(changes, n_changes);
|
|
|
a19bc6 |
changes = NULL; n_changes = 0;
|
|
|
a19bc6 |
|
|
|
a19bc6 |
- assert_se(unit_file_enable(UNIT_FILE_SYSTEM, false, root, STRV_MAKE("linked3.service"), false, &changes, &n_changes) == -ELOOP);
|
|
|
a19bc6 |
+ assert_se(unit_file_enable(UNIT_FILE_SYSTEM, 0, root, STRV_MAKE("linked3.service"), &changes, &n_changes) == -ELOOP);
|
|
|
a19bc6 |
unit_file_changes_free(changes, n_changes);
|
|
|
a19bc6 |
changes = NULL; n_changes = 0;
|
|
|
a19bc6 |
}
|
|
|
a19bc6 |
@@ -318,14 +318,14 @@ static void test_default(const char *root) {
|
|
|
a19bc6 |
|
|
|
a19bc6 |
assert_se(unit_file_get_default(UNIT_FILE_SYSTEM, root, &def) == -ENOENT);
|
|
|
a19bc6 |
|
|
|
a19bc6 |
- assert_se(unit_file_set_default(UNIT_FILE_SYSTEM, root, "idontexist.target", false, &changes, &n_changes) == -ENOENT);
|
|
|
a19bc6 |
+ assert_se(unit_file_set_default(UNIT_FILE_SYSTEM, 0, root, "idontexist.target", &changes, &n_changes) == -ENOENT);
|
|
|
a19bc6 |
assert_se(n_changes == 0);
|
|
|
a19bc6 |
unit_file_changes_free(changes, n_changes);
|
|
|
a19bc6 |
changes = NULL; n_changes = 0;
|
|
|
a19bc6 |
|
|
|
a19bc6 |
assert_se(unit_file_get_default(UNIT_FILE_SYSTEM, root, &def) == -ENOENT);
|
|
|
a19bc6 |
|
|
|
a19bc6 |
- assert_se(unit_file_set_default(UNIT_FILE_SYSTEM, root, "test-default.target", false, &changes, &n_changes) >= 0);
|
|
|
a19bc6 |
+ assert_se(unit_file_set_default(UNIT_FILE_SYSTEM, 0, root, "test-default.target", &changes, &n_changes) >= 0);
|
|
|
a19bc6 |
assert_se(n_changes == 1);
|
|
|
a19bc6 |
assert_se(changes[0].type == UNIT_FILE_SYMLINK);
|
|
|
a19bc6 |
assert_se(streq(changes[0].source, "/usr/lib/systemd/system/test-default-real.target"));
|
|
|
a19bc6 |
@@ -355,7 +355,7 @@ static void test_add_dependency(const char *root) {
|
|
|
a19bc6 |
p = strjoina(root, "/usr/lib/systemd/system/add-dependency-test-service.service");
|
|
|
a19bc6 |
assert_se(symlink("real-add-dependency-test-service.service", p) >= 0);
|
|
|
a19bc6 |
|
|
|
a19bc6 |
- assert_se(unit_file_add_dependency(UNIT_FILE_SYSTEM, false, root, STRV_MAKE("add-dependency-test-service.service"), "add-dependency-test-target.target", UNIT_WANTS, false, &changes, &n_changes) >= 0);
|
|
|
a19bc6 |
+ assert_se(unit_file_add_dependency(UNIT_FILE_SYSTEM, 0, root, STRV_MAKE("add-dependency-test-service.service"), "add-dependency-test-target.target", UNIT_WANTS, &changes, &n_changes) >= 0);
|
|
|
a19bc6 |
assert_se(n_changes == 1);
|
|
|
a19bc6 |
assert_se(changes[0].type == UNIT_FILE_SYMLINK);
|
|
|
a19bc6 |
assert_se(streq(changes[0].source, "/usr/lib/systemd/system/real-add-dependency-test-service.service"));
|
|
|
a19bc6 |
@@ -392,7 +392,7 @@ static void test_template_enable(const char *root) {
|
|
|
a19bc6 |
assert_se(unit_file_get_state(UNIT_FILE_SYSTEM, root, "template-symlink@def.service", &state) >= 0 && state == UNIT_FILE_DISABLED);
|
|
|
a19bc6 |
assert_se(unit_file_get_state(UNIT_FILE_SYSTEM, root, "template-symlink@foo.service", &state) >= 0 && state == UNIT_FILE_DISABLED);
|
|
|
a19bc6 |
|
|
|
a19bc6 |
- assert_se(unit_file_enable(UNIT_FILE_SYSTEM, false, root, STRV_MAKE("template@.service"), false, &changes, &n_changes) >= 0);
|
|
|
a19bc6 |
+ assert_se(unit_file_enable(UNIT_FILE_SYSTEM, 0, root, STRV_MAKE("template@.service"), &changes, &n_changes) >= 0);
|
|
|
a19bc6 |
assert_se(n_changes == 1);
|
|
|
a19bc6 |
assert_se(changes[0].type == UNIT_FILE_SYMLINK);
|
|
|
a19bc6 |
assert_se(streq(changes[0].source, "/usr/lib/systemd/system/template@.service"));
|
|
|
a19bc6 |
@@ -408,7 +408,7 @@ static void test_template_enable(const char *root) {
|
|
|
a19bc6 |
assert_se(unit_file_get_state(UNIT_FILE_SYSTEM, root, "template-symlink@def.service", &state) >= 0 && state == UNIT_FILE_ENABLED);
|
|
|
a19bc6 |
assert_se(unit_file_get_state(UNIT_FILE_SYSTEM, root, "template-symlink@foo.service", &state) >= 0 && state == UNIT_FILE_DISABLED);
|
|
|
a19bc6 |
|
|
|
a19bc6 |
- assert_se(unit_file_disable(UNIT_FILE_SYSTEM, false, root, STRV_MAKE("template@.service"), &changes, &n_changes) >= 0);
|
|
|
a19bc6 |
+ assert_se(unit_file_disable(UNIT_FILE_SYSTEM, 0, root, STRV_MAKE("template@.service"), &changes, &n_changes) >= 0);
|
|
|
a19bc6 |
assert_se(n_changes == 1);
|
|
|
a19bc6 |
assert_se(changes[0].type == UNIT_FILE_UNLINK);
|
|
|
a19bc6 |
assert_se(streq(changes[0].path, p));
|
|
|
a19bc6 |
@@ -422,7 +422,7 @@ static void test_template_enable(const char *root) {
|
|
|
a19bc6 |
assert_se(unit_file_get_state(UNIT_FILE_SYSTEM, root, "template-symlink@def.service", &state) >= 0 && state == UNIT_FILE_DISABLED);
|
|
|
a19bc6 |
assert_se(unit_file_get_state(UNIT_FILE_SYSTEM, root, "template-symlink@foo.service", &state) >= 0 && state == UNIT_FILE_DISABLED);
|
|
|
a19bc6 |
|
|
|
a19bc6 |
- assert_se(unit_file_enable(UNIT_FILE_SYSTEM, false, root, STRV_MAKE("template@foo.service"), false, &changes, &n_changes) >= 0);
|
|
|
a19bc6 |
+ assert_se(unit_file_enable(UNIT_FILE_SYSTEM, 0, root, STRV_MAKE("template@foo.service"), &changes, &n_changes) >= 0);
|
|
|
a19bc6 |
assert_se(changes[0].type == UNIT_FILE_SYMLINK);
|
|
|
a19bc6 |
assert_se(streq(changes[0].source, "/usr/lib/systemd/system/template@.service"));
|
|
|
a19bc6 |
p = strjoina(root, SYSTEM_CONFIG_UNIT_PATH"/multi-user.target.wants/template@foo.service");
|
|
|
a19bc6 |
@@ -437,7 +437,7 @@ static void test_template_enable(const char *root) {
|
|
|
a19bc6 |
assert_se(unit_file_get_state(UNIT_FILE_SYSTEM, root, "template-symlink@def.service", &state) >= 0 && state == UNIT_FILE_DISABLED);
|
|
|
a19bc6 |
assert_se(unit_file_get_state(UNIT_FILE_SYSTEM, root, "template-symlink@foo.service", &state) >= 0 && state == UNIT_FILE_ENABLED);
|
|
|
a19bc6 |
|
|
|
a19bc6 |
- assert_se(unit_file_disable(UNIT_FILE_SYSTEM, false, root, STRV_MAKE("template@foo.service"), &changes, &n_changes) >= 0);
|
|
|
a19bc6 |
+ assert_se(unit_file_disable(UNIT_FILE_SYSTEM, 0, root, STRV_MAKE("template@foo.service"), &changes, &n_changes) >= 0);
|
|
|
a19bc6 |
assert_se(n_changes == 1);
|
|
|
a19bc6 |
assert_se(changes[0].type == UNIT_FILE_UNLINK);
|
|
|
a19bc6 |
assert_se(streq(changes[0].path, p));
|
|
|
a19bc6 |
@@ -453,7 +453,7 @@ static void test_template_enable(const char *root) {
|
|
|
a19bc6 |
assert_se(unit_file_get_state(UNIT_FILE_SYSTEM, root, "template-symlink@foo.service", &state) >= 0 && state == UNIT_FILE_DISABLED);
|
|
|
a19bc6 |
assert_se(unit_file_get_state(UNIT_FILE_SYSTEM, root, "template-symlink@quux.service", &state) >= 0 && state == UNIT_FILE_DISABLED);
|
|
|
a19bc6 |
|
|
|
a19bc6 |
- assert_se(unit_file_enable(UNIT_FILE_SYSTEM, false, root, STRV_MAKE("template-symlink@quux.service"), false, &changes, &n_changes) >= 0);
|
|
|
a19bc6 |
+ assert_se(unit_file_enable(UNIT_FILE_SYSTEM, 0, root, STRV_MAKE("template-symlink@quux.service"), &changes, &n_changes) >= 0);
|
|
|
a19bc6 |
assert_se(changes[0].type == UNIT_FILE_SYMLINK);
|
|
|
a19bc6 |
assert_se(streq(changes[0].source, "/usr/lib/systemd/system/template@.service"));
|
|
|
a19bc6 |
p = strjoina(root, SYSTEM_CONFIG_UNIT_PATH"/multi-user.target.wants/template@quux.service");
|
|
|
a19bc6 |
@@ -498,7 +498,7 @@ static void test_indirect(const char *root) {
|
|
|
a19bc6 |
assert_se(unit_file_get_state(UNIT_FILE_SYSTEM, root, "indirectb.service", &state) >= 0 && state == UNIT_FILE_DISABLED);
|
|
|
a19bc6 |
assert_se(unit_file_get_state(UNIT_FILE_SYSTEM, root, "indirectc.service", &state) >= 0 && state == UNIT_FILE_INDIRECT);
|
|
|
a19bc6 |
|
|
|
a19bc6 |
- assert_se(unit_file_enable(UNIT_FILE_SYSTEM, false, root, STRV_MAKE("indirectc.service"), false, &changes, &n_changes) >= 0);
|
|
|
a19bc6 |
+ assert_se(unit_file_enable(UNIT_FILE_SYSTEM, 0, root, STRV_MAKE("indirectc.service"), &changes, &n_changes) >= 0);
|
|
|
a19bc6 |
assert_se(n_changes == 1);
|
|
|
a19bc6 |
assert_se(changes[0].type == UNIT_FILE_SYMLINK);
|
|
|
a19bc6 |
assert_se(streq(changes[0].source, "/usr/lib/systemd/system/indirectb.service"));
|
|
|
a19bc6 |
@@ -511,7 +511,7 @@ static void test_indirect(const char *root) {
|
|
|
a19bc6 |
assert_se(unit_file_get_state(UNIT_FILE_SYSTEM, root, "indirectb.service", &state) >= 0 && state == UNIT_FILE_ENABLED);
|
|
|
a19bc6 |
assert_se(unit_file_get_state(UNIT_FILE_SYSTEM, root, "indirectc.service", &state) >= 0 && state == UNIT_FILE_INDIRECT);
|
|
|
a19bc6 |
|
|
|
a19bc6 |
- assert_se(unit_file_disable(UNIT_FILE_SYSTEM, false, root, STRV_MAKE("indirectc.service"), &changes, &n_changes) >= 0);
|
|
|
a19bc6 |
+ assert_se(unit_file_disable(UNIT_FILE_SYSTEM, 0, root, STRV_MAKE("indirectc.service"), &changes, &n_changes) >= 0);
|
|
|
a19bc6 |
assert_se(n_changes == 1);
|
|
|
a19bc6 |
assert_se(changes[0].type == UNIT_FILE_UNLINK);
|
|
|
a19bc6 |
p = strjoina(root, SYSTEM_CONFIG_UNIT_PATH"/multi-user.target.wants/indirectb.service");
|
|
|
a19bc6 |
@@ -551,7 +551,7 @@ static void test_preset_and_list(const char *root) {
|
|
|
a19bc6 |
assert_se(unit_file_get_state(UNIT_FILE_SYSTEM, root, "preset-yes.service", &state) >= 0 && state == UNIT_FILE_DISABLED);
|
|
|
a19bc6 |
assert_se(unit_file_get_state(UNIT_FILE_SYSTEM, root, "preset-no.service", &state) >= 0 && state == UNIT_FILE_DISABLED);
|
|
|
a19bc6 |
|
|
|
a19bc6 |
- assert_se(unit_file_preset(UNIT_FILE_SYSTEM, false, root, STRV_MAKE("preset-yes.service"), UNIT_FILE_PRESET_FULL, false, &changes, &n_changes) >= 0);
|
|
|
a19bc6 |
+ assert_se(unit_file_preset(UNIT_FILE_SYSTEM, 0, root, STRV_MAKE("preset-yes.service"), UNIT_FILE_PRESET_FULL, &changes, &n_changes) >= 0);
|
|
|
a19bc6 |
assert_se(n_changes == 1);
|
|
|
a19bc6 |
assert_se(changes[0].type == UNIT_FILE_SYMLINK);
|
|
|
a19bc6 |
assert_se(streq(changes[0].source, "/usr/lib/systemd/system/preset-yes.service"));
|
|
|
a19bc6 |
@@ -563,7 +563,7 @@ static void test_preset_and_list(const char *root) {
|
|
|
a19bc6 |
assert_se(unit_file_get_state(UNIT_FILE_SYSTEM, root, "preset-yes.service", &state) >= 0 && state == UNIT_FILE_ENABLED);
|
|
|
a19bc6 |
assert_se(unit_file_get_state(UNIT_FILE_SYSTEM, root, "preset-no.service", &state) >= 0 && state == UNIT_FILE_DISABLED);
|
|
|
a19bc6 |
|
|
|
a19bc6 |
- assert_se(unit_file_disable(UNIT_FILE_SYSTEM, false, root, STRV_MAKE("preset-yes.service"), &changes, &n_changes) >= 0);
|
|
|
a19bc6 |
+ assert_se(unit_file_disable(UNIT_FILE_SYSTEM, 0, root, STRV_MAKE("preset-yes.service"), &changes, &n_changes) >= 0);
|
|
|
a19bc6 |
assert_se(n_changes == 1);
|
|
|
a19bc6 |
assert_se(changes[0].type == UNIT_FILE_UNLINK);
|
|
|
a19bc6 |
p = strjoina(root, SYSTEM_CONFIG_UNIT_PATH"/multi-user.target.wants/preset-yes.service");
|
|
|
a19bc6 |
@@ -574,7 +574,7 @@ static void test_preset_and_list(const char *root) {
|
|
|
a19bc6 |
assert_se(unit_file_get_state(UNIT_FILE_SYSTEM, root, "preset-yes.service", &state) >= 0 && state == UNIT_FILE_DISABLED);
|
|
|
a19bc6 |
assert_se(unit_file_get_state(UNIT_FILE_SYSTEM, root, "preset-no.service", &state) >= 0 && state == UNIT_FILE_DISABLED);
|
|
|
a19bc6 |
|
|
|
a19bc6 |
- assert_se(unit_file_preset(UNIT_FILE_SYSTEM, false, root, STRV_MAKE("preset-no.service"), UNIT_FILE_PRESET_FULL, false, &changes, &n_changes) >= 0);
|
|
|
a19bc6 |
+ assert_se(unit_file_preset(UNIT_FILE_SYSTEM, 0, root, STRV_MAKE("preset-no.service"), UNIT_FILE_PRESET_FULL, &changes, &n_changes) >= 0);
|
|
|
a19bc6 |
assert_se(n_changes == 0);
|
|
|
a19bc6 |
unit_file_changes_free(changes, n_changes);
|
|
|
a19bc6 |
changes = NULL; n_changes = 0;
|
|
|
a19bc6 |
@@ -582,7 +582,7 @@ static void test_preset_and_list(const char *root) {
|
|
|
a19bc6 |
assert_se(unit_file_get_state(UNIT_FILE_SYSTEM, root, "preset-yes.service", &state) >= 0 && state == UNIT_FILE_DISABLED);
|
|
|
a19bc6 |
assert_se(unit_file_get_state(UNIT_FILE_SYSTEM, root, "preset-no.service", &state) >= 0 && state == UNIT_FILE_DISABLED);
|
|
|
a19bc6 |
|
|
|
a19bc6 |
- assert_se(unit_file_preset_all(UNIT_FILE_SYSTEM, false, root, UNIT_FILE_PRESET_FULL, false, &changes, &n_changes) >= 0);
|
|
|
a19bc6 |
+ assert_se(unit_file_preset_all(UNIT_FILE_SYSTEM, 0, root, UNIT_FILE_PRESET_FULL, &changes, &n_changes) >= 0);
|
|
|
a19bc6 |
|
|
|
a19bc6 |
assert_se(n_changes > 0);
|
|
|
a19bc6 |
|
|
|
a19bc6 |
diff --git a/src/test/test-install.c b/src/test/test-install.c
|
|
|
181b3f |
index 08a1faf2c..0cae0e794 100644
|
|
|
a19bc6 |
--- a/src/test/test-install.c
|
|
|
a19bc6 |
+++ b/src/test/test-install.c
|
|
|
a19bc6 |
@@ -73,12 +73,12 @@ int main(int argc, char* argv[]) {
|
|
|
a19bc6 |
|
|
|
a19bc6 |
log_error("enable");
|
|
|
a19bc6 |
|
|
|
a19bc6 |
- r = unit_file_enable(UNIT_FILE_SYSTEM, false, NULL, (char**) files, false, &changes, &n_changes);
|
|
|
a19bc6 |
+ r = unit_file_enable(UNIT_FILE_SYSTEM, 0, NULL, (char**) files, &changes, &n_changes);
|
|
|
a19bc6 |
assert_se(r >= 0);
|
|
|
a19bc6 |
|
|
|
a19bc6 |
log_error("enable2");
|
|
|
a19bc6 |
|
|
|
a19bc6 |
- r = unit_file_enable(UNIT_FILE_SYSTEM, false, NULL, (char**) files, false, &changes, &n_changes);
|
|
|
a19bc6 |
+ r = unit_file_enable(UNIT_FILE_SYSTEM, 0, NULL, (char**) files, &changes, &n_changes);
|
|
|
a19bc6 |
assert_se(r >= 0);
|
|
|
a19bc6 |
|
|
|
a19bc6 |
dump_changes(changes, n_changes);
|
|
|
a19bc6 |
@@ -93,7 +93,7 @@ int main(int argc, char* argv[]) {
|
|
|
a19bc6 |
changes = NULL;
|
|
|
a19bc6 |
n_changes = 0;
|
|
|
a19bc6 |
|
|
|
a19bc6 |
- r = unit_file_disable(UNIT_FILE_SYSTEM, false, NULL, (char**) files, &changes, &n_changes);
|
|
|
a19bc6 |
+ r = unit_file_disable(UNIT_FILE_SYSTEM, 0, NULL, (char**) files, &changes, &n_changes);
|
|
|
a19bc6 |
assert_se(r >= 0);
|
|
|
a19bc6 |
|
|
|
a19bc6 |
dump_changes(changes, n_changes);
|
|
|
a19bc6 |
@@ -107,10 +107,10 @@ int main(int argc, char* argv[]) {
|
|
|
a19bc6 |
changes = NULL;
|
|
|
a19bc6 |
n_changes = 0;
|
|
|
a19bc6 |
|
|
|
a19bc6 |
- r = unit_file_mask(UNIT_FILE_SYSTEM, false, NULL, (char**) files, false, &changes, &n_changes);
|
|
|
a19bc6 |
+ r = unit_file_mask(UNIT_FILE_SYSTEM, 0, NULL, (char**) files, &changes, &n_changes);
|
|
|
a19bc6 |
assert_se(r >= 0);
|
|
|
a19bc6 |
log_error("mask2");
|
|
|
a19bc6 |
- r = unit_file_mask(UNIT_FILE_SYSTEM, false, NULL, (char**) files, false, &changes, &n_changes);
|
|
|
a19bc6 |
+ r = unit_file_mask(UNIT_FILE_SYSTEM, 0, NULL, (char**) files, &changes, &n_changes);
|
|
|
a19bc6 |
assert_se(r >= 0);
|
|
|
a19bc6 |
|
|
|
a19bc6 |
dump_changes(changes, n_changes);
|
|
|
a19bc6 |
@@ -124,10 +124,10 @@ int main(int argc, char* argv[]) {
|
|
|
a19bc6 |
changes = NULL;
|
|
|
a19bc6 |
n_changes = 0;
|
|
|
a19bc6 |
|
|
|
a19bc6 |
- r = unit_file_unmask(UNIT_FILE_SYSTEM, false, NULL, (char**) files, &changes, &n_changes);
|
|
|
a19bc6 |
+ r = unit_file_unmask(UNIT_FILE_SYSTEM, 0, NULL, (char**) files, &changes, &n_changes);
|
|
|
a19bc6 |
assert_se(r >= 0);
|
|
|
a19bc6 |
log_error("unmask2");
|
|
|
a19bc6 |
- r = unit_file_unmask(UNIT_FILE_SYSTEM, false, NULL, (char**) files, &changes, &n_changes);
|
|
|
a19bc6 |
+ r = unit_file_unmask(UNIT_FILE_SYSTEM, 0, NULL, (char**) files, &changes, &n_changes);
|
|
|
a19bc6 |
assert_se(r >= 0);
|
|
|
a19bc6 |
|
|
|
a19bc6 |
dump_changes(changes, n_changes);
|
|
|
a19bc6 |
@@ -141,7 +141,7 @@ int main(int argc, char* argv[]) {
|
|
|
a19bc6 |
changes = NULL;
|
|
|
a19bc6 |
n_changes = 0;
|
|
|
a19bc6 |
|
|
|
a19bc6 |
- r = unit_file_mask(UNIT_FILE_SYSTEM, false, NULL, (char**) files, false, &changes, &n_changes);
|
|
|
a19bc6 |
+ r = unit_file_mask(UNIT_FILE_SYSTEM, 0, NULL, (char**) files, &changes, &n_changes);
|
|
|
a19bc6 |
assert_se(r >= 0);
|
|
|
a19bc6 |
|
|
|
a19bc6 |
dump_changes(changes, n_changes);
|
|
|
a19bc6 |
@@ -155,10 +155,10 @@ int main(int argc, char* argv[]) {
|
|
|
a19bc6 |
changes = NULL;
|
|
|
a19bc6 |
n_changes = 0;
|
|
|
a19bc6 |
|
|
|
a19bc6 |
- r = unit_file_disable(UNIT_FILE_SYSTEM, false, NULL, (char**) files, &changes, &n_changes);
|
|
|
a19bc6 |
+ r = unit_file_disable(UNIT_FILE_SYSTEM, 0, NULL, (char**) files, &changes, &n_changes);
|
|
|
a19bc6 |
assert_se(r >= 0);
|
|
|
a19bc6 |
log_error("disable2");
|
|
|
a19bc6 |
- r = unit_file_disable(UNIT_FILE_SYSTEM, false, NULL, (char**) files, &changes, &n_changes);
|
|
|
a19bc6 |
+ r = unit_file_disable(UNIT_FILE_SYSTEM, 0, NULL, (char**) files, &changes, &n_changes);
|
|
|
a19bc6 |
assert_se(r >= 0);
|
|
|
a19bc6 |
|
|
|
a19bc6 |
dump_changes(changes, n_changes);
|
|
|
a19bc6 |
@@ -172,7 +172,7 @@ int main(int argc, char* argv[]) {
|
|
|
a19bc6 |
changes = NULL;
|
|
|
a19bc6 |
n_changes = 0;
|
|
|
a19bc6 |
|
|
|
a19bc6 |
- r = unit_file_unmask(UNIT_FILE_SYSTEM, false, NULL, (char**) files, &changes, &n_changes);
|
|
|
a19bc6 |
+ r = unit_file_unmask(UNIT_FILE_SYSTEM, 0, NULL, (char**) files, &changes, &n_changes);
|
|
|
a19bc6 |
assert_se(r >= 0);
|
|
|
a19bc6 |
|
|
|
a19bc6 |
dump_changes(changes, n_changes);
|
|
|
a19bc6 |
@@ -186,7 +186,7 @@ int main(int argc, char* argv[]) {
|
|
|
a19bc6 |
changes = NULL;
|
|
|
a19bc6 |
n_changes = 0;
|
|
|
a19bc6 |
|
|
|
a19bc6 |
- r = unit_file_enable(UNIT_FILE_SYSTEM, false, NULL, (char**) files2, false, &changes, &n_changes);
|
|
|
a19bc6 |
+ r = unit_file_enable(UNIT_FILE_SYSTEM, 0, NULL, (char**) files2, &changes, &n_changes);
|
|
|
a19bc6 |
assert_se(r >= 0);
|
|
|
a19bc6 |
|
|
|
a19bc6 |
dump_changes(changes, n_changes);
|
|
|
a19bc6 |
@@ -200,7 +200,7 @@ int main(int argc, char* argv[]) {
|
|
|
a19bc6 |
changes = NULL;
|
|
|
a19bc6 |
n_changes = 0;
|
|
|
a19bc6 |
|
|
|
a19bc6 |
- r = unit_file_disable(UNIT_FILE_SYSTEM, false, NULL, STRV_MAKE(basename(files2[0])), &changes, &n_changes);
|
|
|
a19bc6 |
+ r = unit_file_disable(UNIT_FILE_SYSTEM, 0, NULL, STRV_MAKE(basename(files2[0])), &changes, &n_changes);
|
|
|
a19bc6 |
assert_se(r >= 0);
|
|
|
a19bc6 |
|
|
|
a19bc6 |
dump_changes(changes, n_changes);
|
|
|
a19bc6 |
@@ -213,7 +213,7 @@ int main(int argc, char* argv[]) {
|
|
|
a19bc6 |
changes = NULL;
|
|
|
a19bc6 |
n_changes = 0;
|
|
|
a19bc6 |
|
|
|
a19bc6 |
- r = unit_file_link(UNIT_FILE_SYSTEM, false, NULL, (char**) files2, false, &changes, &n_changes);
|
|
|
a19bc6 |
+ r = unit_file_link(UNIT_FILE_SYSTEM, 0, NULL, (char**) files2, &changes, &n_changes);
|
|
|
a19bc6 |
assert_se(r >= 0);
|
|
|
a19bc6 |
|
|
|
a19bc6 |
dump_changes(changes, n_changes);
|
|
|
a19bc6 |
@@ -227,7 +227,7 @@ int main(int argc, char* argv[]) {
|
|
|
a19bc6 |
changes = NULL;
|
|
|
a19bc6 |
n_changes = 0;
|
|
|
a19bc6 |
|
|
|
a19bc6 |
- r = unit_file_disable(UNIT_FILE_SYSTEM, false, NULL, STRV_MAKE(basename(files2[0])), &changes, &n_changes);
|
|
|
a19bc6 |
+ r = unit_file_disable(UNIT_FILE_SYSTEM, 0, NULL, STRV_MAKE(basename(files2[0])), &changes, &n_changes);
|
|
|
a19bc6 |
assert_se(r >= 0);
|
|
|
a19bc6 |
|
|
|
a19bc6 |
dump_changes(changes, n_changes);
|
|
|
a19bc6 |
@@ -240,7 +240,7 @@ int main(int argc, char* argv[]) {
|
|
|
a19bc6 |
changes = NULL;
|
|
|
a19bc6 |
n_changes = 0;
|
|
|
a19bc6 |
|
|
|
a19bc6 |
- r = unit_file_link(UNIT_FILE_SYSTEM, false, NULL, (char**) files2, false, &changes, &n_changes);
|
|
|
a19bc6 |
+ r = unit_file_link(UNIT_FILE_SYSTEM, 0, NULL, (char**) files2, &changes, &n_changes);
|
|
|
a19bc6 |
assert_se(r >= 0);
|
|
|
a19bc6 |
|
|
|
a19bc6 |
dump_changes(changes, n_changes);
|
|
|
a19bc6 |
@@ -254,7 +254,7 @@ int main(int argc, char* argv[]) {
|
|
|
a19bc6 |
changes = NULL;
|
|
|
a19bc6 |
n_changes = 0;
|
|
|
a19bc6 |
|
|
|
a19bc6 |
- r = unit_file_reenable(UNIT_FILE_SYSTEM, false, NULL, (char**) files2, false, &changes, &n_changes);
|
|
|
a19bc6 |
+ r = unit_file_reenable(UNIT_FILE_SYSTEM, 0, NULL, (char**) files2, &changes, &n_changes);
|
|
|
a19bc6 |
assert_se(r >= 0);
|
|
|
a19bc6 |
|
|
|
a19bc6 |
dump_changes(changes, n_changes);
|
|
|
a19bc6 |
@@ -268,7 +268,7 @@ int main(int argc, char* argv[]) {
|
|
|
a19bc6 |
changes = NULL;
|
|
|
a19bc6 |
n_changes = 0;
|
|
|
a19bc6 |
|
|
|
a19bc6 |
- r = unit_file_disable(UNIT_FILE_SYSTEM, false, NULL, STRV_MAKE(basename(files2[0])), &changes, &n_changes);
|
|
|
a19bc6 |
+ r = unit_file_disable(UNIT_FILE_SYSTEM, 0, NULL, STRV_MAKE(basename(files2[0])), &changes, &n_changes);
|
|
|
a19bc6 |
assert_se(r >= 0);
|
|
|
a19bc6 |
|
|
|
a19bc6 |
dump_changes(changes, n_changes);
|
|
|
a19bc6 |
@@ -280,7 +280,7 @@ int main(int argc, char* argv[]) {
|
|
|
a19bc6 |
changes = NULL;
|
|
|
a19bc6 |
n_changes = 0;
|
|
|
a19bc6 |
|
|
|
a19bc6 |
- r = unit_file_preset(UNIT_FILE_SYSTEM, false, NULL, (char**) files, UNIT_FILE_PRESET_FULL, false, &changes, &n_changes);
|
|
|
a19bc6 |
+ r = unit_file_preset(UNIT_FILE_SYSTEM, 0, NULL, (char**) files, UNIT_FILE_PRESET_FULL, &changes, &n_changes);
|
|
|
a19bc6 |
assert_se(r >= 0);
|
|
|
a19bc6 |
|
|
|
a19bc6 |
dump_changes(changes, n_changes);
|