Zdenek Dohnal [Mon, 15 Aug 2022 14:04:50 +0000 (16:04 +0200)]
cups/dest.c: Look for default printer on network as well
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.
Some PPD files are larger than the current limit and they don't reside
in directories handled by `cups-driverd`, so users have to add them via
Web UI. The limit is now 2 MiB, the same as in PAPPL.
Tyson Tan [Sat, 16 Jul 2022 14:22:13 +0000 (22:22 +0800)]
Corrected Simplified Chinese translations of page sizes and others
Corrected Simplified Chinese translations of page sizes and envelope sizes to match standards and reflect the original meanings. Corrected duplex translations. Replaced full-width brackets with half-width ones, which is the preferred practice of Chinese translation for FOSS projects.
Zdenek Dohnal [Wed, 22 Jun 2022 07:23:45 +0000 (09:23 +0200)]
scheduler/ipp.c: Allocate device_uri via cupsdSetString()
If a driverless printer has .local in its URI, we resolve the
URI and save the resolved one as new device URI. The problem was that
a local pointer was assigned to the structure which is passed to the
function as parameter, so the pointer became invalid once the execution
left the create_local_bg_thread() function.
We need to allocate the device URI via cupsdSetString() - the string is
then freed when the printer is deleted or cupsd shuts down.
Zdenek Dohnal [Mon, 20 Jun 2022 16:17:58 +0000 (18:17 +0200)]
Don't override color settings from print dialog
When we put print-color-mode as a default attribute, it always overrides
settings from print dialog. We need to respect those settings and transform
the known PPD options into print-color-mode options.
Till Kamppeter [Fri, 10 Jun 2022 19:19:29 +0000 (21:19 +0200)]
create_local_printer(): Improved comparison of device URI host name
Improved the comparison of the device URI host name with the CUPS
server's host name to find out whether the temporary queue is for a
local IPP service.
- Compare case-insensitively as host names are case-insensitive
- If we have the DNS-SD host name (DNSSDHostName) of the CUPS server,
consider names equal if they only differ by the presence or absense
of a trailing dot ('.')
- If we only have the ServerName (for example with "Browsing = Off",
not sharing printers), consider also a server name without ".local"
equal to a device URI host name with ".local" as equal.
Till Kamppeter [Wed, 16 Mar 2022 17:02:09 +0000 (18:02 +0100)]
Fix crash when DNSSDHostName is NULL
If cupsd is running without Browsing (when not sharing printers) the
global variable DNSSDHostName of the scheduler is not set, staying
NULL. Therefore the previous commit causes a crash with this
configuration of CUPS.
This commit does a NULL check on DNSSDHostName and falls back to
ServerName if needed, where it also does a NULL check and if this is
also NULL, it refrains from any attempt to correct the device URI's
hostname to "localhost".
As ServerName usually contains the server's hostname without ".local"
suffix but the device URIs coming from Avahi usually have a suffixed
host name (and there are also the ".local" and ".local." variants of
the suffix), we consider hostnames also as equal if one has the
suffix, the other not, or if we have the variants with and without
trailing dot.
In addition, there are also HAVE_DNSSD conditionals added around the
code using DNSSDHostName now.
Till Kamppeter [Sun, 13 Mar 2022 20:31:58 +0000 (21:31 +0100)]
For local services use "localhost" in device URI of temporary queue
To print to a temporary CUPS queue for a discovered IPP printer the
client has to send an IPP_OP_CUPS_CREATE_LOCAL_PRINTER IPP request to
the CUPS daemon with the details for creating the temporary queue.
CUPS then calls its create_local_printer() function to actually create
the queue. This is already automatically and correctly done if the
client uses the convenience API of libcups.
The GTK print dialog does not use the convenience API though. It
displays all IPP printers for which CUPS can create temporary queues
correctly, but it fails on services which are only available on the
local machine and not on the network (loopback interface, "localhost")
whereas printing via temporary queue on network/remote services works
perfectly.
The problem is that Avahi advertises the local services not with the
"localhost" host name but with the network host name of the local
machine. The libcups convenience API functions can cope with this and
send correct device URIs with the "localhost" host name to CUPS and so
the temporary queue gets created correctly.
The GTK dialog wants fully asynchronous CUPS operation and throws the
libcups API completely overboard doing all by itself, and sending
incorrect device URIs with the network hostname for the local
services. CUPS creates the temporary queue with this URI then and
fails to do the get-printer-attributes request on the printer to
generate the PPD file, leaving the temporary queue in a non-functional
state.
This commit correct/works around this by checking whether the device
URI's host name is the same as the DNS-SD host name of the local
machine and if so, replaces the device URI's host name by "localhost".
Now one can select local services like IPP-over-USB printers or
Printer Applications in the GTK print dialog and printing on them
through an auto-generated temporary CUPS queue works.
I decided to fix/work around this problem in CUPS as we see that no
every print client developer uses the libcups convenience API.
Zdenek Dohnal [Wed, 1 Jun 2022 04:48:31 +0000 (06:48 +0200)]
choose-device.tmpl: Add device uri into title of found network printer
There can be many printers on the same network with the same printer
model, which causes confusion for users about which one to add. This PR
adds a title for every found network printer, which contains the
printer's device uri. The title is shown when user hover the mouse over
the found entry.
Partially fixes #393, thanks to Pro-pra for the PR!
The previous algorithm didn't expect the strings can have a different
length, so one string can be a substring of the other and such substring
was reported as equal to the longer string.
The current mode for `gnutls_bye()` in client use cases strictly
follows TLS v1.2 standard, which in this particular part says:
```
Unless some other fatal alert has been transmitted, each party is
required to send a close_notify alert before closing the write
side of the connection. The other party MUST respond with a
close_notify alert of its own and close down the connection immediately,
discarding any pending writes. It is not required for the initiator
of the close to wait for the responding close_notify alert before
closing the read side of the connection.
```
and waits for the other side of TLS connection to confirm the close.
Unfortunately it can undesired for reasons:
- we support switching of TLS versions in CUPS, and this mode strictly
follows TLS v1.2 - so for older version this behavior is not expected
and can cause delays
- even some TLS v1.2 implementations (like Windows Server 2016) don't
comply TLS v1.2 behavior even if it says it does - in that case,
encrypted printing takes 30s till HTTP timeout is reached, because the
other side didn't send confirmation
- AFAIU openssl's SSL_shutdown() doesn't make this TLS v1.2 difference,
so we could end up with two TLS implementations in CUPS which will
behave differently
Since the standard defines that waiting for confirmation is not required
and due the problems above, I would propose using GNUTLS_SHUT_WR mode
regardless of HTTP mode.
cupsdDeleteTemporaryPrinters() deletes temporary queues which their last
status was updated 1 minute ago or older. It doesn't take into account
the fact the printer can be processing a big print job and cupsd deletes
the temp queue either way.
The fix in the PR now set cupsd to ignore queues which are in processing
state. If the delay in job processing is caused by an error in printer,
the correct error should kick in IPP backend.
Michael R Sweet [Mon, 7 Mar 2022 17:14:29 +0000 (12:14 -0500)]
Fix some web interface issues:
- Transition web interface/stylesheet to use "cups-header", "cups-body", and
"cups-footer" classes.
- Tweak background colors for documentation sidebar, block quotes, and code.
Zdenek Dohnal [Fri, 4 Mar 2022 07:23:22 +0000 (08:23 +0100)]
scheduler/ipp.c: Polish mDNS resolving
- no need to include http-private.h, cupsd.h has cups-private.h, which
includes http-private.h
- call _httpResolve() only for mDNS hostnames and then pass the pointer
to original printer->device_uri instead of copying
- add logging messages
Zdenek Dohnal [Wed, 2 Mar 2022 12:42:59 +0000 (13:42 +0100)]
scheduler/ipp.c: Resolve possible mDNS uri (Fixes #340, #343)
Users sometimes pass URIs from dnssd and driverless backends as a
device URI for IPP Everywhere queues. These URIs have mDNS hostnames in
it, so they need to be resolved before used in connection.