Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

printer forwarding on ubuntu #928

Closed
totaam opened this issue Jul 28, 2015 · 12 comments
Closed

printer forwarding on ubuntu #928

totaam opened this issue Jul 28, 2015 · 12 comments
Labels

Comments

@totaam
Copy link
Collaborator

totaam commented Jul 28, 2015

Issue migrated from trac ticket # 928

component: server | priority: major | resolution: fixed

2015-07-28 17:13:22: joshiggins created the issue


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=
@totaam
Copy link
Collaborator Author

totaam commented Jul 28, 2015

2015-07-28 17:21:34: antoine changed status from new to assigned

@totaam
Copy link
Collaborator Author

totaam commented Jul 28, 2015

2015-07-28 17:21:34: antoine commented


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.

@totaam
Copy link
Collaborator Author

totaam commented Jul 28, 2015

2015-07-28 17:45:52: joshiggins commented


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.

@totaam
Copy link
Collaborator Author

totaam commented Jul 29, 2015

2015-07-29 16:16:31: antoine commented


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 [r10124](.. commit a31b6fc), [r10120](.. commit 39368b0) (+fixup in [r10130](.. commit ed74e39)), [r10131](.. commit 63f5272), [r10132](.. commit 8756437). Also added more permission setup info to [Printing](r10124](..-commit-a31b6fc86c815b857ee3450266c906e097fe2232), 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.

@totaam
Copy link
Collaborator Author

totaam commented Jul 30, 2015

2015-07-30 07:50:43: antoine commented


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 ...

@totaam
Copy link
Collaborator Author

totaam commented Jul 30, 2015

2015-07-30 11:28:24: antoine commented


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

I have no idea about the permission issue.

@totaam
Copy link
Collaborator Author

totaam commented Jul 30, 2015

2015-07-30 15:05:36: antoine commented


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.

@totaam
Copy link
Collaborator Author

totaam commented Jul 30, 2015

2015-07-30 16:11:09: antoine commented


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)

@totaam
Copy link
Collaborator Author

totaam commented Aug 2, 2015

2015-08-02 19:40:17: joshiggins commented


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.

@totaam
Copy link
Collaborator Author

totaam commented Aug 3, 2015

2015-08-03 05:39:03: antoine commented


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/...

@totaam
Copy link
Collaborator Author

totaam commented Aug 5, 2015

2015-08-05 13:33:24: joshiggins commented


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

@totaam
Copy link
Collaborator Author

totaam commented Aug 5, 2015

2015-08-05 13:34:31: joshiggins commented


I guess since it "works for me".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant