LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 02-12-2009, 12:11 PM   #1
faentur
LQ Newbie
 
Registered: Nov 2004
Posts: 12

Rep: Reputation: 0
How are permissions on /dev devices set at boot time?


Specifically I'm looking at devices like /dev/dsp, /dev/mixer, etc - all the sound devices. On boot they're set to 0660: after login the pam_console process changes them to 0666, as defined in /etc/security/console.perms.

I'd like to have them set to 0666 at boot time - *before* the first user logs in - so sound can be played using remote terminals. I think it might be pam_console that sets the original perms at boot time, but I can't figure out how from the man pages - or if I can change it.

for the moment I've thrown a 'chmod' command into /etc/X11/xdm/Xsetup_0 so that those files are all changed when X starts, but that's a hack: I'm looking for a more elegant solution.

thx
faentur
 
Old 02-13-2009, 05:50 AM   #2
ilikejam
Senior Member
 
Registered: Aug 2003
Location: Glasgow
Distribution: Fedora / Solaris
Posts: 3,109

Rep: Reputation: 97
Hi.

Take a look in /etc/security/console.perms[.d] and all should be revealed.

Dave
 
Old 02-17-2009, 01:35 PM   #3
faentur
LQ Newbie
 
Registered: Nov 2004
Posts: 12

Original Poster
Rep: Reputation: 0
Thanks, Dave, I looked at /etc/security/console.perms, but as I said in my initial update I want to modify permissions before the first user logs in.

Console.perms only takes effect after the first user logs in at the gui console. But there's definitely a mechanism that resets those permissions at boot time: I've tried rebooting the machine, ssh'ing in and changing the permissions, and then rebooting again without anyone ever logging in at the gui. The permissions revert to their original state.
 
Old 02-17-2009, 02:00 PM   #4
ilikejam
Senior Member
 
Registered: Aug 2003
Location: Glasgow
Distribution: Fedora / Solaris
Posts: 3,109

Rep: Reputation: 97
Apologies, must have read your post in haste.

The devices are created at boot, so you're getting the defaults for your sound devices. The permissions can be set in the udev rules.
On RedHat/Fedora, the sound device rules are in /etc/udev/rules.d/40-alsa.rules , but as the file says, it'll be overwritten on update.
Probably best to create a 99-my.rules in that directory to munge the permissions once the devices have been created (udev runs through all the files in there in numerical order). On my system, I'd use something like:
Code:
KERNEL=="controlC[0-9]*",	MODE="0666"
KERNEL=="hwC[D0-9]*",		MODE="0666"
KERNEL=="pcmC[D0-9cp]*",	MODE="0666"
KERNEL=="midiC[D0-9]*",		MODE="0666"
KERNEL=="timer",		MODE="0666"
KERNEL=="seq",			MODE="0666"
KERNEL=="mixer0",		MODE="0666"
KERNEL=="dsp0",			MODE="0666"
KERNEL=="audio0",		MODE="0666"
Haven't actually tried this, but I think it should work OK. If not, just edit the udev rule file that creates the devices, and add the ', MODE="0666"'.

Dave
 
Old 02-17-2009, 02:03 PM   #5
nx5000
Senior Member
 
Registered: Sep 2005
Location: Out
Posts: 3,307

Rep: Reputation: 57
udev creates devices on modern systems
Look in /etc/udev/rules
Here it is 91-permissions.rules
 
Old 02-19-2009, 07:06 PM   #6
faentur
LQ Newbie
 
Registered: Nov 2004
Posts: 12

Original Poster
Rep: Reputation: 0
Lightbulb

Well, those are great suggestions... and they totally make sense, but they didn't quite work for me. I tried both creating a new file, /etc/udev/rules.d/99-sounddev.rules

Code:
KERNEL="dsp0",          MODE="0666"
KERNEL="audio0",        MODE="0666"
KERNEL="midi[CD0-9]*",  MODE="0666"
KERNEL="mixer0",        MODE="0666"
etc., etc.

I also tried editing /etc/udev/rules.d/50-udev.rules:

Code:
# alsa devices
KERNEL="seq",            NAME="snd/%k", MODE="0666"
KERNEL="audio0",        SYMLINK="audio",        MODE="0666"
KERNEL="dsp0",          SYMLINK="dsp",  MODE="0666"
KERNEL="mixer0",        SYMLINK="mixer",        MODE="0666"
etc., etc.

Rebooted after each change, of course, and saw no changes. However, I did keep researching and found the solution: looking at /etc/udev/udev.conf I spied the following:
Quote:
# udev_permissions - The name and location of the udev permission file
udev_permissions="/etc/udev/permissions.d/"

# default_mode - set the default mode for all nodes that have no
# explicit match in the permissions file
default_mode="0600"
Ah-Ha! I took a look at /etc/udev/permissions.d/50-udev.permissions and found:
Code:
# audio devices
dsp*:root:root:0660
audio*:root:root:0660
midi*:root:root:0660
mixer*:root:root:0660
sequencer*:root:root:0660
sound/*:root:root:0660
snd/*:root:root:0660
beep:root:root:0660
admm*:root:root:0660
adsp*:root:root:0660
aload*:root:root:0660
amidi*:root:root:0660
dmfm*:root:root:0660
dmmidi*:root:root:0660
sndstat:root:root:0660
Yup, that's it. Changed those to 0666 and that solved the problem.

Thanks for your help, guys, couldn't have figured it out without the helpful boot in the right direction!
 
  


Reply



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
Identifying network devices at boot time. robertkey Linux - Networking 2 01-10-2009 12:58 AM
How to set permissions on devices jborn Linux - Hardware 6 03-27-2006 07:44 PM
Automatically set permissions on /dev/ttyUSB0 MicahCarrick Linux - Software 1 03-22-2006 08:20 AM
How to set user permissions for USB ports at boot? drazenko Linux - Hardware 1 07-27-2004 09:13 AM
mounting 2 ide-scsi devices /dev/cdrom and /dev/cdrom1 issue penguin123 Linux - Hardware 3 09-26-2003 08:36 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 08:59 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
Open Source Consulting | Domain Registration