Solved Access permisions to cd0 for user

I am trying to sort out permissions to device cd0 so that sysutils/k3b-kde4 can see the device. For now when it starts it shows error: No optical drive found. When k3b is started as root is sees the device properly.

I have all the permissions set up and I can mount cd0 as the user:

/etc/devfs.rules
Code:
[system=10]
add path 'usb*'  mode 0770 group cups
add path 'ugen*'  mode 0660 group cups
add path 'ad[0-9]\*'  mode 0666
add path 'ada[0-9]\*'  mode 0666
add path 'da[0-9]\*'  mode 0666
add path 'acd[0-9]\*'  mode 0666
add path 'cd[0-9]\*'  mode 0666
add path 'mmcsd[0-9]\*'  mode 0666

/etc/rc.conf
Code:
hald_enable="YES"
dbus_enable="YES"
devfs_system_ruleset="system"

/etc/devfs.conf
Code:
own  /dev/cd0  root:operator
perm /dev/cd0  0666

The user is in the operator group:

Code:
g@crayon2:~ % id
uid=1001(g) gid=1001(g) groups=1001(g),0(wheel),5(operator),193(cups)

Code:
g@crayon2:~ % ls -l /dev/cd0
crw-rw-rw-  1 root  operator  0x89  6 Mar 22:19 /dev/cd0

I can see the device with lshal

Code:
g@crayon2:~ % lshal | less
(...)
udi = '/org/freedesktop/Hal/devices/storage_serial_K117CI82858'
  block.device = '/dev/cd0'  (string)
  block.freebsd.cam_path = '3,0,0'  (string)
  block.is_volume = false  (bool)

However, cdrdao can't query the device when I run it as the user:

Code:
g@crayon2:~ % cdrdao disk-info --device 3,0,0
Cdrdao version 1.2.3 - (C) Andreas Mueller <andreas@daneb.de>
ERROR: Cannot open SCSI device '3,0,0':
ERROR: Please use option '--device {[proto:]bus,id,lun}|device', e.g. --device 0,6,0, --device ATA:0,0,0 or --device /dev/cdrom
ERROR: Cannot setup device 3,0,0.

It can when I run it as root:

Code:
root@crayon2:~ # cdrdao disk-info --device 3,0,0
Cdrdao version 1.2.3 - (C) Andreas Mueller <andreas@daneb.de>

3,0,0: HL-DT-ST BD-RE  GGW-H20L Rev: YL07
Using driver: Generic SCSI-3/MMC - Version 2.0 (options 0x0000)

That data below may not reflect the real status of the inserted medium
if a simulation run was performed before. Reload the medium in this case.

CD-RW  : no
Total Capacity  : n/a
CD-R medium  : Princo Corporation
  Short Strategy Type, e.g. Phthalocyanine
Recording Speed  : n/a
CD-R empty  : no
Toc Type  : CD-ROM XA
Sessions  : 1
Last Track  : 1
Appendable  : no

What's going on here?
 
Great, good point! I didn't know that there may be other logical devices attached to the same physical device. Especially this proved useful:

Code:
root@crayon2:~ # camcontrol devlist
(...)
<HL-DT-ST BD-RE  GGW-H20L YL07>  at scbus3 target 0 lun 0 (pass3,cd0)

So I added xpt* and pass* to devfs.rules:
Code:
[system=10]
(...)
add path 'cd[0-9]\*'  mode 0666
add path 'xpt[0-9]\*'  mode 0666
add path 'pass[0-9]\*'  mode 0666

and added pass3 specifically to devfs.conf:

Code:
perm /dev/pass3  0666

and now it works!
 
Sometimes the program that does things this low-level, also needs root for other things. Raising scheduling priority, locking into RAM, etc. Verify your CD burns... :)

Juha
 
Certainly k3b isn't one of them as they specifically warn the user to sort out their permissions rather than run k3b as root :)
 
Back
Top