Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 73064 - [PATCH] udev: thoughts about permission rules application
Summary: [PATCH] udev: thoughts about permission rules application
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: All All
: High normal (vote)
Assignee: Greg Kroah-Hartman (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-12-01 12:42 UTC by Gregorio Guidi (RETIRED)
Modified: 2005-02-08 13:35 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
udev-match-symlink-perms.patch (udev-match-symlink-perms.patch,1.25 KB, patch)
2004-12-01 12:43 UTC, Gregorio Guidi (RETIRED)
Details | Diff
udev-gentoo-rules.patch (udev-gentoo-rules.patch,1.17 KB, patch)
2004-12-03 15:02 UTC, Gregorio Guidi (RETIRED)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Gregorio Guidi (RETIRED) gentoo-dev 2004-12-01 12:42:35 UTC
The default configuration for udev includes permission rules as the following:

cdrom*:root:cdrom:0660
dvd:root:cdrom:0660
rdvd:root:cdrom:0660
cdroms/*:root:cdrom:0660

discs/*/*:root:disk:660

these are rarely effective, as they only match symlinks and not the actual 
device. In fact, I cannot think of an easy way to express the rule:
"assign the discs to the 'disk' group and the cdroms to the 'cdrom' group",
because udev cannot say whether e.g. 'hdc' is a disk or a cdrom.
More precisely, udev can say whether 'hdc' is a disk or a cdrom only looking
at the symlinks assigned to them... so here comes the question:

would it make sense to match the symlink names, and not only the real name,
against the permission rules? I would be interested in gregkh's opinion on 
that...

For those who are interested, I'm going to attach a working patch that does  that.
Comment 1 Gregorio Guidi (RETIRED) gentoo-dev 2004-12-01 12:43:32 UTC
Created attachment 45074 [details, diff]
udev-match-symlink-perms.patch
Comment 2 Greg Kroah-Hartman (RETIRED) gentoo-dev 2004-12-01 13:54:15 UTC
You can specify permissions in udev rules files for just this reason.

I suggest you make a modification to the default rules file, not a 
patch to udev itself.

If you do make such a patch, please attach it here and reopen the bug.
Comment 3 Gregorio Guidi (RETIRED) gentoo-dev 2004-12-01 15:50:25 UTC
Mmm... sorry but I miss the point.
Is it possible to write a default permission rule to discriminate
cdroms and discs, without changing the default /dev layout, and
without hardcoding their position on the ide bus?
Comment 4 Greg Kroah-Hartman (RETIRED) gentoo-dev 2004-12-03 10:53:15 UTC
Yes it is.  Look at the current rules that test for cdroms :)
Comment 5 Gregorio Guidi (RETIRED) gentoo-dev 2004-12-03 15:02:49 UTC
Created attachment 45228 [details, diff]
udev-gentoo-rules.patch

Ok, now I got it, thanks.

The attached mini-patch makes sure that by default cdroms and floppies
are assigned to the associated groups. This is important in case pam_console
is switched off by default (see bug 31877).
Comment 6 Greg Kroah-Hartman (RETIRED) gentoo-dev 2004-12-03 16:37:00 UTC
But you aren't naming the hd devices anymore.

Why did you take out the NAME="%k" section?
Comment 7 Gregorio Guidi (RETIRED) gentoo-dev 2004-12-04 01:11:50 UTC
Because I wanted to keep the rule that creates devfs-style symlinks to cdroms 
and disks, without making that rule block the rule parsing and prevent the 
subsequent rule being applied.
I left the disc creation to the default rule (assign "%k" name), but it could 
be added explicitely just below that, maybe something like this:

BUS="ide", KERNEL="hd*", NAME="%k", MODE="0660", GROUP="disk"
Comment 8 Gregorio Guidi (RETIRED) gentoo-dev 2004-12-08 03:30:52 UTC
Forgot to reopen.
Comment 9 Martin Schlemmer (RETIRED) gentoo-dev 2004-12-13 13:10:54 UTC
Dont the new ide-devfs.sh with the GROUP= support fix this?
Comment 10 Gregorio Guidi (RETIRED) gentoo-dev 2004-12-14 08:00:08 UTC
Indeed, the new ide-devfs.sh solves the original problem in a very clean way,
thanks.

My last last request is just to correctly set the group for floppy devices:

--- etc/udev/gentoo/udev.permissions.orig       2004-12-14 16:44:01.145414880 +0100
+++ etc/udev/gentoo/udev.permissions    2004-12-14 16:45:08.302205496 +0100
@@ -52,6 +52,7 @@

 # floppy devices
 fd[01]*:root:floppy:0660
+floppy/*:root:floppy:0660

 # audio devices
 dsp*:root:audio:0660

and then this bug can be closed.

By the way, you may want to apply this one, too:
(internal documentation of ide-devfs.sh)

--- extras/ide-devfs.sh.orig    2004-12-14 16:45:30.645808752 +0100
+++ extras/ide-devfs.sh 2004-12-14 16:45:56.201923632 +0100
@@ -2,7 +2,7 @@

 # udev external PROGRAM script
 # return devfs-names for ide-devices
-# BUS="ide", KERNEL="hd*", PROGRAM="/etc/udev/ide-devfs.sh %k %b %n", NAME="%k", SYMLINK="%c{1} %c{2}"
+# BUS="ide", KERNEL="hd*", PROGRAM="/etc/udev/ide-devfs.sh %k %b %n", NAME="%k", SYMLINK="%c{1} %c{2}", GROUP="%c{3}"

 HOST="${2%\.[0-9]}"
 TARGET="${2#[0-9]\.}"
Comment 11 Martin Schlemmer (RETIRED) gentoo-dev 2004-12-15 11:00:27 UTC
Right.  Greg, do you mind ... ?
Comment 12 Greg Kroah-Hartman (RETIRED) gentoo-dev 2004-12-15 16:24:57 UTC
Will fix in next udev release.
Comment 13 Greg Kroah-Hartman (RETIRED) gentoo-dev 2005-02-08 13:35:26 UTC
Ok, now it's fixed...