-
Notifications
You must be signed in to change notification settings - Fork 264
Description
After updating from Fedora 40 to Fedora 41 I noticed the Gnome printer selection window would often hang (the "force quit or wait" dialog is shown) when selecting a printer. This is obviously not a CUPS issue but a Gnome bug since apparently they didn't take in to account querying a printer is a blocking operation and should be handled off the main UI-thread. Other UI toolkits are also affected by this. For example the print dialog in LibreOffice also hangs sometimes.
However this made me investigate why this 10 second hang was sometimes happening when selecting a printer in the print dialog window. It turns out the CUPS server itself (which runs remotely, there is no local CUPS service) sometimes seems to hang for 10 seconds when a client tries to connect with it over TLS. The CUPS server runs on FreeBSD 14.2 and is CUPS 2.4.11. I actually updated to these latest versions. Before that it was running FreeBSD 13.4 with CUPS 2.4.10 and I was experiencing the same issue with Fedora 41 clients.
This is what /etc/cups/client.conf on a Fedora 41 client looks like:
ServerName print.nl2.serviceplanet.nl
AllowAnyRoot No
AllowExpiredCerts No
TrustOnFirstUse No
UserAgentTokens ProductOnly
ValidateCerts Yes
# 'Always' means the CUPS client will immediately do HTTPS instead of trying to upgrade an HTTP
# connection (i.e. STARTTLS). This is required when using "SSLListen :631" on the server (which we do).
Encryption Always
SSLOptions MinTLS1.2
This is what running truss on the cupsd process on the server side looks like when the process hangs:
access("/usr/local/etc/cups/ssl/office-support-1.crt",R_OK) = 0 (0x0)
access("/usr/local/etc/cups/ssl/office-support-1.key",R_OK) = 0 (0x0)
access("/usr/local/etc/cups/ssl/office-support-1.crt",R_OK) = 0 (0x0)
access("/usr/local/etc/cups/ssl/office-support-1.key",R_OK) = 0 (0x0)
open("/usr/local/etc/cups/ssl/office-support-1.key",O_RDONLY|O_CLOEXEC,0666) = 25 (0x19)
fstat(25,{ mode=-rw-r----- ,inode=1570,size=1704,blksize=32768 }) = 0 (0x0)
lseek(25,0x0,SEEK_CUR) = 0 (0x0)
read(25,"-----BEGIN PRIVATE KEY-----\nMII"...,1705) = 1704 (0x6a8)
read(25,0xc37766ad4a8,1) = 0 (0x0)
close(25) = 0 (0x0)
open("/usr/local/etc/cups/ssl/office-support-1.crt",O_RDONLY|O_CLOEXEC,0666) = 25 (0x19)
fstat(25,{ mode=-rw-r--r-- ,inode=1571,size=4174,blksize=32768 }) = 0 (0x0)
lseek(25,0x0,SEEK_CUR) = 0 (0x0)
fstat(25,{ mode=-rw-r--r-- ,inode=1571,size=4174,blksize=32768 }) = 0 (0x0)
read(25,"subject=C = NL, ST = Zuid-Hollan"...,32768) = 4174 (0x104e)
read(25,0xc377b038f80,32768) = 0 (0x0)
close(25) = 0 (0x0)
madvise(0xc3779a97000,4096,MADV_FREE) = 0 (0x0)
getpid() = 41054 (0xa05e)
setsockopt(23,SOL_SOCKET,SO_RCVTIMEO,0xc376c9bffc0,16) = 0 (0x0)
setsockopt(23,SOL_SOCKET,SO_SNDTIMEO,0xc376c9bffc0,16) = 0 (0x0)
----------------------------8<--------------------------------------------------------------------------------------------------------
CUPS freezes for 10 seconds
----------------------------8<--------------------------------------------------------------------------------------------------------
poll({ 23/POLLIN },1,10000) = 0 (0x0)
__sysctl("kern.hostname",2,0xc376c9c0cc0,0xc376c9bcca0,0x0,0) = 0 (0x0)
getpid() = 41054 (0xa05e)
sendto(4,"<51>1 2024-12-27T14:26:55.617251"...,164,0,NULL,0) = 164 (0xa4)
kevent(3,{ 23,EVFILT_READ,EV_DELETE,0,0,0xc37767481a0 },1,0x0,0,{ 0.000000000 }) = 0 (0x0)
close(23) = 0 (0x0)
kevent(3,0x0,0,{ 5,EVFILT_READ,0x0,0,0x1,0xc3776748d40 12,EVFILT_READ,0x0,0,0x1f2,0xc37766beb20 13,EVFILT_READ,0x0,0,0x1f3,0xc3776748600 14,EVFILT_READ,0x0,0,0x1f7,0xc37766bea80 },32768,{ 1.000000000 }) = 4 (0x4)
accept(5,{ AF_INET 172.16.1.58:51284 },0xc376c9c1444) = 23 (0x17)
setsockopt(23,SOL_SOCKET,SO_NOSIGPIPE,0xc376c9c1440,4) = 0 (0x0)
setsockopt(23,IPPROTO_TCP,TCP_NODELAY,0xc376c9c1440,4) = 0 (0x0)
fcntl(23,F_SETFD,FD_CLOEXEC) = 0 (0x0)
getsockname(23,{ AF_INET 10.201.11.11:631 },0xc376c9c159c) = 0 (0x0)
getsockname(23,{ AF_INET 10.201.11.11:631 },0xc376c9c159c) = 0 (0x0)
kevent(3,{ 23,EVFILT_READ,EV_ADD,0,0,0xc37767481a0 },1,0x0,0,{ 0.000000000 }) = 0 (0x0)
getsockname(23,{ AF_INET 10.201.11.11:631 },0xc376c9c0030) = 0 (0x0)
fstatat(AT_FDCWD,"/etc/resolv.conf",{ mode=-rw-r--r-- ,inode=110,size=51,blksize=32768 },0x0) = 0 (0x0)
open("/etc/hosts",O_RDONLY|O_CLOEXEC,0666) = 25 (0x19)
fstat(25,{ mode=-rw-r--r-- ,inode=156,size=1188,blksize=32768 }) = 0 (0x0)
read(25,"# $FreeBSD: src/etc/hosts,v 1.16"...,32768) = 1188 (0x4a4)
close(25) = 0 (0x0)
access("/usr/local/etc/cups/ssl/office-support-1.crt",R_OK) = 0 (0x0)
access("/usr/local/etc/cups/ssl/office-support-1.key",R_OK) = 0 (0x0)
access("/usr/local/etc/cups/ssl/office-support-1.crt",R_OK) = 0 (0x0)
access("/usr/local/etc/cups/ssl/office-support-1.key",R_OK) = 0 (0x0)
open("/usr/local/etc/cups/ssl/office-support-1.key",O_RDONLY|O_CLOEXEC,0666) = 25 (0x19)
fstat(25,{ mode=-rw-r----- ,inode=1570,size=1704,blksize=32768 }) = 0 (0x0)
lseek(25,0x0,SEEK_CUR) = 0 (0x0)
read(25,"-----BEGIN PRIVATE KEY-----\nMII"...,1705) = 1704 (0x6a8)
read(25,0xc37766ad4a8,1) = 0 (0x0)
close(25) = 0 (0x0)
open("/usr/local/etc/cups/ssl/office-support-1.crt",O_RDONLY|O_CLOEXEC,0666) = 25 (0x19)
fstat(25,{ mode=-rw-r--r-- ,inode=1571,size=4174,blksize=32768 }) = 0 (0x0)
lseek(25,0x0,SEEK_CUR) = 0 (0x0)
fstat(25,{ mode=-rw-r--r-- ,inode=1571,size=4174,blksize=32768 }) = 0 (0x0)
read(25,"subject=C = NL, ST = Zuid-Hollan"...,32768) = 4174 (0x104e)
read(25,0xc377b038f80,32768) = 0 (0x0)
The freeze of the cupsd process is also reflected in the debug logs:
D [27/Dec/2024:14:40:57 +0100] [Client 207] Closing connection.
D [27/Dec/2024:14:40:57 +0100] cupsdSetBusyState: newbusy="Not busy", busy="Not busy"
D [27/Dec/2024:14:40:57 +0100] cupsdSetBusyState: newbusy="Active clients", busy="Not busy"
D [27/Dec/2024:14:40:57 +0100] [Client 208] Server address is "10.201.11.11".
D [27/Dec/2024:14:40:57 +0100] [Client 208] Accepted from 172.16.1.58:45648 (IPv4)
D [27/Dec/2024:14:40:57 +0100] [Client 208] Waiting for request.
----------------------------8<--------------------------------------------------------------------------------------------------------
CUPS freezes for 10 seconds
----------------------------8<--------------------------------------------------------------------------------------------------------
E [27/Dec/2024:14:41:07 +0100] [Client 208] Unable to encrypt connection: Error in the pull function.
D [27/Dec/2024:14:41:07 +0100] [Client 208] Closing connection.
This is what Wireshark looks like on the client where the 10 second wait can be seen after initiating TLS:
At first I thought this seemed like a DNS issue. But from what I can tell all the DNS resolving seems to be fine. I'm not really sure what is happening here. By default FreeBSD uses GnuTLS with CUPS. I think it should also be possible to build CUPS 1.4 with OpenSSL nowadays?
This is what cupsd.conf on the server looks like (which is not terribly exiting):
#
# Configuration file for the CUPS scheduler. See "man cupsd.conf" for a
# complete description of this file.
#
# Log general information in error_log - change "warn" to "debug"
# for troubleshooting...
LogLevel warn
PageLogFormat
# Specifies the maximum size of the log files before they are rotated. The value "0" disables log rotation.
MaxLogSize 1m
# Retry the job after waiting for N seconds; the JobRetryInterval directive controls the value of N.
ErrorPolicy retry-job
JobRetryInterval 30
SSLListen 0.0.0.0:631
SSLOptions MinTLS1.2
Listen /var/run/cups/cups.sock
ServerName print.nl2.serviceplanet.nl
ServerTokens ProductOnly
ServerAdmin <REDACTED>
# Show shared printers on the local network.
Browsing On
# Beware that setting this to 'none' causes the web ui to list printers as "not shared". What that means is that
# they aren't shared via protocols such as Bonjour. They are still "shared" via IPP however.
BrowseLocalProtocols none
# Do not lookup DNS names of connecting clients.
HostNameLookups Off
# We don't want to use persistent storage because ideally even with all drives failed the print
# server should still work. Job history might also contain sensitive document names.
PreserveJobFiles No
AutoPurgeJobs Yes
# Default authentication type, when authentication is required...
DefaultAuthType Basic
# Web interface setting...
WebInterface Yes
# Restrict access to the server...
<Location />
Order allow,deny
Allow all
</Location>
# Restrict access to the admin pages...
<Location /admin>
Order allow,deny
Allow all
</Location>
# Restrict access to configuration files...
<Location /admin/conf>
AuthType Default
Require user @SYSTEM
Order allow,deny
Allow all
</Location>
# Restrict access to log files...
<Location /admin/log>
AuthType Default
Require user @SYSTEM
Order allow,deny
Allow all
</Location>
# Set the default printer/job policies...
<Policy default>
# Job/subscription privacy...
JobPrivateAccess default
JobPrivateValues default
SubscriptionPrivateAccess default
SubscriptionPrivateValues default
# Job-related operations must be done by the owner or an administrator...
<Limit Create-Job Print-Job Print-URI Validate-Job>
Order deny,allow
</Limit>
<Limit Send-Document Send-URI Hold-Job Release-Job Restart-Job Purge-Jobs Set-Job-Attributes Create-Job-Subscription Renew-Subscription Cancel-Subscription Get-Notifications Reprocess-Job Cancel-Current-Job Suspend-Current-Job Resume-Job Cancel-My-Jobs Close-Job CUPS-Move-Job CUPS-Get-Document>
Require user @OWNER @SYSTEM
Order deny,allow
</Limit>
# All administration operations require an administrator to authenticate...
<Limit CUPS-Add-Modify-Printer CUPS-Delete-Printer CUPS-Add-Modify-Class CUPS-Delete-Class CUPS-Set-Default CUPS-Get-Devices>
AuthType Default
Require user @SYSTEM
Order deny,allow
</Limit>
# All printer operations require a printer operator to authenticate...
<Limit Pause-Printer Resume-Printer Enable-Printer Disable-Printer Pause-Printer-After-Current-Job Hold-New-Jobs Release-Held-New-Jobs Deactivate-Printer Activate-Printer Restart-Printer Shutdown-Printer Startup-Printer Promote-Job Schedule-Job-After Cancel-Jobs CUPS-Accept-Jobs CUPS-Reject-Jobs>
AuthType Default
Require user @SYSTEM
Order deny,allow
</Limit>
# Only the owner or an administrator can cancel or authenticate a job...
<Limit Cancel-Job CUPS-Authenticate-Job>
Require user @OWNER @SYSTEM
Order deny,allow
</Limit>
<Limit All>
Order deny,allow
</Limit>
</Policy>
