Adding containerized environment support socket path communication with frontend#65
Merged
tillkamppeter merged 33 commits intoOpenPrinting:masterfrom Apr 27, 2026
Merged
Conversation
…ket and add cupsFreeOptions and g_free for failure return paths
…ups for better job creation feedback
cupsCreateDestJob() was called with a manually managed http_t* from cupsConnectDest(). This creates a TCP connection to the printer queue where Local peer credential auth is impossible and Kerberos is unavailable, causing a 401 Unauthorized when the CUPS policy requires authentication. Fix by using CUPS_HTTP_DEFAULT for all CUPS job I/O. This causes the CUPS library to connect to cupsd via the Unix domain socket, where the kernel automatically vouches for the caller's UID via peer credentials (SO_PEERCRED), satisfying the authenticated policy without a password. Also fix a thread safety bug: cupsStartDestDocument was called on the main thread but cupsWriteRequestData and cupsFinishDestDocument were called on the worker thread using the same http_t*. Since CUPS_HTTP_DEFAULT is per-thread (stored in _cups_globals_t), all three calls must be on the same thread. Move cupsStartDestDocument and cupsCopyDestInfo into the worker thread alongside the data transfer calls.
Remove p->http from PrinterCUPS and replace ensure_printer_connection() with ensure_dest_info() which only manages p->dinfo. All CUPS API calls now use CUPS_HTTP_DEFAULT, letting the library manage its own per-thread Unix domain socket connection to cupsd. Also fix a memory leak in cups_get_Resolution which never freed its dinfo or closed its http_t.
…ive print thread count
…et/print_fd signatures for thread management
… anf fix use of memory after free
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
We start the document only after obtaining the client fd (after accept() for the legacy path, or directly for the FD path). For the FD path this is critical: the frontend receives sv[1] over D-Bus asynchronously and may not have started writing yet. Opening the CUPS HTTP POST before any data is available risks a CUPS server-side timeout ("No file in print request"). By deferring cupsStartDestDocument until the client fd is ready, the first cupsWriteRequestData call follows immediately with no gap.
We always try the FD-passing path first (printFd D-Bus method). This works across Snap/container sandbox boundaries because no socket file is involved. Falls back to the legacy socket-file path (printSocket) only when the backend returns G_DBUS_ERROR_UNKNOWN_METHOD, meaning it is an older backend that does not implement printFd.
On success:
returns an open, writable file descriptor ready for print data
sets *jobid — job ID string, caller must g_free()
sets *socket_path — socket file path (if socket fallback was used) NULL (if FD path was used) ;
Add use_fd flag in thread data
Add backend_obj_wait_for_print_threads function
Update printdatathread
Add print_fd function , on_handle_print_fd function