LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices



Reply
 
Search this Thread
Old 02-18-2009, 11:49 PM   #1
orbit
Member
 
Registered: Sep 2006
Location: Australia
Distribution: Slackware
Posts: 176

Rep: Reputation: 30
First UDEV Rule, Not quite there ...


Hello,
I am trying to build a udev rule that will enable all floppy devices and usb devices to automatically have full r/w/x access allowed to everyone.

This is my first attempt at a udev rule, so please be patient.

I have started on this document : http://reactivated.net/writing_udev_rules.html and am moving through it.

What I have made so far (in /etc/udev/rules.d/98-local-rules) is the following:

Code:
KERNEL=="sd[0-9]*", NAME="sd/%n", SYMLINK+="%k", GROUP="plugdev", MODE="0666"
KERNEL=="sd[0-9]*", OWNER="user", MODE="0666"
KERNEL=="fd[0-9]*", NAME="fd/%n", SYMLINK+="%k", GROUP="floppy", MODE="0666"
KERNEL=="fd[0-9]*", OWNER="user", MODE="0666"
Unfortunately, after a reboot, this seems to have had no effect whatsoever on my fd*/sd* permissions.

So, before I get lost on a wrong tangent; can anyone offer firstly confirmation that I am on the right path with this syntax, and secondly a pointer in where I went wrong with it?

Thanks for any positive advice
 
Old 02-19-2009, 12:34 AM   #2
DavidHindman
Member
 
Registered: Dec 2008
Distribution: Slack 13 + JWM
Posts: 101

Rep: Reputation: 23
I'm not an expert, but I wrote some udev rules a couple of weeks ago.

I think man udev gives some critical information that's not in the document you cited.

There are two sets of udev rules. The default set of rules is in /lib/udev/rules.d/. The custom rule set is in /etc/udev/rules.d/.

If your custom udev rules seem to have no effect, maybe your custom rules are failing to override the default udev rules in /lib/udev/rules.d/.

For example, the floppy devices fd* are created in /lib/udev/rules.d/50-udev-default-rules. In order to override those rules, your custom rules file would need to be in /etc/udev/rules.d/ 50-udev-default-rules.

Anyway, take a look at the man page for udev and see if you are properly taking into account the existence of the default rules already in /lib/udev/rules.d/.

Last edited by DavidHindman; 02-19-2009 at 12:40 AM. Reason: Correct an error
 
Old 02-19-2009, 02:15 AM   #3
orbit
Member
 
Registered: Sep 2006
Location: Australia
Distribution: Slackware
Posts: 176

Original Poster
Rep: Reputation: 30
Hi DavidHindman, thanks for your response.

I know what you mean about 'master' rules not allowing user rules to be run, but after looking ... I don't have a /lib/udev/rules.d/ directory? Are you using Slackware .. or another Linux?

So anyway I scrapped the first attempt and tried again, this time I created:

Code:
BUS=="usb", KERNEL="sd[a-z][1-9]",NAME="sd/%n", SYMLINK+="%k", GROUP="users", Mode=="0777"
KERNEL=="sd[0-9]*", OWNER="user", MODE="0777"
BUS=="floppy", KERNEL=="fd[0-9]*", NAME="fd/%n", SYMLINK+="%k", GROUP="users", MODE="0777"
KERNEL=="fd[0-9]*", OWNER="user", MODE="0777"
I saved this in /etc/udev/rules.d/98-local.rules ... then rebooted.

Result is that absolutely nothing has changed? USB and floppies are still mounting [ user - root : drwxr-xr-x ]

Am I missing something here? Why after two attempts has nothing changed (for good or bad)? Am I working on the right file?

Right now I am having a very hard time getting my head around these (seemingly thousands) of Options and Variables in UDEV syntax, and am quite confused as to what is the correct way to go.

So if anyone can shed some light as to whether I am even remotely on track .. or ... way out of the ballpark, I would really appreciate it.


Thanks very much for any assistance.

Cheers

.

Last edited by orbit; 02-19-2009 at 02:17 AM.
 
Old 02-19-2009, 02:53 AM   #4
DavidHindman
Member
 
Registered: Dec 2008
Distribution: Slack 13 + JWM
Posts: 101

Rep: Reputation: 23
Quote:
Originally Posted by orbit View Post
Are you using Slackware?
Yes, Slackware 12.2. I should have specified the version. Maybe yours is different.

