PKGBUILDs/extra/cups/guid.patch

42 lines
1.2 KiB
Diff
Raw Permalink Normal View History

2021-12-05 16:55:11 +00:00
--- cups-2.4.0/scheduler/cups-exec.c 2021-11-29 16:19:34.235186064 +0100
+++ cups-2.4.0/scheduler/cups-exec.c.new 2021-11-29 16:25:30.764049649 +0100
2024-06-03 18:20:26 +00:00
@@ -134,9 +134,15 @@ main(int argc, /* I - Number of command-line args */
2021-12-05 16:55:11 +00:00
# if CUPS_SNAP
if (setgroups(0, NULL))
# else
2018-01-31 06:35:15 +00:00
- if (setgroups(1, &gid))
2021-12-05 16:55:11 +00:00
-# endif /* CUPS_SNAP */
2018-01-31 06:35:15 +00:00
+#include <pwd.h>
2024-06-03 18:20:26 +00:00
+#include <grp.h>
2018-01-31 06:35:15 +00:00
+ struct passwd * pwd = getpwuid(uid);
+ if(initgroups(pwd->pw_name,pwd->pw_gid))
+ {
+ fprintf(stderr, "DEBUG: initgroups failed\n");
exit(errno + 100);
+ }
2021-12-05 16:55:11 +00:00
+# endif /* CUPS_SNAP */
2018-01-31 06:35:15 +00:00
if (uid && setuid(uid))
exit(errno + 100);
2021-12-05 16:55:11 +00:00
--- cups-2.4.0/scheduler/util.c 2021-11-29 15:27:31.000000000 +0100
+++ cups-2.4.0/scheduler/util.c.new 2021-11-29 16:29:58.810719066 +0100
2024-06-03 18:20:26 +00:00
@@ -296,7 +296,17 @@
2018-01-31 06:35:15 +00:00
*/
if (!getuid() && user)
- setuid(user); /* Run as restricted user */
+ {
+#include <pwd.h>
2024-06-03 18:20:26 +00:00
+#include <grp.h>
2018-01-31 06:35:15 +00:00
+ struct passwd * pwd = getpwuid(user);
+ if(initgroups(pwd->pw_name,pwd->pw_gid))
+ {
+ fprintf(stderr, "DEBUG: initgroups failed\n");
+ exit(errno + 100);
+ }
+ setuid(user); /* Run as restricted user */
+ }
if ((fd = open("/dev/null", O_RDONLY)) > 0)
{