File: Pam-group-after-fork.patch

package info (click to toggle)
cron 3.0pl1-162
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 3,204 kB
  • sloc: ansic: 47,007; perl: 733; makefile: 429; sh: 425; python: 36
file content (26 lines) | stat: -rw-r--r-- 924 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
Description: Runs PAM_REINITIALIZE_CRED after fork to apply correct rights to child process.
Author: Jorge Rocha Gualtieri <jorge@jrg.com.br>
Last-Update: 2021-03-01
Bug-Debian: https://bugs.debian.org/983817
Bug-Ubuntu: https://bugs.launchpad.net/bugs/1917350

The feature provided by this patch is tested with the script
debian/tests/check-messages-sent-by-cron (second part of the script)

Index: cron/do_command.c
===================================================================
--- cron.orig/do_command.c
+++ cron/do_command.c
@@ -231,6 +231,12 @@ child_process(e, u)
 		  exit(ERROR_EXIT);
 		}
 # endif
+
+#if defined(USE_PAM)
+                if (pamh != NULL) {
+                        pam_setcred(pamh, PAM_REINITIALIZE_CRED | PAM_SILENT);
+                }
+#endif
 		if (setuid(e->uid) !=0) { /* we aren't root after this... */
 			char msg[256];
 			snprintf(msg, 256, "do_command:setuid(%lu) failed: %s",