From hsu@katiska.runkoverkot.net  Thu Dec 27 02:05:59 2001
Return-Path: <hsu@katiska.runkoverkot.net>
Received: from katiska.runkoverkot.net (ns1.bbnetworks.net [212.16.96.1])
	by hub.freebsd.org (Postfix) with ESMTP id BC39437B417
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 27 Dec 2001 02:05:57 -0800 (PST)
Received: (from hsu@localhost)
	by katiska.runkoverkot.net (8.11.6/8.11.6) id fBRA5rM02065;
	Thu, 27 Dec 2001 12:05:53 +0200 (EET)
	(envelope-from hsu)
Message-Id: <200112271005.fBRA5rM02065@katiska.runkoverkot.net>
Date: Thu, 27 Dec 2001 12:05:53 +0200 (EET)
From: Heikki Suonsivu <hsu@bbnetworks.net>
Reply-To: Heikki Suonsivu <hsu@bbnetworks.net>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: find terminates with "find: fts_read: Permission denied"
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         33235
>Category:       bin
>Synopsis:       find terminates with "find: fts_read: Permission denied"
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Dec 27 02:10:00 PST 2001
>Closed-Date:    Fri Feb 16 23:32:59 GMT 2007
>Last-Modified:  Fri Feb 16 23:32:59 GMT 2007
>Originator:     Heikki Suonsivu
>Release:        FreeBSD 4.4-STABLE i386
>Organization:
bbnetworks
>Environment:
System: FreeBSD katiska.runkoverkot.net 4.4-STABLE FreeBSD 4.4-STABLE #1: Fri Oct 12 03:29:04 EEST 2001 hsu@katiska.runkoverkot.net:/usr/obj/usr/src/sys/CAT i386

Stable from october.  I think the problem has been around for a while,
but I had had no time to figure out why locate database seemed to be empty.

>Description:

Symtom is that locate update does not include all files in the
database, because the find terminates early.

>How-To-Repeat:

On one of my hosts this will terminate when run as nobody:

find -s / \! \( -fstype ufs \) -prune -or -path /tmp -prune -or -path /usr/tmp
-prune -or -path /var/tmp -prune -or -print
...
/xx/sorted/2001/12/13/image_2001_1213_142409_01.jpg
/xx/sorted/2001/12/13/image_2001_1213_142418_01.jpg
/xx/sorted/2001/12/13/imagfind: fts_read: Permission denied
e_2001_1213_142430_01.jpg
/xx/sorted/2001/12/13/image_2001_1213_142436_01.jpg
/xx/sorted/2001/12/14
/xx/sorted/2001/12/14/image_2001_1214_050908_01.jpg
/xx/sorted/2001/12/14/image_2001_1214_050910_01.jpg
/xx/sorted/2001/12/14/image_2001_1214_050923_01.jpg

The command is what locate.updatedb uses.  I found this when trying to
figure out why locate database did not contain some of the files which
certainly were there.

>Fix:

If -s is left out, find completes.  Thus, workaround for
locate.updatedb problem is replacing -s with "| sort" after find, but
that is not particularly efficient.  Find should not consider
permission denied a fatal error.  

>Release-Note:
>Audit-Trail:

From: "Crist J . Clark" <cjc@FreeBSD.ORG>
To: Heikki Suonsivu <hsu@bbnetworks.net>
Cc: FreeBSD-gnats-submit@FreeBSD.ORG
Subject: Re: bin/33235: find terminates with "find: fts_read: Permission denied"
Date: Fri, 28 Dec 2001 00:31:58 -0800

 On Thu, Dec 27, 2001 at 12:05:53PM +0200, Heikki Suonsivu wrote:
 [snip]
 
 > >How-To-Repeat:
 > 
 > On one of my hosts this will terminate when run as nobody:
 > 
 > find -s / \! \( -fstype ufs \) -prune -or -path /tmp -prune -or -path /usr/tmp
 > -prune -or -path /var/tmp -prune -or -print
 > ...
 > /xx/sorted/2001/12/13/image_2001_1213_142409_01.jpg
 > /xx/sorted/2001/12/13/image_2001_1213_142418_01.jpg
 > /xx/sorted/2001/12/13/imagfind: fts_read: Permission denied
 > e_2001_1213_142430_01.jpg
 > /xx/sorted/2001/12/13/image_2001_1213_142436_01.jpg
 > /xx/sorted/2001/12/14
 > /xx/sorted/2001/12/14/image_2001_1214_050908_01.jpg
 > /xx/sorted/2001/12/14/image_2001_1214_050910_01.jpg
 > /xx/sorted/2001/12/14/image_2001_1214_050923_01.jpg
 > 
 > The command is what locate.updatedb uses.  I found this when trying to
 > figure out why locate database did not contain some of the files which
 > certainly were there.
 > 
 > >Fix:
 > 
 > If -s is left out, find completes.  Thus, workaround for
 > locate.updatedb problem is replacing -s with "| sort" after find, but
 > that is not particularly efficient.  Find should not consider
 > permission denied a fatal error.  
 
 A "permission denied" is usually not a fatal error, but in this case,
 the fts_read(3) call is getting the error, which shouldn't happen. I
 _think_ I understand why this may be happening. When you use the '-s'
 switch, there may be an attempt to compare a file name to one that we
 cannot read... But I'm not sure how this could happen. Could you give
 us a long listing of the portion of file hierarchy (both a little
 before and after too) where you think this is failing?
 -- 
 "It's always funny until someone gets hurt. Then it's hilarious."
 
 Crist J. Clark                     |     cjclark@alum.mit.edu
                                    |     cjclark@jhu.edu
 http://people.freebsd.org/~cjc/    |     cjc@freebsd.org
State-Changed-From-To: open->closed 
State-Changed-By: cjc 
State-Changed-When: Sat Jul 13 15:15:58 PDT 2002 
State-Changed-Why:  
Feedback timeout. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=33235 
State-Changed-From-To: closed->open 
State-Changed-By: mpp 
State-Changed-When: Fri Feb 16 22:53:37 UTC 2007 
State-Changed-Why:  


http://www.freebsd.org/cgi/query-pr.cgi?pr=33235 
State-Changed-From-To: open->closed 
State-Changed-By: mpp 
State-Changed-When: Fri Feb 16 23:24:31 UTC 2007 
State-Changed-Why:  
This problem happens if the underlying directory for a mount 
point does not have world read/execute permission.  find -s will 
fail when it is done with the directory tree for that mount point. 

Unmounting the file system and fixing the permissions on the 
underlying directory fixes this problem. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=33235 
>Unformatted:
