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

Compare commits

...

6 Commits

Author SHA1 Message Date
Yu Watanabe
23d8003bb6 time-util: fix typo 2020-12-14 17:56:01 +01:00
Yu Watanabe
61f8a7bd3e core/namespace: use existing /proc when not enough priviledge
Fixes #17860.
2020-12-14 16:12:43 +01:00
Yu Watanabe
0ebc9f23fa core/namespace: ignore ENOENT for /proc/sys/kernel/domainname and hostname
If they do not exist, hostname or domainname cannot be modified. So, it is ok.

Fixes #17866, especially https://github.com/systemd/systemd/issues/17866#issuecomment-744118614.
2020-12-14 14:15:28 +00:00
Lennart Poettering
38abd1bfc5 Update TODO 2020-12-14 13:51:10 +01:00
Yu Watanabe
28423d9a75 tree-wide: fix typo 2020-12-14 12:05:55 +00:00
Ilya Dmitrichenko
65af8442df nspawn: remove outdated comment regarding bpffs
bpffs fully respects mount namespaces since kernel version 4.7

References:

- e27f4a942a
- 612bacad78
2020-12-14 10:50:42 +01:00
12 changed files with 51 additions and 41 deletions

6
NEWS
View File

@ -3809,7 +3809,7 @@ CHANGES WITH 237:
by default even when owned by root and read-only. This behaviour was by default even when owned by root and read-only. This behaviour was
inherited from older tools, but there have been requests to remove inherited from older tools, but there have been requests to remove
it, and it's not obvious why this restriction was made in the first it, and it's not obvious why this restriction was made in the first
place. Please speak up now, if you are aware of software that reqires place. Please speak up now, if you are aware of software that requires
this behaviour, otherwise we'll remove the restriction in v238. this behaviour, otherwise we'll remove the restriction in v238.
* A new environment variable $SYSTEMD_OFFLINE is now understood by * A new environment variable $SYSTEMD_OFFLINE is now understood by
@ -6907,7 +6907,7 @@ CHANGES WITH 220:
* New /etc/fstab options x-systemd.requires= and * New /etc/fstab options x-systemd.requires= and
x-systemd.requires-mounts-for= are now supported to express x-systemd.requires-mounts-for= are now supported to express
additional dependencies for mounts. This is useful for additional dependencies for mounts. This is useful for
journalling file systems that support external journal journaling file systems that support external journal
devices or overlay file systems that require underlying file devices or overlay file systems that require underlying file
systems to be mounted. systems to be mounted.
@ -7521,7 +7521,7 @@ CHANGES WITH 218:
* nspawn's --link-journal= switch gained two new values * nspawn's --link-journal= switch gained two new values
"try-guest" and "try-host" that work like "guest" and "try-guest" and "try-host" that work like "guest" and
"host", but do not fail if the host has no persistent "host", but do not fail if the host has no persistent
journalling enabled. -j is now equivalent to journaling enabled. -j is now equivalent to
--link-journal=try-guest. --link-journal=try-guest.
* macvlan network devices created by nspawn will now have * macvlan network devices created by nspawn will now have

4
TODO
View File

@ -20,6 +20,8 @@ Janitorial Clean-ups:
Features: Features:
* expose MS_NOSYMFOLLOW in various places
* cryptsetup: optionally, when run during boot-up and password is never * cryptsetup: optionally, when run during boot-up and password is never
entered, and we are on AC power (or so), power off machine again entered, and we are on AC power (or so), power off machine again
@ -1008,7 +1010,7 @@ Features:
- logind: when the power button is pressed short, just popup a - logind: when the power button is pressed short, just popup a
logout dialog. If it is pressed for 1s, do the usual logout dialog. If it is pressed for 1s, do the usual
shutdown. Inspiration are Macs here. shutdown. Inspiration are Macs here.
- expose "Locked" property on logind sesison objects - expose "Locked" property on logind session objects
- maybe allow configuration of the StopTimeout for session scopes - maybe allow configuration of the StopTimeout for session scopes
- rename session scope so that it includes the UID. THat way - rename session scope so that it includes the UID. THat way
the session scope can be arranged freely in slices and we don't have the session scope can be arranged freely in slices and we don't have

View File

