From dan_strick@sbcglobal.net  Fri Mar 16 17:12:59 2012
Return-Path: <dan_strick@sbcglobal.net>
Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52])
	by hub.freebsd.org (Postfix) with ESMTP id F2AAF106566C
	for <freebsd-gnats-submit@freebsd.org>; Fri, 16 Mar 2012 17:12:59 +0000 (UTC)
	(envelope-from dan_strick@sbcglobal.net)
Received: from nm15.bullet.mail.sp2.yahoo.com (nm15.bullet.mail.sp2.yahoo.com [98.139.91.85])
	by mx1.freebsd.org (Postfix) with SMTP id C401C8FC12
	for <freebsd-gnats-submit@freebsd.org>; Fri, 16 Mar 2012 17:12:59 +0000 (UTC)
Received: from [72.30.22.93] by nm15.bullet.mail.sp2.yahoo.com with NNFMP; 16 Mar 2012 17:12:53 -0000
Received: from [68.142.194.243] by tm15.bullet.mail.sp2.yahoo.com with NNFMP; 16 Mar 2012 17:12:53 -0000
Received: from [66.94.237.123] by t1.bullet.mud.yahoo.com with NNFMP; 16 Mar 2012 17:12:53 -0000
Received: from [127.0.0.1] by omp1028.access.mail.mud.yahoo.com with NNFMP; 16 Mar 2012 17:12:53 -0000
Received: (qmail 29433 invoked from network); 16 Mar 2012 17:12:52 -0000
Received: from mist.nodomain (dan_strick@69.228.91.213 with login)
        by smtp102.sbc.mail.mud.yahoo.com with SMTP; 16 Mar 2012 10:12:52 -0700 PDT
Received: from mist.nodomain (localhost [127.0.0.1])
	by mist.nodomain (8.14.5/8.14.5) with ESMTP id q2GHCk4g051598;
	Fri, 16 Mar 2012 10:12:46 -0700 (PDT)
	(envelope-from dan@mist.nodomain)
Received: (from dan@localhost)
	by mist.nodomain (8.14.5/8.14.5/Submit) id q2GHCkuN051597;
	Fri, 16 Mar 2012 10:12:46 -0700 (PDT)
	(envelope-from dan)
Message-Id: <201203161712.q2GHCkuN051597@mist.nodomain>
Date: Fri, 16 Mar 2012 10:12:46 -0700 (PDT)
From: Dan Strick <mla_strick@att.net>
Reply-To: Dan Strick <mla_strick@att.net>
To: FreeBSD-gnats-submit@freebsd.org
Cc: mla@mist.nodomain
Subject: calendar -a does not work
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         166181
>Category:       bin
>Synopsis:       [patch] calendar(1): calendar -a does not work
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Mar 16 17:20:03 UTC 2012
>Closed-Date:    
>Last-Modified:  Thu Mar 13 23:50:00 UTC 2014
>Originator:     Dan Strick
>Release:        FreeBSD 9.0-RELEASE i386
>Organization:
>Environment:
System: FreeBSD mist 9.0-RELEASE FreeBSD 9.0-RELEASE #1: Thu Jan 26 02:06:21 PST 2012 root@mist:/sys/i386/compile/MIST i386
>Description:
	When I run "caledar -a", it seems to ignore my calendar file.
>How-To-Repeat:
	Create a personal calendar file with test entries and run
	"calendar -a" as root.
>Fix:
	I don't claim to understand exactly how this code was intended to
	work, but I made the problem go away by adding the line

		y = NULL;

	just before the last return statement in the walkthrough_dates()
	function in the source file dates.c.


	Here is the context diff:

		*** dates.c.ori Mon Jan  2 19:23:46 2012
		--- dates.c     Fri Mar 16 09:26:44 2012
		***************
		*** 401,406 ****
		--- 401,407 ----
               		 *e = d->events;
		                return (1);
        		}
		+       y = NULL;
  
        		return (0);
  		}
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->eadler 
Responsible-Changed-By: eadler 
Responsible-Changed-When: Sat Mar 24 04:31:43 UTC 2012 
Responsible-Changed-Why:  
I'll take it - for future reference, please use unified diffs only 

