Skip to contentSkip to conversation

Add creation of dev/mapper/control to nightly tests.

PATCH New Dave Wysochanski 2 participants 4 messages Apr 15, 2010 – Apr 16, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Add creation of dev/mapper/control to nightly tests.

This works around a problem with using the /tmp directory for
the dev/mapper/control node. The failure I saw was this.
When LVM_TEST_DIR was rooted at /tmp/..., the first dmsetup command would fail with this error:
/tmp/LVMTEST26998.J29FayOVWy/dev/mapper/control: matchpathcon 0020000 failed:

The second dmsetup command would always succeed though. Also, when LVM_TEST_DIR was rooted at /root/..., this failure would not occur.

I stepped through this in gdb and found that mknod was indeed creating the control node correctly, however, matchpathcon would fail. The reason it did not fail the second or subsequent iterations of dmsetup is that the control node was already there, and dmsetup does not try to set the selinux security context in that case. One clue may be in the fact that it seems the default security context for files in /tmp/... is <<none>>:
matchpathcon /root/LVMTEST26998.J29FayOVWy/dev/mapper/control
/root/LVMTEST26998.J29FayOVWy/dev/mapper/control system_u:object_r:admin_home_t:s0
matchpathcon /tmp/LVMTEST26998.J29FayOVWy/dev/mapper/control
/tmp/LVMTEST26998.J29FayOVWy/dev/mapper/control <<none>>
matchpathcon /tmp/LVMTEST26998.J29FayOVWy/dev/mapper/control
/tmp/LVMTEST26998.J29FayOVWy/dev/mapper/control <<none>>
matchpathcon /dev/mapper/control
/dev/mapper/control system_u:object_r:lvm_control_t:s0

I would imagine this is why the matchpathcon() call fails. There may be a better fix for this but at this point for the nightly tests we can create the 'control' node explicitly.

---
 test/test-utils.sh |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
test/test-utils.sh +2 -0
index c2755c6..92b5047 100644
@@ -83,6 +83,8 @@ prepare_testroot() {
 	export LVM_SYSTEM_DIR=$TESTDIR/etc
 	export DM_DEV_DIR=$TESTDIR/dev
 	mkdir $LVM_SYSTEM_DIR $DM_DEV_DIR $DM_DEV_DIR/mapper $TESTDIR/lib
+	minor=`cat /proc/misc | grep device-mapper | awk '{print $1}'`
+	mknod $DM_DEV_DIR/mapper/control c 10 $minor
 
 	cd $TESTDIR
 
Signature · 1 line
1.6.2.5
#1 lore raw

PATCH 1/1 Add creation of dev/mapper/control to nightly tests.

Quoted 1 line · Dave Wysochanski

/tmp/LVMTEST26998.J29FayOVWy/dev/mapper/control: matchpathcon 0020000 failed:

So after creating the subdir in /tmp, set its selinux label to something more appropriate.

Alasdair

#2 lore raw

PATCH 1/1 Add creation of dev/mapper/control to nightly tests.

In reply to Dave Wysochanski

test/test-utils.sh prepare_testroot() { · line 87

Quoted 2 lines · Dave Wysochanski
test/test-utils.sh +2 -0
+	minor=`cat /proc/misc | grep device-mapper | awk '{print $1}'`
+	mknod $DM_DEV_DIR/mapper/control c 10 $minor

Just to be clear, I don't want to see this hack enter the tree, and the problem is in the machine's configuration, not the test scripts. At this stage we are not trying to test the selinux policy through these scripts. Maybe we can do that soon: I don't think it would be very hard to do.

If you enable selinux, then you abide by its restrictions. If you really don't like the default policy (which sensibly doesn't let you run tests like these in /tmp) you change it ('semanage fcontext' on the top-level testing dir).

Alasdair

#3 lore raw

PATCH 1/1 Add creation of dev/mapper/control to nightly tests.

Quoted 9 lines · Alasdair G Kergon

test/test-utils.sh prepare_testroot() { · line 87

Quoted 2 lines · Dave Wysochanski
test/test-utils.sh +2 -0
+	minor=`cat /proc/misc | grep device-mapper | awk '{print $1}'`
+	mknod $DM_DEV_DIR/mapper/control c 10 $minor

Just to be clear, I don't want to see this hack enter the tree, and the problem is in the machine's configuration, not the test scripts. At this stage we are not trying to test the selinux policy through these scripts. Maybe we can do that soon: I don't think it would be very hard to do.

Quoted 5 lines

If you enable selinux, then you abide by its restrictions. If you really don't like the default policy (which sensibly doesn't let you run tests like these in /tmp) you change it ('semanage fcontext' on the top-level testing dir).

Sure - I will work on a better patch.