Andreas Karlson [Tue, 9 Apr 2024 13:14:22 +0000 (15:14 +0200)]
scheduler: Fix potential bug when adding new printers (Issue #934)
When adding a new printer a thread is created to handle PPD generation,
and the requesting client connection might close while the thread is running.
This commit prevents full connection cleanup until the thread is finished.
Sometimes headers are not correctly copied into response to the client (some are missing). It happens because sent_header is set prematurely before the actual send happens. The present code in affected cupsdWriteClient() scope looks like code remains from CUPS 1.6.3, where cupsdSendHeader() is called earlier and generates the required headers by itself - the current cupsdSendHeader() sends only the headers which are saved in array fields, so the premature setting of sent_header sometimes causes not having all headers in the response.
With the change, testing via curl gives reliable results all time.
Zdenek Dohnal [Thu, 15 Feb 2024 17:15:55 +0000 (18:15 +0100)]
ppd-cache.c: Check for required attributes if URF or PWG Raster are found
Some devices have image/urf in document-format-supported, but is missing urf-supported
if AirPrint support is turned off, which breaks PPD generation. Check for attribute
urf-supported when we are about to decide whether the printer uses AirPrint, so in case
the device supports another driverless standard, we can use it for PPD generation.
Apply the same for PWG Raster too.
Zdenek Dohnal [Wed, 14 Feb 2024 13:22:40 +0000 (14:22 +0100)]
Use PAM password-auth or system-auth if present
Enables possibility to use PAM modules password-auth or system-auth
if they exist during compilation. password-auth module is
for remote authentication and system-auth for local authentication.
Zdenek Dohnal [Tue, 16 Jan 2024 12:30:17 +0000 (13:30 +0100)]
backend/ipp.c: Fix printing jobs with long names on older IPP printers
On older printers (ones which don't support IPP operation Create-Job)
we concatenate job number and title into one string, which we use as
IPP attribute job-name. If the original title was almost 255 chars,
the joining the strings will overflow maximal required length
for this attribute, and Validate-Job fails.
We could check whether the string is longer than 255 and cut it,
but I chose to shrink the buffer to 256, since we already use snprintf()
which will cut the string and put null terminator for us.
Zdenek Dohnal [Mon, 15 Jan 2024 15:09:19 +0000 (16:09 +0100)]
backend/ipp.c: Fix infinite loop with Kerberos
If IP address was used with Kerberos, IPP backend retried connection
indefinitely. The fix is to abort when we find out hostname is an IP
address and we require Kerberos.
Zdenek Dohnal [Fri, 15 Dec 2023 09:59:54 +0000 (10:59 +0100)]
httpAddrConnect2: Check for error if POLLHUP is in valid revents
Some Linux kernel versions put POLLOUT|POLLHUP into revents when client tries to connect with httpAddrConnect2(), which makes the connection fail.
Let's check the option SO_ERROR before scratching the attempt - if there is no error, remove POLLHUP from revents.
I've re-purposed previously Solaris-only code to be used everywhere if the conditions are met - this should prevent bigger delays than necessary.
Slightly different issue than #827, but with similar symptoms (kernel sending POLLOUT|POLLHUP).
Zdenek Dohnal [Wed, 29 Nov 2023 14:10:45 +0000 (15:10 +0100)]
scheduler: Fix build failure on Linux with '-Werror -Wall'
The string which we add into array stays `const` after fixing #814
(because `strdup()`, which caused memory leak returned `char *`)
and compiler fails because of it if it runs with '-Werror -Wall'.
zdohnal [Fri, 24 Nov 2023 05:08:17 +0000 (06:08 +0100)]
scheduler/colorman.c: Fix memory leak during creating color profile
Since the array profiles is set to use strdup() as a copy function, we
don't have to use strdup() on the element which is passed as parameter
of cupsArrayAdd() - using the strdup() as we used till now causes
memory leak.
Zdenek Dohnal [Mon, 30 Oct 2023 10:34:55 +0000 (11:34 +0100)]
scheduler/job.c: unload job before freeing job history in cupsdDeleteJob()
With "PreserveJobHistory Off", LogLevel not set to debug (or debug2),
and "LogDebugHistory 200" (the default), cupsdDeleteJob() frees the
job history and then unloads the job. However, unload_job() calls
cupsdLogJob() which re-creates the job history and puts "Unloading..."
into it because level (debug) is greater than LogLevel (warn) and
LogDebugHistory is set to 200 messages by default. Unused (and
unreachable) job history is left behind, resulting in a memory leak.
Zdenek Dohnal [Mon, 30 Oct 2023 09:49:14 +0000 (10:49 +0100)]
scheduler/colorman.c: Fix memory leak during creating color profile
Since the array `profiles` is set to use `strdup()` as a copy function, we
don't have to use `strdup()` on the element which is passed as parameter
of `cupsArrayAdd()` - using the `strdup()` as we used till now causes
memory leak.
Reproducer is the same as https://github.com/OpenPrinting/cups/pull/813
cups/ppd-cache.c: Add cupsUrfSupported to generated PPD (see #804)
It fixes driverless printing on Pantum BM5100ADW Series and, probably,
on many other devices.
- Without this parameter, /usr/lib/cups/filter/universal generates RGB
image/urf even for monochrome printer
- Pantum BM5100ADW Series rejects to print these RGB images with
the "Print job canceled at printer" status.
- Probably, this issue affects many other devices
zdohnal [Wed, 4 Oct 2023 07:29:20 +0000 (09:29 +0200)]
cups/hash.c: Put support for MacOS/Win SSL libs back
- I mustn't remove their support in patch release - this should happen in 2.5 only.
- I have put back support for several hashes as well - they should be removed in 2.5.
- restrict usage of second block hashing only if OpenSSL/LibreSSL/GnuTLS is available (since IMO I found its implementation useless for SSL libs, which will be removed in 2.5)
This removes hard dependency on OpenSSL/LibreSSL or GnuTLS in 2.4.x, which will happen in 2.5.
Zdenek Dohnal [Tue, 3 Oct 2023 11:59:40 +0000 (13:59 +0200)]
cups/hash.c: Put support for MacOS/Win SSL libs back
- I mustn't remove their support in patch release - this should happen in
2.5 only.
- I have put back support for several hashes as well - they
should be removed in 2.5.
- restrict usage of second block hashing only if OpenSSL/LibreSSL/GnuTLS
is available
We didn't check for end of buffer if it looks there is an escaped
character - check for NULL terminator there and if found, return NULL
as return value and in `ptr`, because a lone backslash is not
a valid PostScript character.
Zdenek Dohnal [Wed, 14 Jun 2023 08:14:38 +0000 (10:14 +0200)]
cups/ppd-cache.c: Put cupsSingleFile into generated PPD
Some printers are not able to print multiple files in one job via IPP
Everywhere. Adding the PPD keyword enables the feature on all printers
in exchange for performance degradation (there is a 1-2s pause between
printed files).
Rose [Sun, 11 Jun 2023 20:09:53 +0000 (16:09 -0400)]
Regression: Certificate data is corrupted during base64 conversion
The bug during which certificates become corrupt was introduced in a521b235a1abc008cb0b2f490a765bb31e2ec14b. It turns out some data was not being truncated after being promoted to an integer, causing 1s to be ORed into the index number when they should not have been.
I only intended to remove the & 255 from the other side, where the & 63 would have rendered that operation redundant.
I apologize for this error. I made the appropriate changes I intended to make in this new PR.