Commit Graph

53 Commits

Author SHA1 Message Date
agc 1f657fa580 Commit patch sent to tech-userlevel with universal approval to add a
version option for calendar(1):

	% calendar -v
	calendar-20160601
	%

For reference, see:

	http://mail-index.netbsd.org/tech-userlevel/2016/06/02/msg010081.html
2016-06-03 02:06:40 +00:00
dholland 3b1701b0a5 Repair accidental regression in -r1.49: for -a mode, don't allow
calendars to be other than regular files unless the -x option is in
effect.

(If not in -a mode, we're running purely as the user whose calendar it
is and if they want to DoS themselves with named pipes it's their own
lookout.)
2015-07-01 06:48:25 +00:00
dholland c1180ac6a1 Correct privilege handling problems in calendar -a (which runs as root
from /etc/daily); do not exec other programs while the real uid is
still 0.

Also, clear the supplementary groups list up front and call initgroups
when becoming another user, to avoid leaking any extra group
privileges that we might have.

And finally, don't silently ignore errors changing uid and gid; those
are serious if they happen.
2015-07-01 06:45:51 +00:00
christos 232e5144bb reorganize to make clear variable use. 2013-11-09 15:57:15 +00:00
matthias 3b1e581385 Stop playing games with stdin and stdout file descriptors.
calendar did not work with nss_ldap installed. Typical symptoms were
      cc1: error: stdout: Bad file descriptor
in daily.out.
2012-04-03 12:03:04 +00:00
wiz 3d8b25a8ff Fix problem of reporting wrong matches noted in PR 41945 by using a patch
provided by Robert Elz in that PR.
2009-12-08 13:49:08 +00:00
dholland b458f98fad If the parser scrapes up something it thinks is positionally a month, but
is numerically out of range, do something reasonable instead of crashing.
PR bin/39627.
2008-09-30 05:51:41 +00:00
lukem 98e5374ccb Remove the \n and tabs from the __COPYRIGHT() strings.
Tweak to use a consistent format.
2008-07-21 14:19:20 +00:00
christos e8853135f2 fixed reversed tests in calendar (from Anon Ymous) 2008-04-09 17:47:53 +00:00
christos 53175f5071 ansi and lint fixes from Anon Ymous 2008-03-07 19:22:22 +00:00
christos 0bdd655872 Treat "Thursday" as "*Thursday" from anon ymous 2008-03-06 17:37:57 +00:00
perry 8b0f9554ff convert __attribute__s to applicable cdefs.h macros 2007-12-15 19:44:37 +00:00
elad 89f8748c35 PR/20319: Jeremy C. Reed: calendar reports other months that have matching
days

Patch applied, thanks!
2006-10-07 07:12:01 +00:00
elad e42f031453 PR/30107: Bob Kemp: calendar reports non-matching days.
Applied patch, and also apply patch from Johan Veenhuizen to fix bug
introduced later on -- thanks for the patches!
2006-09-23 22:25:19 +00:00
jld 42ddba8762 Correct logic error in wildcard handling, which was causing the
day-of-month on normal entries to always be treated as a wildcard.

Specifically, "if (x&(y|z))" is equivalent to "if ((x&y)||(x&z))", not
"if ((x&y)&&(x&z))", which latter is clearly what was intended.
2006-03-24 23:30:08 +00:00
wiz bbd944217e Add missing break. From YOMURA Masanori in PR 30751. 2005-07-15 09:45:04 +00:00
lukem 658ed3362c appease gcc -Wuninitialized 2005-06-02 01:35:57 +00:00
jwise 8e40de5fcb Since we fall back to /etc/calendar now (if present), put that path properly
in pathnames.h.
2004-12-07 16:47:32 +00:00
jwise 4f1d9bdb73 Play with calendar syntax a little, allowing both of month and day
to be wildcarded.

As a side effect, this allows '**' in the date field to match every
day of the year, which is very useful for TODO items.

It's important to note that the syntax has a lot of hardcoded (and
undocumented) ambiguity resolution stuff, and is crying out for a
simplification, and maybe some use of yacc and lex.

When this is done, a minor flag day (and probably a compatibility
flag :-( ) should be included, for current users who are making
use of some of the corner cases.  I'll raise this on tech-userlevel
before going there.  CVS:
----------------------------------------------------------------------
2004-12-06 20:38:43 +00:00
wiz 53693aebe6 Add -x to usage and to getopt options string (hi Jim!). 2004-11-30 10:39:53 +00:00
jwise 69de851d35 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.
2004-11-30 01:54:17 +00:00
jwise e7f10875fa On further thought, always search for calendar files in the caller's home
directory when called directly (this was already done for calendar -a, by
definition).

Old behavior is still available by setting "CALENDAR_DIR=.".
2004-11-29 18:25:14 +00:00
jwise d728174e30 Instead of searching only for a calendar file named `calendar' in the current
directory, use the first found of:

	./calendar
	./.calendar
	/etc/calendar

Note that currently only the first found of these is used (so that users may
override a system calendar placed in /etc if desired).  Users who want can always
use #include to continue the chain...
2004-11-29 17:03:43 +00:00
jmmv b635f565e7 Homogenize usage messages: make the 'usage' word all lowercase, as this seems
to be the most common practice in our tree.
2004-01-05 23:23:32 +00:00
briggs ef852c60a0 Add option to remove escape character before comment character in
fparseln().  Add escape characters before comment characters in the
few places those appear in the calendar data files.
2003-09-30 15:00:18 +00:00
agc 89aaa1bb64 Move UCB-licensed code from 4-clause to 3-clause licence.
Patches provided by Joel Baker in PR 22365, verified by myself.
2003-08-07 11:13:06 +00:00
lukem d348d3d723 tweaks for fparseln(3) move from libutil to libc:
- remove #include <util.h> if nothing else needed it
- remove LDFLAGS+=-lutil if nothing else needed it
2002-11-30 03:10:53 +00:00
christos bb58ba64b2 - knf
- use cpp -traditional, since the default has now changed. We want to allow
  unmatched single quotes!
- use fparseln, instead of a fixed 2k buffer.
- make all locals static and move to the top. This is so we can eventually
  make calendar understand languages other than us_en
- add braces and continue's to clarify things.
- replace gratuitous fprintf uses with warnx.
- replace vforks() with forks() since we tried to print errors with stdio.
- add more warnings so that we know how things fail.

XXX: Eventually we'll have to remove the cpp dependency, and we should:
	- make it use m4 instead [bad, breaks compatibility]
    or
	- add a small cpp like parser for #include [bad, too much code]
2001-12-04 15:55:32 +00:00
cgd a8ec668ddf convert to use getprogname() 2001-02-19 23:03:42 +00:00
cgd 9725bb291b __CONCAT does token pasting, not string concatnation. if something like:
__CONCAT("foo","bar");
actually works to concantate strings, it's because the preprocessor expands
it into "foo""bar" as separate strings, and then ANSI string concatenation
is performed on that.  It's more straightforward to just use ANSI string
concatenation directly, and newer GCCs complain (rightly) about misuse
of token pasting.
2000-12-20 01:03:16 +00:00
christos e8048693f8 Open only plain files [please someone add O_REG_ONLY]. Since /etc/daily
runs calendar -a, a malicious user can put a fifo in his home directory
to prevent calendar from completing. Many thanks to: dynamo@ime.net
2000-11-29 15:29:51 +00:00
simonb 2c0eddaf19 Don't declare 'extern opt*' getopt variables.
Don't need to declare __progname in getmmdd() - it's already done earlier
in this file.
2000-04-14 06:07:14 +00:00
drochner 85cbf55d16 Since our gcc doesn't warn about NULL format strings anymore, we can
fix the incorrect err(1, "%s", "") et al.
Closes PR bin/7592 by cgd.
1999-11-09 15:06:30 +00:00
lukem 3f8c4dac86 revert previous 1999-11-02 10:55:47 +00:00
lukem 0895d2339e remove superfluous '-' in getopt string 1999-11-02 10:52:49 +00:00
christos 9b6b9cac77 - factor out common code
- char -> unsigned char
1998-11-06 22:56:38 +00:00
wsanchez 1426fb14d2 Use __CONCAT to concatenate strings "-I" and _PATH_CALENDARS. 1998-10-12 20:51:06 +00:00
wsanchez 76847494e0 Replace _PATH_INCLUE with _PATH_CALENDARS for clarity. 1998-10-12 20:38:55 +00:00
mycroft 519d858510 __AUDIT__ cleanup. 1998-07-28 19:22:54 +00:00
mycroft f9f7e98dab const poisoning. 1998-07-27 07:41:31 +00:00
kleink c31696e747 Need <time.h> for time(), localtime(), strftim() and mktime() prototypes. 1998-04-01 20:50:17 +00:00
christos ae32ae7441 - Y2K fixes
- fix usage message
1998-02-04 15:19:50 +00:00
lukem 0b3de1cab3 WARNSify, fix .Nm usage, deprecate register 1997-10-18 12:27:31 +00:00
thorpej a73d0efd45 Enhancements from Ty Sarna <tsarna@endicor.com>, per PR #3935. Allow
user to:
- get entries from a file other than "calendar".
- get entries for a different date than today.
- get entries for a whole week in advance, or only one day.
1997-08-26 19:58:10 +00:00
lukem 19474db41e Ensure calendar doesn't go past \0 in a string.
From Douglas Crosher <dtc@scrooge.ee.swin.oz.au> in [bin/1018]
1997-06-20 08:11:34 +00:00
jtc 29ab121b2f Sync with 4.4lite2 1995-09-02 05:38:38 +00:00
glass e9d0e83acb merged with 4.4Lite. 1995-03-27 08:46:11 +00:00
hpeyerl fdecad7de9 Fix for verbal dayname parsing and support for CALENDAR_DIR
environment variable.  Also take out a superfluous word in the
manpage.
1995-03-26 03:59:07 +00:00
cgd 7bcf44497f invoke cpp with -P 1994-12-30 21:57:09 +00:00
cgd 749dc802ca fix "bin/135: calendar bug", and another bug found while looking into it.
the reported bug was fixed with the reported fix, from Keith White
<kwhite@csi.UOttawa.CA>.  The newly-found bug was fixed by me.
1994-02-22 09:46:29 +00:00