From rfg@monkeys.com  Wed May 26 14:17:31 2004
Return-Path: <rfg@monkeys.com>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 8A15116A4CE
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 26 May 2004 14:17:31 -0700 (PDT)
Received: from segfault.monkeys.com (segfault.monkeys.com [66.60.159.24])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 3BCED43D3F
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 26 May 2004 14:17:29 -0700 (PDT)
	(envelope-from rfg@monkeys.com)
Received: by segfault.monkeys.com (Postfix, from userid 1237)
	id 08E6BEA6B; Wed, 26 May 2004 14:17:18 -0700 (PDT)
Message-Id: <20040526211718.08E6BEA6B@segfault.monkeys.com>
Date: Wed, 26 May 2004 14:17:18 -0700 (PDT)
From: Ronald F.Guilmette <rfg@monkeys.com>
Reply-To: Ronald F.Guilmette <rfg@monkeys.com>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: file(1) does a poor job of recognizing Makefiles
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         67236
>Category:       bin
>Synopsis:       file(1) does a poor job of recognizing Makefiles
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed May 26 14:20:14 PDT 2004
>Closed-Date:    Thu May 27 14:44:35 PDT 2004
>Last-Modified:  Thu May 27 21:40:21 PDT 2004
>Originator:     Ronald F. Guilmette
>Release:        FreeBSD 5.2.1-RELEASE i386
>Organization:
infinite Monkeys & Co.
>Environment:
System: FreeBSD segfault.monkeys.com 5.2.1-RELEASE FreeBSD 5.2.1-RELEASE #0: Sat Mar 13 19:19:29 PST 2004 root@segfault.monkeys.com:/usr/src/sys/i386/compile/rfg20040313-4 i386

>Description:

