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
This commit is contained in:
Stefan Eßer 2020-10-29 08:26:38 +00:00
parent 9abc762138
commit 3fa2a149d6

View File

@ -228,6 +228,7 @@ main(int argc, char *argv[])
if (setusercontext(lc, pw, pw->pw_uid, if (setusercontext(lc, pw, pw->pw_uid,
LOGIN_SETALL) != 0) LOGIN_SETALL) != 0)
errx(1, "setusercontext"); errx(1, "setusercontext");
setenv("HOME", pw->pw_dir, 1);
cal(); cal();
exit(0); exit(0);
} }