Skip to contentSkip to conversation

tools/hotplug: systemd changes for 4.5

PATCH Superseded Olaf Hering 3 participants 14 messages Dec 8, 2014 – Dec 12, 2014

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover tools/hotplug: systemd changes for 4.5

This is a resend of this series, with just the low hanging fruits:
http://lists.xenproject.org/archives/html/xen-devel/2014-12/msg00669.html

The mentioned wrapper to run xenstored from systemd without duplicate functionality found in the sysv runlevel script will be send in another patch, once it is ready.

Olaf

Olaf Hering (4):
tools/hotplug: remove SELinux options from var-lib-xenstored.mount tools/hotplug: remove XENSTORED_ROOTDIR from service file tools/hotplug: remove EnvironmentFile from
xen-qemu-dom0-disk-backend.service
tools/hotplug: use xencommons as EnvironmentFile

 tools/hotplug/Linux/systemd/var-lib-xenstored.mount.in            | 4 +---
 tools/hotplug/Linux/systemd/xen-qemu-dom0-disk-backend.service.in | 1 -
 tools/hotplug/Linux/systemd/xenconsoled.service.in                | 2 +-
 tools/hotplug/Linux/systemd/xenstored.service.in                  | 1 -
 4 files changed, 2 insertions(+), 6 deletions(-)
#1 lore raw

PATCH v2 1/4 tools/hotplug: remove SELinux options from var-lib-xenstored.mount

Using SELinux mount options per default breaks several systems. Either the context= mount option is not known at all to the kernel, or the default value "none" is unknown to SELinux. In both cases the unit will fail.

The proper place to specify mount options is /etc/fstab. Appearently systemd is kind enough to use values from there even if Options= or What= is specified in a .mount file.

Remove XENSTORED_MOUNT_CTX, the reference to a non-existant EnvironmentFile and trim default Options= for the mount point.

The removed code was first mentioned in the patch referenced below, with the following description:
...
* Some systems define the selinux context in the systemd Option for the /var/lib/xenstored tmpfs:

       Options=mode=755,context="system_u:object_r:xenstored_var_lib_t:s0"

For the upstream version we remove that and let systems specify the context on their system /etc/default/xenstored or /etc/sysconfig/xenstored $XENSTORED_MOUNT_CTX variable
...
It is nowhere stated (on xen-devel) what "Some systems" means, which is unfortunately common practice in nearly all opensource projects.
http://lists.xenproject.org/archives/html/xen-devel/2014-03/msg02462.html

Cc Ian Jackson <[email protected]>
Cc Stefano Stabellini <[email protected]>
Cc Ian Campbell <[email protected]>
Cc Wei Liu <[email protected]>
Cc Anthony PERARD <[email protected]>
Cc M A Young <[email protected]>
Cc Luis R. Rodriguez <[email protected]>
---
 tools/hotplug/Linux/systemd/var-lib-xenstored.mount.in | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
tools/hotplug/Linux/systemd/var-lib-xenstored.mount.in +1 -3
index d5e04db..11a7d50 100644
@@ -6,9 +6,7 @@ ConditionPathExists=/proc/xen/capabilities
 RefuseManualStop=true
 
 [Mount]
-Environment=XENSTORED_MOUNT_CTX=none
-EnvironmentFile=-@CONFIG_DIR@/@CONFIG_LEAF_DIR@/xenstored
 What=xenstore
 Where=@XEN_LIB_STORED@
 Type=tmpfs
-Options=mode=755,context="$XENSTORED_MOUNT_CTX"
+Options=mode=755
#2 lore raw

PATCH v2 2/4 tools/hotplug: remove XENSTORED_ROOTDIR from service file

In reply to Olaf Hering

There is no need to export XENSTORED_ROOTDIR. This variable can be enabled in sysconfig/xencommons. If the variable is unset xenstored will automatically use @XEN_LIB_STORED@.

Cc Ian Jackson <[email protected]>
Cc Stefano Stabellini <[email protected]>
Cc Ian Campbell <[email protected]>
Cc Wei Liu <[email protected]>
---
 tools/hotplug/Linux/systemd/xenstored.service.in | 1 -
 1 file changed, 1 deletion(-)
tools/hotplug/Linux/systemd/xenstored.service.in +0 -1
index 780bdd6..0f0ac58 100644
@@ -9,7 +9,6 @@ ConditionPathExists=/proc/xen/capabilities
 [Service]
 Type=notify
 Environment=XENSTORED_ARGS=
-Environment=XENSTORED_ROOTDIR=@XEN_LIB_STORED@
 Environment=XENSTORED=@XENSTORED@
 EnvironmentFile=-@CONFIG_DIR@/@CONFIG_LEAF_DIR@/xencommons
 ExecStartPre=/bin/grep -q control_d /proc/xen/capabilities
#3 lore raw

PATCH v2 3/4 tools/hotplug: remove EnvironmentFile from xen-qemu-dom0-disk-backend.service

In reply to Olaf Hering

The references Environment file does not exist, and the service file does not make use of variables anyway.

Cc Ian Jackson <[email protected]>
Cc Stefano Stabellini <[email protected]>
Cc Ian Campbell <[email protected]>
Cc Wei Liu <[email protected]>
---
 tools/hotplug/Linux/systemd/xen-qemu-dom0-disk-backend.service.in | 1 -
 1 file changed, 1 deletion(-)
tools/hotplug/Linux/systemd/xen-qemu-dom0-disk-backend.service.in +0 -1
index 0a5807a..274cec0 100644
@@ -8,7 +8,6 @@ ConditionPathExists=/proc/xen/capabilities
 
 [Service]
 Type=simple
-EnvironmentFile=-@CONFIG_DIR@/@CONFIG_LEAF_DIR@/xenstored
 PIDFile=@XEN_RUN_DIR@/qemu-dom0.pid
 ExecStartPre=/bin/grep -q control_d /proc/xen/capabilities
 ExecStartPre=/bin/mkdir -p @XEN_RUN_DIR@
#4 lore raw

PATCH v2 4/4 tools/hotplug: use xencommons as EnvironmentFile

In reply to Olaf Hering

The referenced sysconfig/xenconsoled does not exist. If anything needs to be specified it has to go into the existing sysconfig/xencommons file.

Cc Ian Jackson <[email protected]>
Cc Stefano Stabellini <[email protected]>
Cc Ian Campbell <[email protected]>
Cc Wei Liu <[email protected]>
---
 tools/hotplug/Linux/systemd/xenconsoled.service.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/hotplug/Linux/systemd/xenconsoled.service.in +1 -1
index cb44cd6..74d0428 100644
@@ -9,7 +9,7 @@ Type=simple
 Environment=XENCONSOLED_ARGS=
 Environment=XENCONSOLED_LOG=none
 Environment=XENCONSOLED_LOG_DIR=@XEN_LOG_DIR@/console
-EnvironmentFile=-@CONFIG_DIR@/@CONFIG_LEAF_DIR@/xenconsoled
+EnvironmentFile=-@CONFIG_DIR@/@CONFIG_LEAF_DIR@/xencommons
 PIDFile=@XEN_RUN_DIR@/xenconsoled.pid
 ExecStartPre=/bin/grep -q control_d /proc/xen/capabilities
 ExecStartPre=/bin/mkdir -p ${XENCONSOLED_LOG_DIR}
#5 lore raw
In reply to Olaf Hering
Quoted 3 lines · Olaf Hering

This is a resend of this series, with just the low hanging fruits:
http://lists.xenproject.org/archives/html/xen-devel/2014-12/msg00669.html

This looks like it would fix some of the issues I saw. I will test it over today.

