# CUPS in a Jail and "Waiting for printer to become available."



## DemoNIck (Aug 9, 2017)

I am creating this thread because I have a problem printing to a CUPS server installed in a FreeBSD jail and I am not sure if this problem is related to a misconfigured jail and/or misconfigured CUPS server.

The host server (skg) installation is a FreeBSD 11.1-RELEASE.
The jail (fileserver) is a base jail type created and managed with iocage (py36-iocage-0.9.8.1) based on 11.1-RELEASE.


```
skg
 |__ jail1(fileserver): cups
 |__ jail2
 |__ jail3
 |__ ...
```
There are 3 usb printers connected to the box which I want to use for remote printing, from clients (MS Windows 10 Pro) in the same lan.
Printers: SAMSUNG CLP-315, HP P1102W and EPSON SX410.

The main idea is that the 3 printers will be configured as RAW printers in the CUPS server (installed in the jail "fileserver"). The Windows clients will be able to access the 3 printers via the ipp protocol and all the clients will have the windows printer drivers installed in order to be able to print on the cups server.

The `dmesg` output on the host skg

```
...
ugen7.3: <Samsung Electronics Co., Ltd. CLP-310 Series> at usbus7
Root mount waiting for: usbus7
ugen7.4: <Hewlett-Packard HP LaserJet Professional P1102w> at usbus7
Root mount waiting for: usbus7
ugen7.5: <EPSON USB2.0 MFPHi-Speed> at usbus7
umass0 numa-domain 0 on uhub3
umass0: <USB2.0 Mass Storage> on usbus7
umass0:  SCSI over Bulk-Only; quirks = 0x0000
umass0:8:0: Attached to scbus8
...

ulpt0: <Samsung Electronics Co., Ltd. CLP-310 Series, class 0/0, rev 2.00/1.00, addr 3> on usbus7
ulpt0: using bi-directional mode
ulpt1 numa-domain 0 on uhub3
ulpt1: <Printer> on usbus7
ulpt1: using bi-directional mode
ulpt2 numa-domain 0 on uhub3
ulpt2: <USB2.0 Printer> on usbus7
ulpt2: using bi-directional mode
```
In order to be able to see and access the usb devices in the jail (fileserver), I have proceed to the following steps:
*
1.* I have added a cups user/group on the host skg with the same UID and GID (193) with the added cups user in the jail (fileserver)
on the host skg

```
root@skg:~ # id cups
uid=193(cups) gid=193(cups) groups=193(cups)
```
on the jail fileserver

```
root@fileserver:~ # id cups
uid=193(cups) gid=193(cups) groups=193(cups)
```
*2.* I enabled vfs.usermount on skg in order for *cups* user to be able to mount the usb devices (not quiet sure if this was necessary, but I enabled it anyway)

```
root@skg:~ # sysctl vfs.usermount
vfs.usermount: 1
```
*3.* I have modified the devfs.rules on the skg. More precisely I edited the /etc/devfs.rules and add the following lines:

```
[devfsrules_unhide_printers=10]
add path ulpt[0-2]* unhide
add path unlpt[0-2]* unhide
add path ulpt[0-2] mode 0660 group cups
add path unlpt[0-2] mode 0660 group cups

[devfsrules_cups_jail=11]
add include $devfsrules_hide_all
add include $devfsrules_unhide_basic
add include $devfsrules_unhide_login
add include $devfsrules_unhide_printers

[devfsrules_login=12]
add path ulpt[0-2] mode 0660 group cups
add path unlpt[0-2] mode 0660 group cups
```
and add the following lines in /etc/rc.conf

```
# devfs.rules
devfs_system_ruleset="12"
```
I also edited the /etc/devfs.conf and add the following lines at the bottom to reassure the proper permissions.

```
# cups
own     ulpt0   root:cups
own     ulpt1   root:cups
own     ulpt2   root:cups
own     unlpt0  root:cups
own     unlpt1  root:cups
own     unlpt2  root:cups
perm    ulpt0   0660
perm    ulpt1   0660
perm    ulpt2   0660
perm    unlpt0  0660
perm    unlpt1  0660
perm    unlpt2  0660
```
After a reboot I have checked the permissions of the printer devices on the host skg.

Permissions on host skg

```
root@skg:/dev # ls -al u*pt*
crw-rw----  1 root  cups  0x9b Aug  9 11:45 ulpt0
crw-rw----  1 root  cups  0xa1 Aug  9 11:45 ulpt1
crw-rw----  1 root  cups  0xc4 Aug  9 11:45 ulpt2
crw-rw----  1 root  cups  0x9e Aug  9 11:45 unlpt0
crw-rw----  1 root  cups  0xa2 Aug  9 11:45 unlpt1
crw-rw----  1 root  cups  0xc5 Aug  9 11:45 unlpt2
```
*4.* In the jail fileserver, I have installed and configured CUPS from ports print/cups

```
root@fileserver:~ # pkg info | grep cups
cups-2.2.3                     Common UNIX Printing System
cups-filters-1.13.5            Additional backends, filters and other software for CUPS
cups-smb-backend-1.0_9         CUPS backend for printing to Windows servers
```
I have checked the permissions of the printer devices on the jail fileserver.

```
root@fileserver:/dev # ls -al u*lpt*
crw-rw----  1 root  cups  0x9b Aug  9 13:27 ulpt0
crw-rw----  1 root  cups  0xa1 Aug  9 13:27 ulpt1
crw-rw----  1 root  cups  0xc4 Aug  9 13:27 ulpt2
crw-rw----  1 root  cups  0x9e Aug  9 13:27 unlpt0
crw-rw----  1 root  cups  0xa2 Aug  9 13:27 unlpt1
crw-rw----  1 root  cups  0xc5 Aug  9 13:27 unlpt2
```
*5.* I have added the 3 printers via the cups web interface in the jail fileserver as RAW printers. I can connect through the CUPS web interface from the lan. I have enabled the cupsd service in the jail's rc.conf. Just a copy/paste from the web interface regarding the 3 installed printers.

```
Queue   Name Description    Location Make and Model     Status
CLP315  Samsung CLP-315     xxx.lan  Local Raw Printer  Idle
P1102W  HP LaserJet P1102w  xxx.lan  Local Raw Printer  Idle
SX410   EPSON Stylus SX410  xxx.lan  Local Raw Printer  Idle

CLP315 (Idle, Accepting Jobs, Shared)
Description: Samsung CLP-315 
Location: xxx.lan 
Driver: Local Raw Printer (grayscale, 2-sided printing)
Connection: usb:/dev/ulpt0 
Defaults: job-sheets=none, none media=unknown

P1102W (Idle, Accepting Jobs, Shared) 
Description: HP LaserJet P1102w
Location: xxx.lan
Driver: Local Raw Printer (grayscale, 2-sided printing)
Connection: usb:/dev/ulpt1
Defaults: job-sheets=none, none media=unknown

SX410 (Idle, Accepting Jobs, Shared) 
Description: EPSON Stylus SX410
Location: xxx.lan
Driver: Local Raw Printer (grayscale, 2-sided printing)
Connection: usb:/dev/ulpt2
Defaults: job-sheets=none, none media=unknown
```
I can see them from the shell in the jail fileserver

```
root@fileserver:~ # lpstat -p
printer CLP315 is idle.  enabled since Wed Aug  9 11:07:31 2017
printer P1102W is idle.  enabled since Wed Aug  9 12:56:20 2017
printer SX410 is idle.  enabled since Wed Aug  9 11:07:31 2017
```
*6.* Just mentioning that I have installed the 3 printers on a windows client and installed the appropriate drivers. (enabled ipp in windows and added the 3 printers network printers in the form of http://fileserver.xxx.lan:631/printers/<QUEUE>, where QUEUE=P1102W,CLP315 and SX410. Yes fileserver.xxx.lan resolves to the correct jail's IP). 

*PROBLEM:*
When I send a print job from the windows client, the printer is not printing anything and I see the following message in the "Jobs" CUPS web gui:

```
processing since
Wed Aug 9 14:32:22 2017 
"Waiting for printer to become available."
```

If I check the logs I can see the following messages in the log:
/var/log/cups/access_log

```
localhost - - [09/Aug/2017:14:32:22 +0300] "POST /printers/P1102W HTTP/1.1" 200 417 Print-Job successful-ok
```
while I have nothing in the /var/log/cups/error_log
and of course there is no printing happening.
I can cancel the job.

Exactly the same thing occurs if I try to print a test page from the CUPS web gui.

Any clue?
Is there a misconfiguration regarding my jail setup?

Thank you in advance for the time you spent to read this long post.


----------

