From: Kay Sievers <kay.sievers@vrfy.org>
To: linux-hotplug@vger.kernel.org
Subject: Re: [PATCH] allow to specify node permissions in the rule
Date: Thu, 11 Mar 2004 02:18:43 +0000 [thread overview]
Message-ID: <20040311021843.GD31657@vrfy.org> (raw)
In-Reply-To: <20040307011223.GA22054@vrfy.org>
[-- Attachment #1: Type: text/plain, Size: 1114 bytes --]
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
[-- Attachment #2: 01-permissions-test.patch --]
[-- Type: text/plain, Size: 1354 bytes --]
===== 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 => <<EOF
+BUS="scsi", KERNEL="sda", NAME="node", OWNER="5000", MODE="0444"
+EOF
+ },
);
# set env
@@ -556,6 +566,26 @@
udev("add", $config->{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";
next prev parent reply other threads:[~2004-03-11 2:18 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-03-07 1:12 [PATCH] allow to specify node permissions in the rule Kay Sievers
2004-03-10 22:41 ` Greg KH
2004-03-11 2:18 ` Kay Sievers [this message]
2004-03-12 1:07 ` Greg KH
2004-03-12 2:20 ` Kay Sievers
2004-03-12 10:43 ` Olaf Hering
2004-03-12 11:19 ` Kay Sievers
2004-03-12 11:30 ` Olaf Hering
2004-03-12 11:35 ` Kay Sievers
2004-03-12 16:43 ` Greg KH
2004-03-12 17:44 ` Greg KH
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20040311021843.GD31657@vrfy.org \
--to=kay.sievers@vrfy.org \
--cc=linux-hotplug@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).