[PATCH] udev-test.pl: fix interaction setgid with permission tests

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The following patch assumes the earlier MODE field patch is applied.

Regards,
Erik



If the udev build directory has the setgid-bit set,
then gid of the build directory propagates to the test directory
and the dummy udev_root directory inside this.  This breaks the
permission tests.  Fix this by explicitly setting gid and mode of
udev_root.
---
 test/udev-test.pl |   15 +++++++++++----
 1 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/test/udev-test.pl b/test/udev-test.pl
index 8f1030d..72b4aef 100755
--- a/test/udev-test.pl
+++ b/test/udev-test.pl
@@ -1753,6 +1753,15 @@ sub symlink_test {
 	}
 }
 
+sub make_udev_root {
+	system("rm -rf $udev_root");
+	mkdir($udev_root) || die "unable to create udev_root: $udev_root\n";
+	# setting group and mode of udev_root ensures the tests work
+	# even if the parent directory has setgid bit enabled.
+	chown (0, 0, $udev_root) || die "unable to chown $udev_root\n";
+	chmod (0755, $udev_root) || die "unable to chmod $udev_root\n";
+}
+
 sub run_test {
 	my ($rules, $number) = @_;
 
@@ -1825,8 +1834,7 @@ sub run_test {
 	print "\n";
 
 	if (defined($rules->{option}) && $rules->{option} eq "clean") {
-		system("rm -rf $udev_root");
-		mkdir($udev_root) || die "unable to create udev_root: $udev_root\n";
+		make_udev_root ();
 	}
 
 }
@@ -1839,8 +1847,7 @@ if (!($<==0)) {
 }
 
 # prepare
-system("rm -rf $udev_root");
-mkdir($udev_root) || die "unable to create udev_root: $udev_root\n";
+make_udev_root ();
 
 # create config file
 open CONF, ">$udev_conf" || die "unable to create config file: $udev_conf";
-- 
1.5.5.1.g1fbb5

--
To unsubscribe from this list: send the line "unsubscribe linux-hotplug" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel]     [Linux DVB]     [Asterisk Internet PBX]     [DCCP]     [Netdev]     [X.org]     [Util Linux NG]     [Fedora Women]     [ALSA Devel]     [Linux USB]

  Powered by Linux