From ru@ucb.crimea.ua  Wed Jan 13 05:18:10 1999
Received: from relay.ucb.crimea.ua (relay.ucb.crimea.ua [212.110.138.1] (may be forged))
          by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id FAA29695
          for <FreeBSD-gnats-submit@freebsd.org>; Wed, 13 Jan 1999 05:17:58 -0800 (PST)
          (envelope-from ru@ucb.crimea.ua)
Received: (from ru@localhost)
	by relay.ucb.crimea.ua (8.9.2/8.9.2/UCB) id PAA05291;
	Wed, 13 Jan 1999 15:16:43 +0200 (EET)
Message-Id: <199901131316.PAA05291@relay.ucb.crimea.ua>
Date: Wed, 13 Jan 1999 15:16:43 +0200 (EET)
From: Ruslan Ermilov <ru@ucb.crimea.ua>
Reply-To: ru@ucb.crimea.ua
To: FreeBSD-gnats-submit@freebsd.org
Subject: msgs: /var/msgs/bounds: No such file or directory
X-Send-Pr-Version: 3.2

>Number:         9471
>Category:       bin
>Synopsis:       [PATCH] msgs: /var/msgs/bounds: No such file or directory
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Wed Jan 13 05:20:01 PST 1999
>Closed-Date:    Tue Jun 8 03:00:14 PDT 1999
>Last-Modified:  Tue Jun  8 03:01:15 PDT 1999
>Originator:     Ruslan Ermilov
>Release:        FreeBSD 2.2.8-STABLE i386
>Organization:
United Commercial Bank
>Environment:

	Both 3.0 and 2.2.8.

>Description:

New installations do not install /var/msgs/bounds file.
Enabling `msgs -f' in either /etc/profile or /etc/cshrc
causes $Synopsis to be displayed every time user logs in.
According to msgs(1):

| The file /var/msgs/bounds shows the low and high number of the messages
| in the directory so that msgs can quickly determine if there are no
| messages for you.  If the contents of bounds is incorrect it can be fixed
| by removing it; msgs will make a new bounds file the next time it is run.
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

This bug was introduced in revision 1.10, and then merged
into RELENG_2_2 in revision 1.8.2.2.


>How-To-Repeat:

Remove /var/msgs/bounds.
Run `msgs'.

>Fix:
	
Index: msgs.c
===================================================================
RCS file: /usr/FreeBSD-CVS/src/usr.bin/msgs/msgs.c,v
retrieving revision 1.8.2.4
diff -u -r1.8.2.4 msgs.c
--- msgs.c	1998/07/17 04:20:04	1.8.2.4
+++ msgs.c	1999/01/13 13:00:13
@@ -170,7 +170,6 @@
 	int rcback = 0;			/* amount to back off of rcfirst */
 	int firstmsg = 0, nextmsg = 0, lastmsg = 0;
 	int blast = 0;
-	struct stat buf;		/* stat to check access of bounds */
 	FILE *bounds;
 
 #ifdef UNBUFFERED
@@ -246,8 +245,6 @@
 	 * determine current message bounds
 	 */
 	snprintf(fname, sizeof(fname), "%s/%s", _PATH_MSGS, BOUNDS);
