Skip to contentSkip to conversation

qemu-iotests: Don't run the test when user is root

RFC Eric Blake 2 participants 2 messages Nov 30, 2018 2 messages not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): cb554c04ee50ac970fa10edaa090982bef18f673.1543593569.git.alifm@linux.ibm.com

Eric Blake

author
#2 lore raw

Adding qemu-devel - all patches should go there, especially if you want to get Peter's attention that this might be a 3.1 candidate if we have other reasons to spin -rc4.

Quoted 18 lines · Farhan Ali

Test 232 creates image files with read-only permission and expects an error message when trying to access the image files with read-only and auto-read-only turned off.

Don't run as root user, since root can open files with read/write access for read-only files.

---
  tests/qemu-iotests/232 | 8 ++++++++
  1 file changed, 8 insertions(+)
tests/qemu-iotests/232 +0 -0
index 0708b8b..05d5f2f 100755
@@ -41,6 +41,14 @@ _supported_fmt generic
  _supported_proto file

tests/qemu-iotests/232 _supported_fmt generic · line 51

Quoted 10 lines
tests/qemu-iotests/232 +8 -0
  _supported_os Linux
 
+tmp='file'
+touch $tmp
+chmod a-w $tmp
+if [ -w $tmp ]
+then
+    _notrun "Cannot run this test as root user"
+fi
+

I know you just copied from my suggestion, but now looking at it, this leaves 'tmp' around in the directory for both success and skip. Better might be to just check whether $TEST_IMG is writable, immediately after the existing 'chmod a-w $TEST_IMG' line (Hmm - that line is already broken for not quoting "$TEST_IMG" in case it contains whitespace).

I don't see this being a reason for -rc4 on its own (most people don't run iotests as root); and the fact that we're still working on the final contents of what the patch should contain, as well as the fact that the patch doesn't affect the main binaries, means that if it were up to me, I'd defer it to 4.0. Kevin may have a different opinion, though, since it is his test, and new to 3.1.

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org
#3 lore raw
Quoted 24 lines · Eric Blake

Adding qemu-devel - all patches should go there, especially if you want to get Peter's attention that this might be a 3.1 candidate if we have other reasons to spin -rc4.

Quoted 21 lines · Farhan Ali

Test 232 creates image files with read-only permission and expects an error message when trying to access the image files with read-only and auto-read-only turned off.

Don't run as root user, since root can open files with read/write access for read-only files.

---
  tests/qemu-iotests/232 | 8 ++++++++

  1 file changed, 8 insertions(+)
tests/qemu-iotests/232 +0 -0
index 0708b8b..05d5f2f 100755
@@ -41,6 +41,14 @@ _supported_fmt generic

  _supported_proto file
  _supported_os Linux

tests/qemu-iotests/232 +2 -0
+tmp='file'
+touch $tmp
Quoted 8 lines

tests/qemu-iotests/232

Quoted 6 lines
tests/qemu-iotests/232 +6 -0
+chmod a-w $tmp
+if [ -w $tmp ]
+then
+    _notrun "Cannot run this test as root user"
+fi
+

I know you just copied from my suggestion, but now looking at it, this leaves 'tmp' around in the directory for both success and skip. Better might be to just check whether $TEST_IMG is writable, immediately after the existing 'chmod a-w $TEST_IMG' line (Hmm - that line is already broken for not quoting "$TEST_IMG" in case it contains whitespace).

Ah yes, I forgot about the fact the 'file' will linger around. I will spin up a v3.

Quoted 3 lines

I don't see this being a reason for -rc4 on its own (most people don't run iotests as root); and the fact that we're still working on the final contents of what the patch should contain, as well as the fact that the patch doesn't affect the main binaries, means that if it were up to me, I'd defer it to 4.0. Kevin may have a different opinion, though, since it is his test, and new to 3.1.