http://www.freebsd.org/cgi/query-pr.cgi?pr=166181 
State-Changed-From-To: open->feedback 
State-Changed-By: eadler 
State-Changed-When: Sat Mar 24 04:38:51 UTC 2012 
State-Changed-Why:  
I can not reproduce this problem - an you provide an example calendar 
file and ls -laot calendar? 

http://www.freebsd.org/cgi/query-pr.cgi?pr=166181 
State-Changed-From-To: feedback->open 
State-Changed-By: eadler 
State-Changed-When: Sun Mar 25 01:02:50 UTC 2012 
State-Changed-Why:  
submitter provided requested information 

http://www.freebsd.org/cgi/query-pr.cgi?pr=166181 

From: Eitan Adler <eadler@freebsd.org>
To: bug-followup@freebsd.org
Cc:  
Subject: Re: bin/166181: [patch] calendar(1): calendar -a does not work
Date: Sun, 6 May 2012 15:55:46 -0400

 ---------- Forwarded message ----------
 From: Dan Strick <dan_strick@sbcglobal.net>
 Date: 24 March 2012 20:58
 Subject: Re: bin/166181: [patch] calendar(1): calendar -a does not work
 To: eadler@freebsd.org
 Cc: mla@mist.nodomain
 
 
 Re: bug report 166181
 
 >
 > =C2=A0I can not reproduce this problem - an you provide an example calend=
 ar
 > =C2=A0file and ls -laot calendar?
 >
 
 Example calendar file (~guest/calendar):
 
 =C2=A0 =C2=A0 =C2=A0 =C2=A0*/24 =C2=A0 =C2=A0test 24
 =C2=A0 =C2=A0 =C2=A0 =C2=A0*/25 =C2=A0 =C2=A0test 25
 =C2=A0 =C2=A0 =C2=A0 =C2=A0*/26 =C2=A0 =C2=A0test 26
 =C2=A0 =C2=A0 =C2=A0 =C2=A0*/27 =C2=A0 =C2=A0test 27
 =C2=A0 =C2=A0 =C2=A0 =C2=A0*/28 =C2=A0 =C2=A0test 28
 =C2=A0 =C2=A0 =C2=A0 =C2=A0*/29 =C2=A0 =C2=A0test 29
 =C2=A0 =C2=A0 =C2=A0 =C2=A0*/30 =C2=A0 =C2=A0test 30
 =C2=A0 =C2=A0 =C2=A0 =C2=A0*/31 =C2=A0 =C2=A0test 31
 
 "ls -laot calendar" produces:
 
 =C2=A0 =C2=A0 =C2=A0 =C2=A0-rw-r--r-- =C2=A01 guest =C2=A0guest =C2=A0- 104=
  Mar 24 17:10 calendar
 
 "ls -laot /usr/bin/calendar*" produces:
 
 =C2=A0 =C2=A0 =C2=A0 =C2=A0-rwxr-xr-x =C2=A01 root =C2=A0wheel =C2=A0- 4528=
 8 Mar 16 09:37 /usr/bin/calendar
 =C2=A0 =C2=A0 =C2=A0 =C2=A0-r-xr-xr-x =C2=A01 root =C2=A0wheel =C2=A0- 4528=
 8 Jan =C2=A02 23:26 /usr/bin/calendar.ori
 
 "calendar.ori" is the program installed with release 9.0 and "calendar" is
 the program I built after modifying the source file "dates.c".
 
 Doing "diff -u dates.c.ori dates.c" produces:
 
 =C2=A0 =C2=A0 =C2=A0 =C2=A0--- dates.c.ori 2012-01-02 19:23:46.000000000 -0=
 800
 =C2=A0 =C2=A0 =C2=A0 =C2=A0+++ dates.c =C2=A0 =C2=A0 2012-03-16 09:26:44.00=
 0000000 -0700
 =C2=A0 =C2=A0 =C2=A0 =C2=A0@@ -401,6 +401,7 @@
 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
 =A0 =C2=A0*e =3D d->events;
 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
 =A0 =C2=A0return (1);
 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0}
 =C2=A0 =C2=A0 =C2=A0 =C2=A0+ =C2=A0 =C2=A0 =C2=A0 y =3D NULL;
 
 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return (0);
 =C2=A0 =C2=A0 =C2=A0 =C2=A0}
 
 Doing "calendar" as user guest produces:
 
 =C2=A0 =C2=A0 =C2=A0 =C2=A0Mar 24 =C2=A0test 24
 =C2=A0 =C2=A0 =C2=A0 =C2=A0Mar 25 =C2=A0test 25
 
 Doing "calendar.ori -a" as root sends this email to guest:
 
 =C2=A0 =C2=A0 =C2=A0 =C2=A0From guest@sbcglobal.net Sat Mar 24 17:47:56 201=
 2
 =C2=A0 =C2=A0 =C2=A0 =C2=A0Date: Sun, 25 Mar 2012 00:47:56 GMT
 =C2=A0 =C2=A0 =C2=A0 =C2=A0From: "Reminder Service" <guest@mist.nodomain>
 =C2=A0 =C2=A0 =C2=A0 =C2=A0To: <guest@mist.nodomain>
 =C2=A0 =C2=A0 =C2=A0 =C2=A0Subject: Saturday, 24 March 2012's Calendar
 =C2=A0 =C2=A0 =C2=A0 =C2=A0Precedence: bulk
 
 =C2=A0 =C2=A0 =C2=A0 =C2=A0Mar 24 =C2=A0test 24
 =C2=A0 =C2=A0 =C2=A0 =C2=A0Mar 25 =C2=A0test 25
 
 Doing "calendar -a" as root sends no email to guest.
 
 
 
 --=20
 Eitan Adler
 Source & Ports committer
 X11, Bugbusting teams
