From mboxrd@z Thu Jan 1 00:00:00 1970 From: Kay Sievers Date: Thu, 11 Mar 2004 02:18:43 +0000 Subject: Re: [PATCH] allow to specify node permissions in the rule Message-Id: <20040311021843.GD31657@vrfy.org> MIME-Version: 1 Content-Type: multipart/mixed; boundary="ZARJHfwaSJQLOEUz" List-Id: References: <20040307011223.GA22054@vrfy.org> In-Reply-To: <20040307011223.GA22054@vrfy.org> To: linux-hotplug@vger.kernel.org --ZARJHfwaSJQLOEUz Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Wed, Mar 10, 2004 at 02:41:19PM -0800, Greg KH wrote: > On Sun, Mar 07, 2004 at 02:12:23AM +0100, Kay Sievers wrote: > > This allows to set the permissions along with the rule. > > > > This is not a general replacement for the permissions config, but it > > may be easier sometimes for the user to specify the permissions along > > with the rule, cause the permissions config file wants the final node > > name to match, which seems sometimes a bit difficult to guess, if > > format % chars are used in the NAME field. > > > > Any value not given in the rule is still be read from the permissions > > file or set to the default. This one will also work: > > > > BUS="usb", KERNEL="video*", NAME="my-%k", OWNER="$local" > > > > A few words to man page are also added and add_perm_dev() is moved into > > namedev_parse.c where it belongs to. > > Hm, as enough people have asked for something like this, I've applied > it. > > 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. Kay --ZARJHfwaSJQLOEUz Content-Type: text/plain; charset=us-ascii Content-Disposition: inline; filename="01-permissions-test.patch" ===== test/udev-test.pl 1.45 vs edited ===== --- 1.45/test/udev-test.pl Thu Mar 11 01:36:18 2004 +++ edited/test/udev-test.pl Thu Mar 11 03:14:35 2004 @@ -524,6 +524,16 @@ 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"; --ZARJHfwaSJQLOEUz-- ------------------------------------------------------- This SF.Net email is sponsored by: IBM Linux Tutorials Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click _______________________________________________ Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net Linux-hotplug-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel