=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/calendar/calendar.c,v retrieving revision 1.11 retrieving revision 1.12 diff -c -r1.11 -r1.12 *** src/usr.bin/calendar/calendar.c 1998/11/04 11:32:02 1.11 --- src/usr.bin/calendar/calendar.c 1998/12/13 07:31:07 1.12 *************** *** 1,4 **** ! /* $OpenBSD: calendar.c,v 1.11 1998/11/04 11:32:02 pjanzen Exp $ */ /* * Copyright (c) 1989, 1993, 1994 --- 1,4 ---- ! /* $OpenBSD: calendar.c,v 1.12 1998/12/13 07:31:07 pjanzen Exp $ */ /* * Copyright (c) 1989, 1993, 1994 *************** *** 43,49 **** #if 0 static const char sccsid[] = "@(#)calendar.c 8.3 (Berkeley) 3/25/94"; #else ! static char rcsid[] = "$OpenBSD: calendar.c,v 1.11 1998/11/04 11:32:02 pjanzen Exp $"; #endif #endif /* not lint */ --- 43,49 ---- #if 0 static const char sccsid[] = "@(#)calendar.c 8.3 (Berkeley) 3/25/94"; #else ! static char rcsid[] = "$OpenBSD: calendar.c,v 1.12 1998/12/13 07:31:07 pjanzen Exp $"; #endif #endif /* not lint */ *************** *** 55,60 **** --- 55,61 ---- #include #include #include + #include #include #include "pathnames.h" *************** *** 67,81 **** int f_dayAfter = 0; /* days after current date */ int f_dayBefore = 0; /* days before current date */ int main(argc, argv) int argc; char *argv[]; { ! int ch; char *caldir; ! (void) setlocale(LC_ALL, ""); while ((ch = getopt(argc, argv, "-af:t:A:B:")) != -1) switch (ch) { --- 68,84 ---- int f_dayAfter = 0; /* days after current date */ int f_dayBefore = 0; /* days before current date */ + struct specialev spev[NUMEV]; + int main(argc, argv) int argc; char *argv[]; { ! int ch, i; char *caldir; ! (void)setlocale(LC_ALL, ""); while ((ch = getopt(argc, argv, "-af:t:A:B:")) != -1) switch (ch) { *************** *** 91,97 **** break; case 't': /* other date, undocumented, for tests */ ! if ((f_time = Mktime (optarg)) <= 0) errx(1, "specified date is outside allowed range"); break; --- 94,100 ---- break; case 't': /* other date, undocumented, for tests */ ! if ((f_time = Mktime(optarg)) <= 0) errx(1, "specified date is outside allowed range"); break; *************** *** 116,130 **** if (f_time <= 0) (void)time(&f_time); ! settime(f_time); if (doall) { while ((pw = getpwent()) != NULL) { (void)setegid(pw->pw_gid); (void)initgroups(pw->pw_name, pw->pw_gid); (void)seteuid(pw->pw_uid); ! if (!chdir(pw->pw_dir)) cal(); (void)seteuid(0); } } --- 119,145 ---- if (f_time <= 0) (void)time(&f_time); ! if (f_dayBefore) { ! /* Move back in time and only look forwards */ ! f_dayAfter += f_dayBefore; ! f_time -= SECSPERDAY * f_dayBefore; ! f_dayBefore = 0; ! } ! settime(&f_time); if (doall) { while ((pw = getpwent()) != NULL) { + (void)setlocale(LC_ALL, ""); (void)setegid(pw->pw_gid); (void)initgroups(pw->pw_name, pw->pw_gid); (void)seteuid(pw->pw_uid); ! if (!chdir(pw->pw_dir)) { cal(); + /* Keep user settings from propogating */ + for (i = 0; i < NUMEV; i++) + if (spev[i].uname != NULL) + free(spev[i].uname); + } (void)seteuid(0); } }