@ -329,7 +329,7 @@ node /org/freedesktop/resolve1 {
<listitem><para>Alternatively, leave both the service name and type empty and specify the full <listitem><para>Alternatively, leave both the service name and type empty and specify the full
domain name of the SRV record (i.e. prefixed with the service type) in the domain parameter. (No IDNA domain name of the SRV record (i.e. prefixed with the service type) in the domain parameter. (No IDNA
coversion is applied in this mode.)</para></listitem> conversion is applied in this mode.)</para></listitem>
</orderedlist> </orderedlist>
<para>The <varname>family</varname> parameter of the <function>ResolveService()</function> method encodes <para>The <varname>family</varname> parameter of the <function>ResolveService()</function> method encodes

View File

@ -1606,7 +1606,7 @@ TimestampStyle timestamp_style_from_string(const char *s) {
return t; return t;
if (streq_ptr(s, "µs")) if (streq_ptr(s, "µs"))
return TIMESTAMP_US; return TIMESTAMP_US;
if (streq_ptr(s, "µs+uts")) if (streq_ptr(s, "µs+utc"))
return TIMESTAMP_US_UTC; return TIMESTAMP_US_UTC;
return t; return t;
} }

View File

@ -859,25 +859,15 @@ static int mount_sysfs(const MountEntry *m) {
} }
static int mount_procfs(const MountEntry *m, const NamespaceInfo *ns_info) { static int mount_procfs(const MountEntry *m, const NamespaceInfo *ns_info) {
_cleanup_free_ char *opts = NULL;
const char *entry_path; const char *entry_path;
int r; int r, n;
assert(m); assert(m);
assert(ns_info); assert(ns_info);
entry_path = mount_entry_path(m);
/* Mount a new instance, so that we get the one that matches our user namespace, if we are running in
* one. i.e we don't reuse existing mounts here under any condition, we want a new instance owned by
* our user namespace and with our hidepid= settings applied. Hence, let's get rid of everything
* mounted on /proc/ first. */
(void) mkdir_p_label(entry_path, 0755);
(void) umount_recursive(entry_path, 0);
if (ns_info->protect_proc != PROTECT_PROC_DEFAULT || if (ns_info->protect_proc != PROTECT_PROC_DEFAULT ||
ns_info->proc_subset != PROC_SUBSET_ALL) { ns_info->proc_subset != PROC_SUBSET_ALL) {
_cleanup_free_ char *opts = NULL;
/* Starting with kernel 5.8 procfs' hidepid= logic is truly per-instance (previously it /* Starting with kernel 5.8 procfs' hidepid= logic is truly per-instance (previously it
* pretended to be per-instance but actually was per-namespace), hence let's make use of it * pretended to be per-instance but actually was per-namespace), hence let's make use of it
@ -891,23 +881,40 @@ static int mount_procfs(const MountEntry *m, const NamespaceInfo *ns_info) {
ns_info->proc_subset == PROC_SUBSET_PID ? ",subset=pid" : ""); ns_info->proc_subset == PROC_SUBSET_PID ? ",subset=pid" : "");
if (!opts) if (!opts)
return -ENOMEM; return -ENOMEM;
}
entry_path = mount_entry_path(m);
(void) mkdir_p_label(entry_path, 0755);
/* Mount a new instance, so that we get the one that matches our user namespace, if we are running in
* one. i.e we don't reuse existing mounts here under any condition, we want a new instance owned by
* our user namespace and with our hidepid= settings applied. Hence, let's get rid of everything
* mounted on /proc/ first. */
n = umount_recursive(entry_path, 0);
r = mount_nofollow_verbose(LOG_DEBUG, "proc", entry_path, "proc", MS_NOSUID|MS_NOEXEC|MS_NODEV, opts); r = mount_nofollow_verbose(LOG_DEBUG, "proc", entry_path, "proc", MS_NOSUID|MS_NOEXEC|MS_NODEV, opts);
if (r < 0) { if (r == -EINVAL && opts)
if (r != -EINVAL)
return r;
/* If this failed with EINVAL then this likely means the textual hidepid= stuff is /* If this failed with EINVAL then this likely means the textual hidepid= stuff is
* not supported by the kernel, and thus the per-instance hidepid= neither, which * not supported by the kernel, and thus the per-instance hidepid= neither, which
* means we really don't want to use it, since it would affect our host's /proc * means we really don't want to use it, since it would affect our host's /proc
* mount. Hence let's gracefully fallback to a classic, unrestricted version. */ * mount. Hence let's gracefully fallback to a classic, unrestricted version. */
} else
return 1;
}
r = mount_nofollow_verbose(LOG_DEBUG, "proc", entry_path, "proc", MS_NOSUID|MS_NOEXEC|MS_NODEV, NULL); r = mount_nofollow_verbose(LOG_DEBUG, "proc", entry_path, "proc", MS_NOSUID|MS_NOEXEC|MS_NODEV, NULL);
if (r == -EPERM) {
/* When we do not have enough priviledge to mount /proc, fallback to use existing /proc. */
if (n > 0)
/* /proc or some of sub-mounts are umounted in the above. Refuse incomplete tree.
* Propagate the original error code returned by mount() in the above. */
return -EPERM;
r = path_is_mount_point(entry_path, NULL, 0);
if (r < 0) if (r < 0)
return r; return log_debug_errno(r, "Unable to determine whether /proc is already mounted: %m");
if (r == 0)
/* /proc is not mounted. Propagate the original error code. */
return -EPERM;
}
return 1; return 1;
} }
@ -1684,10 +1691,12 @@ int setup_namespace(
*(m++) = (MountEntry) { *(m++) = (MountEntry) {
.path_const = "/proc/sys/kernel/hostname", .path_const = "/proc/sys/kernel/hostname",
.mode = READONLY, .mode = READONLY,
.ignore = true,
}; };
*(m++) = (MountEntry) { *(m++) = (MountEntry) {
.path_const = "/proc/sys/kernel/domainname", .path_const = "/proc/sys/kernel/domainname",
.mode = READONLY, .mode = READONLY,
.ignore = true,
}; };
} }