Responsible-Changed-From-To: eadler->freebsd-bugs 
Responsible-Changed-By: eadler 
Responsible-Changed-When: Sun Sep 2 17:05:13 UTC 2012 
Responsible-Changed-Why:  
I won't be looking at this PR for a while and I need to clear some out 
of my queue 

http://www.freebsd.org/cgi/query-pr.cgi?pr=166181 

From: Steve Grandi <grandi@noao.edu>
To: bug-followup@FreeBSD.org,
 mla_strick@att.net
Cc:  
Subject: Re: bin/166181: [patch] calendar(1): calendar -a does not work
Date: Thu, 2 May 2013 12:41:11 -0700

 Proposed patch causes information from ALL calendars on the system to be =
 mailed to each user.  Not an acceptable solution.
 
 --=20
 Steve Grandi
 National Optical Astronomy Observatory/AURA Inc., Tucson AZ USA
 Internet: grandi@noao.edu  Voice: +1 520 318-8228  FAX: 318-8360
 
 
 

From: mla_strick@att.net 
To: bug-followup@FreeBSD.org, grandi@noao
Cc: mla_strick@att.net
Subject: SRe: bin/166181: [patch] calendar(1): calendar -a does not work
Date: Wed,  8 May 2013 16:21:30 -0700 (PDT)

 >
 > Proposed patch causes information from ALL calendars on the system to be
 > mailed to each user.  Not an acceptable solution.
 >
 
 I confess to not understanding how the calendar program code is
 supposed to work.  I may have confused it by using the same user id
 for two different password file entries.  I noticed, for example, that
 lines from one user's calendar file were sometimes mailed to the other
 user.
 
 I have since given up on running "calendar -a" via the /etc/periodic
 mechanism and now just run calendar for myself out of my own crontab.
 So far this seems to work.
 
 Dan Strick
 mla_strick@att.net

From: oliver <oliver@beefrankly.org>
To: bug-followup@FreeBSD.org, mla_strick@att.net
Cc:  
Subject: Re: bin/166181: [patch] calendar(1): calendar -a does not work
Date: Fri, 14 Mar 2014 00:37:13 +0100

 --MP_/2_vQjW5KtHVoyOm9Zq0qQ6L
 Content-Type: text/plain; charset=US-ASCII
 Content-Transfer-Encoding: 7bit
 Content-Disposition: inline
 
 I found this problem is still there in stable/10.0 and CURRRENT.
 
 I could reproduce the problem:
 
 If you have multiple calendar files for multiple users, only the first
 calendar file will be mailed. That's because the function
 walkthrough_dates was only intended to run once. So it does not reset
 its state and stays on the last day. 
 
 This can be fixed, as the PR sender did, but that causes the program to
 start from the beginning, adding the new events from the next users
 calendar to the existing struct. so for every run, the old entries are
 kept and the new ones are added. So events from a users (private)
 calendar are send to other users, which is not acceptable.
 
 So here is a patch that cleans up the events after each call of cal()
 in "-a" mode and resets the struct for a new run.
 
 I've tested the patch against some test calendars, and could not find
 any further issues. Every user only gets the events from his own
 calendar.
 
 
 Greetings, Oliver
 --MP_/2_vQjW5KtHVoyOm9Zq0qQ6L
 Content-Type: text/plain
 Content-Transfer-Encoding: 7bit
 Content-Disposition: attachment; filename=patch.txt
 
 diff -u /usr/src/usr.bin/calendar/calendar.c ./calendar.c
 --- /usr/src/usr.bin/calendar/calendar.c	2014-03-03 19:22:25.000000000 +0100
 +++ ./calendar.c	2014-03-12 23:36:31.000000000 +0100
 @@ -209,8 +209,10 @@
  			(void)setegid(pw->pw_gid);
  			(void)initgroups(pw->pw_name, pw->pw_gid);
  			(void)seteuid(pw->pw_uid);
 -			if (!chdir(pw->pw_dir))
 +			if (!chdir(pw->pw_dir)) {
  				cal();
 +				remove_all_events();
 +			}
  			(void)seteuid(0);
  		}
  	else
 diff -u /usr/src/usr.bin/calendar/calendar.h ./calendar.h
 --- /usr/src/usr.bin/calendar/calendar.h	2014-03-03 19:22:25.000000000 +0100
 +++ ./calendar.h	2014-03-12 23:53:24.000000000 +0100
 @@ -120,6 +120,7 @@
  struct event *event_add(int, int, int, char *, int, char *, char *);
  void	event_continue(struct event *events, char *txt);
  void	event_print_all(FILE *fp);
 +
  struct event {
  	int	year;
  	int	month;
 @@ -183,6 +184,8 @@
  extern int debug_remember;
  void	generatedates(struct tm *tp1, struct tm *tp2);
  void	dumpdates(void);
 +void	remove_all_events(void);
 +void	remove_eventlist(struct event **list);
  int	remember_ymd(int y, int m, int d);
  int	remember_yd(int y, int d, int *rm, int *rd);
  int	first_dayofweek_of_year(int y);
 @@ -190,6 +193,7 @@
  int	walkthrough_dates(struct event **e);
  void	addtodate(struct event *e, int year, int month, int day);
  
 +
  /* pom.c */
  #define	MAXMOONS	18
  void	pom(int year, double UTCoffset, int *fms, int *nms);
 Common subdirectories: /usr/src/usr.bin/calendar/calendars and ./calendars
 diff -u /usr/src/usr.bin/calendar/dates.c ./dates.c
 --- /usr/src/usr.bin/calendar/dates.c	2014-02-19 00:43:47.000000000 +0100
 +++ ./dates.c	2014-03-13 00:44:43.000000000 +0100
 @@ -256,6 +256,45 @@
  	}
  }
  
 +
 +void
 +remove_eventlist(struct event **head) 
 +{
 +	struct event *del;
 +	del = *head;
 +	while(del != NULL) {
 +		*head = (*head)->next;  		
 +		free(del);
 +		del = *head;
 +	}
 +	free(*head);
 +}
 +
 +
 +void
 +remove_all_events(void)
 +{
 +	struct cal_year *y;
 +	struct cal_month *m;
 +	struct cal_day *d;
 +
 +	y = hyear;
 +	while (y != NULL) {
 +		m = y->months;
 +		while (m != NULL) {
 +			d = m->days;
 +			while (d != NULL) {
 +				remove_eventlist(&d->events);
 +				d->events = NULL;
 +				d = d->nextday;
 +			}
 +			m = m->nextmonth;
 +		}
 +		y = y->nextyear;
 +	}
 +}
 +
 +
  int
  remember_ymd(int yy, int mm, int dd)
  {
 @@ -368,6 +407,7 @@
          return (-1);
  }
  
 +
  int
  walkthrough_dates(struct event **e)
  {
 @@ -401,6 +441,7 @@
  		return (1);
  	}
  
 +	y = NULL;
  	return (0);
  }
 
 --MP_/2_vQjW5KtHVoyOm9Zq0qQ6L--
>Unformatted:
