1
0
mirror of https://github.com/systemd/systemd synced 2025-09-26 15:24:44 +02:00

Compare commits

..

No commits in common. "55260eeb781cf99f546380b1d15ee1bebddf24d7" and "dca63b5b46f36989f69b154d7af3b4da433ae59e" have entirely different histories.

25 changed files with 224 additions and 405 deletions

View File

@ -25,13 +25,6 @@ expression e;
- return r; - return r;
@@ @@
identifier log_LEVEL_errno =~ "^log_(debug|info|notice|warning|error|emergency)_errno$"; identifier log_LEVEL_errno =~ "^log_(debug|info|notice|warning|error|emergency)_errno$";
local idexpression r;
@@
+ return
log_LEVEL_errno(r, ...);
- return r;
@@
identifier log_LEVEL_errno =~ "^log_(debug|info|notice|warning|error|emergency)_errno$";
expression e; expression e;
@@ @@
+ return + return
@ -46,57 +39,3 @@ local idexpression r;
- log_LEVEL_errno(e, args); - log_LEVEL_errno(e, args);
- r = e; - r = e;
+ r = log_LEVEL_errno(e, args); + r = log_LEVEL_errno(e, args);
@@
identifier log_UNIT_LEVEL_errno =~ "^log_(unit|link|netdev|device|token)_(debug|info|notice|warning|error|emergency)_errno$";
local idexpression r;
expression e;
expression u;
@@
- r = -e;
+ r =
log_UNIT_LEVEL_errno(u, e, ...);
@@
identifier log_UNIT_LEVEL_errno =~ "^log_(unit|link|netdev|device|token)_(debug|info|notice|warning|error|emergency)_errno$";
local idexpression r;
expression e;
expression u;
@@
+ r =
log_UNIT_LEVEL_errno(u, e, ...);
- r = -e;
@@
identifier log_UNIT_LEVEL_errno =~ "^log_(unit|link|netdev|device|token)_(debug|info|notice|warning|error|emergency)_errno$";
local idexpression r;
expression e;
expression u;
@@
- r =
+ return
log_UNIT_LEVEL_errno(u, e, ...);
- return r;
@@
identifier log_UNIT_LEVEL_errno =~ "^log_(unit|link|netdev|device|token)_(debug|info|notice|warning|error|emergency)_errno$";
local idexpression r;
expression u;
@@
+ return
log_UNIT_LEVEL_errno(u, r, ...);
- return r;
@@
identifier log_UNIT_LEVEL_errno =~ "^log_(unit|link|netdev|device|token)_(debug|info|notice|warning|error|emergency)_errno$";
expression e;
expression u;
@@
+ return
log_UNIT_LEVEL_errno(u, e, ...);
- return -e;
@@
identifier log_UNIT_LEVEL_errno =~ "^log_(unit|link|netdev|device|token)_(debug|info|notice|warning|error|emergency)_errno$";
expression list args;
expression e;
expression u;
local idexpression r;
@@
- log_UNIT_LEVEL_errno(u, e, args);
- r = e;
+ r = log_UNIT_LEVEL_errno(u, e, args);

View File

@ -15,15 +15,9 @@ log_debug("Found no default boot entry :(");
expression e; expression e;
expression list args; expression list args;
@@ @@
(
/* Ignore specific cases in src/import/{export,import,pull}.c where we want to return positive value on success. */
log_info("Exiting.");
return -r;
|
- log_info(args); - log_info(args);
- return -e; - return -e;
+ return log_info_errno(SYNTHETIC_ERRNO(e), args); + return log_info_errno(SYNTHETIC_ERRNO(e), args);
)
@@ @@
expression e; expression e;
expression list args; expression list args;
@ -52,211 +46,3 @@ expression list args;
@@ @@
- log_LEVEL_errno(ERRNO, args); - log_LEVEL_errno(ERRNO, args);
+ log_LEVEL_errno(SYNTHETIC_ERRNO(ERRNO), args); + log_LEVEL_errno(SYNTHETIC_ERRNO(ERRNO), args);
@@
identifier log_UNIT_LEVEL_errno =~ "^log_(unit|link|device|token)_(debug|info|notice|warning|error|emergency)_errno$";
identifier ERRNO =~ "^E[A-Z]+$";
expression u;
expression list args;
@@
- log_UNIT_LEVEL_errno(u, ERRNO, args);
+ log_UNIT_LEVEL_errno(u, SYNTHETIC_ERRNO(ERRNO), args);
@@
expression e;
expression u;
expression list args;
@@
- log_unit_debug(u, args);
- return -e;
+ return log_unit_debug_errno(u, SYNTHETIC_ERRNO(e), args);
@@
expression e;
expression u;
expression list args;
@@
- log_unit_info(u, args);
- return -e;
+ return log_unit_info_errno(u, SYNTHETIC_ERRNO(e), args);
@@
expression e;
expression u;
expression list args;
@@
- log_unit_notice(u, args);
- return -e;
+ return log_unit_notice_errno(u, SYNTHETIC_ERRNO(e), args);
@@
expression e;
expression u;
expression list args;
@@
- log_unit_error(u, args);
- return -e;
+ return log_unit_error_errno(u, SYNTHETIC_ERRNO(e), args);
@@
expression e;
expression u;
expression list args;
@@
- log_unit_emergency(u, args);
- return -e;
+ return log_unit_emergency_errno(u, SYNTHETIC_ERRNO(e), args);
@@
expression e;
expression u;
expression list args;
@@
- log_link_debug(u, args);
- return -e;
+ return log_link_debug_errno(u, SYNTHETIC_ERRNO(e), args);
@@
expression e;
expression u;
expression list args;
@@
- log_link_info(u, args);
- return -e;
+ return log_link_info_errno(u, SYNTHETIC_ERRNO(e), args);
@@
expression e;
expression u;
expression list args;
@@
- log_link_notice(u, args);
- return -e;
+ return log_link_notice_errno(u, SYNTHETIC_ERRNO(e), args);
@@
expression e;
expression u;
expression list args;
@@
- log_link_error(u, args);
- return -e;
+ return log_link_error_errno(u, SYNTHETIC_ERRNO(e), args);
@@
expression e;
expression u;
expression list args;
@@
- log_link_emergency(u, args);
- return -e;
+ return log_link_emergency_errno(u, SYNTHETIC_ERRNO(e), args);
@@
expression e;
expression u;
expression list args;
@@
- log_netdev_debug(u, args);
- return -e;
+ return log_netdev_debug_errno(u, SYNTHETIC_ERRNO(e), args);
@@
expression e;
expression u;
expression list args;
@@
- log_netdev_info(u, args);
- return -e;
+ return log_netdev_info_errno(u, SYNTHETIC_ERRNO(e), args);
@@
expression e;
expression u;
expression list args;
@@
- log_netdev_notice(u, args);
- return -e;
+ return log_netdev_notice_errno(u, SYNTHETIC_ERRNO(e), args);
@@
expression e;
expression u;
expression list args;
@@
- log_netdev_error(u, args);
- return -e;
+ return log_netdev_error_errno(u, SYNTHETIC_ERRNO(e), args);
@@
expression e;
expression u;
expression list args;
@@
- log_netdev_emergency(u, args);
- return -e;
+ return log_netdev_emergency_errno(u, SYNTHETIC_ERRNO(e), args);
@@
expression e;
expression u;
expression list args;
@@
- log_device_debug(u, args);
- return -e;
+ return log_device_debug_errno(u, SYNTHETIC_ERRNO(e), args);
@@
expression e;
expression u;
expression list args;
@@
- log_device_info(u, args);
- return -e;
+ return log_device_info_errno(u, SYNTHETIC_ERRNO(e), args);
@@
expression e;
expression u;
expression list args;
@@
- log_device_notice(u, args);
- return -e;
+ return log_device_notice_errno(u, SYNTHETIC_ERRNO(e), args);
@@
expression e;
expression u;
expression list args;
@@
- log_device_error(u, args);
- return -e;
+ return log_device_error_errno(u, SYNTHETIC_ERRNO(e), args);
@@
expression e;
expression u;
expression list args;
@@
- log_device_emergency(u, args);
- return -e;
+ return log_device_emergency_errno(u, SYNTHETIC_ERRNO(e), args);
@@
expression e;
expression u;
expression list args;
@@
- log_token_debug(u, args);
- return -e;
+ return log_token_debug_errno(u, SYNTHETIC_ERRNO(e), args);
@@
expression e;
expression u;
expression list args;
@@
- log_token_info(u, args);
- return -e;
+ return log_token_info_errno(u, SYNTHETIC_ERRNO(e), args);
@@
expression e;
expression u;
expression list args;
@@
- log_token_notice(u, args);
- return -e;
+ return log_token_notice_errno(u, SYNTHETIC_ERRNO(e), args);
@@
expression e;
expression u;
expression list args;
@@
- log_token_error(u, args);
- return -e;
+ return log_token_error_errno(u, SYNTHETIC_ERRNO(e), args);
@@
expression e;
expression u;
expression list args;
@@
- log_token_emergency(u, args);
- return -e;
+ return log_token_emergency_errno(u, SYNTHETIC_ERRNO(e), args);

