1
0
mirror of https://github.com/systemd/systemd synced 2026-03-26 00:34:53 +01:00

Compare commits

..

13 Commits

Author SHA1 Message Date
Yu Watanabe
d065fdd337
bus-wait-for-jobs: fix failed job logging (#40043)
Follow-ups for 0d91a204cb78d692f23e80d3a08f9b81ecad753a.
Fixes #40030.
2025-12-10 19:00:39 +09:00
David Tardon
085c2a2338 manager-serialize: add logging for ENOMEM 2025-12-10 18:59:44 +09:00
David Tardon
94446e4f5a tree-wide: flatten nested error checks 2025-12-10 18:59:44 +09:00
Zbigniew Jędrzejewski-Szmek
13a74f350e
tar-util: allow to build without acl support (#39965)
This adds minimal definitions provided by libacl to make tar-util built
without libacl support.
Fixes the following compile error:
```
../src/shared/tar-util.c:62:9: error: unknown type name 'acl_t'
   62 |         acl_t acl_access, acl_default;
      |         ^~~~~
```

Follow-up for 4ded7f7a434c59534f65a0f9d391c55961eb110d.
Fixes #39928.
Replaces #39954.
2025-12-10 09:42:50 +01:00
Yu Watanabe
fc7aca10c9 bus-wait-for-jobs: assign unique error code from service result 2025-12-10 17:22:35 +09:00
David Santamaría Rogado
a07b184e8c hwdb: sensor: Remove Lenovo IdeaPad D330 accel mount matrix
Reading values from iio-sensor we are getting bad values. This matrix was added because the panel was a vertical one but the normal position is horizontal and the sensor is not bad oriented.

Removing the matrix ensure we have correct orientation values and prevent from misleads where the incorrect values we were getting messed up.

For example mutter actually is setting incorrect screen rotation for devices with panel orientation quirks.

I'm pretty sure that there are more devices where we have incorrectly "corrected" the sensor values when the only problem was the panel orientation.

Signed-off-by: David Santamaría Rogado <howl.nsp@gmail.com>
2025-12-10 14:23:33 +09:00
Lennart Poettering
4362d942c4 hostname: explain a bit why hostnames should be single DNS labels, not fqdns 2025-12-10 14:17:11 +09:00
Yu Watanabe
286527a1c1 bus-wait-for-jobs: do not say "Unexpected job result" when job is simply failed 2025-12-10 04:20:39 +09:00
Yu Watanabe
473f427757 bus-wait-for-jobs: use SYNTHETIC_ERRNO()
Since 0d91a204cb78d692f23e80d3a08f9b81ecad753a, we always logs
something. Hence, we can use SYNTHETIC_ERRNO().
2025-12-10 04:16:25 +09:00
Yu Watanabe
0fe1de0812 bus-wait-for-jobs: fix quiet argument for log_job_error_with_service_result()
The argument 'quiet' is a boolean, not a integrer and not a log level.

Follow-up for 0d91a204cb78d692f23e80d3a08f9b81ecad753a.
Fixes #40030.
2025-12-10 04:16:21 +09:00
Yu Watanabe
cbe34b4e73 tar-util: allow to build without libacl support
Fixes #39928.
Follow-up for 4ded7f7a434c59534f65a0f9d391c55961eb110d.
2025-12-10 00:49:27 +09:00
Yu Watanabe
f75c49916b tar-util: allocate ACL entry only when necessary
Follow-up for 4ded7f7a434c59534f65a0f9d391c55961eb110d.
2025-12-10 00:49:27 +09:00
Yu Watanabe
4976d6e9ac acl-util: define minimal types and constants even when acl support is disabled 2025-12-10 00:48:37 +09:00
18 changed files with 204 additions and 195 deletions

View File

@ -756,10 +756,6 @@ sensor:modalias:acpi:BMA250E*:dmi:bvnLENOVO:*:pvrLenovoMIIX3-1030:*
sensor:modalias:acpi:SMO8500*:dmi:bvnLENOVO:*:pvrLenovoMIIX3-830:*
ACCEL_MOUNT_MATRIX=-1, 0, 0; 0, 1, 0; 0, 0, 1
# IdeaPad D330-10IGM (both 81H3 and 81MD product names)
sensor:modalias:acpi:BOSC0200*:dmi:*:svnLENOVO:*:pvrLenovoideapadD330-10IGM:*
ACCEL_MOUNT_MATRIX=0, 1, 0; -1, 0, 0; 0, 0, 1
# IdeaPad Miix 300
sensor:modalias:acpi:SMO8500*:dmi:bvnLENOVO:*:pvrMIIX300-*:*
ACCEL_MOUNT_MATRIX=0, -1, 0; -1, 0, 0; 0, 0, 1

View File

@ -38,10 +38,12 @@
<para>The file should contain a single newline-terminated hostname string. Comments (lines starting with
a <literal>#</literal>) are ignored. The hostname should be composed of up to 64 7-bit ASCII lower-case
alphanumeric characters or hyphens forming a valid DNS domain name. It is recommended that this name
contains only a single label, i.e. without any dots. Invalid characters will be filtered out in an
attempt to make the name valid, but obviously it is recommended to use a valid name and not rely on this
filtering.</para>
alphanumeric characters or hyphens forming a valid DNS domain name. It is strongly recommended that this
name contains only a single DNS label, i.e does not contain any dots. This recommendation reflects both
usual expectations of applications, and the fact that the Linux kernel limits the length of the system
hostname to 64 (i.e. close to the maximum DNS label length of 63) rather than 255 (the maximum DNS domain
name length). When applied, invalid characters will be filtered out in an attempt to make the name valid,
but obviously it is recommended to use a valid name and not rely on this filtering.</para>
<para id="question-mark-hostname-pattern">If the question mark character <literal>?</literal> appears in
the hostname, it is automatically substituted by a hexadecimal character derived from the

View File

@ -1263,12 +1263,10 @@ int flush_accept(int fd) {
int cfd;
r = fd_wait_for_event(fd, POLLIN, 0);
if (r < 0) {
if (r == -EINTR)
continue;
if (r < 0)
return r;
}
if (r == 0)
return 0;
@ -1305,12 +1303,10 @@ ssize_t flush_mqueue(int fd) {
ssize_t l;
r = fd_wait_for_event(fd, POLLIN, /* timeout= */ 0);
if (r < 0) {
if (r == -EINTR)
continue;
if (r < 0)
return r;
}
if (r == 0)
return count;

View File

@ -199,12 +199,10 @@ static Virtualization detect_vm_dmi_vendor(void) {
_cleanup_free_ char *s = NULL;
r = read_one_line_file(*vendor, &s);
if (r < 0) {
if (r == -ENOENT)
continue;
if (r < 0)
return r;
}
FOREACH_ELEMENT(dmi_vendor, dmi_vendor_table)
if (startswith(s, dmi_vendor->vendor)) {

View File

@ -810,12 +810,10 @@ static int report_credentials_per_func(const char *title, int (*get_directory_fu
assert(get_directory_func);
r = get_directory_func(&d);
if (r < 0) {
if (r == -ENXIO) /* Env var not set */
return 0;
if (r < 0)
return log_warning_errno(r, "Failed to determine %s directory: %m", title);
}
r = readdir_all_at(AT_FDCWD, d, RECURSE_DIR_SORT|RECURSE_DIR_IGNORE_DOT, &de);
if (r < 0)

View File

@ -5573,16 +5573,13 @@ int config_parse_emergency_action(
runtime_scope = ltype; /* otherwise, assume the scope is passed in via ltype */
r = parse_emergency_action(rvalue, runtime_scope, x);
if (r < 0) {
if (r == -EOPNOTSUPP)
log_syntax(unit, LOG_WARNING, filename, line, r,
"%s= specified as %s mode action, ignoring: %s",
lvalue, runtime_scope_to_string(runtime_scope), rvalue);
else
else if (r < 0)
log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse %s=, ignoring: %s", lvalue, rvalue);
return 0;
}
return 0;
}

View File

@ -198,18 +198,16 @@ static int manager_deserialize_one_unit(Manager *m, const char *name, FILE *f, F
int r;
r = manager_load_unit(m, name, NULL, NULL, &u);
if (r < 0) {
if (r == -ENOMEM)
return r;
return log_oom();
if (r < 0)
return log_notice_errno(r, "Failed to load unit \"%s\", skipping deserialization: %m", name);
}
r = unit_deserialize_state(u, f, fds);
if (r < 0) {
if (r == -ENOMEM)
return r;
return log_oom();
if (r < 0)
return log_notice_errno(r, "Failed to deserialize unit \"%s\", skipping: %m", name);
}
return 0;
}

View File

@ -174,7 +174,6 @@ static int run(int argc, char *argv[]) {
case ACTION_ESCAPE:
if (arg_path) {
r = unit_name_path_escape(*i, &e);
if (r < 0) {
if (r == -EINVAL) {
/* If escaping failed because the string was invalid, let's print a
* friendly message about it. Catch these specific error cases
@ -187,10 +186,9 @@ static int run(int argc, char *argv[]) {
if (!path_is_normalized(*i))
return log_error_errno(r, "Input '%s' is not a normalized file system path, failed to escape.", *i);
}
if (r < 0)
/* All other error cases. */
return log_error_errno(r, "Failed to escape string: %m");
}
/* If the escaping worked, then still warn if the path is not like we'd like
* it. Because that means escaping is not necessarily reversible. */

View File

@ -71,12 +71,10 @@ static int fscrypt_unlink_key(UserRecord *h) {
char *d;
r = keyring_describe(*key, &description);
if (r < 0) {
if (r == -ENOKEY) /* Something else deleted it already, that's ok. */
continue;
if (r < 0)
return log_error_errno(r, "Failed to describe key id %d: %m", *key);
}
/* The description is the final element as per manpage. */
d = strrchr(description, ';');

View File

@ -2353,16 +2353,12 @@ int home_create_luks(
0,
LOCK_EX,
&setup->loop);
if (r < 0) {
if (r == -ENOENT) { /* this means /dev/loop-control doesn't exist, i.e. we are in a container
if (r == -ENOENT) /* this means /dev/loop-control doesn't exist, i.e. we are in a container
* or similar and loopback bock devices are not available, return a
* recognizable error in this case. */
log_error_errno(r, "Loopback block device support is not available on this system.");
return -ENOLINK; /* Make recognizable */
}
return log_error_errno(SYNTHETIC_ERRNO(ENOLINK), "Loopback block device support is not available on this system.");
if (r < 0)
return log_error_errno(r, "Failed to set up loopback device for %s: %m", setup->temporary_image_path);
}
log_info("Setting up loopback device %s completed.", setup->loop->node ?: ip);

View File

@ -1802,12 +1802,10 @@ int device_read_db_internal_filename(sd_device *device, const char *filename) {
assert(filename);
r = read_full_file(filename, &db, &db_len);
if (r < 0) {
if (r == -ENOENT)
return 0;
if (r < 0)
return log_device_debug_errno(device, r, "sd-device: Failed to read db '%s': %m", filename);
}
/* devices with a database entry are initialized */
device->is_initialized = true;

View File

@ -772,14 +772,13 @@ int manager_read_efi_boot_loader_entries(Manager *m) {
return 0;
r = efi_loader_get_entries(&m->efi_boot_loader_entries);
if (r < 0) {
if (r == -ENOENT || ERRNO_IS_NOT_SUPPORTED(r)) {
if (r == -ENOENT || ERRNO_IS_NEG_NOT_SUPPORTED(r)) {
log_debug_errno(r, "Boot loader reported no entries.");
m->efi_boot_loader_entries_set = true;
return 0;
}
if (r < 0)
return log_error_errno(r, "Failed to determine entries reported by boot loader: %m");
}
m->efi_boot_loader_entries_set = true;
return 1;

View File

@ -2820,15 +2820,13 @@ static int method_schedule_shutdown(sd_bus_message *message, void *userdata, sd_
if (elapse == USEC_INFINITY) {
if (m->maintenance_time) {
r = calendar_spec_next_usec(m->maintenance_time, now(CLOCK_REALTIME), &elapse);
if (r < 0) {
if (r == -ENOENT)
return sd_bus_error_set(error,
BUS_ERROR_DESIGNATED_MAINTENANCE_TIME_NOT_SCHEDULED,
"No upcoming maintenance window scheduled");
if (r < 0)
return sd_bus_error_set_errnof(error, r,
"Failed to determine next maintenance window: %m");
}
log_info("Scheduled %s at maintenance window %s", type, FORMAT_TIMESTAMP(elapse));
} else

View File

@ -8297,13 +8297,12 @@ static int context_fstab(Context *context) {
switch (arg_append_fstab) {
case APPEND_AUTO: {
r = read_full_file(path, &c, NULL);
if (r < 0) {
if (r == -ENOENT) {
log_debug("File fstab not found in %s", path);
break;
}
if (r < 0)
return log_error_errno(r, "Failed to open %s: %m", path);
}
const char *acs, *ace;
acs = find_line(c, AUTOMATIC_FSTAB_HEADER_START);
@ -9713,11 +9712,10 @@ static int parse_efi_variable_factory_reset(void) {
return 0;
r = efi_get_variable_string(EFI_SYSTEMD_VARIABLE_STR("FactoryReset"), &value);
if (r < 0) {
if (r == -ENOENT || ERRNO_IS_NOT_SUPPORTED(r))
if (r == -ENOENT || ERRNO_IS_NEG_NOT_SUPPORTED(r))
return 0;
if (r < 0)
return log_error_errno(r, "Failed to read EFI variable FactoryReset: %m");
}
log_warning("Warning, EFI variable FactoryReset is in use, please migrate to use FactoryResetRequest instead, support will be removed in v260!");
@ -9738,11 +9736,10 @@ static int remove_efi_variable_factory_reset(void) {
// FIXME: Remove this in v260, see above
r = efi_set_variable(EFI_SYSTEMD_VARIABLE_STR("FactoryReset"), NULL, 0);
if (r < 0) {
if (r == -ENOENT || ERRNO_IS_NOT_SUPPORTED(r))
if (r == -ENOENT || ERRNO_IS_NEG_NOT_SUPPORTED(r))
return 0;
if (r < 0)
return log_error_errno(r, "Failed to remove EFI variable FactoryReset: %m");
}
log_info("Successfully unset EFI variable FactoryReset.");
return 0;

View File

@ -68,10 +68,27 @@ static inline int acl_set_perm(acl_permset_t ps, acl_perm_t p, bool b) {
#else
typedef void *acl_t;
typedef int acl_tag_t;
typedef unsigned acl_type_t;
#define ACL_READ 0x04
#define ACL_WRITE 0x02
#define ACL_EXECUTE 0x01
/* acl_tag_t */
#define ACL_UNDEFINED_TAG (0x00)
#define ACL_USER_OBJ (0x01)
#define ACL_USER (0x02)
#define ACL_GROUP_OBJ (0x04)
#define ACL_GROUP (0x08)
#define ACL_MASK (0x10)
#define ACL_OTHER (0x20)
/* acl_type_t */
#define ACL_TYPE_ACCESS (0x8000)
#define ACL_TYPE_DEFAULT (0x4000)
static inline int dlopen_libacl(void) {
return -EOPNOTSUPP;
}

View File

@ -161,28 +161,31 @@ static int bus_job_get_service_result(BusWaitForJobs *d, char **ret) {
ret);
}
static void log_job_error_with_service_result(
static int log_job_error_with_service_result(
const char* service,
const char *result,
bool quiet,
const char* const* extra_args) {
static const struct {
const char *result, *explanation;
const char *result;
int error;
const char *explanation;
} explanations[] = {
{ "resources", "of unavailable resources or another system error" },
{ "protocol", "the service did not take the steps required by its unit configuration" },
{ "timeout", "a timeout was exceeded" },
{ "exit-code", "the control process exited with error code" },
{ "signal", "a fatal signal was delivered to the control process" },
{ "core-dump", "a fatal signal was delivered causing the control process to dump core" },
{ "watchdog", "the service failed to send watchdog ping" },
{ "start-limit-hit", "start of the service was attempted too often" },
{ "oom-kill", "of an out-of-memory (OOM) siutation" },
{ "resources", EMFILE, "of unavailable resources or another system error" },
{ "protocol", EPROTONOSUPPORT, "the service did not take the steps required by its unit configuration" },
{ "timeout", ETIMEDOUT, "a timeout was exceeded" },
{ "exit-code", EBADE, "the control process exited with error code" },
{ "signal", ENOTRECOVERABLE, "a fatal signal was delivered to the control process" },
{ "core-dump", ECONNABORTED, "a fatal signal was delivered causing the control process to dump core" },
{ "watchdog", ECONNRESET, "the service failed to send watchdog ping" },
{ "start-limit-hit", EBUSY, "start of the service was attempted too often" },
{ "oom-kill", ENOMEM, "of an out-of-memory (OOM) situation" },
};
_cleanup_free_ char *service_shell_quoted = NULL;
const char *systemctl = "systemctl", *journalctl = "journalctl";
int r;
assert(service);
@ -199,7 +202,8 @@ static void log_job_error_with_service_result(
if (!isempty(result))
FOREACH_ELEMENT(i, explanations)
if (streq(result, i->result)) {
log_full(quiet ? LOG_DEBUG : LOG_ERR,
r = log_full_errno(quiet ? LOG_DEBUG : LOG_ERR,
SYNTHETIC_ERRNO(i->error),
"Job for %s failed because %s.\n"
"See \"%s status %s\" and \"%s -xeu %s\" for details.\n",
service, i->explanation,
@ -208,7 +212,8 @@ static void log_job_error_with_service_result(
goto extra;
}
log_full(quiet ? LOG_DEBUG : LOG_ERR,
r = log_full_errno(quiet ? LOG_DEBUG : LOG_ERR,
SYNTHETIC_ERRNO(ENOMEDIUM),
"Job for %s failed.\n"
"See \"%s status %s\" and \"%s -xeu %s\" for details.\n",
service,
@ -223,6 +228,8 @@ extra:
"followed by \"%1$s start %2$s\" again.",
systemctl,
service_shell_quoted ?: "<service>");
return r;
}
static int check_wait_response(BusWaitForJobs *d, WaitJobsFlags flags, const char* const* extra_args) {
@ -247,60 +254,44 @@ static int check_wait_response(BusWaitForJobs *d, WaitJobsFlags flags, const cha
int priority = FLAGS_SET(flags, BUS_WAIT_JOBS_LOG_ERROR) ? LOG_ERR : LOG_DEBUG;
if (streq(d->result, "canceled"))
log_full(priority, "Job for %s canceled.", d->name);
else if (streq(d->result, "timeout"))
log_full(priority, "Job for %s timed out.", d->name);
else if (streq(d->result, "dependency"))
log_full(priority, "A dependency job for %s failed. See 'journalctl -xe' for details.", d->name);
else if (streq(d->result, "invalid"))
log_full(priority, "%s is not active, cannot reload.", d->name);
else if (streq(d->result, "assert"))
log_full(priority, "Assertion failed on job for %s.", d->name);
else if (streq(d->result, "unsupported"))
log_full(priority, "Operation on or unit type of %s not supported on this system.", d->name);
else if (streq(d->result, "collected"))
log_full(priority, "Queued job for %s was garbage collected.", d->name);
else if (streq(d->result, "once"))
log_full(priority, "Unit %s was started already once and can't be started again.", d->name);
else if (streq(d->result, "frozen"))
log_full(priority, "Cannot perform operation on frozen unit %s.", d->name);
else if (streq(d->result, "concurrency"))
log_full(priority, "Concurrency limit of a slice unit %s is contained in has been reached.", d->name);
else if (endswith(d->name, ".service")) {
/* Job result is unknown. For services, let's also try Result property. */
_cleanup_free_ char *result = NULL;
return log_full_errno(priority, SYNTHETIC_ERRNO(ECANCELED), "Job for %s canceled.", d->name);
if (streq(d->result, "timeout"))
return log_full_errno(priority, SYNTHETIC_ERRNO(ETIME), "Job for %s timed out.", d->name);
if (streq(d->result, "dependency"))
return log_full_errno(priority, SYNTHETIC_ERRNO(EIO), "A dependency job for %s failed. See 'journalctl -xe' for details.", d->name);
if (streq(d->result, "invalid"))
return log_full_errno(priority, SYNTHETIC_ERRNO(ENOEXEC), "%s is not active, cannot reload.", d->name);
if (streq(d->result, "assert"))
return log_full_errno(priority, SYNTHETIC_ERRNO(EPROTO), "Assertion failed on job for %s.", d->name);
if (streq(d->result, "unsupported"))
return log_full_errno(priority, SYNTHETIC_ERRNO(EOPNOTSUPP), "Operation on or unit type of %s not supported on this system.", d->name);
if (streq(d->result, "collected"))
return log_full_errno(priority, SYNTHETIC_ERRNO(ECANCELED), "Queued job for %s was garbage collected.", d->name);
if (streq(d->result, "once"))
return log_full_errno(priority, SYNTHETIC_ERRNO(ESTALE), "Unit %s was started already once and can't be started again.", d->name);
if (streq(d->result, "frozen"))
return log_full_errno(priority, SYNTHETIC_ERRNO(EDEADLK), "Cannot perform operation on frozen unit %s.", d->name);
if (streq(d->result, "concurrency"))
return log_full_errno(priority, SYNTHETIC_ERRNO(ETOOMANYREFS), "Concurrency limit of a slice unit %s is contained in has been reached.", d->name);
if (!streq(d->result, "failed"))
log_debug("Unexpected job result '%s' for unit '%s', assuming server side newer than us.",
d->result, d->name);
/* Job is failed, or result is unknown. For non-service units, just show a generic message. */
if (!endswith(d->name, ".service"))
return log_full_errno(priority, SYNTHETIC_ERRNO(ENOMEDIUM), "Job failed. See \"journalctl -xe\" for details.");
/* For services, let's also try Result property. */
_cleanup_free_ char *result = NULL;
r = bus_job_get_service_result(d, &result);
if (r < 0)
log_debug_errno(r, "Failed to get Result property of unit %s, ignoring: %m",
d->name);
log_debug_errno(r, "Failed to get Result property of unit %s, ignoring: %m", d->name);
log_job_error_with_service_result(d->name, result, priority, extra_args);
} else /* Otherwise we just show a generic message. */
log_full(priority, "Job failed. See \"journalctl -xe\" for details.");
if (STR_IN_SET(d->result, "canceled", "collected"))
return -ECANCELED;
else if (streq(d->result, "timeout"))
return -ETIME;
else if (streq(d->result, "dependency"))
return -EIO;
else if (streq(d->result, "invalid"))
return -ENOEXEC;
else if (streq(d->result, "assert"))
return -EPROTO;
else if (streq(d->result, "unsupported"))
return -EOPNOTSUPP;
else if (streq(d->result, "once"))
return -ESTALE;
else if (streq(d->result, "frozen"))
return -EDEADLK;
else if (streq(d->result, "concurrency"))
return -ETOOMANYREFS;
return log_debug_errno(SYNTHETIC_ERRNO(ENOMEDIUM),
"Unexpected job result '%s' for unit '%s', assuming server side newer than us.",
d->result, d->name);
return log_job_error_with_service_result(
d->name, result,
/* quiet= */ !FLAGS_SET(flags, BUS_WAIT_JOBS_LOG_ERROR),
extra_args);
}
int bus_wait_for_jobs(BusWaitForJobs *d, WaitJobsFlags flags, const char* const* extra_args) {

View File

@ -88,10 +88,12 @@ static void open_inode_done(OpenInode *of) {
of->path = mfree(of->path);
}
xattr_done_many(of->xattr, of->n_xattr);
#if HAVE_ACL
if (of->acl_access)
sym_acl_free(of->acl_access);
if (of->acl_default)
sym_acl_free(of->acl_default);
#endif
}
static void open_inode_done_many(OpenInode *array, size_t n) {
@ -113,14 +115,22 @@ static int open_inode_apply_acl(OpenInode *of) {
return 0;
if (of->acl_access) {
#if HAVE_ACL
if (sym_acl_set_fd(of->fd, of->acl_access) < 0)
RET_GATHER(r, log_error_errno(errno, "Failed to adjust ACLs of '%s': %m", of->path));
#else
log_debug("The archive entry '%s' has ACLs, but ACL support is disabled.", of->path);
#endif
}
if (of->filetype == S_IFDIR && of->acl_default) {
#if HAVE_ACL
/* There's no API to set default ACLs by fd, hence go by /proc/self/fd/ path */
if (sym_acl_set_file(FORMAT_PROC_FD_PATH(of->fd), ACL_TYPE_DEFAULT, of->acl_default) < 0)
RET_GATHER(r, log_error_errno(errno, "Failed to adjust default ACLs of '%s': %m", of->path));
#else
log_debug("The archive entry '%s' has default ACLs, but ACL support is disabled.", of->path);
#endif
}
return r;
@ -444,6 +454,7 @@ static int archive_entry_read_acl(
return 0;
assert(c > 0);
#if HAVE_ACL
r = dlopen_libacl();
if (r < 0) {
log_debug_errno(r, "Not restoring ACL data on inode as libacl is not available: %m");
@ -454,6 +465,7 @@ static int archive_entry_read_acl(
a = sym_acl_init(c);
if (!a)
return log_oom();
#endif
for (;;) {
int rtype, permset, tag, qual;
@ -473,10 +485,6 @@ static int archive_entry_read_acl(
assert(rtype == type);
acl_entry_t e;
if (sym_acl_create_entry(&a, &e) < 0)
return log_error_errno(errno, "Failed to create ACL entry: %m");
static const struct {
int libarchive;
acl_tag_t libacl;
@ -498,9 +506,8 @@ static int archive_entry_read_acl(
if (ntag == ACL_UNDEFINED_TAG)
continue;
if (sym_acl_set_tag_type(e, ntag) < 0)
return log_error_errno(errno, "Failed to set ACL entry tag: %m");
#if HAVE_ACL
acl_entry_t e;
if (IN_SET(ntag, ACL_USER, ACL_GROUP)) {
id_t id = qual;
/* Suppress ACL entries for invalid UIDs/GIDS */
@ -511,8 +518,20 @@ static int archive_entry_read_acl(
if (FLAGS_SET(flags, TAR_SQUASH_UIDS_ABOVE_64K) && id >= NSRESOURCE_UIDS_64K)
continue;
if (sym_acl_create_entry(&a, &e) < 0)
return log_error_errno(errno, "Failed to create ACL entry: %m");
if (sym_acl_set_tag_type(e, ntag) < 0)
return log_error_errno(errno, "Failed to set ACL entry tag: %m");
if (sym_acl_set_qualifier(e, &id) < 0)
return log_error_errno(errno, "Failed to set ACL entry qualifier: %m");
} else {
if (sym_acl_create_entry(&a, &e) < 0)
return log_error_errno(errno, "Failed to create ACL entry: %m");
if (sym_acl_set_tag_type(e, ntag) < 0)
return log_error_errno(errno, "Failed to set ACL entry tag: %m");
}
acl_permset_t p;
@ -533,11 +552,19 @@ static int archive_entry_read_acl(
if (sym_acl_set_permset(e, p) < 0)
return log_error_errno(errno, "Failed to set ACL entry permission set: %m");
#else
*acl = POINTER_MAX; /* Indicate the entry has valid ACLs. */
return 0;
#endif
}
#if HAVE_ACL
if (*acl)
sym_acl_free(*acl);
*acl = TAKE_PTR(a);
#else
*acl = NULL; /* Indicate the entry has no ACL. */
#endif
return 0;
}
@ -803,7 +830,10 @@ int tar_x(int input_fd, int tree_fd, TarFlags flags) {
gid_t gid = GID_INVALID;
struct timespec mtime = { .tv_nsec = UTIME_OMIT };
unsigned fflags = 0;
_cleanup_(acl_freep) acl_t acl_access = NULL, acl_default = NULL;
#if HAVE_ACL
_cleanup_(acl_freep)
#endif
acl_t acl_access = NULL, acl_default = NULL;
XAttr *xa = NULL;
size_t n_xa = 0;
CLEANUP_ARRAY(xa, n_xa, xattr_done_many);
@ -1119,6 +1149,7 @@ static int archive_generate_sparse(struct archive_entry *entry, int fd) {
return 0;
}
#if HAVE_ACL
static int archive_write_acl(
struct archive_entry *entry,
acl_type_t ntype,
@ -1208,6 +1239,7 @@ static int archive_write_acl(
return 0;
}
#endif
static int archive_item(
RecurseDirEvent event,
@ -1293,6 +1325,7 @@ static int archive_item(
sym_archive_entry_set_symlink(entry, s);
}
#if HAVE_ACL
if (inode_type_can_acl(sx->stx_mode)) {
r = dlopen_libacl();
@ -1322,6 +1355,7 @@ static int archive_item(
}
}
}
#endif
_cleanup_free_ char *xattrs = NULL;
r = flistxattr_malloc(inode_fd, &xattrs);

View File

@ -51,14 +51,12 @@ static int builtin_net_setup_link(UdevEvent *event, int argc, char **argv) {
return log_device_warning_errno(dev, r, "Failed to get link information: %m");
r = link_get_config(ctx, link);
if (r < 0) {
if (r == -ENOENT) {
log_device_debug_errno(dev, r, "No matching link configuration found, ignoring device.");
return 0;
}
if (r < 0)
return log_device_error_errno(dev, r, "Failed to get link config: %m");
}
r = link_apply_config(ctx, link);
if (r == -ENODEV)