mirror of
https://github.com/morgan9e/systemd
synced 2026-04-14 08:25:20 +09:00
various: use _NEG_ macros to reduce indentation
No functional change intended.
This commit is contained in:
@@ -936,11 +936,10 @@ int path_is_root_at(int dir_fd, const char *path) {
|
||||
int mntid;
|
||||
|
||||
r = path_get_mnt_id_at_fallback(dir_fd, "", &mntid);
|
||||
if (r < 0) {
|
||||
if (ERRNO_IS_NOT_SUPPORTED(r))
|
||||
return true; /* skip the mount ID check */
|
||||
if (ERRNO_IS_NEG_NOT_SUPPORTED(r))
|
||||
return true; /* skip the mount ID check */
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
assert(mntid >= 0);
|
||||
|
||||
st.nsx.stx_mnt_id = mntid;
|
||||
@@ -951,11 +950,10 @@ int path_is_root_at(int dir_fd, const char *path) {
|
||||
int mntid;
|
||||
|
||||
r = path_get_mnt_id_at_fallback(dir_fd, "..", &mntid);
|
||||
if (r < 0) {
|
||||
if (ERRNO_IS_NOT_SUPPORTED(r))
|
||||
return true; /* skip the mount ID check */
|
||||
if (ERRNO_IS_NEG_NOT_SUPPORTED(r))
|
||||
return true; /* skip the mount ID check */
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
assert(mntid >= 0);
|
||||
|
||||
pst.nsx.stx_mnt_id = mntid;
|
||||
|
||||
@@ -94,14 +94,12 @@ static int extension_release_strict_xattr_value(int extension_release_fd, const
|
||||
/* No xattr or cannot parse it? Then skip this. */
|
||||
_cleanup_free_ char *extension_release_xattr = NULL;
|
||||
r = fgetxattr_malloc(extension_release_fd, "user.extension-release.strict", &extension_release_xattr);
|
||||
if (r < 0) {
|
||||
if (!ERRNO_IS_XATTR_ABSENT(r))
|
||||
return log_debug_errno(r,
|
||||
"%s/%s: Failed to read 'user.extension-release.strict' extended attribute from file, ignoring: %m",
|
||||
extension_release_dir_path, filename);
|
||||
|
||||
return log_debug_errno(r, "%s/%s does not have user.extension-release.strict xattr, ignoring.", extension_release_dir_path, filename);
|
||||
}
|
||||
if (ERRNO_IS_NEG_XATTR_ABSENT(r))
|
||||
return log_debug_errno(r, "%s/%s does not have user.extension-release.strict xattr, ignoring.",
|
||||
extension_release_dir_path, filename);
|
||||
if (r < 0)
|
||||
return log_debug_errno(r, "%s/%s: Failed to read 'user.extension-release.strict' extended attribute from file, ignoring: %m",
|
||||
extension_release_dir_path, filename);
|
||||
|
||||
/* Explicitly set to request strict matching? Skip it. */
|
||||
r = parse_boolean(extension_release_xattr);
|
||||
|
||||
@@ -118,12 +118,10 @@ int is_pressure_supported(void) {
|
||||
|
||||
FOREACH_STRING(p, "/proc/pressure/cpu", "/proc/pressure/io", "/proc/pressure/memory") {
|
||||
r = read_virtual_file(p, 0, NULL, NULL);
|
||||
if (r < 0) {
|
||||
if (r == -ENOENT || ERRNO_IS_NOT_SUPPORTED(r))
|
||||
return (cached = false);
|
||||
|
||||
if (r == -ENOENT || ERRNO_IS_NEG_NOT_SUPPORTED(r))
|
||||
return (cached = false);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
}
|
||||
|
||||
return (cached = true);
|
||||
|
||||
@@ -43,12 +43,11 @@ static int boot_config_load_and_select(
|
||||
_cleanup_strv_free_ char **efi_entries = NULL;
|
||||
|
||||
r = efi_loader_get_entries(&efi_entries);
|
||||
if (r < 0) {
|
||||
if (r == -ENOENT || ERRNO_IS_NOT_SUPPORTED(r))
|
||||
log_debug_errno(r, "Boot loader reported no entries.");
|
||||
else
|
||||
log_warning_errno(r, "Failed to determine entries reported by boot loader, ignoring: %m");
|
||||
} else
|
||||
if (r == -ENOENT || ERRNO_IS_NEG_NOT_SUPPORTED(r))
|
||||
log_debug_errno(r, "Boot loader reported no entries.");
|
||||
else if (r < 0)
|
||||
log_warning_errno(r, "Failed to determine entries reported by boot loader, ignoring: %m");
|
||||
else
|
||||
(void) boot_config_augment_from_loader(config, efi_entries, /* only_auto= */ false);
|
||||
}
|
||||
|
||||
|
||||
@@ -2191,9 +2191,9 @@ static int method_enqueue_marked_jobs(sd_bus_message *message, void *userdata, s
|
||||
r = bus_unit_queue_job_one(message, u,
|
||||
JOB_TRY_RESTART, JOB_FAIL, flags,
|
||||
reply, error);
|
||||
if (ERRNO_IS_NEG_RESOURCE(r))
|
||||
return r;
|
||||
if (r < 0) {
|
||||
if (ERRNO_IS_RESOURCE(r))
|
||||
return r;
|
||||
if (ret >= 0)
|
||||
ret = r;
|
||||
sd_bus_error_free(error);
|
||||
|
||||
@@ -5112,27 +5112,24 @@ static int exec_child(
|
||||
}
|
||||
|
||||
if (context->oom_score_adjust_set) {
|
||||
/* When we can't make this change due to EPERM, then let's silently skip over it. User namespaces
|
||||
* prohibit write access to this file, and we shouldn't trip up over that. */
|
||||
/* When we can't make this change due to EPERM, then let's silently skip over it. User
|
||||
* namespaces prohibit write access to this file, and we shouldn't trip up over that. */
|
||||
r = set_oom_score_adjust(context->oom_score_adjust);
|
||||
if (r < 0) {
|
||||
if (ERRNO_IS_PRIVILEGE(r))
|
||||
log_unit_debug_errno(unit, r, "Failed to adjust OOM setting, assuming containerized execution, ignoring: %m");
|
||||
else {
|
||||
*exit_status = EXIT_OOM_ADJUST;
|
||||
return log_unit_error_errno(unit, r, "Failed to adjust OOM setting: %m");
|
||||
}
|
||||
if (ERRNO_IS_NEG_PRIVILEGE(r))
|
||||
log_unit_debug_errno(unit, r,
|
||||
"Failed to adjust OOM setting, assuming containerized execution, ignoring: %m");
|
||||
else if (r < 0) {
|
||||
*exit_status = EXIT_OOM_ADJUST;
|
||||
return log_unit_error_errno(unit, r, "Failed to adjust OOM setting: %m");
|
||||
}
|
||||
}
|
||||
|
||||
if (context->coredump_filter_set) {
|
||||
r = set_coredump_filter(context->coredump_filter);
|
||||
if (r < 0) {
|
||||
if (ERRNO_IS_PRIVILEGE(r))
|
||||
log_unit_debug_errno(unit, r, "Failed to adjust coredump_filter, ignoring: %m");
|
||||
else
|
||||
return log_unit_error_errno(unit, r, "Failed to adjust coredump_filter: %m");
|
||||
}
|
||||
if (ERRNO_IS_NEG_PRIVILEGE(r))
|
||||
log_unit_debug_errno(unit, r, "Failed to adjust coredump_filter, ignoring: %m");
|
||||
else if (r < 0)
|
||||
return log_unit_error_errno(unit, r, "Failed to adjust coredump_filter: %m");
|
||||
}
|
||||
|
||||
if (context->nice_set) {
|
||||
@@ -5180,13 +5177,11 @@ static int exec_child(
|
||||
|
||||
if (mpol_is_valid(numa_policy_get_type(&context->numa_policy))) {
|
||||
r = apply_numa_policy(&context->numa_policy);
|
||||
if (r < 0) {
|
||||
if (ERRNO_IS_NOT_SUPPORTED(r))
|
||||
log_unit_debug_errno(unit, r, "NUMA support not available, ignoring.");
|
||||
else {
|
||||
*exit_status = EXIT_NUMA_POLICY;
|
||||
return log_unit_error_errno(unit, r, "Failed to set NUMA memory policy: %m");
|
||||
}
|
||||
if (ERRNO_IS_NEG_NOT_SUPPORTED(r))
|
||||
log_unit_debug_errno(unit, r, "NUMA support not available, ignoring.");
|
||||
else if (r < 0) {
|
||||
*exit_status = EXIT_NUMA_POLICY;
|
||||
return log_unit_error_errno(unit, r, "Failed to set NUMA memory policy: %m");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5468,14 +5463,12 @@ static int exec_child(
|
||||
* namespace without the ability to set up "lo". Hence gracefully skip things then. */
|
||||
if (ns_type_supported(NAMESPACE_NET) && have_effective_cap(CAP_NET_ADMIN) > 0) {
|
||||
r = setup_shareable_ns(runtime->shared->netns_storage_socket, CLONE_NEWNET);
|
||||
if (r < 0) {
|
||||
if (ERRNO_IS_PRIVILEGE(r))
|
||||
log_unit_notice_errno(unit, r,
|
||||
"PrivateNetwork=yes is configured, but network namespace setup not permitted, proceeding without: %m");
|
||||
else {
|
||||
*exit_status = EXIT_NETWORK;
|
||||
return log_unit_error_errno(unit, r, "Failed to set up network namespacing: %m");
|
||||
}
|
||||
if (ERRNO_IS_NEG_PRIVILEGE(r))
|
||||
log_unit_notice_errno(unit, r,
|
||||
"PrivateNetwork=yes is configured, but network namespace setup not permitted, proceeding without: %m");
|
||||
else if (r < 0) {
|
||||
*exit_status = EXIT_NETWORK;
|
||||
return log_unit_error_errno(unit, r, "Failed to set up network namespacing: %m");
|
||||
}
|
||||
} else if (context->network_namespace_path) {
|
||||
*exit_status = EXIT_NETWORK;
|
||||
|
||||
@@ -159,13 +159,11 @@ int enroll_password(
|
||||
}
|
||||
|
||||
r = check_password_quality(new_password, /* old */ NULL, /* user */ NULL, &error);
|
||||
if (r < 0) {
|
||||
if (ERRNO_IS_NOT_SUPPORTED(r))
|
||||
log_warning("Password quality check is not supported, proceeding anyway.");
|
||||
else
|
||||
return log_error_errno(r, "Failed to check password quality: %m");
|
||||
}
|
||||
if (r == 0)
|
||||
if (ERRNO_IS_NEG_NOT_SUPPORTED(r))
|
||||
log_warning("Password quality check is not supported, proceeding anyway.");
|
||||
else if (r < 0)
|
||||
return log_error_errno(r, "Failed to check password quality: %m");
|
||||
else if (r == 0)
|
||||
log_warning("Specified password does not pass quality checks (%s), proceeding anyway.", error);
|
||||
|
||||
keyslot = crypt_keyslot_add_by_volume_key(
|
||||
|
||||
@@ -1728,11 +1728,12 @@ static int attach_luks_or_plain_or_bitlk_by_tpm2(
|
||||
found_some
|
||||
? "No TPM2 metadata matching the current system state found in LUKS2 header, falling back to traditional unlocking."
|
||||
: "No TPM2 metadata enrolled in LUKS2 header, falling back to traditional unlocking.");
|
||||
if (r < 0) {
|
||||
if (ERRNO_IS_NOT_SUPPORTED(r)) /* TPM2 support not compiled in? */
|
||||
return log_debug_errno(SYNTHETIC_ERRNO(EAGAIN), "TPM2 support not available, falling back to traditional unlocking.");
|
||||
if (ERRNO_IS_NEG_NOT_SUPPORTED(r))
|
||||
/* TPM2 support not compiled in? */
|
||||
return log_debug_errno(SYNTHETIC_ERRNO(EAGAIN),
|
||||
"TPM2 support not available, falling back to traditional unlocking.");
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
|
||||
found_some = true;
|
||||
|
||||
|
||||
@@ -792,13 +792,11 @@ static int prompt_root_password(int rfd) {
|
||||
}
|
||||
|
||||
r = check_password_quality(*a, /* old */ NULL, "root", &error);
|
||||
if (r < 0) {
|
||||
if (ERRNO_IS_NOT_SUPPORTED(r))
|
||||
log_warning("Password quality check is not supported, proceeding anyway.");
|
||||
else
|
||||
return log_error_errno(r, "Failed to check password quality: %m");
|
||||
}
|
||||
if (r == 0)
|
||||
if (ERRNO_IS_NEG_NOT_SUPPORTED(r))
|
||||
log_warning("Password quality check is not supported, proceeding anyway.");
|
||||
else if (r < 0)
|
||||
return log_error_errno(r, "Failed to check password quality: %m");
|
||||
else if (r == 0)
|
||||
log_warning("Password is weak, accepting anyway: %s", error);
|
||||
|
||||
r = ask_password_tty(-1, msg2, NULL, 0, 0, NULL, &b);
|
||||
|
||||
@@ -285,11 +285,10 @@ int home_resize_directory(
|
||||
return r;
|
||||
|
||||
r = home_update_quota_auto(h, NULL);
|
||||
if (r < 0) {
|
||||
if (ERRNO_IS_NOT_SUPPORTED(r))
|
||||
return -ESOCKTNOSUPPORT; /* make recognizable */
|
||||
if (ERRNO_IS_NEG_NOT_SUPPORTED(r))
|
||||
return -ESOCKTNOSUPPORT; /* make recognizable */
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
|
||||
r = home_store_embedded_identity(new_home, setup->root_fd, h->uid, embedded_home);
|
||||
if (r < 0)
|
||||
|
||||
@@ -498,11 +498,10 @@ static int acquire_open_luks_device(
|
||||
return r;
|
||||
|
||||
r = sym_crypt_init_by_name(&cd, setup->dm_name);
|
||||
if (r < 0) {
|
||||
if ((ERRNO_IS_DEVICE_ABSENT(r) || r == -EINVAL) && graceful)
|
||||
return 0;
|
||||
if ((ERRNO_IS_NEG_DEVICE_ABSENT(r) || r == -EINVAL) && graceful)
|
||||
return 0;
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to initialize cryptsetup context for %s: %m", setup->dm_name);
|
||||
}
|
||||
|
||||
cryptsetup_enable_logging(cd);
|
||||
|
||||
@@ -1639,12 +1638,11 @@ int home_deactivate_luks(UserRecord *h, HomeSetup *setup) {
|
||||
cryptsetup_enable_logging(setup->crypt_device);
|
||||
|
||||
r = sym_crypt_deactivate_by_name(setup->crypt_device, setup->dm_name, 0);
|
||||
if (r < 0) {
|
||||
if (ERRNO_IS_DEVICE_ABSENT(r) || r == -EINVAL)
|
||||
log_debug_errno(r, "LUKS device %s is already detached.", setup->dm_node);
|
||||
else
|
||||
return log_info_errno(r, "LUKS device %s couldn't be deactivated: %m", setup->dm_node);
|
||||
} else {
|
||||
if (ERRNO_IS_NEG_DEVICE_ABSENT(r) || r == -EINVAL)
|
||||
log_debug_errno(r, "LUKS device %s is already detached.", setup->dm_node);
|
||||
else if (r < 0)
|
||||
return log_info_errno(r, "LUKS device %s couldn't be deactivated: %m", setup->dm_node);
|
||||
else {
|
||||
log_info("LUKS device detaching completed.");
|
||||
we_detached = true;
|
||||
}
|
||||
@@ -2026,11 +2024,10 @@ static int wait_for_devlink(const char *path) {
|
||||
return log_error_errno(SYNTHETIC_ERRNO(ETIMEDOUT), "Device link %s still hasn't shown up, giving up.", path);
|
||||
|
||||
r = fd_wait_for_event(inotify_fd, POLLIN, until - w);
|
||||
if (r < 0) {
|
||||
if (ERRNO_IS_TRANSIENT(r))
|
||||
continue;
|
||||
if (ERRNO_IS_NEG_TRANSIENT(r))
|
||||
continue;
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to watch inotify: %m");
|
||||
}
|
||||
|
||||
(void) flush_fd(inotify_fd);
|
||||
}
|
||||
|
||||
@@ -55,32 +55,26 @@ int home_update_quota_classic(UserRecord *h, const char *path) {
|
||||
return log_error_errno(SYNTHETIC_ERRNO(ENODEV), "File system %s not backed by a block device.", path);
|
||||
|
||||
r = quotactl_devnum(QCMD_FIXED(Q_GETQUOTA, USRQUOTA), devno, h->uid, &req);
|
||||
if (r < 0) {
|
||||
if (ERRNO_IS_NOT_SUPPORTED(r))
|
||||
return log_error_errno(r, "No UID quota support on %s.", path);
|
||||
|
||||
if (r != -ESRCH)
|
||||
return log_error_errno(r, "Failed to query disk quota for UID " UID_FMT ": %m", h->uid);
|
||||
|
||||
if (r == -ESRCH)
|
||||
zero(req);
|
||||
} else {
|
||||
else if (ERRNO_IS_NEG_NOT_SUPPORTED(r))
|
||||
return log_error_errno(r, "No UID quota support on %s.", path);
|
||||
else if (r < 0)
|
||||
return log_error_errno(r, "Failed to query disk quota for UID " UID_FMT ": %m", h->uid);
|
||||
else if (FLAGS_SET(req.dqb_valid, QIF_BLIMITS) && h->disk_size / QIF_DQBLKSIZE == req.dqb_bhardlimit) {
|
||||
/* Shortcut things if everything is set up properly already */
|
||||
if (FLAGS_SET(req.dqb_valid, QIF_BLIMITS) && h->disk_size / QIF_DQBLKSIZE == req.dqb_bhardlimit) {
|
||||
log_info("Configured quota already matches the intended setting, not updating quota.");
|
||||
return 0;
|
||||
}
|
||||
log_info("Configured quota already matches the intended setting, not updating quota.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
req.dqb_valid = QIF_BLIMITS;
|
||||
req.dqb_bsoftlimit = req.dqb_bhardlimit = h->disk_size / QIF_DQBLKSIZE;
|
||||
|
||||
r = quotactl_devnum(QCMD_FIXED(Q_SETQUOTA, USRQUOTA), devno, h->uid, &req);
|
||||
if (r < 0) {
|
||||
if (r == -ESRCH)
|
||||
return log_error_errno(SYNTHETIC_ERRNO(ENOTTY), "UID quota not available on %s.", path);
|
||||
|
||||
if (r == -ESRCH)
|
||||
return log_error_errno(SYNTHETIC_ERRNO(ENOTTY), "UID quota not available on %s.", path);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to set disk quota for UID " UID_FMT ": %m", h->uid);
|
||||
}
|
||||
|
||||
log_info("Updated per-UID quota.");
|
||||
|
||||
|
||||
@@ -57,13 +57,11 @@ int client_context_read_log_filter_patterns(ClientContext *c, const char *cgroup
|
||||
return log_debug_errno(r, "Failed to get the unit's cgroup path for %s: %m", cgroup);
|
||||
|
||||
r = cg_get_xattr_malloc(SYSTEMD_CGROUP_CONTROLLER, unit_cgroup, "user.journald_log_filter_patterns", &xattr);
|
||||
if (r < 0) {
|
||||
if (!ERRNO_IS_XATTR_ABSENT(r))
|
||||
return log_debug_errno(r, "Failed to get user.journald_log_filter_patterns xattr for %s: %m", unit_cgroup);
|
||||
|
||||
if (ERRNO_IS_NEG_XATTR_ABSENT(r)) {
|
||||
client_set_filtering_patterns(c, NULL, NULL);
|
||||
return 0;
|
||||
}
|
||||
} else if (r < 0)
|
||||
return log_debug_errno(r, "Failed to get user.journald_log_filter_patterns xattr for %s: %m", unit_cgroup);
|
||||
|
||||
xattr_end = xattr + r;
|
||||
|
||||
@@ -79,7 +77,8 @@ int client_context_read_log_filter_patterns(ClientContext *c, const char *cgroup
|
||||
* before writing to xattr. */
|
||||
deny_list_xattr = memchr(xattr, (char)0xff, r);
|
||||
if (!deny_list_xattr)
|
||||
return log_debug_errno(SYNTHETIC_ERRNO(EBADMSG), "Missing delimiter in cgroup user.journald_log_filter_patterns attribute: %m");
|
||||
return log_debug_errno(SYNTHETIC_ERRNO(EBADMSG),
|
||||
"Missing delimiter in cgroup user.journald_log_filter_patterns attribute: %m");
|
||||
|
||||
r = client_parse_log_filter_nulstr(xattr, deny_list_xattr - xattr, &allow_list);
|
||||
if (r < 0)
|
||||
|
||||
@@ -214,11 +214,10 @@ int link_rfkilled(Link *link) {
|
||||
assert(link);
|
||||
|
||||
r = link_get_wiphy(link, &w);
|
||||
if (r < 0) {
|
||||
if (ERRNO_IS_NOT_SUPPORTED(r) || ERRNO_IS_DEVICE_ABSENT(r))
|
||||
return false; /* Typically, non-wifi interface or running in container */
|
||||
if (ERRNO_IS_NEG_NOT_SUPPORTED(r) || ERRNO_IS_NEG_DEVICE_ABSENT(r))
|
||||
return false; /* Typically, non-wifi interface or running in container */
|
||||
if (r < 0)
|
||||
return log_link_debug_errno(link, r, "Could not get phy: %m");
|
||||
}
|
||||
|
||||
return wiphy_rfkilled(w);
|
||||
}
|
||||
@@ -339,20 +338,16 @@ static int wiphy_update(Wiphy *w) {
|
||||
assert(w);
|
||||
|
||||
r = wiphy_update_device(w);
|
||||
if (r < 0) {
|
||||
if (ERRNO_IS_DEVICE_ABSENT(r))
|
||||
log_wiphy_debug_errno(w, r, "Failed to update wiphy device, ignoring: %m");
|
||||
else
|
||||
return log_wiphy_warning_errno(w, r, "Failed to update wiphy device: %m");
|
||||
}
|
||||
if (ERRNO_IS_NEG_DEVICE_ABSENT(r))
|
||||
log_wiphy_debug_errno(w, r, "Failed to update wiphy device, ignoring: %m");
|
||||
else if (r < 0)
|
||||
return log_wiphy_warning_errno(w, r, "Failed to update wiphy device: %m");
|
||||
|
||||
r = wiphy_update_rfkill(w);
|
||||
if (r < 0) {
|
||||
if (ERRNO_IS_DEVICE_ABSENT(r))
|
||||
log_wiphy_debug_errno(w, r, "Failed to update rfkill device, ignoring: %m");
|
||||
else
|
||||
return log_wiphy_warning_errno(w, r, "Failed to update rfkill device: %m");
|
||||
}
|
||||
if (ERRNO_IS_NEG_DEVICE_ABSENT(r))
|
||||
log_wiphy_debug_errno(w, r, "Failed to update rfkill device, ignoring: %m");
|
||||
else if (r < 0)
|
||||
return log_wiphy_warning_errno(w, r, "Failed to update rfkill device: %m");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -2839,16 +2839,15 @@ static int setup_machine_id(const char *directory) {
|
||||
* container behaves nicely). */
|
||||
|
||||
r = id128_get_machine(directory, &arg_uuid);
|
||||
if (r < 0) {
|
||||
if (!ERRNO_IS_MACHINE_ID_UNSET(r)) /* If the file is missing, empty, or uninitialized, we don't mind */
|
||||
return log_error_errno(r, "Failed to read machine ID from container image: %m");
|
||||
|
||||
if (ERRNO_IS_NEG_MACHINE_ID_UNSET(r)) {
|
||||
/* If the file is missing, empty, or uninitialized, we don't mind */
|
||||
if (sd_id128_is_null(arg_uuid)) {
|
||||
r = sd_id128_randomize(&arg_uuid);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to acquire randomized machine UUID: %m");
|
||||
}
|
||||
}
|
||||
} else if (r < 0)
|
||||
return log_error_errno(r, "Failed to read machine ID from container image: %m");
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -3826,20 +3825,19 @@ static int outer_child(
|
||||
arg_uid_shift != 0) {
|
||||
|
||||
r = remount_idmap(directory, arg_uid_shift, arg_uid_range, UID_INVALID, REMOUNT_IDMAPPING_HOST_ROOT);
|
||||
if (r < 0) {
|
||||
if (r == -EINVAL || ERRNO_IS_NOT_SUPPORTED(r)) {
|
||||
/* This might fail because the kernel or file system doesn't support idmapping. We
|
||||
* can't really distinguish this nicely, nor do we have any guarantees about the
|
||||
* error codes we see, could be EOPNOTSUPP or EINVAL. */
|
||||
if (arg_userns_ownership != USER_NAMESPACE_OWNERSHIP_AUTO)
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EOPNOTSUPP),
|
||||
"ID mapped mounts are apparently not available, sorry.");
|
||||
if (r == -EINVAL || ERRNO_IS_NEG_NOT_SUPPORTED(r)) {
|
||||
/* This might fail because the kernel or file system doesn't support idmapping. We
|
||||
* can't really distinguish this nicely, nor do we have any guarantees about the
|
||||
* error codes we see, could be EOPNOTSUPP or EINVAL. */
|
||||
if (arg_userns_ownership != USER_NAMESPACE_OWNERSHIP_AUTO)
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EOPNOTSUPP),
|
||||
"ID mapped mounts are apparently not available, sorry.");
|
||||
|
||||
log_debug("ID mapped mounts are apparently not available on this kernel or for the selected file system, reverting to recursive chown()ing.");
|
||||
arg_userns_ownership = USER_NAMESPACE_OWNERSHIP_CHOWN;
|
||||
} else
|
||||
return log_error_errno(r, "Failed to set up ID mapped mounts: %m");
|
||||
} else {
|
||||
log_debug("ID mapped mounts are apparently not available on this kernel or for the selected file system, reverting to recursive chown()ing.");
|
||||
arg_userns_ownership = USER_NAMESPACE_OWNERSHIP_CHOWN;
|
||||
} else if (r < 0)
|
||||
return log_error_errno(r, "Failed to set up ID mapped mounts: %m");
|
||||
else {
|
||||
log_debug("ID mapped mounts available, making use of them.");
|
||||
idmap = true;
|
||||
}
|
||||
@@ -4264,15 +4262,13 @@ static int nspawn_dispatch_notify_fd(sd_event_source *source, int fd, uint32_t r
|
||||
}
|
||||
|
||||
n = recvmsg_safe(fd, &msghdr, MSG_DONTWAIT|MSG_CMSG_CLOEXEC);
|
||||
if (n < 0) {
|
||||
if (ERRNO_IS_TRANSIENT(n))
|
||||
return 0;
|
||||
if (n == -EXFULL) {
|
||||
log_warning("Got message with truncated control data (too many fds sent?), ignoring.");
|
||||
return 0;
|
||||
}
|
||||
if (ERRNO_IS_NEG_TRANSIENT(n))
|
||||
return 0;
|
||||
else if (n == -EXFULL) {
|
||||
log_warning("Got message with truncated control data (too many fds sent?), ignoring.");
|
||||
return 0;
|
||||
} else if (n < 0)
|
||||
return log_warning_errno(n, "Couldn't read notification socket: %m");
|
||||
}
|
||||
|
||||
cmsg_close_all(&msghdr);
|
||||
|
||||
@@ -5414,13 +5410,11 @@ static int cant_be_in_netns(void) {
|
||||
return log_error_errno(errno, "Failed to allocate udev control socket: %m");
|
||||
|
||||
r = connect_unix_path(fd, AT_FDCWD, "/run/udev/control");
|
||||
if (r < 0) {
|
||||
if (r == -ENOENT || ERRNO_IS_DISCONNECT(r))
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EOPNOTSUPP),
|
||||
"Sorry, but --image= requires access to the host's /run/ hierarchy, since we need access to udev.");
|
||||
|
||||
if (r == -ENOENT || ERRNO_IS_NEG_DISCONNECT(r))
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EOPNOTSUPP),
|
||||
"Sorry, but --image= requires access to the host's /run/ hierarchy, since we need access to udev.");
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to connect socket to udev control socket: %m");
|
||||
}
|
||||
|
||||
r = getpeercred(fd, &ucred);
|
||||
if (r < 0)
|
||||
|
||||
@@ -796,13 +796,10 @@ int manager_recv(Manager *m, int fd, DnsProtocol protocol, DnsPacket **ret) {
|
||||
iov = IOVEC_MAKE(DNS_PACKET_DATA(p), p->allocated);
|
||||
|
||||
l = recvmsg_safe(fd, &mh, 0);
|
||||
if (l < 0) {
|
||||
if (ERRNO_IS_TRANSIENT(l))
|
||||
return 0;
|
||||
return l;
|
||||
}
|
||||
if (l == 0)
|
||||
if (ERRNO_IS_NEG_TRANSIENT(l))
|
||||
return 0;
|
||||
if (l <= 0)
|
||||
return l;
|
||||
|
||||
assert(!(mh.msg_flags & MSG_TRUNC));
|
||||
|
||||
@@ -914,11 +911,10 @@ static int sendmsg_loop(int fd, struct msghdr *mh, int flags) {
|
||||
return -errno;
|
||||
|
||||
r = fd_wait_for_event(fd, POLLOUT, LESS_BY(end, now(CLOCK_MONOTONIC)));
|
||||
if (r < 0) {
|
||||
if (ERRNO_IS_TRANSIENT(r))
|
||||
continue;
|
||||
if (ERRNO_IS_NEG_TRANSIENT(r))
|
||||
continue;
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
if (r == 0)
|
||||
return -ETIMEDOUT;
|
||||
}
|
||||
@@ -942,11 +938,10 @@ static int write_loop(int fd, void *message, size_t length) {
|
||||
return -errno;
|
||||
|
||||
r = fd_wait_for_event(fd, POLLOUT, LESS_BY(end, now(CLOCK_MONOTONIC)));
|
||||
if (r < 0) {
|
||||
if (ERRNO_IS_TRANSIENT(r))
|
||||
continue;
|
||||
if (ERRNO_IS_NEG_TRANSIENT(r))
|
||||
continue;
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
if (r == 0)
|
||||
return -ETIMEDOUT;
|
||||
}
|
||||
|
||||
@@ -158,16 +158,14 @@ static int ask_password_keyring(const char *keyname, AskPasswordFlags flags, cha
|
||||
return -EUNATCH;
|
||||
|
||||
r = lookup_key(keyname, &serial);
|
||||
if (r < 0) {
|
||||
/* when retrieving the distinction between "kernel or container manager don't support
|
||||
* or allow this" and "no matching key known" doesn't matter. Note that we propagate
|
||||
* EACCESS here (even if EPERM not) since that is used if the keyring is available but
|
||||
* we lack access to the key. */
|
||||
if (ERRNO_IS_NOT_SUPPORTED(r) || r == -EPERM)
|
||||
return -ENOKEY;
|
||||
|
||||
if (ERRNO_IS_NEG_NOT_SUPPORTED(r) || r == -EPERM)
|
||||
/* When retrieving, the distinction between "kernel or container manager don't support or
|
||||
* allow this" and "no matching key known" doesn't matter. Note that we propagate EACCESS
|
||||
* here (even if EPERM not) since that is used if the keyring is available, but we lack
|
||||
* access to the key. */
|
||||
return -ENOKEY;
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
|
||||
return retrieve_key(serial, ret);
|
||||
}
|
||||
@@ -867,14 +865,12 @@ int ask_password_agent(
|
||||
};
|
||||
|
||||
n = recvmsg_safe(socket_fd, &msghdr, 0);
|
||||
if (n < 0) {
|
||||
if (ERRNO_IS_TRANSIENT(n))
|
||||
continue;
|
||||
if (n == -EXFULL) {
|
||||
log_debug("Got message with truncated control data, ignoring.");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ERRNO_IS_NEG_TRANSIENT(n))
|
||||
continue;
|
||||
else if (n == -EXFULL) {
|
||||
log_debug("Got message with truncated control data, ignoring.");
|
||||
continue;
|
||||
} else if (n < 0) {
|
||||
r = (int) n;
|
||||
goto finish;
|
||||
}
|
||||
|
||||
@@ -844,14 +844,11 @@ static int fd_copy_fifo(
|
||||
r = RET_NERRNO(mkfifoat(dt, to, st->st_mode & 07777));
|
||||
if (copy_flags & COPY_MAC_CREATE)
|
||||
mac_selinux_create_file_clear();
|
||||
if (r < 0) {
|
||||
if (FLAGS_SET(copy_flags, COPY_GRACEFUL_WARN) && (ERRNO_IS_PRIVILEGE(r) || ERRNO_IS_NOT_SUPPORTED(r))) {
|
||||
log_notice_errno(r, "Failed to copy fifo '%s', ignoring: %m", from);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (FLAGS_SET(copy_flags, COPY_GRACEFUL_WARN) && (ERRNO_IS_NEG_PRIVILEGE(r) || ERRNO_IS_NEG_NOT_SUPPORTED(r))) {
|
||||
log_notice_errno(r, "Failed to copy fifo '%s', ignoring: %m", from);
|
||||
return 0;
|
||||
} else if (r < 0)
|
||||
return r;
|
||||
}
|
||||
|
||||
if (fchownat(dt, to,
|
||||
uid_is_valid(override_uid) ? override_uid : st->st_uid,
|
||||
@@ -898,14 +895,11 @@ static int fd_copy_node(
|
||||
r = RET_NERRNO(mknodat(dt, to, st->st_mode, st->st_rdev));
|
||||
if (copy_flags & COPY_MAC_CREATE)
|
||||
mac_selinux_create_file_clear();
|
||||
if (r < 0) {
|
||||
if (FLAGS_SET(copy_flags, COPY_GRACEFUL_WARN) && (ERRNO_IS_PRIVILEGE(r) || ERRNO_IS_NOT_SUPPORTED(r))) {
|
||||
log_notice_errno(r, "Failed to copy node '%s', ignoring: %m", from);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (FLAGS_SET(copy_flags, COPY_GRACEFUL_WARN) && (ERRNO_IS_NEG_PRIVILEGE(r) || ERRNO_IS_NEG_NOT_SUPPORTED(r))) {
|
||||
log_notice_errno(r, "Failed to copy node '%s', ignoring: %m", from);
|
||||
return 0;
|
||||
} else if (r < 0)
|
||||
return r;
|
||||
}
|
||||
|
||||
if (fchownat(dt, to,
|
||||
uid_is_valid(override_uid) ? override_uid : st->st_uid,
|
||||
|
||||
@@ -82,14 +82,12 @@ int get_keymaps(char ***ret) {
|
||||
&(struct recurse_dir_userdata) {
|
||||
.keymaps = keymaps,
|
||||
});
|
||||
if (r < 0) {
|
||||
if (r == -ENOENT)
|
||||
continue;
|
||||
if (ERRNO_IS_RESOURCE(r))
|
||||
return log_warning_errno(r, "Failed to read keymap list from %s: %m", dir);
|
||||
|
||||
if (r == -ENOENT)
|
||||
continue;
|
||||
if (ERRNO_IS_NEG_RESOURCE(r))
|
||||
return log_warning_errno(r, "Failed to read keymap list from %s: %m", dir);
|
||||
if (r < 0)
|
||||
log_debug_errno(r, "Failed to read keymap list from %s, ignoring: %m", dir);
|
||||
}
|
||||
}
|
||||
|
||||
_cleanup_strv_free_ char **l = set_get_strv(keymaps);
|
||||
|
||||
@@ -57,14 +57,13 @@ static int load_user(
|
||||
}
|
||||
|
||||
r = json_parse_file(NULL, j, JSON_PARSE_SENSITIVE, &privileged_v, NULL, NULL);
|
||||
if (r < 0) {
|
||||
if (ERRNO_IS_PRIVILEGE(r))
|
||||
have_privileged = false;
|
||||
else if (r == -ENOENT)
|
||||
have_privileged = true; /* if the privileged file doesn't exist, we are complete */
|
||||
else
|
||||
return r;
|
||||
} else {
|
||||
if (ERRNO_IS_NEG_PRIVILEGE(r))
|
||||
have_privileged = false;
|
||||
else if (r == -ENOENT)
|
||||
have_privileged = true; /* if the privileged file doesn't exist, we are complete */
|
||||
else if (r < 0)
|
||||
return r;
|
||||
else {
|
||||
r = json_variant_merge(&v, privileged_v);
|
||||
if (r < 0)
|
||||
return r;
|
||||
@@ -202,14 +201,13 @@ static int load_group(
|
||||
}
|
||||
|
||||
r = json_parse_file(NULL, j, JSON_PARSE_SENSITIVE, &privileged_v, NULL, NULL);
|
||||
if (r < 0) {
|
||||
if (ERRNO_IS_PRIVILEGE(r))
|
||||
have_privileged = false;
|
||||
else if (r == -ENOENT)
|
||||
have_privileged = true; /* if the privileged file doesn't exist, we are complete */
|
||||
else
|
||||
return r;
|
||||
} else {
|
||||
if (ERRNO_IS_NEG_PRIVILEGE(r))
|
||||
have_privileged = false;
|
||||
else if (r == -ENOENT)
|
||||
have_privileged = true; /* if the privileged file doesn't exist, we are complete */
|
||||
else if (r < 0)
|
||||
return r;
|
||||
else {
|
||||
r = json_variant_merge(&v, privileged_v);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
@@ -313,11 +313,10 @@ static int write_to_terminal(const char *tty, const char *message) {
|
||||
return -ETIME;
|
||||
|
||||
k = fd_wait_for_event(fd, POLLOUT, end - t);
|
||||
if (k < 0) {
|
||||
if (ERRNO_IS_TRANSIENT(k))
|
||||
continue;
|
||||
if (ERRNO_IS_NEG_TRANSIENT(k))
|
||||
continue;
|
||||
if (k < 0)
|
||||
return k;
|
||||
}
|
||||
if (k == 0)
|
||||
return -ETIME;
|
||||
|
||||
|
||||
@@ -1368,14 +1368,11 @@ int varlink_flush(Varlink *v) {
|
||||
}
|
||||
|
||||
r = fd_wait_for_event(v->fd, POLLOUT, USEC_INFINITY);
|
||||
if (r < 0) {
|
||||
if (ERRNO_IS_TRANSIENT(r))
|
||||
continue;
|
||||
|
||||
if (ERRNO_IS_NEG_TRANSIENT(r))
|
||||
continue;
|
||||
if (r < 0)
|
||||
return varlink_log_errno(v, r, "Poll failed on fd: %m");
|
||||
}
|
||||
|
||||
assert(r != 0);
|
||||
assert(r > 0);
|
||||
|
||||
handle_revents(v, r);
|
||||
}
|
||||
|
||||
@@ -195,13 +195,11 @@ static int run(int argc, char *argv[]) {
|
||||
continue;
|
||||
|
||||
r = sd_bus_process(b, &m);
|
||||
if (r < 0) {
|
||||
/* treat 'connection reset by peer' as clean exit condition */
|
||||
if (ERRNO_IS_DISCONNECT(r))
|
||||
return 0;
|
||||
|
||||
if (ERRNO_IS_NEG_DISCONNECT(r))
|
||||
/* Treat 'connection reset by peer' as clean exit condition */
|
||||
return 0;
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to process bus: %m");
|
||||
}
|
||||
|
||||
if (m) {
|
||||
r = sd_bus_send(a, m, NULL);
|
||||
@@ -241,11 +239,8 @@ static int run(int argc, char *argv[]) {
|
||||
};
|
||||
|
||||
r = ppoll_usec(p, ELEMENTSOF(p), t);
|
||||
if (r < 0) {
|
||||
if (ERRNO_IS_TRANSIENT(r)) /* don't be bothered by signals, i.e. EINTR */
|
||||
continue;
|
||||
if (r < 0 && !ERRNO_IS_TRANSIENT(r)) /* don't be bothered by signals, i.e. EINTR */
|
||||
return log_error_errno(r, "ppoll() failed: %m");
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user