View File

@ -323,13 +323,6 @@ evdev:atkbd:dmi:bvn*:bvr*:bd*:svnDell*:pnInspiron*1110:*
evdev:atkbd:dmi:bvn*:bvr*:bd*:svnDell*:pnInspiron*1210:* evdev:atkbd:dmi:bvn*:bvr*:bd*:svnDell*:pnInspiron*1210:*
KEYBOARD_KEY_84=wlan KEYBOARD_KEY_84=wlan
# Dell Inspiron 11 3168
evdev:atkbd:dmi:bvn*:bvr*:bd*:svnDell*:pnInspiron11-3168:pvr*
KEYBOARD_KEY_c7=!home # Fn-LeftArrow
KEYBOARD_KEY_cf=!end # Fn-RightArrow
KEYBOARD_KEY_c9=!pageup # Fn-UpArrow
KEYBOARD_KEY_d1=!pagedown # Fn-DownArrow
# Dell Inspiron 1520 and Latitude 2110 # Dell Inspiron 1520 and Latitude 2110
evdev:atkbd:dmi:bvn*:bvr*:bd*:svnDell*:pnInspiron*1520:* evdev:atkbd:dmi:bvn*:bvr*:bd*:svnDell*:pnInspiron*1520:*
evdev:atkbd:dmi:bvn*:bvr*:bd*:svnDell*:pnLatitude*2110:* evdev:atkbd:dmi:bvn*:bvr*:bd*:svnDell*:pnLatitude*2110:*

View File

