mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-01-11 05:17:44 +03:00
mount-setup: try mounting 'efivarfs' only if the system bootet with EFI
This commit is contained in:
parent
3dfb265083
commit
6aa220e019
3
TODO
3
TODO
@ -1,7 +1,4 @@
|
|||||||
Bugfixes:
|
Bugfixes:
|
||||||
* mount efivars only if /sys/firmware/efi/ exists
|
|
||||||
(add *condition callback to API mounts array and check for directory)
|
|
||||||
|
|
||||||
* check systemd-tmpfiles for selinux context hookup for mknod(), symlink() and similar
|
* check systemd-tmpfiles for selinux context hookup for mknod(), symlink() and similar
|
||||||
|
|
||||||
* swap units that are activated by one name but shown in the kernel under another are semi-broken
|
* swap units that are activated by one name but shown in the kernel under another are semi-broken
|
||||||
|
@ -46,14 +46,20 @@
|
|||||||
#define TTY_GID 5
|
#define TTY_GID 5
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
typedef enum MountMode {
|
||||||
|
MNT_NONE = 0,
|
||||||
|
MNT_FATAL = 1 << 0,
|
||||||
|
MNT_IN_CONTAINER = 1 << 1,
|
||||||
|
} MountMode;
|
||||||
|
|
||||||
typedef struct MountPoint {
|
typedef struct MountPoint {
|
||||||
const char *what;
|
const char *what;
|
||||||
const char *where;
|
const char *where;
|
||||||
const char *type;
|
const char *type;
|
||||||
const char *options;
|
const char *options;
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
bool fatal;
|
bool (*condition_fn)(void);
|
||||||
bool in_container;
|
MountMode mode;
|
||||||
} MountPoint;
|
} MountPoint;
|
||||||
|
|
||||||
/* The first three entries we might need before SELinux is up. The
|
/* The first three entries we might need before SELinux is up. The
|
||||||
@ -62,16 +68,26 @@ typedef struct MountPoint {
|
|||||||
#define N_EARLY_MOUNT 4
|
#define N_EARLY_MOUNT 4
|
||||||
|
|
||||||
static const MountPoint mount_table[] = {
|
static const MountPoint mount_table[] = {
|
||||||
{ "proc", "/proc", "proc", NULL, MS_NOSUID|MS_NOEXEC|MS_NODEV, true, true },
|
{ "proc", "/proc", "proc", NULL, MS_NOSUID|MS_NOEXEC|MS_NODEV,
|
||||||
{ "sysfs", "/sys", "sysfs", NULL, MS_NOSUID|MS_NOEXEC|MS_NODEV, true, true },
|
NULL, MNT_FATAL|MNT_IN_CONTAINER },
|
||||||
{ "devtmpfs", "/dev", "devtmpfs", "mode=755", MS_NOSUID|MS_STRICTATIME, true, true },
|
{ "sysfs", "/sys", "sysfs", NULL, MS_NOSUID|MS_NOEXEC|MS_NODEV,
|
||||||
{ "securityfs", "/sys/kernel/security", "securityfs", NULL, MS_NOSUID|MS_NOEXEC|MS_NODEV, false, false },
|
NULL, MNT_FATAL|MNT_IN_CONTAINER },
|
||||||
{ "efivarfs", "/sys/firmware/efi/efivars", "efivarfs", NULL, MS_NOSUID|MS_NOEXEC|MS_NODEV, false, false },
|
{ "devtmpfs", "/dev", "devtmpfs", "mode=755", MS_NOSUID|MS_STRICTATIME,
|
||||||
{ "tmpfs", "/dev/shm", "tmpfs", "mode=1777", MS_NOSUID|MS_NODEV|MS_STRICTATIME, true, true },
|
NULL, MNT_FATAL|MNT_IN_CONTAINER },
|
||||||
{ "devpts", "/dev/pts", "devpts", "mode=620,gid=" STRINGIFY(TTY_GID), MS_NOSUID|MS_NOEXEC, false, true },
|
{ "securityfs", "/sys/kernel/security", "securityfs", NULL, MS_NOSUID|MS_NOEXEC|MS_NODEV,
|
||||||
{ "tmpfs", "/run", "tmpfs", "mode=755", MS_NOSUID|MS_NODEV|MS_STRICTATIME, true, true },
|
NULL, MNT_NONE },
|
||||||
{ "tmpfs", "/sys/fs/cgroup", "tmpfs", "mode=755", MS_NOSUID|MS_NOEXEC|MS_NODEV|MS_STRICTATIME, false, true },
|
{ "efivarfs", "/sys/firmware/efi/efivars", "efivarfs", NULL, MS_NOSUID|MS_NOEXEC|MS_NODEV,
|
||||||
{ "cgroup", "/sys/fs/cgroup/systemd", "cgroup", "none,name=systemd", MS_NOSUID|MS_NOEXEC|MS_NODEV, false, true },
|
is_efiboot, MNT_NONE },
|
||||||
|
{ "tmpfs", "/dev/shm", "tmpfs", "mode=1777", MS_NOSUID|MS_NODEV|MS_STRICTATIME,
|
||||||
|
NULL, MNT_FATAL|MNT_IN_CONTAINER },
|
||||||
|
{ "devpts", "/dev/pts", "devpts", "mode=620,gid=" STRINGIFY(TTY_GID), MS_NOSUID|MS_NOEXEC,
|
||||||
|
NULL, MNT_IN_CONTAINER },
|
||||||
|
{ "tmpfs", "/run", "tmpfs", "mode=755", MS_NOSUID|MS_NODEV|MS_STRICTATIME,
|
||||||
|
NULL, MNT_FATAL|MNT_IN_CONTAINER },
|
||||||
|
{ "tmpfs", "/sys/fs/cgroup", "tmpfs", "mode=755", MS_NOSUID|MS_NOEXEC|MS_NODEV|MS_STRICTATIME,
|
||||||
|
NULL, MNT_IN_CONTAINER },
|
||||||
|
{ "cgroup", "/sys/fs/cgroup/systemd", "cgroup", "none,name=systemd", MS_NOSUID|MS_NOEXEC|MS_NODEV,
|
||||||
|
NULL, MNT_IN_CONTAINER },
|
||||||
};
|
};
|
||||||
|
|
||||||
/* These are API file systems that might be mounted by other software,
|
/* These are API file systems that might be mounted by other software,
|
||||||
@ -119,6 +135,9 @@ static int mount_one(const MountPoint *p, bool relabel) {
|
|||||||
|
|
||||||
assert(p);
|
assert(p);
|
||||||
|
|
||||||
|
if (p->condition_fn && !p->condition_fn())
|
||||||
|
return 0;
|
||||||
|
|
||||||
/* Relabel first, just in case */
|
/* Relabel first, just in case */
|
||||||
if (relabel)
|
if (relabel)
|
||||||
label_fix(p->where, true, true);
|
label_fix(p->where, true, true);
|
||||||
@ -131,7 +150,7 @@ static int mount_one(const MountPoint *p, bool relabel) {
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* Skip securityfs in a container */
|
/* Skip securityfs in a container */
|
||||||
if (!p->in_container && detect_container(NULL) > 0)
|
if (!(p->mode & MNT_IN_CONTAINER) && detect_container(NULL) > 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* The access mode here doesn't really matter too much, since
|
/* The access mode here doesn't really matter too much, since
|
||||||
@ -149,8 +168,8 @@ static int mount_one(const MountPoint *p, bool relabel) {
|
|||||||
p->type,
|
p->type,
|
||||||
p->flags,
|
p->flags,
|
||||||
p->options) < 0) {
|
p->options) < 0) {
|
||||||
log_full(p->fatal ? LOG_ERR : LOG_DEBUG, "Failed to mount %s: %s", p->where, strerror(errno));
|
log_full((p->mode & MNT_FATAL) ? LOG_ERR : LOG_DEBUG, "Failed to mount %s: %s", p->where, strerror(errno));
|
||||||
return p->fatal ? -errno : 0;
|
return (p->mode & MNT_FATAL) ? -errno : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Relabel again, since we now mounted something fresh here */
|
/* Relabel again, since we now mounted something fresh here */
|
||||||
@ -289,7 +308,6 @@ int mount_cgroup_controllers(char ***join_controllers) {
|
|||||||
p.type = "cgroup";
|
p.type = "cgroup";
|
||||||
p.options = options;
|
p.options = options;
|
||||||
p.flags = MS_NOSUID|MS_NOEXEC|MS_NODEV;
|
p.flags = MS_NOSUID|MS_NOEXEC|MS_NODEV;
|
||||||
p.fatal = false;
|
|
||||||
|
|
||||||
r = mount_one(&p, true);
|
r = mount_one(&p, true);
|
||||||
free(controller);
|
free(controller);
|
||||||
|
Loading…
Reference in New Issue
Block a user