Apply devfs rules in a jail

Status
Not open for further replies.

damian0815

Cadet
Joined
Feb 4, 2012
Messages
4
Hi all,

I'm trying to setup cups to print to a usb-attached printer. I followed the instructions here: http://superuser.com/questions/673880/airprint-and-airplay-on-freenas to install cups in a jail on the FreeNAS machine. I've got cups working (if I manually chmod a+rw /dev/ulpt0), but I can't seem to get the devfs rules to apply: /etc/rc.d/devfs restart in the jail results in 'devfs rule: ioctl DEVFSIO_RGETNEXT: Operation not permitted'

Following some advice from #freebsd on IRC I added a cups user to the host with the same userid and groupid, and then added the devfs rules to the host rather than the jail. So now on the host:

Code:
[user@freenas ~]$ ls -lh /dev/ulpt0
crw-rw----  1 root  cups  0x67 Jan 10 09:07 /dev/ulpt0


But in the jail:
Code:
# ls -lh /dev/ulpt0
crw-r--r--  1 root  operator  0x67 Jan 10 09:07 /dev/ulpt0


I tried adding jail_cups_devfs_ruleset=usbrules to the rc.conf but that didn't help either.

What's the magic trick to getting devfs rules working in a jail?
 

Joshua Parker Ruehlig

Hall of Famer
Joined
Dec 5, 2011
Messages
5,949
Hi all,

I'm trying to setup cups to print to a usb-attached printer. I followed the instructions here: http://superuser.com/questions/673880/airprint-and-airplay-on-freenas to install cups in a jail on the FreeNAS machine. I've got cups working (if I manually chmod a+rw /dev/ulpt0), but I can't seem to get the devfs rules to apply: /etc/rc.d/devfs restart in the jail results in 'devfs rule: ioctl DEVFSIO_RGETNEXT: Operation not permitted'

Following some advice from #freebsd on IRC I added a cups user to the host with the same userid and groupid, and then added the devfs rules to the host rather than the jail. So now on the host:

Code:
[user@freenas ~]$ ls -lh /dev/ulpt0
crw-rw----  1 root  cups  0x67 Jan 10 09:07 /dev/ulpt0


But in the jail:
Code:
# ls -lh /dev/ulpt0
crw-r--r--  1 root  operator  0x67 Jan 10 09:07 /dev/ulpt0


I tried adding jail_cups_devfs_ruleset=usbrules to the rc.conf but that didn't help either.

What's the magic trick to getting devfs rules working in a jail?
You need to allow the device to appear in the jail, from devfs rules on the host
How I do this on a FreeBSD10 machine
  • create a new devfs ruleset in /etc/devfs.rules, unhiding the path needed (ulpt* for you)
  • make the jail use that ruleset, jail_EXAMPLE_devfs_ruleset="#”
  • set devfs_load_rulesets="YES" in rc.conf (this might not be needed in FreeBSD/NAS9.X)
I don't know if there's a clean way to do this on FreeNAS

EDIT
ahh, you just need to set the ownership. this is how I did this in my devfs.rules
this is what I did on my FreeBSD host's devfs, you don't need the user to exist on the host, you can specify things by UID/GID
Code:
add path 'zvol/zroot/webserver-files/db/innodb' mode 0660 group 88 unhide
 

flounder0049

Cadet
Joined
Jan 27, 2015
Messages
2
I'm trying to do this exact task myself, and having the same lack of success. Here's what I've done:

On FreeNAS host:

-- /etc/devfs.rules --
[jail_devfs=110]
add path 'unlpt*' mode 0660 group cups
add path 'ulpt*' mode 0660 group cups
add path 'lpt*' mode 0660 group cups
add path 'usb/4.2.0' mode 0660 group cups

-- /etc/rc.conf --
jail_FreeBSD_devfs_ruleset="110"
devfs_load_rulesets="YES"

Then I run "service devfs restart" on the host (no warnings), and even stop/start the jail. Still nothing:

[root@freenas] ~# jexec 15 ls -l /dev
...
crw-r--r-- 1 root operator 0xaf Jan 26 22:11 ulpt0
crw-r--r-- 1 root operator 0xb0 Jan 26 22:11 unlpt0
...
 

flounder0049

Cadet
Joined
Jan 27, 2015
Messages
2
As a follow-up, running "devfs -m /mnt/tank/jails/FreeBSD/dev -s 110 applyset" fixes the permissions and a test page prints fine. So it's just a matter of applying the rules automatically.

During my research on this issue, I also came across suggestions to provide /etc/jail.conf, which I did with the following:

-- /etc/jail.conf --
FreeBSD {
devfs_ruleset="110";
}

This doesn't work either. As it appears the configuration for jails has evolved over the last few FreeBSD releases, it'd be nice to know which one FreeNAS is using....
 
Status
Not open for further replies.
Top