--- 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 ||
