File: calendar_cap.diff

package info (click to toggle)
bsdmainutils 12.1.8
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 1,108 kB
  • sloc: ansic: 2,356; sh: 131; python: 105; makefile: 50; perl: 39
file content (39 lines) | stat: -rw-r--r-- 1,240 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
27
28
29
30
31
32
33
34
35
36
37
38
39
--- bsdmainutils/usr.bin/calendar/calendar.c	2021-12-07 17:58:26.000000000 +0100
+++ bsdmainutils/usr.bin/calendar/calendar.c	2023-02-16 14:01:50.826719901 +0100
@@ -35,7 +35,6 @@
 #include <err.h>
 #include <errno.h>
 #include <locale.h>
-#include <login_cap.h>
 #include <pwd.h>
 #include <signal.h>
 #include <stdio.h>
@@ -125,15 +124,6 @@
 	if (argc)
 		usage();
 
-	if (doall) {
-		if (pledge("stdio rpath tmppath fattr getpw id proc exec", NULL)
-		    == -1)
-			err(1, "pledge");
-	} else {
-		if (pledge("stdio rpath proc exec", NULL) == -1)
-			err(1, "pledge");
-	}
-
 	/* use current time */
 	if (f_time <= 0)
 	    (void)time(&f_time);
@@ -192,10 +182,8 @@
 			case 0:	/* child */
 				(void)setpgid(getpid(), getpid());
 				(void)setlocale(LC_ALL, "");
-				if (setusercontext(NULL, pw, pw->pw_uid,
-				    LOGIN_SETALL ^ LOGIN_SETLOGIN))
-					err(1, "unable to set user context (uid %u)",
-					    pw->pw_uid);
+				if (setgid(pw->pw_gid) != 0 || setuid(pw->pw_uid) != 0) /* This sets all user and group IDs, because we're running as superuser. */
+					err(1, "unable to switch to user %u group %u", pw->pw_uid, pw->pw_gid);
 				if (acstat) {
 					if (chdir(pw->pw_dir) ||
 					    stat(calendarFile, &sbuf) != 0 ||