@ -33,7 +33,7 @@ try:
OneOrMore, Combine, Or, Optional, Suppress, Group, OneOrMore, Combine, Or, Optional, Suppress, Group,
nums, alphanums, printables, nums, alphanums, printables,
stringEnd, pythonStyleComment, stringEnd, pythonStyleComment,
ParseBaseException, __diag__) ParseBaseException)
except ImportError: except ImportError:
print('pyparsing is not available') print('pyparsing is not available')
sys.exit(77) sys.exit(77)
@ -50,12 +50,6 @@ except ImportError:
# don't do caching on old python # don't do caching on old python
lru_cache = lambda: (lambda f: f) lru_cache = lambda: (lambda f: f)
__diag__.warn_multiple_tokens_in_named_alternation = True
__diag__.warn_ungrouped_named_tokens_in_collection = True
__diag__.warn_name_set_on_empty_Forward = True
__diag__.warn_on_multiple_string_args_to_oneof = True
__diag__.enable_debug_on_named_expressions = True
EOL = LineEnd().suppress() EOL = LineEnd().suppress()
EMPTYLINE = LineEnd() EMPTYLINE = LineEnd()
COMMENTLINE = pythonStyleComment + EOL COMMENTLINE = pythonStyleComment + EOL
@ -117,9 +111,9 @@ def hwdb_grammar():
def property_grammar(): def property_grammar():
ParserElement.setDefaultWhitespaceChars(' ') ParserElement.setDefaultWhitespaceChars(' ')
dpi_setting = Group(Optional('*')('DEFAULT') + INTEGER('DPI') + Suppress('@') + INTEGER('HZ'))('SETTINGS*') dpi_setting = (Optional('*')('DEFAULT') + INTEGER('DPI') + Suppress('@') + INTEGER('HZ'))('SETTINGS*')
mount_matrix_row = SIGNED_REAL + ',' + SIGNED_REAL + ',' + SIGNED_REAL mount_matrix_row = SIGNED_REAL + ',' + SIGNED_REAL + ',' + SIGNED_REAL
mount_matrix = Group(mount_matrix_row + ';' + mount_matrix_row + ';' + mount_matrix_row)('MOUNT_MATRIX') mount_matrix = (mount_matrix_row + ';' + mount_matrix_row + ';' + mount_matrix_row)('MOUNT_MATRIX')
xkb_setting = Optional(Word(alphanums + '+-/@._')) xkb_setting = Optional(Word(alphanums + '+-/@._'))
props = (('MOUSE_DPI', Group(OneOrMore(dpi_setting))), props = (('MOUSE_DPI', Group(OneOrMore(dpi_setting))),

View File

@ -174,15 +174,19 @@ static int automount_verify(Automount *a) {
assert(a); assert(a);
assert(UNIT(a)->load_state == UNIT_LOADED); assert(UNIT(a)->load_state == UNIT_LOADED);
if (path_equal(a->where, "/")) if (path_equal(a->where, "/")) {
return log_unit_error_errno(UNIT(a), SYNTHETIC_ERRNO(ENOEXEC), "Cannot have an automount unit for the root directory. Refusing."); log_unit_error(UNIT(a), "Cannot have an automount unit for the root directory. Refusing.");
return -ENOEXEC;
}
r = unit_name_from_path(a->where, ".automount", &e); r = unit_name_from_path(a->where, ".automount", &e);
if (r < 0) if (r < 0)
return log_unit_error_errno(UNIT(a), r, "Failed to generate unit name from path: %m"); return log_unit_error_errno(UNIT(a), r, "Failed to generate unit name from path: %m");
if (!unit_has_name(UNIT(a), e)) if (!unit_has_name(UNIT(a), e)) {
return log_unit_error_errno(UNIT(a), SYNTHETIC_ERRNO(ENOEXEC), "Where= setting doesn't match unit name. Refusing."); log_unit_error(UNIT(a), "Where= setting doesn't match unit name. Refusing.");
return -ENOEXEC;
}
return 0; return 0;
} }
@ -807,8 +811,10 @@ static int automount_start(Unit *u) {
assert(a); assert(a);
assert(IN_SET(a->state, AUTOMOUNT_DEAD, AUTOMOUNT_FAILED)); assert(IN_SET(a->state, AUTOMOUNT_DEAD, AUTOMOUNT_FAILED));
if (path_is_mount_point(a->where, NULL, 0) > 0) if (path_is_mount_point(a->where, NULL, 0) > 0) {
return log_unit_error_errno(u, SYNTHETIC_ERRNO(EEXIST), "Path %s is already a mount point, refusing start.", a->where); log_unit_error(u, "Path %s is already a mount point, refusing start.", a->where);
return -EEXIST;
}
r = unit_test_trigger_loaded(u); r = unit_test_trigger_loaded(u);
if (r < 0) if (r < 0)

View File

@ -686,10 +686,14 @@ int bpf_firewall_install(Unit *u) {
supported = bpf_firewall_supported(); supported = bpf_firewall_supported();
if (supported < 0) if (supported < 0)
return supported; return supported;
if (supported == BPF_FIREWALL_UNSUPPORTED) if (supported == BPF_FIREWALL_UNSUPPORTED) {
return log_unit_debug_errno(u, SYNTHETIC_ERRNO(EOPNOTSUPP), "BPF firewalling not supported on this manager, proceeding without."); log_unit_debug(u, "BPF firewalling not supported on this manager, proceeding without.");
if (supported != BPF_FIREWALL_SUPPORTED_WITH_MULTI && u->type == UNIT_SLICE) return -EOPNOTSUPP;
return log_unit_debug_errno(u, SYNTHETIC_ERRNO(EOPNOTSUPP), "BPF_F_ALLOW_MULTI is not supported on this manager, not doing BPF firewall on slice units."); }
if (supported != BPF_FIREWALL_SUPPORTED_WITH_MULTI && u->type == UNIT_SLICE) {
log_unit_debug(u, "BPF_F_ALLOW_MULTI is not supported on this manager, not doing BPF firewall on slice units.");
return -EOPNOTSUPP;
}
if (supported != BPF_FIREWALL_SUPPORTED_WITH_MULTI && if (supported != BPF_FIREWALL_SUPPORTED_WITH_MULTI &&
(!set_isempty(u->ip_bpf_custom_ingress) || !set_isempty(u->ip_bpf_custom_egress))) (!set_isempty(u->ip_bpf_custom_ingress) || !set_isempty(u->ip_bpf_custom_egress)))
return log_unit_debug_errno(u, SYNTHETIC_ERRNO(EOPNOTSUPP), "BPF_F_ALLOW_MULTI not supported on this manager, cannot attach custom BPF programs."); return log_unit_debug_errno(u, SYNTHETIC_ERRNO(EOPNOTSUPP), "BPF_F_ALLOW_MULTI not supported on this manager, cannot attach custom BPF programs.");

View File

@ -515,10 +515,11 @@ static int device_setup_unit(Manager *m, sd_device *dev, const char *path, bool
if (DEVICE(u)->state == DEVICE_PLUGGED && if (DEVICE(u)->state == DEVICE_PLUGGED &&
DEVICE(u)->sysfs && DEVICE(u)->sysfs &&
sysfs && sysfs &&
!path_equal(DEVICE(u)->sysfs, sysfs)) !path_equal(DEVICE(u)->sysfs, sysfs)) {
return log_unit_debug_errno(u, SYNTHETIC_ERRNO(EEXIST), log_unit_debug(u, "Device %s appeared twice with different sysfs paths %s and %s, ignoring the latter.",
"Device %s appeared twice with different sysfs paths %s and %s, ignoring the latter.", e, DEVICE(u)->sysfs, sysfs);
e, DEVICE(u)->sysfs, sysfs); return -EEXIST;
}
delete = false; delete = false;

View File

@ -3769,20 +3769,23 @@ static int exec_child(
r = dynamic_creds_realize(dcreds, suggested_paths, &uid, &gid); r = dynamic_creds_realize(dcreds, suggested_paths, &uid, &gid);
if (r < 0) { if (r < 0) {
*exit_status = EXIT_USER; *exit_status = EXIT_USER;
if (r == -EILSEQ) if (r == -EILSEQ) {
return log_unit_error_errno(unit, SYNTHETIC_ERRNO(EOPNOTSUPP), log_unit_error(unit, "Failed to update dynamic user credentials: User or group with specified name already exists.");
"Failed to update dynamic user credentials: User or group with specified name already exists."); return -EOPNOTSUPP;
}
return log_unit_error_errno(unit, r, "Failed to update dynamic user credentials: %m"); return log_unit_error_errno(unit, r, "Failed to update dynamic user credentials: %m");
} }
if (!uid_is_valid(uid)) { if (!uid_is_valid(uid)) {
*exit_status = EXIT_USER; *exit_status = EXIT_USER;
return log_unit_error_errno(unit, SYNTHETIC_ERRNO(ESRCH), "UID validation failed for \""UID_FMT"\"", uid); log_unit_error(unit, "UID validation failed for \""UID_FMT"\"", uid);
return -ESRCH;
} }
if (!gid_is_valid(gid)) { if (!gid_is_valid(gid)) {
*exit_status = EXIT_USER; *exit_status = EXIT_USER;
return log_unit_error_errno(unit, SYNTHETIC_ERRNO(ESRCH), "GID validation failed for \""GID_FMT"\"", gid); log_unit_error(unit, "GID validation failed for \""GID_FMT"\"", gid);
return -ESRCH;
} }
if (dcreds->user) if (dcreds->user)
@ -4625,11 +4628,15 @@ int exec_spawn(Unit *unit,
context->std_output == EXEC_OUTPUT_SOCKET || context->std_output == EXEC_OUTPUT_SOCKET ||
context->std_error == EXEC_OUTPUT_SOCKET) { context->std_error == EXEC_OUTPUT_SOCKET) {
if (params->n_socket_fds > 1) if (params->n_socket_fds > 1) {
return log_unit_error_errno(unit, SYNTHETIC_ERRNO(EINVAL), "Got more than one socket."); log_unit_error(unit, "Got more than one socket.");
return -EINVAL;
}
if (params->n_socket_fds == 0) if (params->n_socket_fds == 0) {
return log_unit_error_errno(unit, SYNTHETIC_ERRNO(EINVAL), "Got no socket."); log_unit_error(unit, "Got no socket.");
return -EINVAL;
}
socket_fd = params->fds[0]; socket_fd = params->fds[0];
} else { } else {

View File

@ -549,19 +549,25 @@ static int mount_verify(Mount *m) {
if (r < 0) if (r < 0)
return log_unit_error_errno(UNIT(m), r, "Failed to generate unit name from mount path: %m"); return log_unit_error_errno(UNIT(m), r, "Failed to generate unit name from mount path: %m");
if (!unit_has_name(UNIT(m), e)) if (!unit_has_name(UNIT(m), e)) {
return log_unit_error_errno(UNIT(m), SYNTHETIC_ERRNO(ENOEXEC), "Where= setting doesn't match unit name. Refusing."); log_unit_error(UNIT(m), "Where= setting doesn't match unit name. Refusing.");
return -ENOEXEC;
}
if (mount_point_is_api(m->where) || mount_point_ignore(m->where)) if (mount_point_is_api(m->where) || mount_point_ignore(m->where)) {
return log_unit_error_errno(UNIT(m), SYNTHETIC_ERRNO(ENOEXEC), "Cannot create mount unit for API file system %s. Refusing.", m->where); log_unit_error(UNIT(m), "Cannot create mount unit for API file system %s. Refusing.", m->where);
return -ENOEXEC;
}
p = get_mount_parameters_fragment(m); p = get_mount_parameters_fragment(m);
if (p && !p->what && !UNIT(m)->perpetual) if (p && !p->what && !UNIT(m)->perpetual)
return log_unit_error_errno(UNIT(m), SYNTHETIC_ERRNO(ENOEXEC), return log_unit_error_errno(UNIT(m), SYNTHETIC_ERRNO(ENOEXEC),
"What= setting is missing. Refusing."); "What= setting is missing. Refusing.");
if (m->exec_context.pam_name && m->kill_context.kill_mode != KILL_CONTROL_GROUP) if (m->exec_context.pam_name && m->kill_context.kill_mode != KILL_CONTROL_GROUP) {
return log_unit_error_errno(UNIT(m), SYNTHETIC_ERRNO(ENOEXEC), "Unit has PAM enabled. Kill mode must be set to control-group'. Refusing."); log_unit_error(UNIT(m), "Unit has PAM enabled. Kill mode must be set to control-group'. Refusing.");
return -ENOEXEC;
}
return 0; return 0;
} }

View File

@ -283,8 +283,10 @@ static int path_verify(Path *p) {
assert(p); assert(p);
assert(UNIT(p)->load_state == UNIT_LOADED); assert(UNIT(p)->load_state == UNIT_LOADED);
if (!p->specs) if (!p->specs) {
return log_unit_error_errno(UNIT(p), SYNTHETIC_ERRNO(ENOEXEC), "Path unit lacks path setting. Refusing."); log_unit_error(UNIT(p), "Path unit lacks path setting. Refusing.");
return -ENOEXEC;
}
return 0; return 0;
} }

View File

@ -131,8 +131,10 @@ static int scope_verify(Scope *s) {
if (set_isempty(UNIT(s)->pids) && if (set_isempty(UNIT(s)->pids) &&
!MANAGER_IS_RELOADING(UNIT(s)->manager) && !MANAGER_IS_RELOADING(UNIT(s)->manager) &&
!unit_has_name(UNIT(s), SPECIAL_INIT_SCOPE)) !unit_has_name(UNIT(s), SPECIAL_INIT_SCOPE)) {
return log_unit_error_errno(UNIT(s), SYNTHETIC_ERRNO(ENOENT), "Scope has no PIDs. Refusing."); log_unit_error(UNIT(s), "Scope has no PIDs. Refusing.");
return -ENOENT;
}
return 0; return 0;
} }
@ -496,7 +498,11 @@ static int scope_deserialize_item(Unit *u, const char *key, const char *value, F
if (parse_pid(value, &pid) < 0) if (parse_pid(value, &pid) < 0)
log_unit_debug(u, "Failed to parse pids value: %s", value); log_unit_debug(u, "Failed to parse pids value: %s", value);
else { else {
r = set_ensure_put(&u->pids, NULL, PID_TO_PTR(pid)); r = set_ensure_allocated(&u->pids, NULL);
if (r < 0)
return r;
r = set_put(u->pids, PID_TO_PTR(pid));
if (r < 0) if (r < 0)
return r; return r;
} }

View File

@ -548,35 +548,51 @@ static int service_verify(Service *s) {
assert(s); assert(s);
assert(UNIT(s)->load_state == UNIT_LOADED); assert(UNIT(s)->load_state == UNIT_LOADED);
if (!s->exec_command[SERVICE_EXEC_START] && !s->exec_command[SERVICE_EXEC_STOP] && if (!s->exec_command[SERVICE_EXEC_START] && !s->exec_command[SERVICE_EXEC_STOP]
UNIT(s)->success_action == EMERGENCY_ACTION_NONE) && UNIT(s)->success_action == EMERGENCY_ACTION_NONE) {
/* FailureAction= only makes sense if one of the start or stop commands is specified. /* FailureAction= only makes sense if one of the start or stop commands is specified.
* SuccessAction= will be executed unconditionally if no commands are specified. Hence, * SuccessAction= will be executed unconditionally if no commands are specified. Hence,
* either a command or SuccessAction= are required. */ * either a command or SuccessAction= are required. */
return log_unit_error_errno(UNIT(s), SYNTHETIC_ERRNO(ENOEXEC), "Service has no ExecStart=, ExecStop=, or SuccessAction=. Refusing."); log_unit_error(UNIT(s), "Service has no ExecStart=, ExecStop=, or SuccessAction=. Refusing.");
return -ENOEXEC;
}
if (s->type != SERVICE_ONESHOT && !s->exec_command[SERVICE_EXEC_START]) if (s->type != SERVICE_ONESHOT && !s->exec_command[SERVICE_EXEC_START]) {
return log_unit_error_errno(UNIT(s), SYNTHETIC_ERRNO(ENOEXEC), "Service has no ExecStart= setting, which is only allowed for Type=oneshot services. Refusing."); log_unit_error(UNIT(s), "Service has no ExecStart= setting, which is only allowed for Type=oneshot services. Refusing.");
return -ENOEXEC;
}
if (!s->remain_after_exit && !s->exec_command[SERVICE_EXEC_START] && UNIT(s)->success_action == EMERGENCY_ACTION_NONE) if (!s->remain_after_exit && !s->exec_command[SERVICE_EXEC_START] && UNIT(s)->success_action == EMERGENCY_ACTION_NONE) {
return log_unit_error_errno(UNIT(s), SYNTHETIC_ERRNO(ENOEXEC), "Service has no ExecStart= and no SuccessAction= settings and does not have RemainAfterExit=yes set. Refusing."); log_unit_error(UNIT(s), "Service has no ExecStart= and no SuccessAction= settings and does not have RemainAfterExit=yes set. Refusing.");
return -ENOEXEC;
}
if (s->type != SERVICE_ONESHOT && s->exec_command[SERVICE_EXEC_START]->command_next) if (s->type != SERVICE_ONESHOT && s->exec_command[SERVICE_EXEC_START]->command_next) {
return log_unit_error_errno(UNIT(s), SYNTHETIC_ERRNO(ENOEXEC), "Service has more than one ExecStart= setting, which is only allowed for Type=oneshot services. Refusing."); log_unit_error(UNIT(s), "Service has more than one ExecStart= setting, which is only allowed for Type=oneshot services. Refusing.");
return -ENOEXEC;
}
if (s->type == SERVICE_ONESHOT && if (s->type == SERVICE_ONESHOT
!IN_SET(s->restart, SERVICE_RESTART_NO, SERVICE_RESTART_ON_FAILURE, SERVICE_RESTART_ON_ABNORMAL, SERVICE_RESTART_ON_WATCHDOG, SERVICE_RESTART_ON_ABORT)) && !IN_SET(s->restart, SERVICE_RESTART_NO, SERVICE_RESTART_ON_FAILURE, SERVICE_RESTART_ON_ABNORMAL, SERVICE_RESTART_ON_WATCHDOG, SERVICE_RESTART_ON_ABORT)) {
return log_unit_error_errno(UNIT(s), SYNTHETIC_ERRNO(ENOEXEC), "Service has Restart= set to either always or on-success, which isn't allowed for Type=oneshot services. Refusing."); log_unit_error(UNIT(s), "Service has Restart= set to either always or on-success, which isn't allowed for Type=oneshot services. Refusing.");
return -ENOEXEC;
}
if (s->type == SERVICE_ONESHOT && !exit_status_set_is_empty(&s->restart_force_status)) if (s->type == SERVICE_ONESHOT && !exit_status_set_is_empty(&s->restart_force_status)) {
return log_unit_error_errno(UNIT(s), SYNTHETIC_ERRNO(ENOEXEC), "Service has RestartForceStatus= set, which isn't allowed for Type=oneshot services. Refusing."); log_unit_error(UNIT(s), "Service has RestartForceStatus= set, which isn't allowed for Type=oneshot services. Refusing.");
return -ENOEXEC;
}
if (s->type == SERVICE_DBUS && !s->bus_name) if (s->type == SERVICE_DBUS && !s->bus_name) {
return log_unit_error_errno(UNIT(s), SYNTHETIC_ERRNO(ENOEXEC), "Service is of type D-Bus but no D-Bus service name has been specified. Refusing."); log_unit_error(UNIT(s), "Service is of type D-Bus but no D-Bus service name has been specified. Refusing.");
return -ENOEXEC;
}
if (s->exec_context.pam_name && !IN_SET(s->kill_context.kill_mode, KILL_CONTROL_GROUP, KILL_MIXED)) if (s->exec_context.pam_name && !IN_SET(s->kill_context.kill_mode, KILL_CONTROL_GROUP, KILL_MIXED)) {
return log_unit_error_errno(UNIT(s), SYNTHETIC_ERRNO(ENOEXEC), "Service has PAM enabled. Kill mode must be set to 'control-group' or 'mixed'. Refusing."); log_unit_error(UNIT(s), "Service has PAM enabled. Kill mode must be set to 'control-group' or 'mixed'. Refusing.");
return -ENOEXEC;
}
if (s->usb_function_descriptors && !s->usb_function_strings) if (s->usb_function_descriptors && !s->usb_function_strings)
log_unit_warning(UNIT(s), "Service has USBFunctionDescriptors= setting, but no USBFunctionStrings=. Ignoring."); log_unit_warning(UNIT(s), "Service has USBFunctionDescriptors= setting, but no USBFunctionStrings=. Ignoring.");
@ -898,14 +914,20 @@ static int service_is_suitable_main_pid(Service *s, pid_t pid, int prio) {
* PID is questionnable but should be accepted if the source of configuration is trusted. > 0 if the PID is * PID is questionnable but should be accepted if the source of configuration is trusted. > 0 if the PID is
* good */ * good */
if (pid == getpid_cached() || pid == 1) if (pid == getpid_cached() || pid == 1) {
return log_unit_full_errno(UNIT(s), prio, SYNTHETIC_ERRNO(EPERM), "New main PID "PID_FMT" is the manager, refusing.", pid); log_unit_full(UNIT(s), prio, "New main PID "PID_FMT" is the manager, refusing.", pid);
return -EPERM;
}
if (pid == s->control_pid) if (pid == s->control_pid) {
return log_unit_full_errno(UNIT(s), prio, SYNTHETIC_ERRNO(EPERM), "New main PID "PID_FMT" is the control process, refusing.", pid); log_unit_full(UNIT(s), prio, "New main PID "PID_FMT" is the control process, refusing.", pid);
return -EPERM;
}
if (!pid_is_alive(pid)) if (!pid_is_alive(pid)) {
return log_unit_full_errno(UNIT(s), prio, SYNTHETIC_ERRNO(ESRCH), "New main PID "PID_FMT" does not exist or is a zombie.", pid); log_unit_full(UNIT(s), prio, "New main PID "PID_FMT" does not exist or is a zombie.", pid);
return -ESRCH;
}
owner = manager_get_unit_by_pid(UNIT(s)->manager, pid); owner = manager_get_unit_by_pid(UNIT(s)->manager, pid);
if (owner == UNIT(s)) { if (owner == UNIT(s)) {
@ -966,18 +988,20 @@ static int service_load_pid_file(Service *s, bool may_warn) {
if (r == 0) { if (r == 0) {
struct stat st; struct stat st;
if (questionable_pid_file) if (questionable_pid_file) {
return log_unit_error_errno(UNIT(s), SYNTHETIC_ERRNO(EPERM), log_unit_error(UNIT(s), "Refusing to accept PID outside of service control group, acquired through unsafe symlink chain: %s", s->pid_file);
"Refusing to accept PID outside of service control group, acquired through unsafe symlink chain: %s", s->pid_file); return -EPERM;
}
/* Hmm, it's not clear if the new main PID is safe. Let's allow this if the PID file is owned by root */ /* Hmm, it's not clear if the new main PID is safe. Let's allow this if the PID file is owned by root */
if (fstat(fd, &st) < 0) if (fstat(fd, &st) < 0)
return log_unit_error_errno(UNIT(s), errno, "Failed to fstat() PID file O_PATH fd: %m"); return log_unit_error_errno(UNIT(s), errno, "Failed to fstat() PID file O_PATH fd: %m");
if (st.st_uid != 0) if (st.st_uid != 0) {
return log_unit_error_errno(UNIT(s), SYNTHETIC_ERRNO(EPERM), log_unit_error(UNIT(s), "New main PID "PID_FMT" does not belong to service, and PID file is not owned by root. Refusing.", pid);
"New main PID "PID_FMT" does not belong to service, and PID file is not owned by root. Refusing.", pid); return -EPERM;
}
log_unit_debug(UNIT(s), "New main PID "PID_FMT" does not belong to service, but we'll accept it since PID file is owned by root.", pid); log_unit_debug(UNIT(s), "New main PID "PID_FMT" does not belong to service, but we'll accept it since PID file is owned by root.", pid);
} }
@ -2103,7 +2127,8 @@ static void service_enter_start(Service *s) {
/* There's no command line configured for the main command? Hmm, that is strange. /* There's no command line configured for the main command? Hmm, that is strange.
* This can only happen if the configuration changes at runtime. In this case, * This can only happen if the configuration changes at runtime. In this case,
* let's enter a failure state. */ * let's enter a failure state. */
r = log_unit_error_errno(UNIT(s), SYNTHETIC_ERRNO(ENXIO), "There's no 'start' task anymore we could start."); log_unit_error(UNIT(s), "There's no 'start' task anymore we could start.");
r = -ENXIO;
goto fail; goto fail;
} }

View File

@ -94,15 +94,19 @@ static int slice_verify(Slice *s) {
assert(s); assert(s);
assert(UNIT(s)->load_state == UNIT_LOADED); assert(UNIT(s)->load_state == UNIT_LOADED);
if (!slice_name_is_valid(UNIT(s)->id)) if (!slice_name_is_valid(UNIT(s)->id)) {
return log_unit_error_errno(UNIT(s), SYNTHETIC_ERRNO(ENOEXEC), "Slice name %s is not valid. Refusing.", UNIT(s)->id); log_unit_error(UNIT(s), "Slice name %s is not valid. Refusing.", UNIT(s)->id);
return -ENOEXEC;
}
r = slice_build_parent_slice(UNIT(s)->id, &parent); r = slice_build_parent_slice(UNIT(s)->id, &parent);
if (r < 0) if (r < 0)
return log_unit_error_errno(UNIT(s), r, "Failed to determine parent slice: %m"); return log_unit_error_errno(UNIT(s), r, "Failed to determine parent slice: %m");
if (parent ? !unit_has_name(UNIT_DEREF(UNIT(s)->slice), parent) : UNIT_ISSET(UNIT(s)->slice)) if (parent ? !unit_has_name(UNIT_DEREF(UNIT(s)->slice), parent) : UNIT_ISSET(UNIT(s)->slice)) {
return log_unit_error_errno(UNIT(s), SYNTHETIC_ERRNO(ENOEXEC), "Located outside of parent slice. Refusing."); log_unit_error(UNIT(s), "Located outside of parent slice. Refusing.");
return -ENOEXEC;
}
return 0; return 0;
} }

View File

@ -384,7 +384,8 @@ int mac_smack_setup(bool *loaded_policy) {
log_info("Successfully wrote Smack onlycap list."); log_info("Successfully wrote Smack onlycap list.");
break; break;
default: default:
return log_emergency_errno(r, "Failed to write Smack onlycap list: %m"); log_emergency_errno(r, "Failed to write Smack onlycap list: %m");
return r;
} }
*loaded_policy = true; *loaded_policy = true;

View File

@ -402,23 +402,35 @@ static int socket_verify(Socket *s) {
assert(s); assert(s);
assert(UNIT(s)->load_state == UNIT_LOADED); assert(UNIT(s)->load_state == UNIT_LOADED);
if (!s->ports) if (!s->ports) {
return log_unit_error_errno(UNIT(s), SYNTHETIC_ERRNO(ENOEXEC), "Unit has no Listen setting (ListenStream=, ListenDatagram=, ListenFIFO=, ...). Refusing."); log_unit_error(UNIT(s), "Unit has no Listen setting (ListenStream=, ListenDatagram=, ListenFIFO=, ...). Refusing.");
return -ENOEXEC;
}
if (s->accept && have_non_accept_socket(s)) if (s->accept && have_non_accept_socket(s)) {
return log_unit_error_errno(UNIT(s), SYNTHETIC_ERRNO(ENOEXEC), "Unit configured for accepting sockets, but sockets are non-accepting. Refusing."); log_unit_error(UNIT(s), "Unit configured for accepting sockets, but sockets are non-accepting. Refusing.");
return -ENOEXEC;
}
if (s->accept && s->max_connections <= 0) if (s->accept && s->max_connections <= 0) {
return log_unit_error_errno(UNIT(s), SYNTHETIC_ERRNO(ENOEXEC), "MaxConnection= setting too small. Refusing."); log_unit_error(UNIT(s), "MaxConnection= setting too small. Refusing.");
return -ENOEXEC;
}
if (s->accept && UNIT_DEREF(s->service)) if (s->accept && UNIT_DEREF(s->service)) {
return log_unit_error_errno(UNIT(s), SYNTHETIC_ERRNO(ENOEXEC), "Explicit service configuration for accepting socket units not supported. Refusing."); log_unit_error(UNIT(s), "Explicit service configuration for accepting socket units not supported. Refusing.");
return -ENOEXEC;
}
if (s->exec_context.pam_name && s->kill_context.kill_mode != KILL_CONTROL_GROUP) if (s->exec_context.pam_name && s->kill_context.kill_mode != KILL_CONTROL_GROUP) {
return log_unit_error_errno(UNIT(s), SYNTHETIC_ERRNO(ENOEXEC), "Unit has PAM enabled. Kill mode must be set to 'control-group'. Refusing."); log_unit_error(UNIT(s), "Unit has PAM enabled. Kill mode must be set to 'control-group'. Refusing.");
return -ENOEXEC;
}
if (!strv_isempty(s->symlinks) && !socket_find_symlink_target(s)) if (!strv_isempty(s->symlinks) && !socket_find_symlink_target(s)) {
return log_unit_error_errno(UNIT(s), SYNTHETIC_ERRNO(ENOEXEC), "Unit has symlinks set but none or more than one node in the file system. Refusing."); log_unit_error(UNIT(s), "Unit has symlinks set but none or more than one node in the file system. Refusing.");
return -ENOEXEC;
}
return 0; return 0;
} }
@ -2495,13 +2507,17 @@ static int socket_start(Unit *u) {
service = SERVICE(UNIT_DEREF(s->service)); service = SERVICE(UNIT_DEREF(s->service));
if (UNIT(service)->load_state != UNIT_LOADED) if (UNIT(service)->load_state != UNIT_LOADED) {
return log_unit_error_errno(u, SYNTHETIC_ERRNO(ENOENT), "Socket service %s not loaded, refusing.", UNIT(service)->id); log_unit_error(u, "Socket service %s not loaded, refusing.", UNIT(service)->id);
return -ENOENT;
}
/* If the service is already active we cannot start the /* If the service is already active we cannot start the
* socket */ * socket */
if (!IN_SET(service->state, SERVICE_DEAD, SERVICE_FAILED, SERVICE_AUTO_RESTART)) if (!IN_SET(service->state, SERVICE_DEAD, SERVICE_FAILED, SERVICE_AUTO_RESTART)) {
return log_unit_error_errno(u, SYNTHETIC_ERRNO(EBUSY), "Socket service %s already active, refusing.", UNIT(service)->id); log_unit_error(u, "Socket service %s already active, refusing.", UNIT(service)->id);
return -EBUSY;
}
} }
assert(IN_SET(s->state, SOCKET_DEAD, SOCKET_FAILED)); assert(IN_SET(s->state, SOCKET_DEAD, SOCKET_FAILED));

View File

@ -287,11 +287,15 @@ static int swap_verify(Swap *s) {
if (r < 0) if (r < 0)
return log_unit_error_errno(UNIT(s), r, "Failed to generate unit name from path: %m"); return log_unit_error_errno(UNIT(s), r, "Failed to generate unit name from path: %m");
if (!unit_has_name(UNIT(s), e)) if (!unit_has_name(UNIT(s), e)) {
return log_unit_error_errno(UNIT(s), SYNTHETIC_ERRNO(ENOEXEC), "Value of What= and unit name do not match, not loading."); log_unit_error(UNIT(s), "Value of What= and unit name do not match, not loading.");
return -ENOEXEC;
}
if (s->exec_context.pam_name && s->kill_context.kill_mode != KILL_CONTROL_GROUP) if (s->exec_context.pam_name && s->kill_context.kill_mode != KILL_CONTROL_GROUP) {
return log_unit_error_errno(UNIT(s), SYNTHETIC_ERRNO(ENOEXEC), "Unit has PAM enabled. Kill mode must be set to 'control-group'. Refusing to load."); log_unit_error(UNIT(s), "Unit has PAM enabled. Kill mode must be set to 'control-group'. Refusing to load.");
return -ENOEXEC;
}
return 0; return 0;
} }

View File

@ -75,8 +75,10 @@ static int timer_verify(Timer *t) {
assert(t); assert(t);
assert(UNIT(t)->load_state == UNIT_LOADED); assert(UNIT(t)->load_state == UNIT_LOADED);
if (!t->values && !t->on_clock_change && !t->on_timezone_change) if (!t->values && !t->on_clock_change && !t->on_timezone_change) {
return log_unit_error_errno(UNIT(t), SYNTHETIC_ERRNO(ENOEXEC), "Timer unit lacks value setting. Refusing."); log_unit_error(UNIT(t), "Timer unit lacks value setting. Refusing.");
return -ENOEXEC;
}
return 0; return 0;
} }
@ -99,13 +101,14 @@ static int timer_add_default_dependencies(Timer *t) {
if (r < 0) if (r < 0)
return r; return r;
LIST_FOREACH(value, v, t->values) LIST_FOREACH(value, v, t->values) {
if (v->base == TIMER_CALENDAR) { if (v->base == TIMER_CALENDAR) {
r = unit_add_dependency_by_name(UNIT(t), UNIT_AFTER, SPECIAL_TIME_SYNC_TARGET, true, UNIT_DEPENDENCY_DEFAULT); r = unit_add_dependency_by_name(UNIT(t), UNIT_AFTER, SPECIAL_TIME_SYNC_TARGET, true, UNIT_DEPENDENCY_DEFAULT);
if (r < 0) if (r < 0)
return r; return r;
break; break;
} }
}
} }
return unit_add_two_dependencies_by_name(UNIT(t), UNIT_BEFORE, UNIT_CONFLICTS, SPECIAL_SHUTDOWN_TARGET, true, UNIT_DEPENDENCY_DEFAULT); return unit_add_two_dependencies_by_name(UNIT(t), UNIT_BEFORE, UNIT_CONFLICTS, SPECIAL_SHUTDOWN_TARGET, true, UNIT_DEPENDENCY_DEFAULT);
@ -256,7 +259,8 @@ static void timer_dump(Unit *u, FILE *f, const char *prefix) {
prefix, yes_no(t->on_clock_change), prefix, yes_no(t->on_clock_change),
prefix, yes_no(t->on_timezone_change)); prefix, yes_no(t->on_timezone_change));
LIST_FOREACH(value, v, t->values) LIST_FOREACH(value, v, t->values) {
if (v->base == TIMER_CALENDAR) { if (v->base == TIMER_CALENDAR) {
_cleanup_free_ char *p = NULL; _cleanup_free_ char *p = NULL;
@ -276,6 +280,7 @@ static void timer_dump(Unit *u, FILE *f, const char *prefix) {
timer_base_to_string(v->base), timer_base_to_string(v->base),
format_timespan(timespan1, sizeof(timespan1), v->value, 0)); format_timespan(timespan1, sizeof(timespan1), v->value, 0));
} }
}
} }
static void timer_set_state(Timer *t, TimerState state) { static void timer_set_state(Timer *t, TimerState state) {
@ -665,7 +670,9 @@ static int timer_start(Unit *u) {
} }
} else if (errno == ENOENT) } else if (errno == ENOENT)
/* The timer has never run before, make sure a stamp file exists. */ /* The timer has never run before,
* make sure a stamp file exists.
*/
(void) touch_file(t->stamp_path, true, USEC_INFINITY, UID_INVALID, GID_INVALID, MODE_INVALID); (void) touch_file(t->stamp_path, true, USEC_INFINITY, UID_INVALID, GID_INVALID, MODE_INVALID);
} }

