Date: Fri, 1 Jan 2021 00:53:21 GMT From: Stefan Eßer <se@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: f1031f07fb8b - stable/11 - MFC: Fix calendar -a processing of files included in the user's home directory Message-ID: <202101010053.1010rL6F055035@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch stable/11 has been updated by se: URL: https://cgit.FreeBSD.org/src/commit/?id=f1031f07fb8b3994ffe14b5d780304e4de1f32fb commit f1031f07fb8b3994ffe14b5d780304e4de1f32fb Author: Stefan Eßer <se@FreeBSD.org> AuthorDate: 2020-10-29 08:26:38 +0000 Commit: Stefan Eßer <se@FreeBSD.org> CommitDate: 2021-01-01 00:46:48 +0000 MFC: Fix calendar -a processing of files included in the user's home directory The existing code performed a chdir() into the home directory, but the parser fell back to using the invoking user's home directory as the base directory for the search for an include file. Since use of the -a option is limited to UID==0, the directory searched was typically ~root/.calendar, not the .calendar directory of the user whose file is being processed. PR: 205580 Reported by: greg.bal4@gmail.com (Greg Balfour) MFC after: 3 days (cherry picked from commit 3fa2a149d68d22fa32ba7b6c09773388ac490fd1) The code in -CURRENT is quite different (forks sub-processes tp process the files for each user) but this change should provide the same functionality as the referenced commit to -CURRENT. --- usr.bin/calendar/calendar.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/usr.bin/calendar/calendar.c b/usr.bin/calendar/calendar.c index 84d188071ea9..222cd57cfd1b 100644 --- a/usr.bin/calendar/calendar.c +++ b/usr.bin/calendar/calendar.c @@ -209,8 +209,10 @@ main(int argc, char *argv[]) (void)setegid(pw->pw_gid); (void)initgroups(pw->pw_name, pw->pw_gid); (void)seteuid(pw->pw_uid); - if (!chdir(pw->pw_dir)) + if (!chdir(pw->pw_dir)) { + setenv("HOME", pw->pw_dir, 1); cal(); + } (void)seteuid(0); } else
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202101010053.1010rL6F055035>