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

Aaron LI aly at crater.dragonflybsd.org
Sat Nov 9 21:11:53 PST 2019


commit f8b849d1082177cbfa11f941feeeced54815dc56
Author: Aaron LI <aly at aaronly.me>
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)'
      fail.
    
      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:
    https://github.com/freebsd/freebsd/commit/7ff75f4a5a3d9ada5bd68384fdded357fa4c1105

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

http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/f8b849d1082177cbfa11f941feeeced54815dc56


-- 
DragonFly BSD source repository



More information about the Commits mailing list