Please also CC Michael (Fedora Xen maintainer) on these changes (I've CC-ed him here).

The mentioned wrapper to run xenstored from systemd without duplicate

Quoted 18 lines

functionality found in the sysv runlevel script will be send in another patch, once it is ready.

Olaf

Olaf Hering (4):
tools/hotplug: remove SELinux options from var-lib-xenstored.mount tools/hotplug: remove XENSTORED_ROOTDIR from service file tools/hotplug: remove EnvironmentFile from
xen-qemu-dom0-disk-backend.service
tools/hotplug: use xencommons as EnvironmentFile

 tools/hotplug/Linux/systemd/var-lib-xenstored.mount.in            | 4 +---
 tools/hotplug/Linux/systemd/xen-qemu-dom0-disk-backend.service.in | 1 -
 tools/hotplug/Linux/systemd/xenconsoled.service.in                | 2 +-
 tools/hotplug/Linux/systemd/xenstored.service.in                  | 1 -
 4 files changed, 2 insertions(+), 6 deletions(-)
#6 lore raw
Quoted 7 lines · Konrad Rzeszutek Wilk
Quoted 2 lines · Olaf Hering

This is a resend of this series, with just the low hanging fruits:
http://lists.xenproject.org/archives/html/xen-devel/2014-12/msg00669.html

This looks like it would fix some of the issues I saw. I will test it over today.
Please also CC Michael (Fedora Xen maintainer) on these changes (I've CC-ed him here).

It would be nice to know if the entire chain of dependencies fails, or just that unit. Furthermore it would be nice to know if there needs to be anyhing related to SELinux in the xen sources. In other words, would xenstored behave correctly if that tmpfs mount would be done without any options?

Olaf

#7 lore raw
Quoted 10 lines · Olaf Hering
Quoted 7 lines · Konrad Rzeszutek Wilk
Quoted 2 lines · Olaf Hering

This is a resend of this series, with just the low hanging fruits:
http://lists.xenproject.org/archives/html/xen-devel/2014-12/msg00669.html

This looks like it would fix some of the issues I saw. I will test it over today.
Please also CC Michael (Fedora Xen maintainer) on these changes (I've CC-ed him here).

Quoted 5 lines

It would be nice to know if the entire chain of dependencies fails, or just that unit. Furthermore it would be nice to know if there needs to be anyhing related to SELinux in the xen sources. In other words, would xenstored behave correctly if that tmpfs mount would be done without any options?

Yes, you do need to set explicit selinux permissions when mounting /var/lib/xenstored as otherwise it gets a tmpfs selinux context which xenstored can't use in enforcing mode.

The other selinux issue is that it seems you can't run xenstored through a shell script wrapper, because it still has startup shell script selinux permissions when it is trying to connect to the sockets, so it doesn't work. It does work if you run xenstored directly from the systemd file.

Michael Young

#8 lore raw
Quoted 3 lines · M A Young

Yes, you do need to set explicit selinux permissions when mounting /var/lib/xenstored as otherwise it gets a tmpfs selinux context which xenstored can't use in enforcing mode.

Is that "enforcing mode" the default? And would it be too cumbersome to have these context settings in fstab?

Quoted 4 lines

The other selinux issue is that it seems you can't run xenstored through a shell script wrapper, because it still has startup shell script selinux permissions when it is trying to connect to the sockets, so it doesn't work. It does work if you run xenstored directly from the systemd file.

This sounds like xenstored has to parse the possible environment variables found in sysconfig.xencommons all by itself? Is there perhaps a way out of the SELinux jail?

Olaf

#9 lore raw
Quoted 3 lines · Olaf Hering

This sounds like xenstored has to parse the possible environment variables found in sysconfig.xencommons all by itself? Is there perhaps a way out of the SELinux jail?

Does all that work with the sysv runlevel scripts?

Olaf

#10 lore raw
Quoted 7 lines · Olaf Hering
Quoted 3 lines · Olaf Hering

This sounds like xenstored has to parse the possible environment variables found in sysconfig.xencommons all by itself? Is there perhaps a way out of the SELinux jail?

Does all that work with the sysv runlevel scripts?

I assume so, but Fedora hasn't used the upstream sysv scripts for a long time (from before I started maintaining it) so I don't know for sure.

Michael Young

#11 lore raw
In reply to Olaf Hering
Quoted 7 lines · Olaf Hering
Quoted 3 lines · M A Young

Yes, you do need to set explicit selinux permissions when mounting /var/lib/xenstored as otherwise it gets a tmpfs selinux context which xenstored can't use in enforcing mode.

Is that "enforcing mode" the default? And would it be too cumbersome to

Yes.

Quoted 1 line

have these context settings in fstab?

That would be a question for the SELinux maintainer..

Quoted 9 lines
Quoted 5 lines

The other selinux issue is that it seems you can't run xenstored through a shell script wrapper, because it still has startup shell script selinux permissions when it is trying to connect to the sockets, so it doesn't work. It does work if you run xenstored directly from the systemd file.

This sounds like xenstored has to parse the possible environment variables found in sysconfig.xencommons all by itself? Is there perhaps a way out of the SELinux jail?

We do want to be in the SELinux jail as you call it.

This is what it looks to be doing:

[konrad@laptop SOURCES]$ more var-lib-xenstored.mount [Unit]
Description=mount xenstore file system ConditionPathExists=/proc/xen RefuseManualStop=true

[Mount]
What=xenstore
Where=/var/lib/xenstored
Type=tmpfs Options=mode=755,context="system_u:object_r:xenstored_var_lib_t:s0" [konrad@laptop SOURCES]$

I wonder if we can detect the context during build-time (an autoconf function that checks whether the build is done for Fedora?)

But what if the version of Fedora is different and the object is called something else?

Quoted 2 lines

Olaf

#12 lore raw
Quoted 4 lines · Konrad Rzeszutek Wilk

I wonder if we can detect the context during build-time (an autoconf function that checks whether the build is done for Fedora?)
But what if the version of Fedora is different and the object is called something else?

Exactly. The build host is not the host where the code runs. It just happens to be the same in your case.

This and the fact that xenstored cant (appearently) be launched via a wrapper script makes we wonder how to deal with SELinux...

Olaf

#13 lore raw
Quoted 11 lines · Olaf Hering
Quoted 1 line · Konrad Rzeszutek Wilk

I wonder if we can detect the context during build-time (an autoconf

function

Quoted 2 lines

that checks whether the build is done for Fedora?)
But what if the version of Fedora is different and the object is

called

Quoted 1 line

something else?

Exactly. The build host is not the host where the code runs. It just happens to be the same in your case.

The file I pasted was the one from the SOURCES directory. Since the end result is an RPM and it works without issues I would surmise the context is OK - for this version of Fedora. But maybe older ones had this?

Quoted 5 lines

This and the fact that xenstored cant (appearently) be launched via a wrapper script makes we wonder how to deal with SELinux...

Olaf