From mouse@Sparkle.Rodents-Montreal.ORG  Tue Jun  9 15:24:27 2009
Return-Path: <mouse@Sparkle.Rodents-Montreal.ORG>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 2A77A1065672
	for <FreeBSD-gnats-submit@freebsd.org>; Tue,  9 Jun 2009 15:24:27 +0000 (UTC)
	(envelope-from mouse@Sparkle.Rodents-Montreal.ORG)
Received: from Sparkle.Rodents-Montreal.ORG (Sparkle.Rodents-Montreal.ORG [216.46.5.7])
	by mx1.freebsd.org (Postfix) with ESMTP id B17DE8FC13
	for <FreeBSD-gnats-submit@freebsd.org>; Tue,  9 Jun 2009 15:24:26 +0000 (UTC)
	(envelope-from mouse@Sparkle.Rodents-Montreal.ORG)
Received: (from mouse@localhost)
	by Sparkle.Rodents-Montreal.ORG (8.8.8/8.8.8) id LAA26385;
	Tue, 9 Jun 2009 11:13:16 -0400 (EDT)
Message-Id: <200906091513.LAA26385@Sparkle.Rodents-Montreal.ORG>
Date: Tue, 9 Jun 2009 11:08:41 -0400 (EDT)
From: der Mouse <mouse@Rodents-Montreal.ORG>
Reply-To: der Mouse <mouse@Rodents-Montreal.ORG>
To: FreeBSD-gnats-submit@freebsd.org
Subject: man -k overrides $PATH for $PAGER
X-Send-Pr-Version: 3.113

>Number:         135417
>Category:       bin
>Synopsis:       [patch] man(1): man -k overrides $PATH for $PAGER
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    brian
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Jun 09 15:30:01 UTC 2009
>Closed-Date:    Sun Jul 05 06:25:22 UTC 2009
>Last-Modified:  Sun Jul  5 06:30:02 UTC 2009
>Originator:     der Mouse
>Release:        FreeBSD 6.3-RELEASE i386, probably later too
>Organization:
Dis-
>Environment:
System: FreeBSD FreeBSD.Rodents.Montreal.QC.CA 6.3-RELEASE FreeBSD 6.3-RELEASE #0: Wed Jan 16 04:45:45 UTC 2008 root@dessler.cse.buffalo.edu:/usr/obj/usr/src/sys/SMP i386
Code inspection indicates presence in 7.2 (apropos,v 1.16) too.
>Description:
	I have a private version of less, which among other things
	supports an option in $LESS that /usr/bin/less does not.  This
	less is in a directory which occurs before /usr/bin in my
	$PATH, and my $PAGER is "less -s".  In most respects this works
	fine.  But when I run man -k, I get an error from the stock
	less provoked by its failure to understand this private option.
	(Normal use of man does not have this problem; it obeys $PAGER
	just fine.)

	This turns out to be because man -k execs apropos, which is a
	shell script that, as one of its first actions, prepends
	/bin:/usr/bin: to $PATH.

	While I noticed this in 6.3, inspecting
	http://ftp7.freebsd.org/sites/ftp.freebsd.org/pub/FreeBSD/development/FreeBSD-CVS/src/gnu/usr.bin/man/apropos/apropos.sh,v
	leads me to think 7.2 uses the same apropos script and thus has
	the same bug.
>How-To-Repeat:
	Create a private "less" executable which is visibly different
	from /usr/bin/less in some way.  Try using it with man -k.

	Here's a specific recipe, assuming "foo" does not exist:

	(sh syntax)
	$ mkdir foo
	$ cd foo
	$ cp /bin/echo less
	$ export PATH=`pwd`:$PATH PAGER="less -s"
	$ man man
	-s
	$ man -k man

	Note that "man man" runs the less in `pwd`, but "man -k man"
	runs the stock less.
>Fix:
	I'm not sure.  Perhaps save $PATH before modifying it and
	restore it when running $PAGER?  This seems to work for me, but
	may not be Right.

