From owner-freebsd-bugs Mon Jun 15 23:30:54 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id XAA00664 for freebsd-bugs-outgoing; Mon, 15 Jun 1998 23:30:54 -0700 (PDT) (envelope-from owner-freebsd-bugs@FreeBSD.ORG) Received: from freefall.freebsd.org (freefall.FreeBSD.ORG [204.216.27.21]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id XAA00652 for ; Mon, 15 Jun 1998 23:30:53 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.8.8/8.8.5) id XAA23148; Mon, 15 Jun 1998 23:30:01 -0700 (PDT) Received: from mortis.futuresouth.com (mortis.futuresouth.com [209.45.228.14]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id XAA29357 for ; Mon, 15 Jun 1998 23:22:42 -0700 (PDT) (envelope-from fullermd@mortis.futuresouth.com) Received: (from fullermd@localhost) by mortis.futuresouth.com (8.8.8/8.8.5) id BAA04865; Tue, 16 Jun 1998 01:22:41 -0500 (CDT) Message-Id: <199806160622.BAA04865@mortis.futuresouth.com> Date: Tue, 16 Jun 1998 01:22:41 -0500 (CDT) From: fullermd@mortis.futuresouth.com Reply-To: fullermd@futuresouth.com To: FreeBSD-gnats-submit@FreeBSD.ORG X-Send-Pr-Version: 3.2 Subject: bin/6963: msgs -p can give misleading errors Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org >Number: 6963 >Category: bin >Synopsis: msgs -p can give misleading errors >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Mon Jun 15 23:30:00 PDT 1998 >Last-Modified: >Originator: Matthew Fuller >Organization: >Release: FreeBSD 2.2.6-STABLE i386 >Environment: This is again rev. 1.9 of msgs.c, but I don't think there's that much difference betweeen it and 1.8.2.1. >Description: msgs -p (and maybe other flags, too) gives misleading error messages, especially on a new install, where /var/msgs/bounds doesn't exist. I moved my bounds file out of the way to create this before and after on a quick 'n' dirty hack, which is probably the 23rd best way to do it, but it works: {~/work/freebsd-hacks} mortis:{325} %msgs -p msgs: /var/msgs/bounds: Permission denied {~/work/freebsd-hacks} mortis:{326} %./msgs -p /var/msgs/bounds: No such file or directory >How-To-Repeat: Have no /var/msgs/bounds file and run msgs -p >Fix: --- msgs.c.orig Tue Jun 16 00:46:04 1998 +++ msgs.c Tue Jun 16 01:12:42 1998 @@ -169,6 +169,7 @@ 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 @@ -244,6 +245,11 @@ * determine current message bounds */ snprintf(fname, sizeof(fname), "%s/%s", _PATH_MSGS, BOUNDS); + if (stat(fname, &buf) < 0) + { + perror(fname); + exit(1); + } bounds = fopen(fname, "r"); if (bounds != NULL) { >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message