View File

@ -181,7 +181,7 @@ int unit_name_printf(const Unit *u, const char* format, char **ret) {
* %N: the id of the unit without the suffix (foo-aaa@bar) * %N: the id of the unit without the suffix (foo-aaa@bar)
* %p: the prefix (foo-aaa) * %p: the prefix (foo-aaa)
* %i: the instance (bar) * %i: the instance (bar)
* %j: the last component of the prefix (aaa) * %j: the last componet of the prefix (aaa)
*/ */
const Specifier table[] = { const Specifier table[] = {

View File

@ -1668,8 +1668,8 @@ int unit_load(Unit *u) {
goto fail; goto fail;
if (u->on_failure_job_mode == JOB_ISOLATE && hashmap_size(u->dependencies[UNIT_ON_FAILURE]) > 1) { if (u->on_failure_job_mode == JOB_ISOLATE && hashmap_size(u->dependencies[UNIT_ON_FAILURE]) > 1) {
r = log_unit_error_errno(u, SYNTHETIC_ERRNO(ENOEXEC), log_unit_error(u, "More than one OnFailure= dependencies specified but OnFailureJobMode=isolate set. Refusing.");
"More than one OnFailure= dependencies specified but OnFailureJobMode=isolate set. Refusing."); r = -ENOEXEC;
goto fail; goto fail;
} }
@ -2022,8 +2022,10 @@ int unit_reload(Unit *u) {
if (state == UNIT_RELOADING) if (state == UNIT_RELOADING)
return -EAGAIN; return -EAGAIN;
if (state != UNIT_ACTIVE) if (state != UNIT_ACTIVE) {
return log_unit_warning_errno(u, SYNTHETIC_ERRNO(ENOEXEC), "Unit cannot be reloaded because it is inactive."); log_unit_warning(u, "Unit cannot be reloaded because it is inactive.");
return -ENOEXEC;
}
following = unit_following(u); following = unit_following(u);
if (following) { if (following) {

View File

@ -445,13 +445,14 @@ static int create_disk(
fprintf(f, "After=%s\n" fprintf(f, "After=%s\n"
"Requires=%s\n", unit, unit); "Requires=%s\n", unit, unit);
if (umount_unit) if (umount_unit) {
fprintf(f, fprintf(f,
"Wants=%s\n" "Wants=%s\n"
"Before=%s\n", "Before=%s\n",
umount_unit, umount_unit,
umount_unit umount_unit
); );
}
} }
if (!nofail) if (!nofail)

View File

@ -400,8 +400,10 @@ int netdev_set_ifindex(NetDev *netdev, sd_netlink_message *message) {
if (r < 0) if (r < 0)
return log_netdev_error_errno(netdev, r, "Could not get rtnl message type: %m"); return log_netdev_error_errno(netdev, r, "Could not get rtnl message type: %m");
if (type != RTM_NEWLINK) if (type != RTM_NEWLINK) {
return log_netdev_error_errno(netdev, SYNTHETIC_ERRNO(EINVAL), "Cannot set ifindex from unexpected rtnl message type."); log_netdev_error(netdev, "Cannot set ifindex from unexpected rtnl message type.");
return -EINVAL;
}
r = sd_rtnl_message_link_get_ifindex(message, &ifindex); r = sd_rtnl_message_link_get_ifindex(message, &ifindex);
if (r < 0) { if (r < 0) {
@ -432,7 +434,7 @@ int netdev_set_ifindex(NetDev *netdev, sd_netlink_message *message) {
if (!streq(netdev->ifname, received_name)) { if (!streq(netdev->ifname, received_name)) {
log_netdev_error(netdev, "Received newlink with wrong IFNAME %s", received_name); log_netdev_error(netdev, "Received newlink with wrong IFNAME %s", received_name);
netdev_enter_failed(netdev); netdev_enter_failed(netdev);
return -EINVAL; return r;
} }
r = sd_netlink_message_enter_container(message, IFLA_LINKINFO); r = sd_netlink_message_enter_container(message, IFLA_LINKINFO);
@ -460,10 +462,11 @@ int netdev_set_ifindex(NetDev *netdev, sd_netlink_message *message) {
} }
if (!streq(kind, received_kind)) { if (!streq(kind, received_kind)) {
log_netdev_error(netdev, "Received newlink with wrong KIND %s, expected %s", log_netdev_error(netdev,
received_kind, kind); "Received newlink with wrong KIND %s, "
"expected %s", received_kind, kind);
netdev_enter_failed(netdev); netdev_enter_failed(netdev);
return -EINVAL; return r;
} }
netdev->ifindex = ifindex; netdev->ifindex = ifindex;

View File

@ -195,8 +195,10 @@ static int link_set_can(Link *link) {
format_timespan(time_string, FORMAT_TIMESPAN_MAX, restart_ms * 1000, MSEC_PER_SEC); format_timespan(time_string, FORMAT_TIMESPAN_MAX, restart_ms * 1000, MSEC_PER_SEC);
if (restart_ms > UINT32_MAX) if (restart_ms > UINT32_MAX) {
return log_link_error_errno(link, SYNTHETIC_ERRNO(ERANGE), "restart timeout (%s) too big.", time_string); log_link_error(link, "restart timeout (%s) too big.", time_string);
return -ERANGE;
}
log_link_debug(link, "Setting restart = %s", time_string); log_link_debug(link, "Setting restart = %s", time_string);

View File

@ -64,14 +64,24 @@ static inline int compare_pgscan(OomdCGroupContext * const *c1, OomdCGroupContex
assert(c1); assert(c1);
assert(c2); assert(c2);
return CMP((*c2)->pgscan, (*c1)->pgscan); if ((*c1)->pgscan > (*c2)->pgscan)
return -1;
else if ((*c1)->pgscan < (*c2)->pgscan)
return 1;
else
return 0;
} }
static inline int compare_swap_usage(OomdCGroupContext * const *c1, OomdCGroupContext * const *c2) { static inline int compare_swap_usage(OomdCGroupContext * const *c1, OomdCGroupContext * const *c2) {
assert(c1); assert(c1);
assert(c2); assert(c2);
return CMP((*c2)->swap_usage, (*c1)->swap_usage); if ((*c1)->swap_usage > (*c2)->swap_usage)
return -1;
else if ((*c1)->swap_usage < (*c2)->swap_usage)
return 1;
else
return 0;
} }
/* Get an array of OomdCGroupContexts from `h`, qsorted from largest to smallest values according to `compare_func`. /* Get an array of OomdCGroupContexts from `h`, qsorted from largest to smallest values according to `compare_func`.

View File

@ -23,7 +23,7 @@ static int fork_and_sleep(unsigned sleep_min) {
if (pid == 0) { if (pid == 0) {
timeout = sleep_min * USEC_PER_MINUTE; timeout = sleep_min * USEC_PER_MINUTE;
ts = now(CLOCK_MONOTONIC); ts = now(CLOCK_MONOTONIC);
for (;;) { while (true) {
n = now(CLOCK_MONOTONIC); n = now(CLOCK_MONOTONIC);
if (ts + timeout < n) { if (ts + timeout < n) {
log_error("Child timed out waiting to be killed"); log_error("Child timed out waiting to be killed");

View File

@ -5,7 +5,6 @@
#include <stdio.h> #include <stdio.h>
#include <unistd.h> #include <unistd.h>
#include "alloc-util.h"
#include "errno-util.h" #include "errno-util.h"
#include "macro.h" #include "macro.h"
@ -94,6 +93,7 @@ static inline char* umount_and_rmdir_and_free(char *p) {
PROTECT_ERRNO; PROTECT_ERRNO;
(void) umount_recursive(p, 0); (void) umount_recursive(p, 0);
(void) rmdir(p); (void) rmdir(p);
return mfree(p); free(p);
return NULL;
} }
DEFINE_TRIVIAL_CLEANUP_FUNC(char*, umount_and_rmdir_and_free); DEFINE_TRIVIAL_CLEANUP_FUNC(char*, umount_and_rmdir_and_free);