From 3b4984d03929448fe088278b6c4d12998110965d Mon Sep 17 00:00:00 2001 From: Mike Pritchard Date: Thu, 6 Feb 1997 05:42:49 +0000 Subject: [PATCH] Initialize the group list when we switch uids when run as root with "calendar -a". Drop all privs when execing other programs. Obtained from: OpenBSD --- usr.bin/calendar/calendar.c | 1 + usr.bin/calendar/io.c | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/usr.bin/calendar/calendar.c b/usr.bin/calendar/calendar.c index 95ecebd743d2..3d7d326fcd3e 100644 --- a/usr.bin/calendar/calendar.c +++ b/usr.bin/calendar/calendar.c @@ -117,6 +117,7 @@ main(argc, argv) if (doall) while ((pw = getpwent()) != NULL) { (void)setegid(pw->pw_gid); + (void)initgroups(pw->pw_name, pw->pw_gid); (void)seteuid(pw->pw_uid); if (!chdir(pw->pw_dir)) cal(); diff --git a/usr.bin/calendar/io.c b/usr.bin/calendar/io.c index fbc5d4658f9f..68b8895c04dd 100644 --- a/usr.bin/calendar/io.c +++ b/usr.bin/calendar/io.c @@ -256,6 +256,8 @@ opencal() (void)close(pdes[1]); } (void)close(pdes[0]); + (void)setuid(geteuid()); + (void)setgid(getegid()); execl(_PATH_CPP, "cpp", "-P", "-I.", _PATH_INCLUDE, NULL); (void)fprintf(stderr, "calendar: execl: %s: %s.\n", _PATH_CPP, strerror(errno)); @@ -305,6 +307,8 @@ closecal(fp) (void)close(pdes[0]); } (void)close(pdes[1]); + (void)setuid(geteuid()); + (void)setegid(getegid()); execl(_PATH_SENDMAIL, "sendmail", "-i", "-t", "-F", "\"Reminder Service\"", "-f", "root", NULL); (void)fprintf(stderr,