Code:
root@barsoom:~# ls /lib/udev/rules.d/
40-alsa.rules          60-persistent-input.rules          80-drivers.rules
40-infiniband.rules    60-persistent-storage-tape.rules   80-libnjb.rules
40-isdn.rules          60-persistent-storage.rules        80-libpisock.rules
40-slackware.rules     60-persistent-v4l.rules            80-libsane.rules
40-zaptel.rules        61-persistent-storage-edd.rules    90-hal.rules
50-udev-default.rules  64-device-mapper.rules             90-libgphoto2.rules
55-hpmud.rules         65-permissions.rules               90-libmtp.rules
60-bluetooth.rules     75-cd-aliases-generator.rules      90-network.rules
60-cdrom_id.rules      75-persistent-net-generator.rules  95-udev-late.rules
60-pcmcia.rules        79-fstab_import.rules              99-fuse.rules
root@barsoom:~# ls /etc/udev/rules.d
40-alsa.rules  40-alsa.rules~  70-persistent-cd.rules  70-persistent-net.rules
root@barsoom:~#
What I've done here is put my new udev rules in /etc/udev/rules.d/40-alsa.rules. This overrides the file of the same name in the /lib/udev/rules.d/ directory.

I think you have "KERNEL=" instead of "KERNEL==" in the first rule of your second attempt, also "MODE==" instead of "MODE=" in the same rule. Every little bug adds up.

Last edited by DavidHindman; 02-19-2009 at 02:55 AM.
 
Old 02-19-2009, 03:03 AM   #5
titopoquito
Senior Member
 
Registered: Jul 2004
Location: Ruhr Area, Germany
Distribution: Slackware64 14.0
Posts: 1,525

Rep: Reputation: 94
I'm not absolutely sure, but I think your problem is that the underlying device node has not the permissions you want. It probably won't help to create just a symlink with other permissions if the real node has other ones.
That said I guess you have to change udev's default rules. Mine (Slackware 12.1) are in /etc/udev/rules.d/50-udev-default.rules, yours should AFAIK be in /lib/udev/rules.d if you are running Slackware 12.2. Look there for the floppy and sd* node creation and change it to your needs ... (to make a copy of this file first is a good idea)
 
Old 02-19-2009, 03:42 AM   #6
DavidHindman
Member
 
Registered: Dec 2008
Distribution: Slack 13 + JWM
Posts: 101

Rep: Reputation: 23
Quote:
Originally Posted by orbit View Post
...What I have made so far (in /etc/udev/rules.d/98-local-rules) is the following...
For the version of udev on Slack 12.2, a rule file must end with the extension .rules

That is, for my version of udev, the file "98-local-rules" would have to be named "98-local-rules.rules", else it would have no effect.

I took your floppy rule and put it into my /etc/udev/rules.d/98-local-rules.rules. I also changed it to generate devices named /dev/xfd* instead of /dev/fd*, so I could isolate the effect of your new rule. It sort of worked, giving the 666 permissions you intended. The device name came out as /dev/xfd/0 instead of /dev/xfd0, but it's close!

Code:
root@barsoom:~# ls -l /dev/xfd/0
brw-rw-rw- 1 root floppy 2, 0 2009-02-19 02:30 /dev/xfd/0

Last edited by DavidHindman; 02-19-2009 at 04:02 AM.
 
Old 02-19-2009, 06:38 PM   #7
orbit
Member
 
Registered: Sep 2006
Location: Australia
Distribution: Slackware
Posts: 176

Original Poster
Rep: Reputation: 30
Hi all,

Thanks for all the great pointers and assistance, I really appreciate it.

I'll get back to this project tonight after work, to see if I can finalise it.

Results of further attempts pending ...

Cheers
 
Old 02-22-2009, 11:08 PM   #8
orbit
Member
 
Registered: Sep 2006
Location: Australia
Distribution: Slackware
Posts: 176

Original Poster
Rep: Reputation: 30
Hi all,

Well after many attempts at setting this usb/floppy rwx rule, I seem to still be having no effective progress.

My latest attempts have included:

Code:
##99-local.rules
# disk devices
KERNEL=="sd*",          NAME="%k", GROUP="disk", Mode="0777"
KERNEL=="ataraid*",     NAME="%k", GROUP="disk", Mode="0777"

# permissions for IDE floppy devices
SUBSYSTEMS=="ide", KERNEL=="*[!0-9]", ENV{DRIVER}=="ide-floppy*", NAME="%k", GROUP="floppy", MODE="0777"


# put all removable devices in group "plugdev"
KERNEL=="hd*[!0-9]", ATTR{removable}=="1", GROUP="plugdev", Mode="0777"
KERNEL=="hd*[0-9]", ATTRS{removable}=="1", GROUP="plugdev", Mode="0777"
KERNEL=="sd*[!0-9]", ATTR{removable}=="1", GROUP="plugdev", Mode="0777"
KERNEL=="sd*[0-9]", ATTRS{removable}=="1", GROUP="plugdev", Mode="0777"

BUS=="usb", KERNEL=="sd[a-z][1-9]", SYMLINK+="%k", GROUP="plugdev", Mode="0777" #, NAME="sd%n",
KERNEL=="sd[0-9]*", OWNER="user", MODE="0777"
BUS=="floppy", KERNEL=="fd[0-9]*", SYMLINK+="%k", GROUP="floppy", MODE="0777" # , NAME="fd%n",
KERNEL=="fd[0-9]*", OWNER="user", MODE="0777"
which I removed and then tried ....

Code:
##10-local.rules
# disk devices
KERNEL=="sd*",          NAME="%k", OWNER="user", GROUP="users", Mode="0777"
KERNEL=="ataraid*",     NAME="%k", GROUP="disk", Mode="0777"

# permissions for IDE floppy devices
SUBSYSTEMS=="ide", KERNEL=="*[!0-9]", ENV{DRIVER}=="ide-floppy*", NAME="%k", OWNER="user", GROUP="users", MODE="0777"


# put all removable devices in group "users"
KERNEL=="hd*[!0-9]", ATTR{removable}=="1", OWNER="user", GROUP="users", Mode="0777"
KERNEL=="hd*[0-9]", ATTRS{removable}=="1", OWNER="user", GROUP="users", Mode="0777"
KERNEL=="sd*[!0-9]", ATTR{removable}=="1", OWNER="user", GROUP="users", Mode="0777"
KERNEL=="sd*[0-9]", ATTRS{removable}=="1", OWNER="user", GROUP="users", Mode="0777"

BUS=="usb", KERNEL=="sd[a-z][1-9]", SYMLINK+="%k", OWNER="user", GROUP="users", Mode="0777"
KERNEL=="sd[0-9]*", OWNER="user", GROUP="users", MODE="0777"
BUS=="floppy", KERNEL=="fd[0-9]*", SYMLINK+="%k", OWNER="user", GROUP="users", MODE="0777"
KERNEL=="fd[0-9]*", OWNER="user", GROUP="users", MODE="0777"

But so far this seems to have had no effect on the 'real world' /read/write/execute permissions and ownerships of these devices.

Quote:
Code:
mount
/dev/sda1 on /media/512_Cruzer type vfat (rw,nosuid,nodev,noatime,flush,uid=1000,utf8,shortname=lower)
root@Crazed-Weasel:/etc/udev/rules.d#
Code:
ls -l /dev/sda1
brwxrwxrwx 1 user plugdev 8, 1 2009-02-23 13:25 /dev/sda1
root@Crazed-Weasel:/media#
Code:
ls -l /media/512_Cruzer
total 5488
-rwxr-xr-x 1 user root 5619080 2009-02-16 13:38 Opera_963_en_Setup.exe
As you can see from the above code, the /dev's are now getting the correct permissions that I have set, but their corresponding /media mountpoints still retain the original permissions (which are no good).

Can anyone offer a suggestion as to how I can make a systemwide policy of making these user (vfat) floppy and USB mountpoints automatically default to rwx for all users?

(Please don't mention fstab as I need this to be done automatically via UDEV/HAL/DBUS? as devices are inserted by the user; without requiring user intervention, or (su)root access editing).

p.s. I'm currently working on a Slackware 12.0.0 system, but would like to migrate this (rule/policy?) [once I get it working] to multiple Slackware 12.1.0 and Slackware 12.2.0 systems.

Appreciation for all positive comments.

Cheers


.

Last edited by orbit; 02-22-2009 at 11:14 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
udev rule: need help DPenguin Linux - Hardware 0 08-04-2008 08:29 PM
Udev Rule Help Please Toods Slackware 1 11-23-2007 09:55 AM
need help with udev rule hussam Linux - Software 2 12-05-2006 04:30 AM
udev rule for usbstick Steve50 Slackware 5 10-13-2006 06:53 AM
udev-Rule for Mobile tuxangler Linux - Hardware 1 03-28-2006 06:41 AM


All times are GMT -5. The time now is 03:45 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration