Skip to contentSkip to conversation

generic/317,318: fail gracefully if userns not supported

PATCH In review Eric Sandeen 4 participants 4 messages Jun 13, 2014 – Jun 17, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 generic/317,318: fail gracefully if userns not supported

generic/317 and generic/318 fail un-gracefully on older kernels which don't support userns; fix that by running a simple test as a prerequisite and fail gracefully if needed.

---

tests/generic/317 +2 -0
index e016a42..8919db2 100755
@@ -56,6 +56,8 @@ _supported_os Linux
 [ -x $nsexec  ] || _notrun "$nsexec executable not found"
 [ -x $lstat64 ] || _notrun "$lstat64 executable not found"
 
+$nsexec -U true 2>/dev/null || _notrun "user namespaces not supported by this kernel"
+
 rm -f $seqres.full
 
 _require_scratch
tests/generic/318 +2 -0
index 0bfbba0..0212712 100755
@@ -57,6 +57,8 @@ _supported_os Linux
 
 [ -x $nsexec ] || _notrun "$nsexec executable not found"
 
+$nsexec -U true 2>/dev/null || _notrun "user namespaces not supported by this kernel"
+
 rm -f $seqres.full
 
 _require_scratch
#1 lore raw
Quoted 12 lines · Eric Sandeen

generic/317 and generic/318 fail un-gracefully on older kernels which don't support userns; fix that by running a simple test as a prerequisite and fail gracefully if needed.

---

tests/generic/317 +0 -0
index e016a42..8919db2 100755

tests/generic/317 _supported_os Linux · line 60

Quoted 5 lines
tests/generic/317 +2 -0
@@ -56,6 +56,8 @@ _supported_os Linux
 [ -x $nsexec  ] || _notrun "$nsexec executable not found"
 [ -x $lstat64 ] || _notrun "$lstat64 executable not found"
 
+$nsexec -U true 2>/dev/null || _notrun "user namespaces not supported by this kernel"
+

Can you turn this into a _requires_user_namespaces()?

i.e. check for $nsexec and the kernel support in one function.

Cheers,

Dave.

Signature · 2 lines
Dave Chinner
[email protected]
#2 lore raw

PATCH v2 1/1 generic/317,318: fail gracefully if userns not supported

In reply to Eric Sandeen

generic/317 and generic/318 fail un-gracefully on older kernels which don't support userns; fix that by running a simple test as a prerequisite and fail gracefully if needed.

Roll that in with the test for executable presence, and make a new _require_userns()

---

V2: _require_userns

common/rc +6 -0
index f27ee53..97ac862 100644
@@ -2115,6 +2115,12 @@ _require_relatime()
 	_scratch_unmount
 }
 
+_require_userns()
+{
+	[ -x src/nsexec ] || _notrun "src/nsexec executable not found"
+	src/nsexec -U true 2>/dev/null || _notrun "userns not supported by this kernel"
+}
+
 _create_loop_device()
 {
 	file=$1
tests/generic/317 +1 -1
index e016a42..efa37c7 100755
@@ -53,7 +53,6 @@ _supported_fs generic
 # only Linux supports user namespace
 _supported_os Linux
 
-[ -x $nsexec  ] || _notrun "$nsexec executable not found"
 [ -x $lstat64 ] || _notrun "$lstat64 executable not found"
 
 rm -f $seqres.full
@@ -62,6 +61,7 @@ _require_scratch
 _need_to_be_root
 _require_user
 _require_ugid_map
+_require_userns
 qa_user_id=`grep $qa_user /etc/passwd |awk -F: '{print $3}'`
 
 _filter_output()
tests/generic/318 +1 -2
index 0bfbba0..8237434 100755
@@ -55,8 +55,6 @@ _supported_fs generic
 # only Linux supports user namespace
 _supported_os Linux
 
-[ -x $nsexec ] || _notrun "$nsexec executable not found"
-
 rm -f $seqres.full
 
 _require_scratch
@@ -64,6 +62,7 @@ _need_to_be_root
 _acl_setup_ids
 _require_acls
 _require_ugid_map
+_require_userns
 ns_acl1=0
 ns_acl2=`expr $acl2 - $acl1`
 ns_acl3=`expr $acl3 - $acl1`
Reviewed-by on v2 1/1
#3 lore raw
Quoted 11 lines · Eric Sandeen

Date: Mon, 16 Jun 2014 21:44:05 -0500
From: Eric Sandeen <[email protected]>
To: Eric Sandeen <[email protected]>, [email protected]
Subject: [PATCH V2] generic/317,318: fail gracefully if userns not supported

generic/317 and generic/318 fail un-gracefully on older kernels which don't support userns; fix that by running a simple test as a prerequisite and fail gracefully if needed.

Roll that in with the test for executable presence, and make a new _require_userns()

Looks good.

Quoted 70 lines

---

V2: _require_userns

common/rc +6 -0
index f27ee53..97ac862 100644
@@ -2115,6 +2115,12 @@ _require_relatime()
 	_scratch_unmount
 }
 
+_require_userns()
+{
+	[ -x src/nsexec ] || _notrun "src/nsexec executable not found"
+	src/nsexec -U true 2>/dev/null || _notrun "userns not supported by this kernel"
+}
+
 _create_loop_device()
 {
 	file=$1
tests/generic/317 +1 -1
index e016a42..efa37c7 100755
@@ -53,7 +53,6 @@ _supported_fs generic
 # only Linux supports user namespace
 _supported_os Linux
 
-[ -x $nsexec  ] || _notrun "$nsexec executable not found"
 [ -x $lstat64 ] || _notrun "$lstat64 executable not found"
 
 rm -f $seqres.full
@@ -62,6 +61,7 @@ _require_scratch
 _need_to_be_root
 _require_user
 _require_ugid_map
+_require_userns
 qa_user_id=`grep $qa_user /etc/passwd |awk -F: '{print $3}'`
 
 _filter_output()
tests/generic/318 +1 -3
index 0bfbba0..8237434 100755
@@ -55,8 +55,6 @@ _supported_fs generic
 # only Linux supports user namespace
 _supported_os Linux
 
-[ -x $nsexec ] || _notrun "$nsexec executable not found"
-
 rm -f $seqres.full
 
 _require_scratch
@@ -64,6 +62,7 @@ _need_to_be_root
 _acl_setup_ids
 _require_acls
 _require_ugid_map
+_require_userns
 ns_acl1=0
 ns_acl2=`expr $acl2 - $acl1`
 ns_acl3=`expr $acl3 - $acl1`
 
--

To unsubscribe from this list: send the line "unsubscribe fstests" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html