# mount cdrom as user



## sk8harddiefast (Oct 4, 2010)

I hope this is the right forum to ask. When I try to mount a cdrom as user it won't let me. Asks for root permissions. The problem is that if I want to see a dvd, I also must run vlc or mplayer as root because as user they cannot read the cdrom. And I guess it's not a good idea to run programs as root. Any idea?


----------



## aragon (Oct 4, 2010)

Some helpful threads:

[thread=17168]Setting permissions to access devices.[/thread]
[thread=15232]Can I mount vfat partition using non root ?[/thread]

If you're using HAL:

http://www.freebsd.org/gnome/docs/halfaq.html#q3


----------



## SIFE (Oct 5, 2010)

Add this to devfs.conf:

```
own acd* U:G
perm acd0 0660
```
U:G is your user with its group.
Allow user to mount via /etc/sysctl:

```
sysctl vfs.usermount=1
```
Don't forget to add it to /etc/sysctl.conf so you haven't to change it after every boot.

```
vfs.usermount=1
```
Now restart devfs:

```
/etc/rc.d/devfs restart
```
See: man devfs.conf


----------



## sk8harddiefast (Oct 5, 2010)

I read both of them. And aragons links and also I tried SIFES post.

My devfs.conf

```
own acd* emberdaemon:wheel
perm acd0 0660
perm acd1 0660
```

My /etc/sysctl

```
sysctl vfs.usermount=1
```

My /etc/sysctl.conf

```
vfs.usermount=1
```

But `/etc/rc.d/devfs restart`

```
chown: acd0: Operation not permitted
chown: acd0t01: Operation not permitted
chown: acd1: Operation not permitted
chmod: acd0: Operation not permitted
chmod: acd1: Operation not permitted
```
Something must be wrong on group on devfs.conf
I tried root, wheel, operator


----------



## Beastie (Oct 5, 2010)

sk8harddiefast said:
			
		

> Something must be wrong on group on devfs.conf
> I tried root, wheel, operator


How? Like this?

```
own	acd*	root:operator
perm	acd*	0660
```


----------



## SIFE (Oct 5, 2010)

MR sk8harddiefast, did you restartdevfs as root?
Also post output of [cmd=]ls /dev[/cmd]


----------



## richardpl (Oct 5, 2010)

FYI vfs.usermount is exploitable.


----------



## kpedersen (Oct 5, 2010)

```
[localrules=5]
add path 'da*' mode 0660 group operator
add path 'cd*' mode 0660 group operator
add path 'acd*' mode 0660 group operator
```

.. is my devfs, just replace `operator` with any group you want the members to be able to mount.

As well as the kernel tunable (sysctl) value, make sure that


```
devfs_system_ruleset="localrules"
```

is in rc.conf

The above is adapted from the tutorial in the official handbook (for usb memory devices)

http://www.freebsd.org/doc/handbook/usb-disks.html
(near the botton)


----------



## sk8harddiefast (Oct 6, 2010)

> MR sk8harddiefast, did you restartdevfs as root


No. As emberdaemon.
*My /dev*


```
acd0        ad10s1e     ata         cuau0.lock  fido        kbd2        mixer2      stderr      ttyv3       ttyvd       ugen4.2     usb
acd0t01     ad10s1f     atkbd0      cuse        fw0         kbdmux0     nfslock     stdin       ttyv4       ttyve       ugen5.1     usbctl
acd1        ad12        audit       dcons       fw0.0       klog        null        stdout      ttyv5       ttyvf       ugen6.1     vboxnetctl
acpi        ad12s1      bpf         devctl      fwmem0      kmem        nvidia0     sysmouse    ttyv6       ufsid       ugen6.2     video0
ad10        ad12s1d     bpf0        devstat     fwmem0.0    log         nvidiactl   ttyu0       ttyv7       ugen0.1     ugen6.3     xpt0
ad10s1      ad14        console     dgdb        geom.ctl    mdctl       pci         ttyu0.init  ttyv8       ugen1.1     ugen7.1     zero
ad10s1a     ad14s1      consolectl  dsp0.0      io          mem         ptmx        ttyu0.lock  ttyv9       ugen2.1     ukbd0
ad10s1b     ad6         ctty        dsp1.0      iso9660     midistat    pts         ttyv0       ttyva       ugen3.1     ums0
ad10s1b.bde ad6s1       cuau0       dsp2.0      kbd0        mixer0      random      ttyv1       ttyvb       ugen3.2     ums1
ad10s1d     ad6s1d      cuau0.init  fd          kbd1        mixer1      sndstat     ttyv2       ttyvc       ugen4.1     urandom
```

I read this http://www.freebsd.org/doc/handbook/usb-disks.html

So I created a file devfs.rules and I wrote these lines

```
[localrules=5]
add path 'da*' mode 0660 group wheel
add path 'cd*' mode 0660 group wheel
add path 'acd*' mode 0660 group wheel
```
Also on rc.conf I add this line

```
devfs_system_ruleset="localrules"
```

Now the output of */etc/rc.d/devfs restart* as emberdaemon

```
devfs rule: ioctl DEVFSIO_RGETNEXT: Operation not permitted
/etc/rc.d/devfs: WARNING: devfs_set_ruleset: you must specify a ruleset number
/etc/rc.d/devfs: WARNING: devfs_apply_ruleset: you must specify a ruleset
```


----------



## Beastie (Oct 6, 2010)

sk8harddiefast said:
			
		

> Now the output of */etc/rc.d/devfs restart* as emberdaemon


As *root*.


----------



## sk8harddiefast (Oct 7, 2010)

Yeap. Worked 
I run vlc as emberdaemon and now can read my dvd 
Also [cmd=]sudo etc/rc.d/devfs restart[/cmd] returns me none error 
Thanks all of you!


----------

