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

How do I set a cups-shared printer as the default printer using lpadmin? #452

Closed
jaimet opened this issue Aug 13, 2022 · 2 comments · Fixed by #455
Closed

How do I set a cups-shared printer as the default printer using lpadmin? #452

jaimet opened this issue Aug 13, 2022 · 2 comments · Fixed by #455
Assignees
Labels
question General usage question

Comments

@jaimet
Copy link

jaimet commented Aug 13, 2022

I have an old HP1100 (parallel-connect!) connected to an old laptop that I am using as a printer server. I have the drivers installed on that printer server and when I ssh into the printer server, I can print to that printer perfectly. All is good:

user@server:~$ lpstat -a
laser accepting requests since Fri 22 Jul 2022 16:50:33 BST
user@server:~$ lp -d laser file.pdf # Success!

I set cups on that printer server to share the printer, and from my main computer I can see it and print to it perfectly too. All is still good:

user@client:~$ lpstat -e
laser_server
user@client:~$ lp -d laser_server file.pdf # Still success!

On my main computer, I have no default printer:

user@client:~$ lpstat -d
no system default destination

So I try to add the network-detected printer as the default:

user@client:~$ sudo lpadmin -d laser_server
lpadmin: The printer or class does not exist.

Ok, let's try by specifying its local name (to the print server) along with the name of the print server:

user@client:~$ sudo lpadmin -h server -d laser
lpadmin: Forbidden

Should I specify a username with sufficient authority?:

user@client:~$ sudo lpadmin -U root -h server -d laser
lpadmin: Forbidden

How do other people achieve this?

FWIW, both printer server and main computer are running Debian stable with cups version 2.3.3op2-3+deb11u2. (I understand that debian stable has a comparatively old version, but surely this must still be achieveable, no?)

@michaelrsweet
Copy link
Member

Use the lpoptions command to set a default remote printer, e.g.:

lpoptions -d printer

@michaelrsweet michaelrsweet added the question General usage question label Aug 13, 2022
@michaelrsweet michaelrsweet self-assigned this Aug 13, 2022
zdohnal added a commit to zdohnal/cups that referenced this issue Aug 15, 2022
The current code of `cupsGetNamedDest()` doesn't look up on network for
a default printer. The result is a temporary queue cannot be set as a
default printer.

Fixes OpenPrinting#452
@zdohnal
Copy link
Member

zdohnal commented Aug 15, 2022

@michaelrsweet unfortunately it doesn't work - meaning you can set the temp queue pointing to a shared remote queue:

$ lpstat -a
lpstat: No destinations added.
$ lpstat -e
hp_fedora
test2_fedora
$ lpstat -t
scheduler is running
system default destination: test2_fedora
...

but printing to it doesn't work:

$ lp -P 25 ~/cslh-pravidla2018-22-web.pdf 
lp: Error - ~/.cups/lpoptions file names default destination that does not exist.

It happens because we use _cupsGetDests(), which sends get-printer-attributes to ipp://localhost:631/printers/<name>, which doesn't exist for temp queue, so it fails, and further down we check only name variable, which is NULL in case of default printer, in cupsGetNamedDest().

To sum it up, we don't look on network when using default printer...

zdohnal added a commit to zdohnal/cups that referenced this issue Jun 6, 2023
…nPrinting#719)

Fixes regression created by OpenPrinting#452 - in case there is no default
destination and `cupsGetNamedDest()` is called to get one (by calling it
with argument `name` as NULL), the function crashes.

It happens because we try to look for the default printer on the network
(where we access `data.name`, which is NULL, in callback), but we never
found out the printer's name.

Original fix by Emilio Cobos Alvarez.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question General usage question
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants