Subject: bin/5395: Allow calendar to use a local calendar dir
To: None <gnats-bugs@gnats.netbsd.org>
From: Heiko W.Rupp <hwr@pilhuhn.de>
List: netbsd-bugs
Date: 05/03/1998 13:50:20
>Number:         5395
>Category:       bin
>Synopsis:       Allow calendar to use a local calendar dir
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Sun May  3 05:05:00 1998
>Last-Modified:
>Originator:     Heiko W.Rupp
>Organization:
private
>Release:        NetBSD 1.3.1
>Environment:
System: NetBSD snert 1.3.1 NetBSD 1.3.1 (SNERT) #1: Thu Apr 30 19:50:31 MEST 1998 hwr@snert:/usr/src/sys/arch/i386/compile/SNERT i386


>Description:
	Many admins don't want to fill the main /usr tree with own files
    as this makes upgrading etc. harder. So local changes often go to
    /usr/local/*. 
    If you want to have site local calendar files (not local to the
    user, but local to the entire site), they need to specify the
    full path in the include within the calendar file
	
>How-To-Repeat:

cat ~/calendar

#include </usr/local/share/calendar/calendar.misc>

>Fix:

Either:
in pathnames.h change from
#define _PATH_INCLUDE   "-I/usr/share/calendar"
to
#define _PATH_INCLUDE   "-I/usr/share/calendar -I/usr/local/share/calendar""

Or (which is more flexible, best would possibly be a /etc/calendar/conf):


*** calendar.c.orig	Sun May  3 12:46:01 1998
--- calendar.c	Sun May  3 13:44:41 1998
***************
*** 76,81 ****
--- 76,82 ----
  char *fname = "calendar", *datestr = NULL;
  struct passwd *pw;
  int doall;
+ char *calendir;
  
  void	 atodays __P((char, char *, unsigned short *));
  void	 cal __P((void));
***************
*** 99,105 ****
  	int ch;
  	char *caldir;
  
! 	while ((ch = getopt(argc, argv, "-ad:f:l:w:")) != -1)
  		switch (ch) {
  		case '-':		/* backward contemptible */
  		case 'a':
--- 100,106 ----
  	int ch;
  	char *caldir;
  
! 	while ((ch = getopt(argc, argv, "-ad:f:l:w:I:")) != -1)
  		switch (ch) {
  		case '-':		/* backward contemptible */
  		case 'a':
***************
*** 121,126 ****
--- 122,130 ----
  		case 'w':
  			atodays(ch, optarg, &weekend);
  			break;
+ 		case 'I':
+ 			calendir = optarg;
+ 			break;
  		case '?':
  		default:
  			usage();
***************
*** 321,326 ****
--- 325,332 ----
  opencal()
  {
  	int fd, pdes[2];
+ 	char *path_cpp;
+ 	int path_cpps;
  
  	/* open up calendar file as stdin */
  	if (!freopen(fname, "r", stdin)) {
***************
*** 342,348 ****
  			(void)close(pdes[1]);
  		}
  		(void)close(pdes[0]);
! 		execl(_PATH_CPP, "cpp", "-P", "-I.", _PATH_INCLUDE, NULL);
  		warn("execl: %s", _PATH_CPP);
  		_exit(1);
  	}
--- 348,359 ----
  			(void)close(pdes[1]);
  		}
  		(void)close(pdes[0]);
! 		path_cpps=strlen(_PATH_INCLUDE)+strlen(calendir)+4;
! 		path_cpp=(char*)malloc(path_cpps);
! 		if(path_cpp==NULL)
! 			_exit(1);
! 		sprintf(path_cpp,"%s -I%s",_PATH_INCLUDE,calendir);
! 		execl(_PATH_CPP, "cpp", "-P", "-I.", path_cpp, NULL);
  		warn("execl: %s", _PATH_CPP);
  		_exit(1);
  	}
*** calendar.1.orig	Sun May  3 12:46:07 1998
--- calendar.1	Sun May  3 13:48:03 1998
***************
*** 46,51 ****
--- 46,52 ----
  .Op Fl l Ar days
  .Op Fl w Ar days
  .Op Fl d Ar MMDD[[YY]YY]
+ .Op Fl I Ar path
  .Sh DESCRIPTION
  The 
  .Nm
***************
*** 82,87 ****
--- 83,91 ----
  value is two, which causes
  .Nm
  to print entries through the weekend on Fridays.
+ .It Fl I Ar path
+ Causes the program to also search calendar files in the directory
+ nominated by path. This is to allow for a site wide local calendar dir.
  .El
  .Pp
  Lines should begin with a month and day.
>Audit-Trail:
>Unformatted: