git: calendar(1): Use login caps for 'calendar -a'

Aaron LI aly at
Sat Nov 9 21:11:53 PST 2019

commit f8b849d1082177cbfa11f941feeeced54815dc56
Author: Aaron LI <aly at>
Date:   Sat Nov 9 21:49:18 2019 +0800

    calendar(1): Use login caps for 'calendar -a'
    * Use 'fork()' and 'setusercontext(LOGIN_SETALL)' for every user.  With
      this change, the complex function 'cal()' that parses user-owned
      calendars is now executed with appropriate user privileges.
      Previously it was run with privileges dropped only temporary for
      execution of 'cal()', and fully dropped only before invoking 'sendmail'.
    * In 'calendar -a' mode, the 'getenv("HOME")' in 'cal_fopen()' function
      always returns the root's home directory instead of the current user's
      home (after fork() and setusercontext()), which makes 'chdir(home)'
      Fix this issue by moving the 'chdir(home)' to the 'main()' function in
      'calendar.c'.  In the meantime, back to home directory in
      'cal_fopen()' function after opening the calendar file.
    Partially based on FreeBSD's commit:

Summary of changes:
 usr.bin/calendar/Makefile   |  4 +--
 usr.bin/calendar/calendar.c | 44 ++++++++++++++++++++-------------
 usr.bin/calendar/io.c       | 60 ++++++++++++---------------------------------
 3 files changed, 44 insertions(+), 64 deletions(-)

DragonFly BSD source repository

More information about the Commits mailing list