Skip site navigation (1)Skip section navigation (2)
Date:      Fri,  4 Jun 1999 02:00:10 -0500 (CDT)
From:      fullermd@over-yonder.net
To:        FreeBSD-gnats-submit@freebsd.org
Subject:   bin/12020: [PATCH] msgs(1) is bad about nonexistent bounds file
Message-ID:  <19990604070010.4FA961F06@mortis.futuresouth.com>

next in thread | raw e-mail | index | archive | help

>Number:         12020
>Category:       bin
>Synopsis:       [PATCH] msgs(1) is bad about nonexistent bounds file
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Jun  4 00:10:01 PDT 1999
>Closed-Date:
>Last-Modified:
>Originator:     Matthew D. Fuller
>Release:        FreeBSD 4.0-CURRENT i386
>Organization:
>Environment:

	Nothing extraordinary

>Description:

	msgs(1) doesn't behave right when bounds file doesn't exist.  Old
	behavior would yield a completely unhelpful error message when the
	file did not exist.  The present behavior will fail to make a bounds
	file no matter what.  This patch attempts to correct that situation
	with a compromise: msgs(1) will attempt to make a new bounds file iff
	it is run with -s option (posting a message).  Else, it bails out if
	the bounds file doesn't exist.  If msgs(1) is run with the -f option
	('quiet' mode), no error message will be displayed, it will simply exit.
	manpage update included.

	*** This pr supercedes pr bin/9471, which has a twisted       ***
	*** history, and an incorrect patch anyway, and can be closed ***

>How-To-Repeat:

	# rm /var/msgs/bounds
	# msgs
	# msgs -s

>Fix:
	

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/06/04 06:50:38
@@ -246,8 +246,22 @@
 	 * determine current message bounds
 	 */
 	snprintf(fname, sizeof(fname), "%s/%s", _PATH_MSGS, BOUNDS);
-	if (stat(fname, &buf) < 0)
-		err(errno, "%s", fname);
+
+	/*
+	 * Test access rights to the bounds file
+	 * This can be a little tricky.  if(send_msg), then
+	 * we will create it.  We assume that if(send_msg),
+	 * then you have write permission there.
+	 * Else, it better be there, or we bail.
+	 */
+	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) {

>Release-Note:
>Audit-Trail:
>Unformatted:


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19990604070010.4FA961F06>