diff --git a/usr.bin/calendar/calendar.1 b/usr.bin/calendar/calendar.1 index 4b9b331ca88b..522e0791a3fd 100644 --- a/usr.bin/calendar/calendar.1 +++ b/usr.bin/calendar/calendar.1 @@ -1,4 +1,4 @@ -.\" $NetBSD: calendar.1,v 1.17 2004/11/29 20:22:31 wiz Exp $ +.\" $NetBSD: calendar.1,v 1.18 2004/11/30 01:54:17 jwise Exp $ .\" .\" Copyright (c) 1989, 1990, 1993 .\" The Regents of the University of California. All rights reserved. @@ -42,6 +42,7 @@ .Op Fl l Ar days .Op Fl w Ar days .Op Fl d Ar MMDD[[YY]YY] +.OP Fl x .Sh DESCRIPTION The .Nm @@ -90,6 +91,21 @@ ahead'' number if and only if the day specified is a Friday. The default value is two, which causes .Nm to print entries through the weekend on Fridays. +.It Fl x +Causes +.Nm +not to set the CPP_RESTRICTED environment variable. Passing this flag +allows users the (somewhat obscure) option of including a named pipe +via +.Xr cpp 1 's +.Pq Li #include +syntax, but opens up the possibility of +.Nm +hanging indefinitely if users do so incorrectly. For this reason, the +.Fl x +flag should never be used with +.Nm +.Fl a . .El .Pp Lines should begin with a month and day. diff --git a/usr.bin/calendar/calendar.c b/usr.bin/calendar/calendar.c index 60d60d6b830d..5ce8e4845ea5 100644 --- a/usr.bin/calendar/calendar.c +++ b/usr.bin/calendar/calendar.c @@ -1,4 +1,4 @@ -/* $NetBSD: calendar.c,v 1.32 2004/11/29 18:25:14 jwise Exp $ */ +/* $NetBSD: calendar.c,v 1.33 2004/11/30 01:54:17 jwise Exp $ */ /* * Copyright (c) 1989, 1993, 1994 @@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1989, 1993\n\ #if 0 static char sccsid[] = "@(#)calendar.c 8.4 (Berkeley) 1/7/95"; #endif -__RCSID("$NetBSD: calendar.c,v 1.32 2004/11/29 18:25:14 jwise Exp $"); +__RCSID("$NetBSD: calendar.c,v 1.33 2004/11/30 01:54:17 jwise Exp $"); #endif /* not lint */ #include @@ -75,6 +75,7 @@ static char *defaultnames[] = {"calendar", ".calendar", "/etc/calendar", NULL}; static struct passwd *pw; static int doall; static char path[MAXPATHLEN + 1]; +static int cpp_restricted = 0; /* 1-based month, 0-based days, cumulative */ static int daytab[][14] = { @@ -148,6 +149,8 @@ main(argc, argv) case 'w': atodays(ch, optarg, &weekend); break; + case 'x': + cpp_restricted = 1; case '?': default: usage(); @@ -365,6 +368,11 @@ opencal(void) (void)close(pdes[1]); } (void)close(pdes[0]); + /* tell CPP to only open regular files */ + if(!cpp_restricted && setenv("CPP_RESTRICTED", "", 1)) + err(1, "Cannot restrict cpp"); + cpp_restricted = 1; + (void)execl(_PATH_CPP, "cpp", "-traditional", "-P", "-I.", "-I" _PATH_CALENDARS, NULL); err(1, "Cannot exec `%s'", _PATH_CPP);