Xpra: Ticket #928: printer forwarding on ubuntu

The cups-pdf package as of vivid (15.04) transitions to printer-driver-cups-pdf and places the PPD file into /usr/share/ppd/cups-pdf/CUPS-PDF.ppd where Xpra can't find it.

After creating a simlink to /usr/share/cups/model/CUPS-PDF.ppd Xpra still won't create the printers and complains that the device URI scheme xpraforwarder:/ is invalid.

The packaged version in winswitch repo doesn't seem to include the xpraforwarder script but not sure if it should be.

Pulled it from the source and placed in /usr/lib/cups/backend/, Xpra will now create the printers but printing from a remote application fails.

Jul 28 16:37:30 josht440 xpraforwarder: '/usr/lib/cups/backend/xpraforwarder' '15' 'joshiggins' 'Test Page' '1' 'job-uuid=urn:uuid:4abe1717-da67-3c0d-582d-086a17fbbe31 job-originating-host-name=localhost time-at-creation=1438097849 time-at-processing=1438097849'
Jul 28 16:37:30 josht440 xpraforwarder: username: joshiggins, title: Test Page, filename: -, job_id: 15
Jul 28 16:37:30 josht440 xpraforwarder: urlparse(xpraforwarder:/tmp?remote-device-uri=None&source=None&socket-dir=%2Fhome%2Fjoshiggins%2F.xpra&display=%3A10&remote-printer=HTLM5+client)=ParseResult(scheme='xpraforwarder', netloc='', path='/tmp', params='', query='remote-device-uri=None&source=None&socket-dir=%2Fhome%2Fjoshiggins%2F.xpra&display=%3A10&remote-printer=HTLM5+client', fragment='')
Jul 28 16:37:30 josht440 xpraforwarder: attributes(remote-device-uri=None&source=None&socket-dir=%2Fhome%2Fjoshiggins%2F.xpra&display=%3A10&remote-printer=HTLM5+client)={'remote-device-uri': ['None'], 'remote-printer': ['HTLM5 client'], 'socket-dir': ['/home/joshiggins/.xpra'], 'display': [':10'], 'source': ['None']}
Jul 28 16:37:30 josht440 xpraforwarder: xpra display: :10
Jul 28 16:37:30 josht440 xpraforwarder: running: ['xpra', '--socket-dir=/home/joshiggins/.xpra', 'print', ':10', '-', 'application/postscript', 'None', 'Test Page', 'HTLM5 client', '1', 'job-uuid=urn:uuid:4abe1717-da67-3c0d-582d-086a17fbbe31 job-originating-host-name=localhost time-at-creation=1438097849 time-at-processing=1438097849']
Jul 28 16:37:30 josht440 xpraforwarder: returncode(['xpra', '--socket-dir=/home/joshiggins/.xpra', 'print', ':10', '-', 'application/postscript', 'None', 'Test Page', 'HTLM5 client', '1', 'job-uuid=urn:uuid:4abe1717-da67-3c0d-582d-086a17fbbe31 job-originating-host-name=localhost time-at-creation=1438097849 time-at-processing=1438097849'])=1
Jul 28 16:37:30 josht440 xpraforwarder: stdout=xpra initialization error: connection failed: [Errno 13] Permission denied
Jul 28 16:37:30 josht440 xpraforwarder: stderr=

Tue, 28 Jul 2015 16:21:34 GMT - Antoine Martin: status changed

OK, I'll take a look at printing under Ubuntu / Debian, r10105 should fix Ubuntu the path issue. (will backport once the backend is also packaged)

As for the Permission denied: my guess is that the forwarder script does not have permission to access the xpra socket. On Fedora, this happens because of selinux, under Ubuntu it could be apparmor I guess.

Tue, 28 Jul 2015 16:45:52 GMT - Josh:

That was fast! thanks.

Also for what it's worth I stopped the apparmor service and restarted cups, which made no difference. Seems as though the xpraforwarder backend script is running as root.

Wed, 29 Jul 2015 15:16:30 GMT - Antoine Martin:

Some improvements and fixes in this area (some of which will be backported): r10124, r10120 (+fixup in r10130), r10131, r10132. Also added more permission setup info to wiki/Printing.

We now connect to the server socket by path, which should be more reliable, no matter what userid runs the cups backend.

With all this, I managed to print from a Fedora trunk beta client connected to a Debian Stretch trunk beta server. (without any other permission issues) I will try Ubuntu 15.04 next.

Thu, 30 Jul 2015 06:50:43 GMT - Antoine Martin:

r10142 makes us ship the cups backend (will backport).

I have tried on Ubuntu and the server crashed hard as I tried to print! Ouch. And the xpraforwarder also failed with the same error as before:

failed to connect to '/home/ubuntu/.xpra/ubuntu-vivid-2': [Errno 13] Permission denied

Despite using the newer command line (not that I was expecting it to fix it):

xpra print socket:/home/ubuntu/.xpra/ubuntu-vivid-2 - application/postscript ...

Thu, 30 Jul 2015 10:28:23 GMT - Antoine Martin:

I believe that the crash is fixed in r10143 and this is not related to printing. r10149 backports the packaging fix to the v0.15.x branch.

I have no idea about the permission issue.

Thu, 30 Jul 2015 14:05:36 GMT - Antoine Martin:

Found it, as per the cups backend docs: CUPS backends are not generally design to be run directly by the user. Aside from the device URI issue ( argv[0] and DEVICE_URI environment variable contain the device URI), CUPS backends also expect specific environment variables and file descriptors, and typically run in a user session that (on OS X) has additional restrictions that affect how it runs. Backends can also be installed with restricted permissions (0500 or 0700) that tell the scheduler to run them as the "root" user instead of an unprivileged user (typically "lp") on the system.

This fixed it for me:

chmod 700 /usr/lib/cups/backend/xpraforwarder

I will now look at doing this for the packaging.

Thu, 30 Jul 2015 15:11:09 GMT - Antoine Martin: owner, status changed

The chmod is now overriden in dh build, see r10165 (r10165 for v0.15.x branch).

I have tested with 15.04 with both 0.16.0 and 0.15.4 from the beta area.

@josh: does that work for you on Ubuntu now? (there are vivid beta 0.16.0 packages you can use for testing)

Sun, 02 Aug 2015 18:40:17 GMT - Josh:

Now I'm getting

Aug  2 19:38:08 josht440 xpraforwarder: '/usr/lib/cups/backend/xpraforwarder' '23' 'joshiggins' 'Test Page' '1' 'job-uuid=urn:uuid:c1ea0f3e-058f-39d8-5fb1-2399a167097e job-originating-host-name=localhost time-at-creation=1438540688 time-at-processing=1438540688'
Aug  2 19:38:08 josht440 xpraforwarder: username: joshiggins, title: Test Page, filename: -, job_id: 23
Aug  2 19:38:08 josht440 xpraforwarder: urlparse(xpraforwarder:/tmp?socket-path=%2Fhome%2Fjoshiggins%2F.xpra%2Fjosht440-11&remote-printer=Send+To+OneNote+2013&remote-device-uri=None&socket-dir=%2Fhome%2Fjoshiggins%2F.xpra&source=da39a3ee5e6b4b0d3255bfef95601890afd80709&display=%3A11)=ParseResult(scheme='xpraforwarder', netloc='', path='/tmp', params='', query='socket-path=%2Fhome%2Fjoshiggins%2F.xpra%2Fjosht440-11&remote-printer=Send+To+OneNote+2013&remote-device-uri=None&socket-dir=%2Fhome%2Fjoshiggins%2F.xpra&source=da39a3ee5e6b4b0d3255bfef95601890afd80709&display=%3A11', fragment='')
Aug  2 19:38:08 josht440 xpraforwarder: attributes(socket-path=%2Fhome%2Fjoshiggins%2F.xpra%2Fjosht440-11&remote-printer=Send+To+OneNote+2013&remote-device-uri=None&socket-dir=%2Fhome%2Fjoshiggins%2F.xpra&source=da39a3ee5e6b4b0d3255bfef95601890afd80709&display=%3A11)={'socket-path': ['/home/joshiggins/.xpra/josht440-11'], 'remote-printer': ['Send To OneNote 2013'], 'remote-device-uri': ['None'], 'socket-dir': ['/home/joshiggins/.xpra'], 'source': ['da39a3ee5e6b4b0d3255bfef95601890afd80709'], 'display': [':11']}
Aug  2 19:38:08 josht440 xpraforwarder: xpra display: :11, socket-path: /home/joshiggins/.xpra/josht440-11
Aug  2 19:38:08 josht440 xpraforwarder: running: ['xpra', 'print', 'socket:/home/joshiggins/.xpra/josht440-11', '-', 'application/postscript', 'da39a3ee5e6b4b0d3255bfef95601890afd80709', 'Test Page', 'Send To OneNote 2013', '1', 'job-uuid=urn:uuid:c1ea0f3e-058f-39d8-5fb1-2399a167097e job-originating-host-name=localhost time-at-creation=1438540688 time-at-processing=1438540688']
Aug  2 19:38:08 josht440 xpraforwarder: failure in xpraforwarder main: [Errno 2] No such file or directory
Aug  2 19:38:08 josht440 org.fedoraproject.Config.Printing[1608]: ** (scp-dbus-service.py:16755): WARNING **: Couldn't connect to accessibility bus: Failed to connect to socket /tmp/dbus-0WSs6aEQvm: Connection refused

but I am going to set up a clean environment and test it again.

Mon, 03 Aug 2015 04:39:03 GMT - Antoine Martin:

josht440 org.fedoraproject.Config.Printing[1608]: ** (scp-dbus-service.py:16755): \
    WARNING **: Couldn't connect to accessibility bus: Failed to connect to socket /tmp/dbus-0WSs6aEQvm: Connection refused

You may need to start a dbus session for xpra if one was not started already. dbus-launch xpra start...

Assuming that the permissions are correct on the debian/xpra/usr/lib/cups/backend/xpraforwarder, you should be able to test the command by hand by running it as root (cut & paste from above):

xpra print socket:/home/...

Wed, 05 Aug 2015 12:33:23 GMT - Josh:

I must have screwed something on my system, on a clean Vivid install using the beta packages it works as expected :)

Wed, 05 Aug 2015 12:34:31 GMT - Josh: status changed; resolution set

I guess since it "works for me".

Sat, 23 Jan 2021 05:10:02 GMT - migration script:

this ticket has been moved to: https://github.com/Xpra-org/xpra/issues/928