1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-02 02:21:44 +03:00

sysctl: do not fail systemd-sysctl.service if /proc/sys is mounted read-only

Let's make missing write access to /proc/sys non-fatal to the sysctl service.

This is a follow-up to 411e869f49 which altered
the condition for running the sysctl service to check for /proc/sys/net being
writable, accepting that /proc/sys might be read-only. In order to ensure the
boot-up stays clean in containers lower the log level for the EROFS errors
generated due to this.
This commit is contained in:
Lennart Poettering 2016-10-25 09:22:22 +02:00
parent a581e45ae8
commit 39540de8ab

View File

@ -51,11 +51,18 @@ static int apply_all(OrderedHashmap *sysctl_options) {
k = sysctl_write(property, value);
if (k < 0) {
log_full_errno(k == -ENOENT ? LOG_INFO : LOG_WARNING, k,
"Couldn't write '%s' to '%s', ignoring: %m", value, property);
/* If the sysctl is not available in the kernel or we are running with reduced privileges and
* cannot write it, then log about the issue at LOG_NOTICE level, and proceed without
* failing. (EROFS is treated as a permission problem here, since that's how container managers
* usually protected their sysctls.) In all other cases log an error and make the tool fail. */
if (r == 0 && k != -ENOENT)
r = k;
if (IN_SET(k, -EPERM, -EACCES, -EROFS, -ENOENT))
log_notice_errno(k, "Couldn't write '%s' to '%s', ignoring: %m", value, property);
else {
log_error_errno(k, "Couldn't write '%s' to '%s': %m", value, property);
if (r == 0)
r = k;
}
}
}