View File

@ -898,7 +898,7 @@ _public_ PAM_EXTERN int pam_sm_acct_mgmt(
return PAM_NEW_AUTHTOK_REQD; return PAM_NEW_AUTHTOK_REQD;
case -EOWNERDEAD: case -EOWNERDEAD:
(void) pam_prompt(handle, PAM_ERROR_MSG, NULL, "Password expired, change requird."); (void) pam_prompt(handle, PAM_ERROR_MSG, NULL, "Password expired, change required.");
return PAM_NEW_AUTHTOK_REQD; return PAM_NEW_AUTHTOK_REQD;
case -EKEYREJECTED: case -EKEYREJECTED:

View File

@ -126,7 +126,7 @@ static int add_syscall_filters(
* @pkey * @pkey
* @swap * @swap
* *
* bpf (NB: bpffs is not namespaced!) * bpf
* fanotify_init * fanotify_init
* fanotify_mark * fanotify_mark
* kexec_file_load * kexec_file_load

View File

@ -27,7 +27,7 @@
/* An arbitrary limit on the length of the chains of components. We don't want to /* An arbitrary limit on the length of the chains of components. We don't want to
* build a very long linked list, which would be slow to iterate over and might cause * build a very long linked list, which would be slow to iterate over and might cause
* our stack to overflow. It's unlikely that legitimate uses require more than a few * our stack to overflow. It's unlikely that legitimate uses require more than a few
* linked compenents anyway. */ * linked components anyway. */
#define CALENDARSPEC_COMPONENTS_MAX 240 #define CALENDARSPEC_COMPONENTS_MAX 240
/* Let's make sure that the microsecond component is safe to be stored in an 'int' */ /* Let's make sure that the microsecond component is safe to be stored in an 'int' */

View File

@ -474,8 +474,7 @@ static int names_platform(sd_device *dev, struct netnames *names, bool test) {
/* Platform devices are named after ACPI table match, and instance id /* Platform devices are named after ACPI table match, and instance id
* eg. "/sys/devices/platform/HISI00C2:00"); * eg. "/sys/devices/platform/HISI00C2:00");
* The Vendor (3 or 4 char), followed by hexdecimal model number : instance id. * The Vendor (3 or 4 char), followed by hexadecimal model number : instance id. */
*/
DISABLE_WARNING_FORMAT_NONLITERAL; DISABLE_WARNING_FORMAT_NONLITERAL;
if (sscanf(syspath, pattern, vendor, &model, &instance, &ethid) != 4) if (sscanf(syspath, pattern, vendor, &model, &instance, &ethid) != 4)

View File

@ -51,7 +51,7 @@ static int exec_list(sd_device_enumerator *e, const char *action, Set **settle_s
"Failed to write '%s' to '%s'%s: %m", "Failed to write '%s' to '%s'%s: %m",
action, filename, ignore ? ", ignoring" : ""); action, filename, ignore ? ", ignoring" : "");
if (IN_SET(r, -EACCES, -EROFS)) if (IN_SET(r, -EACCES, -EROFS))
/* Inovoked by unpriviledged user, or read only filesystem. Return earlier. */ /* Inovoked by unprivileged user, or read only filesystem. Return earlier. */
return r; return r;
if (ret == 0 && !ignore) if (ret == 0 && !ignore)
ret = r; ret = r;

View File

@ -7,7 +7,7 @@
# #
# Run after sys-script.py # Run after sys-script.py
# Usage: sd-script.py <directory> <num> # Usage: sd-script.py <directory> <num>
# <num> is the number of device nodes (disks + partititions) # <num> is the number of device nodes (disks + partitions)
# to create in addition to what sys-script.py already did. # to create in addition to what sys-script.py already did.
# The script can be run several times in a row if <num> is increased, # The script can be run several times in a row if <num> is increased,
# adding yet more device entries. # adding yet more device entries.