The file(1) command does a poor job of differentiating Makefiles from
ASCII English text files.  Just having as little as one English language
comment line (starting with #) in the Makefile can be enough to cause
file(1) to incorrectly identify the file as an ASCII English text file,
rather than as a Makefile.

>How-To-Repeat:

Run the file(1) command on the Makefile included below:
===========================================================================
SHELL = /bin/sh

# 	Copyright (c) 2003 Ronald F. Guilmette; All rights reserved.  The

CC = gcc
OPT = -O
INCLUDES =
CFLAGS = -Wall -Wmissing-prototypes -pedantic -fno-common -g $(OPT) $(INCLUDES)
LDFLAGS = -L/usr/local/bind/lib
LIBBIND = -lbind

# Use the following for Solaris
#LIBS = -lsocket -lnsl -lresolv

INSTALL = install -c
TROFF = groff
MKDIR = mkdir

BASEDIR = /usr/local/local
BINDIR = $(BASEDIR)/bin
MANDIR = $(BASEDIR)/man

PROGS = nbanner
MAN_PAGES = nbanner.1
POSTSCRIPT_MANPAGES = nbanner.ps

all:	$(PROGS) $(MAN_PAGES)

postscript:	$(POSTSCRIPT_MANPAGES)

nbanner:	nbanner.o errors.o syslog-names.o io-errors.o utils.o \
		args.o
	$(CC) $(LDFLAGS) -o nbanner nbanner.o errors.o syslog-names.o io-errors.o \
		utils.o args.o $(LIBBIND) $(LIBS)

nbanner.o:	nbanner.c common.h errors.h io-errors.h utils.h \
		args.h
	$(CC) $(CFLAGS) -c nbanner.c

args.o:	args.c common.h errors.h utils.h args.h
	$(CC) $(CFLAGS) -c args.c

errors.o:	errors.c common.h syslog-names.h errors.h
	$(CC) $(CFLAGS) -c errors.c

io-errors.o:	io-errors.c common.h errors.h
	$(CC) $(CFLAGS) -c io-errors.c

utils.o:	utils.c utils.h common.h errors.h
	$(CC) $(CFLAGS) -c utils.c

syslog-names.o:	syslog-names.c syslog-names.h
	$(CC) $(CFLAGS) -c syslog-names.c

nbanner.ps:	nbanner.1
	$(TROFF) -t -mdoc nbanner.1 > $@

nbanner.x75:	nbanner.1
	$(TROFF) -t -mdoc -TX75 nbanner.1

install: all
	-$(MKDIR) -p $(BINDIR) 2> /dev/null
	$(INSTALL) nbanner $(BINDIR)
	-$(MKDIR) -p $(MANDIR)/man1 2> /dev/null
	$(INSTALL) nbanner.1 $(MANDIR)/man1

clean:
	-rm -f *.o

clobber:	clean
	-rm -f $(PROGS) $(POSTSCRIPT_MANPAGES)

.PHONY:	all postscript nbanner.x75 clean clobber
===========================================================================

>Fix:

I personally don't know what the proper fix will be.  As a workaround, it
may be sufficient to either (a) eliminate all comment lines from Makefiles
or else (b) limit the number of English words in such comments.  (Note that
in the example makefile above, just eliminating the word "The" from the end
of the comment line seems to be sufficient to prevent file(1) from incorrectly
identifying the type of the file.)
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: simon 
State-Changed-When: Thu May 27 14:44:29 PDT 2004 
State-Changed-Why:  
File is externally maintained and FreeBSD does not make local 
modifications to it, so please take this up with the find developers. 
You can find file at ftp://ftp.astron.com/pub/file/. 
Note: there is a new version of find available, but I tested 
it and it does not do a better job of detecting makefiles. 

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

From: Edwin Groothuis <edwin@mavetju.org>
To: "Ronald F. Guilmette" <rfg@monkeys.com>
Cc: "Simon L. Nielsen" <simon@FreeBSD.org>,
	FreeBSD Gnats Submit <freebsd-gnats-submit@freebsd.org>
Subject: Re: bin/67236: file(1) does a poor job of recognizing Makefiles
Date: Fri, 28 May 2004 08:49:48 +1000

 On Thu, May 27, 2004 at 03:38:16PM -0700, Ronald F. Guilmette wrote:
 > Excuse me, but it would appear that your suggestion that I take up
 > this issue with the (external) maintainer of file(1) may be impractical
 > for this simple reason that the specific version of the file(1)
 
 I found the maintainer of file(1) to be pretty tolerant regarding
 this. I have submitted him a patch for file(1) to recognized the
 FreeBSD ELF version handling for 5.x binaries against the file(1)
 from 5.2.1 which is version 3.41.
 
 He has incorperated it in the 4.0.9 version, while the layout of
 the source was completely different.
 
 Edwin
 
 > Would it be possible for the FreeBSD maintainers to upgrade the version
 > of file(1) that is being distributed with FreeBSD to version 4.09 which,
 > according to the information above, seems to be the now current version?
 
 Check ports/sysutils/file, it's there. Just not in the base system.
 
 Edwin
 
 -- 
 Edwin Groothuis      |            Personal website: http://www.mavetju.org
 edwin@mavetju.org    |          Weblog: http://weblog.barnet.com.au/edwin/

From: "Ronald F. Guilmette" <rfg@monkeys.com>
To: Edwin Groothuis <edwin@mavetju.org>
Cc: "Simon L. Nielsen" <simon@FreeBSD.org>,
	FreeBSD Gnats Submit <freebsd-gnats-submit@freebsd.org>
Subject: Re: bin/67236: file(1) does a poor job of recognizing Makefiles 
Date: Thu, 27 May 2004 16:09:15 -0700

 In message <20040527224948.GA2148@k7.mavetju>, you wrote:
 
 >On Thu, May 27, 2004 at 03:38:16PM -0700, Ronald F. Guilmette wrote:
 >> Excuse me, but it would appear that your suggestion that I take up
 >> this issue with the (external) maintainer of file(1) may be impractical
 >> for this simple reason that the specific version of the file(1)
 >
 >I found the maintainer of file(1) to be pretty tolerant regarding
 >this. I have submitted him a patch for file(1) to recognized the
 >FreeBSD ELF version handling for 5.x binaries against the file(1)
 >from 5.2.1 which is version 3.41.
 >
 >He has incorperated it in the 4.0.9 version, while the layout of
 >the source was completely different.
 >
 >Edwin
 >
 >> Would it be possible for the FreeBSD maintainers to upgrade the version
 >> of file(1) that is being distributed with FreeBSD to version 4.09 which,
 >> according to the information above, seems to be the now current version?
 >
 >Check ports/sysutils/file, it's there. Just not in the base system.
 
 Would it be impertinent of me to ask why the latest version of file(1)
 is not in the base system?
 

From: Edwin Groothuis <edwin@mavetju.org>
To: "Ronald F. Guilmette" <rfg@monkeys.com>
Cc: "Simon L. Nielsen" <simon@FreeBSD.org>,
	FreeBSD Gnats Submit <freebsd-gnats-submit@freebsd.org>
Subject: Re: bin/67236: file(1) does a poor job of recognizing Makefiles
Date: Fri, 28 May 2004 09:20:12 +1000

 On Thu, May 27, 2004 at 04:09:15PM -0700, Ronald F. Guilmette wrote:
 > >Check ports/sysutils/file, it's there. Just not in the base system.
 > 
 > Would it be impertinent of me to ask why the latest version of file(1)
 > is not in the base system?
 
 obrien@ imported the 3.41 version, you could ask him to import the
 newest version. Or ask him why he hasn't done it yet.
 
 Edwin
 
 -- 
 Edwin Groothuis      |            Personal website: http://www.mavetju.org
 edwin@mavetju.org    |          Weblog: http://weblog.barnet.com.au/edwin/

From: "Ronald F. Guilmette" <rfg@monkeys.com>
To: Edwin Groothuis <edwin@mavetju.org>
Cc: "Simon L. Nielsen" <simon@FreeBSD.org>,
	FreeBSD Gnats Submit <freebsd-gnats-submit@freebsd.org>
Subject: Re: bin/67236: file(1) does a poor job of recognizing Makefiles 
Date: Thu, 27 May 2004 16:52:26 -0700

 In message <20040527232011.GK2165@k7.mavetju>, you wrote:
 
 >On Thu, May 27, 2004 at 04:09:15PM -0700, Ronald F. Guilmette wrote:
 >> >Check ports/sysutils/file, it's there. Just not in the base system.
 >> 
 >> Would it be impertinent of me to ask why the latest version of file(1)
 >> is not in the base system?
 >
 >obrien@ imported the 3.41 version, you could ask him to import the
 >newest version. Or ask him why he hasn't done it yet.
 
 
 OK, I have sent him the question.

From: "David O'Brien" <obrien@freebsd.org>
To: "Ronald F. Guilmette" <rfg@monkeys.com>
Cc: FreeBSD Gnats Submit <freebsd-gnats-submit@freebsd.org>
Subject: Re: bin/67236: file(1) does a poor job of recognizing Makefiles
Date: Thu, 27 May 2004 21:05:22 -0700

 On Thu, May 27, 2004 at 04:51:51PM -0700, Ronald F. Guilmette wrote:
 > Edwin Groothuis says that I should ask you why the latest version of
 > the file(1) command (4.09) is not presently imported into the FreeBSD
 > base system.  (See below.)
 
 Version 4.x is built in a rather different way than 3.x.  Given the PITA
 in the 3.x->4.y change, I haven't seen a good reason to do it yet.
 
 That said, there may soon be a good reason to have libmagic, so I'll have
 to do it sometime.
 
 -- 
 -- David  (obrien@FreeBSD.org)

From: Edwin Groothuis <edwin@mavetju.org>
To: David O'Brien <obrien@freebsd.org>
Cc: FreeBSD Gnats Submit <freebsd-gnats-submit@freebsd.org>
Subject: Re: bin/67236: file(1) does a poor job of recognizing Makefiles
Date: Fri, 28 May 2004 14:29:48 +1000

 On Thu, May 27, 2004 at 09:10:26PM -0700, David O'Brien wrote:
 >  On Thu, May 27, 2004 at 04:51:51PM -0700, Ronald F. Guilmette wrote:
 >  > Edwin Groothuis says that I should ask you why the latest version of
 >  > the file(1) command (4.09) is not presently imported into the FreeBSD
 >  > base system.  (See below.)
 >  
 >  Version 4.x is built in a rather different way than 3.x.  Given the PITA
 >  in the 3.x->4.y change, I haven't seen a good reason to do it yet.
 
 A good reason might be that 4.0.9 properly interprets the ELF
 information in the 5.x executables. Try "file /bin/sh" on a -current
 machine and see which version of FreeBSD it thinks it is. Also see
 bin/63830 for a patch against file 3.x.
 
 Edwin
 -- 
 Edwin Groothuis      |            Personal website: http://www.mavetju.org
 edwin@mavetju.org    |          Weblog: http://weblog.barnet.com.au/edwin/
>Unformatted:
