mirror of
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git
synced 2025-01-01 00:18:15 +01:00
Search the include path for the argument to -f, to make lives easier for
those of us who want to figure out how old Jim Mock is, but only want to type 'calendar -f calendar.freebsd'. This is done in a way that should be totally backwards compatible with no noticable differences, at all. Reviewed by: mux MFC after: 4 weeks
This commit is contained in:
parent
6ee0eb7eda
commit
afb325f75d
@ -68,7 +68,7 @@ __FBSDID("$FreeBSD$");
|
||||
|
||||
|
||||
const char *calendarFile = "calendar"; /* default calendar file */
|
||||
const char *calendarHome = ".calendar"; /* HOME */
|
||||
const char *calendarHomes[] = { ".calendar", _PATH_INCLUDE }; /* HOME */
|
||||
const char *calendarNoMail = "nomail"; /* don't sent mail if this file exist */
|
||||
|
||||
struct fixs neaster, npaskha;
|
||||
@ -236,13 +236,14 @@ FILE *
|
||||
opencal()
|
||||
{
|
||||
uid_t uid;
|
||||
int fd, pdes[2];
|
||||
size_t i;
|
||||
int fd, found, pdes[2];
|
||||
struct stat sbuf;
|
||||
|
||||
/* open up calendar file as stdin */
|
||||
if (!freopen(calendarFile, "r", stdin)) {
|
||||
if (doall) {
|
||||
if (chdir(calendarHome) != 0)
|
||||
if (chdir(calendarHomes[0]) != 0)
|
||||
return (NULL);
|
||||
if (stat(calendarNoMail, &sbuf) == 0)
|
||||
return (NULL);
|
||||
@ -250,9 +251,15 @@ opencal()
|
||||
return (NULL);
|
||||
} else {
|
||||
chdir(getenv("HOME"));
|
||||
if (!(chdir(calendarHome) == 0 &&
|
||||
freopen(calendarFile, "r", stdin)))
|
||||
errx(1, "no calendar file: ``%s'' or ``~/%s/%s\n", calendarFile, calendarHome, calendarFile);
|
||||
for (found = i = 0; i < sizeof(calendarHomes) /
|
||||
sizeof(calendarHomes[0]); i++)
|
||||
if (chdir(calendarHomes[i]) == 0 &&
|
||||
freopen(calendarFile, "r", stdin)) {
|
||||
found = 1;
|
||||
break;
|
||||
}
|
||||
if (!found)
|
||||
errx(1, "no calendar file: ``%s''", calendarFile);
|
||||
}
|
||||
}
|
||||
if (pipe(pdes) < 0)
|
||||
|
Loading…
Reference in New Issue
Block a user