Now that cpp(1) understands the CPP_RESTRICTED environment variable, set
that before invoking cpp -- and provide (with appropriate man page warnings) an option to run cpp without this set.
This commit is contained in:
parent
48f45412af
commit
69de851d35
|
@ -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.
|
||||
|
|
|
@ -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 <sys/param.h>
|
||||
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue