RHEL-54579 [rhel-10] Do not look into /root/.cups/lpoptions when using cupsGetNamedDest as root

Resolves: RHEL-54579
This commit is contained in:
Zdenek Dohnal 2024-11-22 10:59:24 +01:00
parent 0138942a7f
commit 6c03e2bbba
2 changed files with 65 additions and 1 deletions

View File

@ -0,0 +1,57 @@
From 8dce8d76c1f9ae1769284e3a3b9405f906956a10 Mon Sep 17 00:00:00 2001
From: Zdenek Dohnal <zdohnal@redhat.com>
Date: Wed, 9 Oct 2024 10:31:18 +0200
Subject: [PATCH] dest.c: Don't look for user config in cupsGetNamedDest as
root
We were still looking into ~/.cups/lpoptions as root in the function,
which IMHO is not expected.
Merged from master
---
cups/dest.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/cups/dest.c b/cups/dest.c
index b48d8f219..3eeb50933 100644
--- a/cups/dest.c
+++ b/cups/dest.c
@@ -1784,7 +1784,11 @@ cupsGetNamedDest(http_t *http, /* I - Connection to server or @code CUPS_HTT
else
instance = NULL;
}
+#if _WIN32
else if (cg->home)
+#else
+ else if (cg->home && getuid() != 0)
+#endif
{
/*
* No default in the environment, try the user's lpoptions files...
@@ -1899,7 +1903,11 @@ cupsGetNamedDest(http_t *http, /* I - Connection to server or @code CUPS_HTT
snprintf(filename, sizeof(filename), "%s/lpoptions", cg->cups_serverroot);
cups_get_dests(filename, dest_name, instance, 0, 1, 1, &dest);
+#if _WIN32
if (cg->home)
+#else
+ if (cg->home && getuid() != 0)
+#endif // _WIN32
{
#if _WIN32
snprintf(filename, sizeof(filename), "%s/AppData/Local/cups/lpoptions", cg->home);
@@ -3493,7 +3501,11 @@ cups_enum_dests(
snprintf(filename, sizeof(filename), "%s/lpoptions", cg->cups_serverroot);
data.num_dests = cups_get_dests(filename, NULL, NULL, 1, user_default != NULL, data.num_dests, &data.dests);
+#if _WIN32
if (cg->home)
+#else
+ if (cg->home && getuid() != 0)
+#endif // _WIN32
{
#if _WIN32
snprintf(filename, sizeof(filename), "%s/AppData/Local/cups/lpoptions", cg->home);
--
2.47.0

View File

@ -22,7 +22,7 @@ Summary: CUPS printing system
Name: cups
Epoch: 1
Version: 2.4.10
Release: 7%{?dist}
Release: 8%{?dist}
# backend/failover.c - BSD-3-Clause
# cups/md5* - Zlib
# scheduler/colorman.c - Apache-2.0 WITH LLVM-exception AND BSD-2-Clause
@ -87,6 +87,8 @@ Patch1000: 0001-cgi-Fix-checkbox-support-fixes-1008.patch
Patch1001: cups-fix-device-uri-in-webui.patch
# RHEL-54345 Creating IPP Everywhere printer fails due race condition
Patch1002: 0001-Fix-IPP-everywhere-printer-setup-Issue-1033.patch
# RHEL-54579 [rhel-10] Do not look into /root/.cups/lpoptions when using cupsGetNamedDest as root
Patch1003: 0001-dest.c-Don-t-look-for-user-config-in-cupsGetNamedDes.patch
##### Patches removed because IMHO they aren't no longer needed
@ -327,6 +329,8 @@ to CUPS daemon. This solution will substitute printer drivers and raw queues in
%patch -P 1001 -p1 -b .device-uri-webui
# RHEL-54345 Creating IPP Everywhere printer fails due race condition
%patch -P 1002 -p1 -b .fix-ippeve-thread-uri
# RHEL-54579 [rhel-10] Do not look into /root/.cups/lpoptions when using cupsGetNamedDest as root
%patch -P 1003 -p1 -b .root-cupsgetnameddest
# Log to the system journal by default (bug #1078781, bug #1519331).
@ -796,6 +800,9 @@ rm -f %{cups_serverbin}/backend/smb
%{_mandir}/man7/ippeveps.7.gz
%changelog
* Fri Nov 22 2024 Zdenek Dohnal <zdohnal@redhat.com> - 1:2.4.10-8
- RHEL-54579 [rhel-10] Do not look into /root/.cups/lpoptions when using cupsGetNamedDest as root
* Thu Nov 14 2024 Zdenek Dohnal <zdohnal@redhat.com> - 1:2.4.10-7
- RHEL-67580 Move /etc/cups/ssl into cups-filesystem and require filesystem in libs