In 10.2-RELEASE running "calendar -a" as root fails when user calendar files contain #include. This worked in 10.0-RELEASE (and previous releases). $ uname -a FreeBSD freebsd.example.com 10.2-RELEASE FreeBSD 10.2-RELEASE #0: Sun Dec 20 10:00:14 CST 2015 root@freebsd.example.com:/usr/obj/usr/src/sys/GENERIC i386 $ id uid=1000(robert) gid=20(staff) groups=20(staff),0(wheel),5(operator) $ date Sun Dec 20 16:47:44 CST 2015 $ cat ~/.calendar/calendar #include <moredates> $ cat ~/.calendar/moredates 12/20 Today is December 20 $ calendar Dec 20 Today is December 20 root@freebsd# id uid=0(root) gid=0(wheel) groups=0(wheel),5(operator) root@freebsd# calendar -a calendar: can't open calendar file "moredates" My original post to -stable and commentary about calendar's -a option: http://docs.freebsd.org/cgi/mid.cgi?1450670833.594.12.camel Related (but closed) bug report: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=200815
Created attachment 218378 [details] Patch for 11.4-RELEASE requires devel/tradcpp
I was asked (http://docs.FreeBSD.org/cgi/mid.cgi?20200928045733.GE72348) to add my patch to fix this issue here. This patch is against 11.4-RELEASE. Note that it requires the installation of the devel/tradcpp port/package.
A commit references this bug: Author: se Date: Thu Oct 29 08:26:39 UTC 2020 New revision: 367126 URL: https://svnweb.freebsd.org/changeset/base/367126 Log: 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 Changes: head/usr.bin/calendar/calendar.c
A commit in branch stable/12 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=de924aa90ca0d5bd7bbb31125864f0ffca021495 commit de924aa90ca0d5bd7bbb31125864f0ffca021495 Author: Stefan EÃer <se@FreeBSD.org> AuthorDate: 2020-10-29 08:26:38 +0000 Commit: Stefan EÃer <se@FreeBSD.org> CommitDate: 2020-12-31 17:04:47 +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(-)
A commit in branch stable/11 references this bug: 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(-)