--- apropos	2008-01-15 19:31:25.000000000 -0500
+++ apropos+	2009-06-09 10:57:43.000000000 -0400
@@ -18,6 +18,7 @@
 # $FreeBSD: src/gnu/usr.bin/man/apropos/apropos.sh,v 1.16 2002/10/21 07:44:42 ru Exp $
 
 
+prepath="$PATH"
 PATH=/bin:/usr/bin:$PATH
 db=whatis	# name of whatis data base
 grepopt=''
@@ -106,6 +107,6 @@
 		printf -- "$line2"
 		exit $exit_nomatch
 	else
-		( printf -- "$line2"; echo "$line"; cat ) | $PAGER
+		( printf -- "$line2"; echo "$line"; cat ) | env PATH="$prepath" $PAGER
 	fi
 )

/~\ The ASCII				  Mouse
\ / Ribbon Campaign
 X  Against HTML		mouse@rodents-montreal.org
/ \ Email!	     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B
>Release-Note:
>Audit-Trail:

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/135417: commit references a PR
Date: Sun, 14 Jun 2009 06:09:43 +0000 (UTC)

 Author: brian
 Date: Sun Jun 14 06:09:33 2009
 New Revision: 194158
 URL: http://svn.freebsd.org/changeset/base/194158
 
 Log:
   Don't set $PATH - if the caller doesn't have /bin and /usr/bin in their
   PATH then they can expect things to break.
   
   PR:		135417
   MFC after:	3 weeks
 
 Modified:
   head/gnu/usr.bin/man/apropos/apropos.sh
 
 Modified: head/gnu/usr.bin/man/apropos/apropos.sh
 ==============================================================================
 --- head/gnu/usr.bin/man/apropos/apropos.sh	Sun Jun 14 06:01:46 2009	(r194157)
 +++ head/gnu/usr.bin/man/apropos/apropos.sh	Sun Jun 14 06:09:33 2009	(r194158)
 @@ -18,7 +18,6 @@
  # $FreeBSD$
  
  
 -PATH=/bin:/usr/bin:$PATH
  db=whatis	# name of whatis data base
  grepopt=''
  
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: open->patched 
State-Changed-By: brian 
State-Changed-When: Sun Jun 14 06:10:06 UTC 2009 
State-Changed-Why:  
Fixed by removing PATH= - I'll MFC in 3 weeks. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=135417 
Responsible-Changed-From-To: freebsd-bugs->brian 
Responsible-Changed-By: vwe 
Responsible-Changed-When: Tue Jun 16 21:31:49 UTC 2009 
Responsible-Changed-Why:  
it's your's! ;) 

http://www.freebsd.org/cgi/query-pr.cgi?pr=135417 
State-Changed-From-To: patched->closed 
State-Changed-By: brian 
State-Changed-When: Sun Jul 5 06:24:24 UTC 2009 
State-Changed-Why:  
Fixed in stable/7 - r195347. 

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

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/135417: commit references a PR
Date: Sun,  5 Jul 2009 06:24:17 +0000 (UTC)

 Author: brian
 Date: Sun Jul  5 06:24:06 2009
 New Revision: 195347
 URL: http://svn.freebsd.org/changeset/base/195347
 
 Log:
   MFC: Don't set $PATH - if the caller doesn't have /bin and /usr/bin in their
        PATH then they can expect things to break.
   
   PR:		135417
 
 Modified:
   stable/7/gnu/usr.bin/man/   (props changed)
   stable/7/gnu/usr.bin/man/apropos/apropos.sh
 
 Modified: stable/7/gnu/usr.bin/man/apropos/apropos.sh
 ==============================================================================
 --- stable/7/gnu/usr.bin/man/apropos/apropos.sh	Sun Jul  5 06:14:59 2009	(r195346)
 +++ stable/7/gnu/usr.bin/man/apropos/apropos.sh	Sun Jul  5 06:24:06 2009	(r195347)
 @@ -18,7 +18,6 @@
  # $FreeBSD$
  
  
 -PATH=/bin:/usr/bin:$PATH
  db=whatis	# name of whatis data base
  grepopt=''
  
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
>Unformatted:
