From: kay.sievers@vrfy.org Date: Fri, 12 Mar 2004 08:58:33 +0000 (-0800) Subject: [PATCH] add permission tests X-Git-Tag: 022~12 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=commitdiff_plain;h=c612a0acc8c45303b5c40538b87e406ac22a26ef;ds=sidebyside [PATCH] add permission tests > Any chance on being able to add a test for this kind of stuff to the > udev-test.pl script? Sure, not brilliant but seems to work :) Only numeric id's are supported so far. --- diff --git a/test/udev-test.pl b/test/udev-test.pl index c12a21ee3..e345b20c5 100644 --- a/test/udev-test.pl +++ b/test/udev-test.pl @@ -522,6 +522,16 @@ EOF BUS="scsi", KERNEL="sda", SYMLINK="symlink-only1" BUS="scsi", KERNEL="sda", SYMLINK="symlink-only2" BUS="scsi", KERNEL="sda", NAME="link", SYMLINK="symlink0" +EOF + }, + { + desc => "permissions test", + subsys => "block", + devpath => "block/sda", + expected => "node", + perms => "5000::0444", + conf => <{subsys}, $config->{devpath}, \$config->{conf}); if (-e "$PWD/$udev_root$config->{expected}") { + if (defined($config->{perms})) { + my $wrong = 0; + my ($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size, + $atime, $mtime, $ctime, $blksize, $blocks) = stat("$PWD/$udev_root$config->{expected}"); + + $config->{perms} =~ m/^(.*):(.*):(.*)$/; + if ($1 ne "") { + if ($uid != $1) { $wrong = 1; }; + } + if ($2 ne "") { + if ($gid != $2) { $wrong = 1; }; + } + if ($3 ne "") { + if (($mode & 07777) != oct($3)) { $wrong = 1; }; + } + if ($wrong == 1) { + printf "expected permissions are: %i:%i:%#o\n", $1, $2, oct($3); + printf "created permissions are : %i:%i:%#o\n", $uid, $gid, $mode & 07777; + } + } print "add: ok "; } else { print "add: error\n";