# sr0 device permissions change on closing the tray

## Lord_Raptor

Hello,

I got an odd problem:

After successfully starting the system, the permission for dev/sr0 are set correctly as defined in udev 

```
brw-rw-rw- root cdrom
```

 But when I open and then close the tray, the permissions are changed to

```
brw-rw---- root disk
```

This means my users cannot access their dvd/cd writers without logging in as root and changing the permissions.

There is no mention of this permission change in dmesg or any other log that I could find on the system. The system is running on kernel version linux-2.6.38.7 

Anyone got any idea where to start searching for a solution

P.S. This problem only appears for sr[0-9] devices, everything attached by IDE works fine

----------

## VoidMage

 :Rolling Eyes:  You should have only sr[0-9] devices.

----------

## Logicien

I do not think the group change because you open/close the tray. It change because it pass from no media to a media in cdrom. Try to boot with a cd in the cdrom, and check the permissions. It have to do with /etc/udev/rules.d/70-persistent-cd.rules . Editing the rules in that file can force the group. I do not know how for the moment.

If the disk group is only for cdrom, I don't think, it is use to for PATA/SATA disks, you can put your users in the disk group as a workaround. A better workaround is to put the mount option users in the line of the cdrom in /etc/fstab. Then all users will be able to mount and unmount the media in cdrom regardless the group of cdrom in /dev.

Me, /dev/sr0 stay in the cdrom group with no or cdrom in. /dev/{cdrom,dvd,scd0} are symbolics links to it. cdrom and sr_mod modules drive the cdrom.

----------

## Lord_Raptor

Hm, maybe I should have explained a little more:

I have no control over which devices are there nor can I start the system from a CD because it is a terminal system that boots over ethernet from another server. And the problem exists on all computers that have a SATA CD/DVD-RW drive

The permission change happens from closing the tray, because it is irrelevant if a CD is in the tray or not and it happens to fast for the drive even to check for a disk.

/etc/udev/rules.d/70-persistent-cd.rules does not exist in this system (maybe that is the problem? all other devices work fine)

I think it may have something to do with KDE automount, but I´m not sure how to confirm that

greetings

Raptor

----------

## Lord_Raptor

I made a debug log of udev, maybe that will help:

http://unreal.lu/udev.log

It begins exactly after I close the drive tray.

Here a snippet from the 50-udev.rules

```

/etc/udev/rules.d/50-udev.rules

32: # all block devices

33: SUBSYSTEM=="block", GROUP="disk"

34: 

35: # cdrom symlinks and other good cdrom naming

36: KERNEL=="sr[0-9]*|hd[a-z]|pcd[0-9]*", ACTION=="add", IMPORT{program}="cdrom_id --export $tempnode"

37: ENV{ID_CDROM}=="?*", GROUP="cdrom", MODE="0666"

```

It seems that the rule at line 36-37 is not executed, only the one at 33.

----------

## VoidMage

A question somebody should have already asked: 'lspci -k' ?

----------

## Lord_Raptor

 *Quote:*   

> 00:00.0 Host bridge: Intel Corporation 82G33/G31/P35/P31 Express DRAM Controller (rev 02)
> 
>         Subsystem: Giga-byte Technology Device 5000
> 
> 00:01.0 PCI bridge: Intel Corporation 82G33/G31/P35/P31 Express PCI Express Root Port (rev 02)
> ...

 

I managed to do a dirty fix, I wrote a seperate udev rule for the sr devices

```
KERNEL=="sr[0-9]*", GROUP="cdrom", MODE="0666"
```

But I dont know if this is a good idea?

----------

## VoidMage

Is "JMicron IDE" CONFIG_PATA_JMICRON or CONFIG_BLK_DEV_JMICRON ?

----------

## wcg

I do not think logician meant boot with a bootable cd necessarily,

he meant boot with any cd in the drive (like some non-bootable

iso9660 data cd). The point is to see what the permissions are on

/dev/sr0 without opening/closing the tray but with mountable media

already in the drive.

If you use an iso9660 data cd, you can try manually mounting

it after booting with the mount command and see if the permissions

change on mount.

(What happens when you open/close a dvd/cd-rom drive? A uevent.

What monitors uevents? udev, X input driver, I do not know what all

else. So there is a good chance that this relates to some default

behavoir of udev in the absence of an applicable rule. But is the actual

result dependent on recognition of the device event or recognition

of the inserted media? That seems to be the sense of logician's question.)

----------

## Lord_Raptor

The drive starts with the correct permissions "brwrwrw root cdrom". I saw in the udev log, that the rule concerning the cdrom drive is not executed again after the system is running, I dont know why. This means the last rule that is executed regarding this device is the standart block device rule, which explains the permissions. The question is, why is the other rule not executed and why on the other hand is the additional rule I inserted executed.

@VoidMage: I dont know what you mean, how to I check that? Are those kernel settings?

----------

## VoidMage

Yes, those two are kernel settings.

----------