-	if (stat(fname, &buf) < 0)
-		err(errno, "%s", fname);
 	bounds = fopen(fname, "r");
 
 	if (bounds != NULL) {

>Release-Note:
>Audit-Trail:

From: "Matthew D. Fuller" <fullermd@futuresouth.com>
To: ru@ucb.crimea.ua, FreeBSD-gnats-submit@FreeBSD.ORG
Cc:  
Subject: Re: bin/9471: msgs: /var/msgs/bounds: No such file or directory
Date: Wed, 13 Jan 1999 18:17:46 -0600

 > | The file /var/msgs/bounds shows the low and high number of the messages
 > | in the directory so that msgs can quickly determine if there are no
 > | messages for you.  If the contents of bounds is incorrect it can be fixed
 > | by removing it; msgs will make a new bounds file the next time it is run.
 
 Simply removing that check will introduce another bug (which was what I
 worked around in that patch).  Looking at it now, I the flaw in it.
 However, since /var/msgs isn't world writable, that will die with an
 unhelpful error message if you, for instance, run msgs -p as a normal user
 in your login files.  You'd need to add checks for that.
 
 I'll take a look at this later tonite and see if I can put together a
 nicer patch.
 
 
 ---
 
 *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
 | Matthew Fuller     http://www.over-yonder.net/~fullermd |
 * fullermd@futuresouth.com       fullermd@over-yonder.net *
 | UNIX Systems Administrator      Specializing in FreeBSD |
 *   FutureSouth Communications   ISPHelp ISP Consulting   *
 |  "The only reason I'm burning my candle at both ends,   |
 *     because I haven't figured out how to light the      *
 |                     middle yet"                         |
 *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

From: "Matthew D. Fuller" <fullermd@futuresouth.com>
To: ru@ucb.crimea.ua, freebsd-gnats-submit@freebsd.org
Cc:  
Subject: Re: bin/9471: msgs: /var/msgs/bounds: No such file or directory
Date: Wed, 13 Jan 1999 23:01:59 -0600

 On Wed, Jan 13, 1999 at 04:20:01PM -0800, a little birdie told me that Matthew D. Fuller remarked
 >  
 >  Simply removing that check will introduce another bug (which was what I
 >  worked around in that patch).  Looking at it now, I the flaw in it.
 >  However, since /var/msgs isn't world writable, that will die with an
 >  unhelpful error message if you, for instance, run msgs -p as a normal user
 >  in your login files.  You'd need to add checks for that.
 >  
 >  I'll take a look at this later tonite and see if I can put together a
 >  nicer patch.
 
 Here's a first stab:
 ASSUMPTION: We only want to actually create the bounds file if we're
 posting a message (thus, theoretically, we're root and can write
 /var/msgs)
 This also makes -f (quiet mode) just shut up and exit.
 The manpage should be updated to reflect, I can throw together a patch if
 this looks good.
 
 Index: msgs.c
 ===================================================================
 RCS file: /usr/cvs/src/usr.bin/msgs/msgs.c,v
 retrieving revision 1.13
 diff -u -r1.13 msgs.c
 --- msgs.c      1998/07/14 19:07:30     1.13
 +++ msgs.c      1999/01/14 04:58:24
 @@ -246,8 +246,14 @@
          * determine current message bounds
          */
         snprintf(fname, sizeof(fname), "%s/%s", _PATH_MSGS, BOUNDS);
 -       if (stat(fname, &buf) < 0)
 -               err(errno, "%s", fname);
 +       if (send_msg != YES) {
 +               if (stat(fname, &buf) < 0) {
 +                       if (hush != YES) 
 +                               err(errno, "%s", fname);
 +                       else
 +                               exit(1);
 +               }
 +       }
         bounds = fopen(fname, "r");
  
         if (bounds != NULL) {
 
 
 
 ---
 
 *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
 | Matthew Fuller     http://www.over-yonder.net/~fullermd |
 * fullermd@futuresouth.com       fullermd@over-yonder.net *
 | UNIX Systems Administrator      Specializing in FreeBSD |
 *   FutureSouth Communications   ISPHelp ISP Consulting   *
 |  "The only reason I'm burning my candle at both ends,   |
 *     because I haven't figured out how to light the      *
 |                     middle yet"                         |
 *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

From: "Matthew D. Fuller" <fullermd@futuresouth.com>
To: freebsd-gnats-submit@freebsd.org
Cc:  
Subject: Re: bin/9471: msgs: /var/msgs/bounds: No such file or directory
Date: Mon, 8 Mar 1999 20:23:28 -0600

 Here's the patch with the manpage update as well.
 
 
 
 Index: msgs.1
 ===================================================================
 RCS file: /usr/cvs/src/usr.bin/msgs/msgs.1,v
 retrieving revision 1.5
 diff -u -r1.5 msgs.1
 --- msgs.1	1998/06/23 16:52:59	1.5
 +++ msgs.1	1999/02/13 00:46:40
 @@ -117,7 +117,16 @@
  .Nm
  will make a new
  .Pa bounds
 -file the next time it is run.
 +file the next time it is run with the
 +.Fl s
 +option.
 +If
 +.Nm
 +is run with any option other than
 +.Fl s ,
 +an error will be displayed if
 +.Pa /var/msgs/bounds
 +does not exist.
  .Pp
  The
  .Fl s
 Index: msgs.c
 ===================================================================
 RCS file: /usr/cvs/src/usr.bin/msgs/msgs.c,v
 retrieving revision 1.13
 diff -u -r1.13 msgs.c
 --- msgs.c	1998/07/14 19:07:30	1.13
 +++ msgs.c	1999/02/13 00:39:01
 @@ -246,8 +246,14 @@
  	 * determine current message bounds
  	 */
  	snprintf(fname, sizeof(fname), "%s/%s", _PATH_MSGS, BOUNDS);
 -	if (stat(fname, &buf) < 0)
 -		err(errno, "%s", fname);
 +	if (send_msg != YES) {
 +		if (stat(fname, &buf) < 0) {
 +			if (hush != YES) 
 +				err(errno, "%s", fname);
 +			else
 +				exit(1);
 +		}
 +	}
  	bounds = fopen(fname, "r");
  
  	if (bounds != NULL) {
 
 
 
 
 
 ---
 
 *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
 | Matthew Fuller     http://www.over-yonder.net/~fullermd |
 * fullermd@futuresouth.com       fullermd@over-yonder.net *
 | UNIX Systems Administrator      Specializing in FreeBSD |
 *   FutureSouth Communications   ISPHelp ISP Consulting   *
 |  "The only reason I'm burning my candle at both ends,   |
 *    is because I haven't figured out how to light the    *
 |                     middle yet"                         |
 *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
 
State-Changed-From-To: open->closed 
State-Changed-By: sheldonh 
State-Changed-When: Tue Jun 8 03:00:14 PDT 1999 
State-Changed-Why:  
Superseded by PR 12020 . 
>Unformatted:
