Compare commits

..

No commits in common. "d2a56598d046f7c44b3dfdb098b92c83920295d9" and "a434236accc8bf072f919bb4c6e85b0dbc36e71f" have entirely different histories.

9 changed files with 220 additions and 387 deletions

View File

@ -5,9 +5,9 @@ title: What settings are currently available for transient units?
# What settings are currently available for transient units? # What settings are currently available for transient units?
Our intention is to make all settings that are available as unit file settings Our intention is to make all settings that are available as unit file settings
also available for transient units, through the D-Bus API. At the moment, also available for transient units, through the D-Bus API. At the moment, some
device, swap, and target units are not supported at all as transient units, but unit types (device, swap, target) are not supported at all via unit types,
others are pretty well supported. but most others are pretty well supported, with some notable omissions.
The lists below contain all settings currently available in unit files. The The lists below contain all settings currently available in unit files. The
ones currently available in transient units are prefixed with `✓`. ones currently available in transient units are prefixed with `✓`.
@ -44,14 +44,15 @@ Most generic unit settings are available for transient units.
✓ JobRunningTimeoutSec= ✓ JobRunningTimeoutSec=
✓ JobTimeoutAction= ✓ JobTimeoutAction=
✓ JobTimeoutRebootArgument= ✓ JobTimeoutRebootArgument=
✓ StartLimitIntervalSec= ✓ StartLimitIntervalSec=SECONDS
✓ StartLimitBurst= ✓ StartLimitBurst=UNSIGNED
✓ StartLimitAction= ✓ StartLimitAction=ACTION
✓ FailureAction= ✓ FailureAction=
✓ SuccessAction= ✓ SuccessAction=
✓ FailureActionExitStatus= ✓ FailureActionExitStatus=
✓ SuccessActionExitStatus= ✓ SuccessActionExitStatus=
✓ RebootArgument= ✓ AddRef=
✓ RebootArgument=STRING
✓ ConditionPathExists= ✓ ConditionPathExists=
✓ ConditionPathExistsGlob= ✓ ConditionPathExistsGlob=
✓ ConditionPathIsDirectory= ✓ ConditionPathIsDirectory=
@ -184,7 +185,6 @@ All execution-related settings are available for transient units.
✓ PrivateMounts= ✓ PrivateMounts=
✓ ProtectKernelTunables= ✓ ProtectKernelTunables=
✓ ProtectKernelModules= ✓ ProtectKernelModules=
✓ ProtectKernelLogs=
✓ ProtectControlGroups= ✓ ProtectControlGroups=
✓ PrivateNetwork= ✓ PrivateNetwork=
✓ PrivateUsers= ✓ PrivateUsers=
@ -271,7 +271,6 @@ All process killing settings are available for transient units:
✓ SendSIGHUP= ✓ SendSIGHUP=
✓ KillMode= ✓ KillMode=
✓ KillSignal= ✓ KillSignal=
✓ RestartKillSignal=
✓ FinalKillSignal= ✓ FinalKillSignal=
✓ WatchdogSignal= ✓ WatchdogSignal=
``` ```
@ -311,7 +310,6 @@ Most service unit settings are available for transient units.
Sockets= Sockets=
✓ USBFunctionDescriptors= ✓ USBFunctionDescriptors=
✓ USBFunctionStrings= ✓ USBFunctionStrings=
✓ OOMPolicy=
``` ```
## Mount Unit Settings ## Mount Unit Settings

View File

@ -309,13 +309,6 @@ static int bus_service_set_transient_property(
if (streq(name, "TimeoutStopUSec")) if (streq(name, "TimeoutStopUSec"))
return bus_set_transient_usec(u, name, &s->timeout_stop_usec, message, flags, error); return bus_set_transient_usec(u, name, &s->timeout_stop_usec, message, flags, error);
if (streq(name, "TimeoutAbortUSec")) {
r = bus_set_transient_usec(u, name, &s->timeout_abort_usec, message, flags, error);
if (r >= 0 && !UNIT_WRITE_FLAGS_NOOP(flags))
s->timeout_abort_set = true;
return r;
}
if (streq(name, "RuntimeMaxUSec")) if (streq(name, "RuntimeMaxUSec"))
return bus_set_transient_usec(u, name, &s->runtime_max_usec, message, flags, error); return bus_set_transient_usec(u, name, &s->runtime_max_usec, message, flags, error);

View File

@ -614,6 +614,7 @@ int config_parse_exec(
assert(e); assert(e);
e += ltype; e += ltype;
rvalue += strspn(rvalue, WHITESPACE);
if (isempty(rvalue)) { if (isempty(rvalue)) {
/* An empty assignment resets the list */ /* An empty assignment resets the list */
@ -1930,40 +1931,6 @@ int config_parse_service_timeout(
return 0; return 0;
} }
int config_parse_timeout_abort(
const char *unit,
const char *filename,
unsigned line,
const char *section,
unsigned section_line,
const char *lvalue,
int ltype,
const char *rvalue,
void *data,
void *userdata) {
usec_t *ret = data;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
assert(ret);
/* Note: apart from setting the arg, this returns an extra bit of information in the return value. */
if (isempty(rvalue)) {
*ret = 0;
return 0; /* "not set" */
}
r = parse_sec(rvalue, ret);
if (r < 0)
return log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse %s= setting, ignoring: %s", lvalue, rvalue);
return 1; /* "set" */
}
int config_parse_service_timeout_abort( int config_parse_service_timeout_abort(
const char *unit, const char *unit,
const char *filename, const char *filename,
@ -1979,12 +1946,24 @@ int config_parse_service_timeout_abort(
Service *s = userdata; Service *s = userdata;
int r; int r;
assert(filename);
assert(lvalue);
assert(rvalue);
assert(s); assert(s);
r = config_parse_timeout_abort(unit, filename, line, section, section_line, lvalue, ltype, rvalue, rvalue += strspn(rvalue, WHITESPACE);
&s->timeout_abort_usec, s); if (isempty(rvalue)) {
if (r >= 0) s->timeout_abort_set = false;
s->timeout_abort_set = r; return 0;
}
r = parse_sec(rvalue, &s->timeout_abort_usec);
if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse TimeoutAbortSec= setting, ignoring: %s", rvalue);
return 0;
}
s->timeout_abort_set = true;
return 0; return 0;
} }
@ -5002,3 +4981,39 @@ int config_parse_crash_chvt(
return 0; return 0;
} }
int config_parse_timeout_abort(
const char* unit,
const char *filename,
unsigned line,
const char *section,
unsigned section_line,
const char *lvalue,
int ltype,
const char *rvalue,
void *data,
void *userdata) {
usec_t *timeout_usec = data;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
assert(timeout_usec);
rvalue += strspn(rvalue, WHITESPACE);
if (isempty(rvalue)) {
*timeout_usec = false;
return 0;
}
r = parse_sec(rvalue, timeout_usec);
if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse DefaultTimeoutAbortSec= setting, ignoring: %s", rvalue);
return 0;
}
*timeout_usec = true;
return 0;
}

View File

@ -539,27 +539,8 @@ DEFINE_SETTER(config_parse_target, log_set_target_from_string, "target");
DEFINE_SETTER(config_parse_color, log_show_color_from_string, "color" ); DEFINE_SETTER(config_parse_color, log_show_color_from_string, "color" );
DEFINE_SETTER(config_parse_location, log_show_location_from_string, "location"); DEFINE_SETTER(config_parse_location, log_show_location_from_string, "location");
static int config_parse_default_timeout_abort(
const char *unit,
const char *filename,
unsigned line,
const char *section,
unsigned section_line,
const char *lvalue,
int ltype,
const char *rvalue,
void *data,
void *userdata) {
int r;
r = config_parse_timeout_abort(unit, filename, line, section, section_line, lvalue, ltype, rvalue,
&arg_default_timeout_abort_usec, userdata);
if (r >= 0)
arg_default_timeout_abort_set = r;
return 0;
}
static int parse_config_file(void) { static int parse_config_file(void) {
const ConfigTableItem items[] = { const ConfigTableItem items[] = {
{ "Manager", "LogLevel", config_parse_level2, 0, NULL }, { "Manager", "LogLevel", config_parse_level2, 0, NULL },
{ "Manager", "LogTarget", config_parse_target, 0, NULL }, { "Manager", "LogTarget", config_parse_target, 0, NULL },
@ -592,7 +573,7 @@ static int parse_config_file(void) {
{ "Manager", "DefaultStandardError", config_parse_output_restricted, 0, &arg_default_std_error }, { "Manager", "DefaultStandardError", config_parse_output_restricted, 0, &arg_default_std_error },
{ "Manager", "DefaultTimeoutStartSec", config_parse_sec, 0, &arg_default_timeout_start_usec }, { "Manager", "DefaultTimeoutStartSec", config_parse_sec, 0, &arg_default_timeout_start_usec },
{ "Manager", "DefaultTimeoutStopSec", config_parse_sec, 0, &arg_default_timeout_stop_usec }, { "Manager", "DefaultTimeoutStopSec", config_parse_sec, 0, &arg_default_timeout_stop_usec },
{ "Manager", "DefaultTimeoutAbortSec", config_parse_default_timeout_abort, 0, NULL }, { "Manager", "DefaultTimeoutAbortSec", config_parse_timeout_abort, 0, &arg_default_timeout_abort_set },
{ "Manager", "DefaultRestartSec", config_parse_sec, 0, &arg_default_restart_usec }, { "Manager", "DefaultRestartSec", config_parse_sec, 0, &arg_default_restart_usec },
{ "Manager", "DefaultStartLimitInterval", config_parse_sec, 0, &arg_default_start_limit_interval }, /* obsolete alias */ { "Manager", "DefaultStartLimitInterval", config_parse_sec, 0, &arg_default_start_limit_interval }, /* obsolete alias */
{ "Manager", "DefaultStartLimitIntervalSec", config_parse_sec, 0, &arg_default_start_limit_interval }, { "Manager", "DefaultStartLimitIntervalSec", config_parse_sec, 0, &arg_default_start_limit_interval },

View File

@ -78,7 +78,7 @@ static int retrieve_key(key_serial_t serial, char ***ret) {
n = keyctl(KEYCTL_READ, (unsigned long) serial, (unsigned long) p, (unsigned long) m, 0); n = keyctl(KEYCTL_READ, (unsigned long) serial, (unsigned long) p, (unsigned long) m, 0);
if (n < 0) if (n < 0)
return -errno; return -errno;
if ((size_t) n <= m) { if ((size_t) n < m) {
nfinal = (size_t) n; nfinal = (size_t) n;
pfinal = TAKE_PTR(p); pfinal = TAKE_PTR(p);
break; break;

View File

@ -421,26 +421,18 @@ static int bus_append_cgroup_property(sd_bus_message *m, const char *field, cons
if (STR_IN_SET(field, "DevicePolicy", "Slice")) if (STR_IN_SET(field, "DevicePolicy", "Slice"))
return bus_append_string(m, field, eq); return bus_append_string(m, field, eq);
if (STR_IN_SET(field, "CPUAccounting", if (STR_IN_SET(field,
"MemoryAccounting", "CPUAccounting", "MemoryAccounting", "IOAccounting", "BlockIOAccounting",
"IOAccounting", "TasksAccounting", "IPAccounting"))
"BlockIOAccounting",
"TasksAccounting",
"IPAccounting"))
return bus_append_parse_boolean(m, field, eq); return bus_append_parse_boolean(m, field, eq);
if (STR_IN_SET(field, "CPUWeight", if (STR_IN_SET(field, "CPUWeight", "StartupCPUWeight", "IOWeight", "StartupIOWeight"))
"StartupCPUWeight",
"IOWeight",
"StartupIOWeight"))
return bus_append_cg_weight_parse(m, field, eq); return bus_append_cg_weight_parse(m, field, eq);
if (STR_IN_SET(field, "CPUShares", if (STR_IN_SET(field, "CPUShares", "StartupCPUShares"))
"StartupCPUShares"))
return bus_append_cg_cpu_shares_parse(m, field, eq); return bus_append_cg_cpu_shares_parse(m, field, eq);
if (STR_IN_SET(field, "AllowedCPUs", if (STR_IN_SET(field, "AllowedCPUs", "AllowedMemoryNodes")) {
"AllowedMemoryNodes")) {
_cleanup_(cpu_set_reset) CPUSet cpuset = {}; _cleanup_(cpu_set_reset) CPUSet cpuset = {};
_cleanup_free_ uint8_t *array = NULL; _cleanup_free_ uint8_t *array = NULL;
size_t allocated; size_t allocated;
@ -456,8 +448,7 @@ static int bus_append_cgroup_property(sd_bus_message *m, const char *field, cons
return bus_append_byte_array(m, field, array, allocated); return bus_append_byte_array(m, field, array, allocated);
} }
if (STR_IN_SET(field, "BlockIOWeight", if (STR_IN_SET(field, "BlockIOWeight", "StartupBlockIOWeight"))
"StartupBlockIOWeight"))
return bus_append_cg_blkio_weight_parse(m, field, eq); return bus_append_cg_blkio_weight_parse(m, field, eq);
if (streq(field, "DisableControllers")) if (streq(field, "DisableControllers"))
@ -602,8 +593,7 @@ static int bus_append_cgroup_property(sd_bus_message *m, const char *field, cons
return 1; return 1;
} }
if (STR_IN_SET(field, "IODeviceWeight", if (STR_IN_SET(field, "IODeviceWeight", "BlockIODeviceWeight")) {
"BlockIODeviceWeight")) {
if (isempty(eq)) if (isempty(eq))
r = sd_bus_message_append(m, "(sv)", field, "a(st)", 0); r = sd_bus_message_append(m, "(sv)", field, "a(st)", 0);
else { else {
@ -663,8 +653,7 @@ static int bus_append_cgroup_property(sd_bus_message *m, const char *field, cons
return 1; return 1;
} }
if (STR_IN_SET(field, "IPAddressAllow", if (STR_IN_SET(field, "IPAddressAllow", "IPAddressDeny")) {
"IPAddressDeny")) {
unsigned char prefixlen; unsigned char prefixlen;
union in_addr_union prefix = {}; union in_addr_union prefix = {};
int family; int family;
@ -784,8 +773,7 @@ static int bus_append_cgroup_property(sd_bus_message *m, const char *field, cons
return 1; return 1;
} }
if (STR_IN_SET(field, "IPIngressFilterPath", if (STR_IN_SET(field, "IPIngressFilterPath", "IPEgressFilterPath")) {
"IPEgressFilterPath")) {
if (isempty(eq)) if (isempty(eq))
r = sd_bus_message_append(m, "(sv)", field, "as", 0); r = sd_bus_message_append(m, "(sv)", field, "as", 0);
else else
@ -817,68 +805,31 @@ static int bus_append_execute_property(sd_bus_message *m, const char *field, con
const char *suffix; const char *suffix;
int r; int r;
if (STR_IN_SET(field, "User", if (STR_IN_SET(field,
"Group", "User", "Group",
"UtmpIdentifier", "UtmpIdentifier", "UtmpMode", "PAMName", "TTYPath",
"UtmpMode", "WorkingDirectory", "RootDirectory", "SyslogIdentifier",
"PAMName", "ProtectSystem", "ProtectHome", "SELinuxContext", "RootImage",
"TTYPath", "RuntimeDirectoryPreserve", "Personality", "KeyringMode", "NetworkNamespacePath"))
"WorkingDirectory",
"RootDirectory",
"SyslogIdentifier",
"ProtectSystem",
"ProtectHome",
"SELinuxContext",
"RootImage",
"RuntimeDirectoryPreserve",
"Personality",
"KeyringMode",
"NetworkNamespacePath"))
return bus_append_string(m, field, eq); return bus_append_string(m, field, eq);
if (STR_IN_SET(field, "IgnoreSIGPIPE", if (STR_IN_SET(field,
"TTYVHangup", "IgnoreSIGPIPE", "TTYVHangup", "TTYReset", "TTYVTDisallocate", "PrivateTmp",
"TTYReset", "PrivateDevices", "PrivateNetwork", "PrivateUsers", "PrivateMounts",
"TTYVTDisallocate", "NoNewPrivileges", "SyslogLevelPrefix", "MemoryDenyWriteExecute", "RestrictRealtime",
"PrivateTmp", "DynamicUser", "RemoveIPC", "ProtectKernelTunables", "ProtectKernelModules",
"PrivateDevices", "ProtectKernelLogs", "ProtectControlGroups", "MountAPIVFS", "CPUSchedulingResetOnFork",
"PrivateNetwork", "LockPersonality", "ProtectHostname", "RestrictSUIDSGID"))
"PrivateUsers",
"PrivateMounts",
"NoNewPrivileges",
"SyslogLevelPrefix",
"MemoryDenyWriteExecute",
"RestrictRealtime",
"DynamicUser",
"RemoveIPC",
"ProtectKernelTunables",
"ProtectKernelModules",
"ProtectKernelLogs",
"ProtectControlGroups",
"MountAPIVFS",
"CPUSchedulingResetOnFork",
"LockPersonality",
"ProtectHostname",
"RestrictSUIDSGID"))
return bus_append_parse_boolean(m, field, eq); return bus_append_parse_boolean(m, field, eq);
if (STR_IN_SET(field, "ReadWriteDirectories", if (STR_IN_SET(field,
"ReadOnlyDirectories", "ReadWriteDirectories", "ReadOnlyDirectories", "InaccessibleDirectories",
"InaccessibleDirectories", "ReadWritePaths", "ReadOnlyPaths", "InaccessiblePaths",
"ReadWritePaths", "RuntimeDirectory", "StateDirectory", "CacheDirectory", "LogsDirectory", "ConfigurationDirectory",
"ReadOnlyPaths", "SupplementaryGroups", "SystemCallArchitectures"))
"InaccessiblePaths",
"RuntimeDirectory",
"StateDirectory",
"CacheDirectory",
"LogsDirectory",
"ConfigurationDirectory",
"SupplementaryGroups",
"SystemCallArchitectures"))
return bus_append_strv(m, field, eq, EXTRACT_UNQUOTE); return bus_append_strv(m, field, eq, EXTRACT_UNQUOTE);
if (STR_IN_SET(field, "SyslogLevel", if (STR_IN_SET(field, "SyslogLevel", "LogLevelMax"))
"LogLevelMax"))
return bus_append_log_level_from_string(m, field, eq); return bus_append_log_level_from_string(m, field, eq);
if (streq(field, "SyslogFacility")) if (streq(field, "SyslogFacility"))
@ -890,8 +841,7 @@ static int bus_append_execute_property(sd_bus_message *m, const char *field, con
if (streq(field, "CPUSchedulingPolicy")) if (streq(field, "CPUSchedulingPolicy"))
return bus_append_sched_policy_from_string(m, field, eq); return bus_append_sched_policy_from_string(m, field, eq);
if (STR_IN_SET(field, "CPUSchedulingPriority", if (STR_IN_SET(field, "CPUSchedulingPriority", "OOMScoreAdjust"))
"OOMScoreAdjust"))
return bus_append_safe_atoi(m, field, eq); return bus_append_safe_atoi(m, field, eq);
if (streq(field, "Nice")) if (streq(field, "Nice"))
@ -906,12 +856,9 @@ static int bus_append_execute_property(sd_bus_message *m, const char *field, con
if (streq(field, "IOSchedulingPriority")) if (streq(field, "IOSchedulingPriority"))
return bus_append_ioprio_parse_priority(m, field, eq); return bus_append_ioprio_parse_priority(m, field, eq);
if (STR_IN_SET(field, "RuntimeDirectoryMode", if (STR_IN_SET(field,
"StateDirectoryMode", "RuntimeDirectoryMode", "StateDirectoryMode", "CacheDirectoryMode",
"CacheDirectoryMode", "LogsDirectoryMode", "ConfigurationDirectoryMode", "UMask"))
"LogsDirectoryMode",
"ConfigurationDirectoryMode",
"UMask"))
return bus_append_parse_mode(m, field, eq); return bus_append_parse_mode(m, field, eq);
if (streq(field, "TimerSlackNSec")) if (streq(field, "TimerSlackNSec"))
@ -926,9 +873,7 @@ static int bus_append_execute_property(sd_bus_message *m, const char *field, con
if (streq(field, "MountFlags")) if (streq(field, "MountFlags"))
return bus_append_mount_propagation_flags_from_string(m, field, eq); return bus_append_mount_propagation_flags_from_string(m, field, eq);
if (STR_IN_SET(field, "Environment", if (STR_IN_SET(field, "Environment", "UnsetEnvironment", "PassEnvironment"))
"UnsetEnvironment",
"PassEnvironment"))
return bus_append_strv(m, field, eq, EXTRACT_UNQUOTE|EXTRACT_CUNESCAPE); return bus_append_strv(m, field, eq, EXTRACT_UNQUOTE|EXTRACT_CUNESCAPE);
if (streq(field, "EnvironmentFile")) { if (streq(field, "EnvironmentFile")) {
@ -980,9 +925,7 @@ static int bus_append_execute_property(sd_bus_message *m, const char *field, con
return 1; return 1;
} }
if (STR_IN_SET(field, "StandardInput", if (STR_IN_SET(field, "StandardInput", "StandardOutput", "StandardError")) {
"StandardOutput",
"StandardError")) {
const char *n, *appended; const char *n, *appended;
if ((n = startswith(eq, "fd:"))) { if ((n = startswith(eq, "fd:"))) {
@ -1054,8 +997,7 @@ static int bus_append_execute_property(sd_bus_message *m, const char *field, con
} }
} }
if (STR_IN_SET(field, "AppArmorProfile", if (STR_IN_SET(field, "AppArmorProfile", "SmackProcessLabel")) {
"SmackProcessLabel")) {
int ignore = 0; int ignore = 0;
const char *s = eq; const char *s = eq;
@ -1071,8 +1013,7 @@ static int bus_append_execute_property(sd_bus_message *m, const char *field, con
return 1; return 1;
} }
if (STR_IN_SET(field, "CapabilityBoundingSet", if (STR_IN_SET(field, "CapabilityBoundingSet", "AmbientCapabilities")) {
"AmbientCapabilities")) {
uint64_t sum = 0; uint64_t sum = 0;
bool invert = false; bool invert = false;
const char *p = eq; const char *p = eq;
@ -1139,8 +1080,7 @@ static int bus_append_execute_property(sd_bus_message *m, const char *field, con
return bus_append_byte_array(m, field, array, allocated); return bus_append_byte_array(m, field, array, allocated);
} }
if (STR_IN_SET(field, "RestrictAddressFamilies", if (STR_IN_SET(field, "RestrictAddressFamilies", "SystemCallFilter")) {
"SystemCallFilter")) {
int whitelist = 1; int whitelist = 1;
const char *p = eq; const char *p = eq;
@ -1238,8 +1178,7 @@ static int bus_append_execute_property(sd_bus_message *m, const char *field, con
return 1; return 1;
} }
if (STR_IN_SET(field, "BindPaths", if (STR_IN_SET(field, "BindPaths", "BindReadOnlyPaths")) {
"BindReadOnlyPaths")) {
const char *p = eq; const char *p = eq;
r = sd_bus_message_open_container(m, SD_BUS_TYPE_STRUCT, "sv"); r = sd_bus_message_open_container(m, SD_BUS_TYPE_STRUCT, "sv");
@ -1391,14 +1330,10 @@ static int bus_append_kill_property(sd_bus_message *m, const char *field, const
if (streq(field, "KillMode")) if (streq(field, "KillMode"))
return bus_append_string(m, field, eq); return bus_append_string(m, field, eq);
if (STR_IN_SET(field, "SendSIGHUP", if (STR_IN_SET(field, "SendSIGHUP", "SendSIGKILL"))
"SendSIGKILL"))
return bus_append_parse_boolean(m, field, eq); return bus_append_parse_boolean(m, field, eq);
if (STR_IN_SET(field, "KillSignal", if (STR_IN_SET(field, "KillSignal", "RestartKillSignal", "FinalKillSignal", "WatchdogSignal"))
"RestartKillSignal",
"FinalKillSignal",
"WatchdogSignal"))
return bus_append_signal_from_string(m, field, eq); return bus_append_signal_from_string(m, field, eq);
return 0; return 0;
@ -1406,10 +1341,7 @@ static int bus_append_kill_property(sd_bus_message *m, const char *field, const
static int bus_append_mount_property(sd_bus_message *m, const char *field, const char *eq) { static int bus_append_mount_property(sd_bus_message *m, const char *field, const char *eq) {
if (STR_IN_SET(field, "What", if (STR_IN_SET(field, "What", "Where", "Options", "Type"))
"Where",
"Options",
"Type"))
return bus_append_string(m, field, eq); return bus_append_string(m, field, eq);
if (streq(field, "TimeoutSec")) if (streq(field, "TimeoutSec"))
@ -1418,9 +1350,7 @@ static int bus_append_mount_property(sd_bus_message *m, const char *field, const
if (streq(field, "DirectoryMode")) if (streq(field, "DirectoryMode"))
return bus_append_parse_mode(m, field, eq); return bus_append_parse_mode(m, field, eq);
if (STR_IN_SET(field, "SloppyOptions", if (STR_IN_SET(field, "SloppyOptions", "LazyUnmount", "ForceUnmount"))
"LazyUnmount",
"ForceUnmount"))
return bus_append_parse_boolean(m, field, eq); return bus_append_parse_boolean(m, field, eq);
return 0; return 0;
@ -1435,11 +1365,9 @@ static int bus_append_path_property(sd_bus_message *m, const char *field, const
if (streq(field, "DirectoryMode")) if (streq(field, "DirectoryMode"))
return bus_append_parse_mode(m, field, eq); return bus_append_parse_mode(m, field, eq);
if (STR_IN_SET(field, "PathExists", if (STR_IN_SET(field,
"PathExistsGlob", "PathExists", "PathExistsGlob", "PathChanged",
"PathChanged", "PathModified", "DirectoryNotEmpty")) {
"PathModified",
"DirectoryNotEmpty")) {
if (isempty(eq)) if (isempty(eq))
r = sd_bus_message_append(m, "(sv)", "Paths", "a(ss)", 0); r = sd_bus_message_append(m, "(sv)", "Paths", "a(ss)", 0);
else else
@ -1455,9 +1383,11 @@ static int bus_append_path_property(sd_bus_message *m, const char *field, const
static int bus_append_scope_property(sd_bus_message *m, const char *field, const char *eq) { static int bus_append_scope_property(sd_bus_message *m, const char *field, const char *eq) {
if (streq(field, "RuntimeMaxSec")) if (streq(field, "RuntimeMaxSec"))
return bus_append_parse_sec_rename(m, field, eq); return bus_append_parse_sec_rename(m, field, eq);
if (streq(field, "TimeoutStopSec")) if (streq(field, "TimeoutStopSec"))
return bus_append_parse_sec_rename(m, field, eq); return bus_append_parse_sec_rename(m, field, eq);
return 0; return 0;
@ -1466,28 +1396,15 @@ static int bus_append_scope_property(sd_bus_message *m, const char *field, const
static int bus_append_service_property(sd_bus_message *m, const char *field, const char *eq) { static int bus_append_service_property(sd_bus_message *m, const char *field, const char *eq) {
int r; int r;
if (STR_IN_SET(field, "PIDFile", if (STR_IN_SET(field,
"Type", "PIDFile", "Type", "Restart", "BusName", "NotifyAccess",
"Restart", "USBFunctionDescriptors", "USBFunctionStrings", "OOMPolicy"))
"BusName",
"NotifyAccess",
"USBFunctionDescriptors",
"USBFunctionStrings",
"OOMPolicy"))
return bus_append_string(m, field, eq); return bus_append_string(m, field, eq);
if (STR_IN_SET(field, "PermissionsStartOnly", if (STR_IN_SET(field, "PermissionsStartOnly", "RootDirectoryStartOnly", "RemainAfterExit", "GuessMainPID"))
"RootDirectoryStartOnly",
"RemainAfterExit",
"GuessMainPID"))
return bus_append_parse_boolean(m, field, eq); return bus_append_parse_boolean(m, field, eq);
if (STR_IN_SET(field, "RestartSec", if (STR_IN_SET(field, "RestartSec", "TimeoutStartSec", "TimeoutStopSec", "RuntimeMaxSec", "WatchdogSec"))
"TimeoutStartSec",
"TimeoutStopSec",
"TimeoutAbortSec",
"RuntimeMaxSec",
"WatchdogSec"))
return bus_append_parse_sec_rename(m, field, eq); return bus_append_parse_sec_rename(m, field, eq);
if (streq(field, "TimeoutSec")) { if (streq(field, "TimeoutSec")) {
@ -1501,25 +1418,14 @@ static int bus_append_service_property(sd_bus_message *m, const char *field, con
if (streq(field, "FileDescriptorStoreMax")) if (streq(field, "FileDescriptorStoreMax"))
return bus_append_safe_atou(m, field, eq); return bus_append_safe_atou(m, field, eq);
if (STR_IN_SET(field, "ExecCondition", if (STR_IN_SET(field,
"ExecStartPre", "ExecCondition", "ExecStartPre", "ExecStart", "ExecStartPost",
"ExecStart", "ExecConditionEx", "ExecStartPreEx", "ExecStartEx", "ExecStartPostEx",
"ExecStartPost", "ExecReload", "ExecStop", "ExecStopPost",
"ExecConditionEx", "ExecReloadEx", "ExecStopEx", "ExecStopPostEx"))
"ExecStartPreEx",
"ExecStartEx",
"ExecStartPostEx",
"ExecReload",
"ExecStop",
"ExecStopPost",
"ExecReloadEx",
"ExecStopEx",
"ExecStopPostEx"))
return bus_append_exec_command(m, field, eq); return bus_append_exec_command(m, field, eq);
if (STR_IN_SET(field, "RestartPreventExitStatus", if (STR_IN_SET(field, "RestartPreventExitStatus", "RestartForceExitStatus", "SuccessExitStatus")) {
"RestartForceExitStatus",
"SuccessExitStatus")) {
_cleanup_free_ int *status = NULL, *signal = NULL; _cleanup_free_ int *status = NULL, *signal = NULL;
size_t n_status = 0, n_signal = 0; size_t n_status = 0, n_signal = 0;
const char *p; const char *p;
@ -1606,70 +1512,39 @@ static int bus_append_service_property(sd_bus_message *m, const char *field, con
static int bus_append_socket_property(sd_bus_message *m, const char *field, const char *eq) { static int bus_append_socket_property(sd_bus_message *m, const char *field, const char *eq) {
int r; int r;
if (STR_IN_SET(field, "Accept", if (STR_IN_SET(field,
"Writable", "Accept", "Writable", "KeepAlive", "NoDelay", "FreeBind", "Transparent", "Broadcast",
"KeepAlive", "PassCredentials", "PassSecurity", "ReusePort", "RemoveOnStop", "SELinuxContextFromNet"))
"NoDelay",
"FreeBind",
"Transparent",
"Broadcast",
"PassCredentials",
"PassSecurity",
"ReusePort",
"RemoveOnStop",
"SELinuxContextFromNet"))
return bus_append_parse_boolean(m, field, eq); return bus_append_parse_boolean(m, field, eq);
if (STR_IN_SET(field, "Priority", if (STR_IN_SET(field, "Priority", "IPTTL", "Mark"))
"IPTTL",
"Mark"))
return bus_append_safe_atoi(m, field, eq); return bus_append_safe_atoi(m, field, eq);
if (streq(field, "IPTOS")) if (streq(field, "IPTOS"))
return bus_append_ip_tos_from_string(m, field, eq); return bus_append_ip_tos_from_string(m, field, eq);
if (STR_IN_SET(field, "Backlog", if (STR_IN_SET(field, "Backlog", "MaxConnections", "MaxConnectionsPerSource", "KeepAliveProbes", "TriggerLimitBurst"))
"MaxConnections",
"MaxConnectionsPerSource",
"KeepAliveProbes",
"TriggerLimitBurst"))
return bus_append_safe_atou(m, field, eq); return bus_append_safe_atou(m, field, eq);
if (STR_IN_SET(field, "SocketMode", if (STR_IN_SET(field, "SocketMode", "DirectoryMode"))
"DirectoryMode"))
return bus_append_parse_mode(m, field, eq); return bus_append_parse_mode(m, field, eq);
if (STR_IN_SET(field, "MessageQueueMaxMessages", if (STR_IN_SET(field, "MessageQueueMaxMessages", "MessageQueueMessageSize"))
"MessageQueueMessageSize"))
return bus_append_safe_atoi64(m, field, eq); return bus_append_safe_atoi64(m, field, eq);
if (STR_IN_SET(field, "TimeoutSec", if (STR_IN_SET(field, "TimeoutSec", "KeepAliveTimeSec", "KeepAliveIntervalSec", "DeferAcceptSec", "TriggerLimitIntervalSec"))
"KeepAliveTimeSec",
"KeepAliveIntervalSec",
"DeferAcceptSec",
"TriggerLimitIntervalSec"))
return bus_append_parse_sec_rename(m, field, eq); return bus_append_parse_sec_rename(m, field, eq);
if (STR_IN_SET(field, "ReceiveBuffer", if (STR_IN_SET(field, "ReceiveBuffer", "SendBuffer", "PipeSize"))
"SendBuffer",
"PipeSize"))
return bus_append_parse_size(m, field, eq, 1024); return bus_append_parse_size(m, field, eq, 1024);
if (STR_IN_SET(field, "ExecStartPre", if (STR_IN_SET(field, "ExecStartPre", "ExecStartPost", "ExecReload", "ExecStopPost"))
"ExecStartPost",
"ExecReload",
"ExecStopPost"))
return bus_append_exec_command(m, field, eq); return bus_append_exec_command(m, field, eq);
if (STR_IN_SET(field, "SmackLabel", if (STR_IN_SET(field,
"SmackLabelIPIn", "SmackLabel", "SmackLabelIPIn", "SmackLabelIPOut", "TCPCongestion",
"SmackLabelIPOut", "BindToDevice", "BindIPv6Only", "FileDescriptorName",
"TCPCongestion", "SocketUser", "SocketGroup"))
"BindToDevice",
"BindIPv6Only",
"FileDescriptorName",
"SocketUser",
"SocketGroup"))
return bus_append_string(m, field, eq); return bus_append_string(m, field, eq);
if (streq(field, "Symlinks")) if (streq(field, "Symlinks"))
@ -1678,14 +1553,9 @@ static int bus_append_socket_property(sd_bus_message *m, const char *field, cons
if (streq(field, "SocketProtocol")) if (streq(field, "SocketProtocol"))
return bus_append_parse_ip_protocol(m, field, eq); return bus_append_parse_ip_protocol(m, field, eq);
if (STR_IN_SET(field, "ListenStream", if (STR_IN_SET(field,
"ListenDatagram", "ListenStream", "ListenDatagram", "ListenSequentialPacket", "ListenNetlink",
"ListenSequentialPacket", "ListenSpecial", "ListenMessageQueue", "ListenFIFO", "ListenUSBFunction")) {
"ListenNetlink",
"ListenSpecial",
"ListenMessageQueue",
"ListenFIFO",
"ListenUSBFunction")) {
if (isempty(eq)) if (isempty(eq))
r = sd_bus_message_append(m, "(sv)", "Listen", "a(ss)", 0); r = sd_bus_message_append(m, "(sv)", "Listen", "a(ss)", 0);
else else
@ -1701,22 +1571,16 @@ static int bus_append_socket_property(sd_bus_message *m, const char *field, cons
static int bus_append_timer_property(sd_bus_message *m, const char *field, const char *eq) { static int bus_append_timer_property(sd_bus_message *m, const char *field, const char *eq) {
int r; int r;
if (STR_IN_SET(field, "WakeSystem", if (STR_IN_SET(field, "WakeSystem", "RemainAfterElapse", "Persistent",
"RemainAfterElapse", "OnTimezoneChange", "OnClockChange"))
"Persistent",
"OnTimezoneChange",
"OnClockChange"))
return bus_append_parse_boolean(m, field, eq); return bus_append_parse_boolean(m, field, eq);
if (STR_IN_SET(field, "AccuracySec", if (STR_IN_SET(field, "AccuracySec", "RandomizedDelaySec"))
"RandomizedDelaySec"))
return bus_append_parse_sec_rename(m, field, eq); return bus_append_parse_sec_rename(m, field, eq);
if (STR_IN_SET(field, "OnActiveSec", if (STR_IN_SET(field,
"OnBootSec", "OnActiveSec", "OnBootSec", "OnStartupSec",
"OnStartupSec", "OnUnitActiveSec","OnUnitInactiveSec")) {
"OnUnitActiveSec",
"OnUnitInactiveSec")) {
if (isempty(eq)) if (isempty(eq))
r = sd_bus_message_append(m, "(sv)", "TimersMonotonic", "a(st)", 0); r = sd_bus_message_append(m, "(sv)", "TimersMonotonic", "a(st)", 0);
else { else {
@ -1752,36 +1616,25 @@ static int bus_append_unit_property(sd_bus_message *m, const char *field, const
bool is_condition = false; bool is_condition = false;
int r; int r;
if (STR_IN_SET(field, "Description", if (STR_IN_SET(field,
"SourcePath", "Description", "SourcePath", "OnFailureJobMode",
"OnFailureJobMode", "JobTimeoutAction", "JobTimeoutRebootArgument",
"JobTimeoutAction", "StartLimitAction", "FailureAction", "SuccessAction",
"JobTimeoutRebootArgument", "RebootArgument", "CollectMode"))
"StartLimitAction",
"FailureAction",
"SuccessAction",
"RebootArgument",
"CollectMode"))
return bus_append_string(m, field, eq); return bus_append_string(m, field, eq);
if (STR_IN_SET(field, "StopWhenUnneeded", if (STR_IN_SET(field,
"RefuseManualStart", "StopWhenUnneeded", "RefuseManualStart", "RefuseManualStop",
"RefuseManualStop", "AllowIsolate", "IgnoreOnIsolate", "DefaultDependencies"))
"AllowIsolate",
"IgnoreOnIsolate",
"DefaultDependencies"))
return bus_append_parse_boolean(m, field, eq); return bus_append_parse_boolean(m, field, eq);
if (STR_IN_SET(field, "JobTimeoutSec", if (STR_IN_SET(field, "JobTimeoutSec", "JobRunningTimeoutSec", "StartLimitIntervalSec"))
"JobRunningTimeoutSec",
"StartLimitIntervalSec"))
return bus_append_parse_sec_rename(m, field, eq); return bus_append_parse_sec_rename(m, field, eq);
if (streq(field, "StartLimitBurst")) if (streq(field, "StartLimitBurst"))
return bus_append_safe_atou(m, field, eq); return bus_append_safe_atou(m, field, eq);
if (STR_IN_SET(field, "SuccessActionExitStatus", if (STR_IN_SET(field, "SuccessActionExitStatus", "FailureActionExitStatus")) {
"FailureActionExitStatus")) {
if (isempty(eq)) if (isempty(eq))
r = sd_bus_message_append(m, "(sv)", field, "i", -1); r = sd_bus_message_append(m, "(sv)", field, "i", -1);
else { else {
@ -1800,8 +1653,7 @@ static int bus_append_unit_property(sd_bus_message *m, const char *field, const
} }
if (unit_dependency_from_string(field) >= 0 || if (unit_dependency_from_string(field) >= 0 ||
STR_IN_SET(field, "Documentation", STR_IN_SET(field, "Documentation", "RequiresMountsFor"))
"RequiresMountsFor"))
return bus_append_strv(m, field, eq, EXTRACT_UNQUOTE); return bus_append_strv(m, field, eq, EXTRACT_UNQUOTE);
t = condition_type_from_string(field); t = condition_type_from_string(field);

View File

@ -227,8 +227,8 @@ static const char* const config_file[] = {
"[Section]\n" "[Section]\n"
"[Section]\n" "[Section]\n"
"setting1=1\n" "setting1=1\n"
"setting1= 2 \t\n" "setting1=2\n"
"setting1= 1\n", /* repeated settings */ "setting1=1\n", /* repeated settings */
"[Section]\n" "[Section]\n"
"[Section]\n" "[Section]\n"

View File

@ -146,7 +146,7 @@ static void test_config_parse_exec(void) {
log_info("/* no command, whitespace only, reset */"); log_info("/* no command, whitespace only, reset */");
r = config_parse_exec(NULL, "fake", 3, "section", 1, r = config_parse_exec(NULL, "fake", 3, "section", 1,
"LValue", 0, "", "LValue", 0, " ",
&c, u); &c, u);
assert_se(r == 0); assert_se(r == 0);
assert_se(c == NULL); assert_se(c == NULL);

View File

@ -536,13 +536,7 @@ install_systemd() {
get_ldpath() { get_ldpath() {
local _bin="$1" local _bin="$1"
local rpath=$(objdump -p "$_bin" 2>/dev/null | awk "/R(UN)?PATH/ { print \"$initdir\" \$2 }" | paste -sd :) objdump -p "$_bin" 2>/dev/null | awk "/R(UN)?PATH/ { print \"$initdir\" \$2 }" | paste -sd :
if [ -z "$rpath" ] ; then
echo $BUILD_DIR
else
echo $rpath
fi
} }
install_missing_libraries() { install_missing_libraries() {