From owner-freebsd-bugs@FreeBSD.ORG Fri Oct 31 00:40:01 2008 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4FF571065672 for ; Fri, 31 Oct 2008 00:40:01 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 2613A8FC16 for ; Fri, 31 Oct 2008 00:40:01 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.3/8.14.3) with ESMTP id m9V0e1ES000217 for ; Fri, 31 Oct 2008 00:40:01 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.3/8.14.3/Submit) id m9V0e015000216; Fri, 31 Oct 2008 00:40:00 GMT (envelope-from gnats) Resent-Date: Fri, 31 Oct 2008 00:40:00 GMT Resent-Message-Id: <200810310040.m9V0e015000216@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Ben Jackson Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C37AD106564A for ; Fri, 31 Oct 2008 00:39:26 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21]) by mx1.freebsd.org (Postfix) with ESMTP id B08B88FC08 for ; Fri, 31 Oct 2008 00:39:26 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.14.3/8.14.3) with ESMTP id m9V0dQIY020087 for ; Fri, 31 Oct 2008 00:39:26 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.14.3/8.14.3/Submit) id m9V0dQPN020086; Fri, 31 Oct 2008 00:39:26 GMT (envelope-from nobody) Message-Id: <200810310039.m9V0dQPN020086@www.freebsd.org> Date: Fri, 31 Oct 2008 00:39:26 GMT From: Ben Jackson To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: bin/128493: find exits if -fstype test fails with EACCES X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 31 Oct 2008 00:40:01 -0000 >Number: 128493 >Category: bin >Synopsis: find exits if -fstype test fails with EACCES >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: Fri Oct 31 00:40:00 UTC 2008 >Closed-Date: >Last-Modified: >Originator: Ben Jackson >Release: 7.1-BETA >Organization: >Environment: FreeBSD kronos.home.ben.com 7.1-BETA FreeBSD 7.1-BETA #0: Wed Sep 17 23:09:13 PDT 2008 bjj@kronos.home.ben.com:/usr/src/sys/amd64/compile/GENERIC amd64 >Description: I have a filesystem mounted on /bak which is mode 770 (actually the dir is mode 660 and a smbfs is mounted on it which promotes that to 770 on the directory nodes). The locate db fails to build because it uses find with -fstype which exits very early when statfs returns EACCES on /bak. I don't know if it's actually a bug that statfs is failing (so this may need to be resolved in the kernel) but it's easy to tolerate it in find. >How-To-Repeat: mkdir /bak chmod 660 /bak mount_smbfs ... /bak /etc/periodic/weekly/310.locate # or better, su to nobody and run the find in /usr/libexec/locate.updatedb by hand >Fix: Possibly the perms check in the statfs() system call should change. If it's correct as-is, the following patch to find tolerates the failure: kronos /usr/src # diff -c usr.bin/find/function.c.orig usr.bin/find/function.c *** usr.bin/find/function.c.orig Thu Oct 30 17:27:13 2008 --- usr.bin/find/function.c Thu Oct 30 17:30:29 2008 *************** *** 833,839 **** /* * -fstype functions -- * ! * True if the file is of a certain type. */ int f_fstype(PLAN *plan, FTSENT *entry) --- 833,839 ---- /* * -fstype functions -- * ! * True if the filesystem is of a certain type. */ int f_fstype(PLAN *plan, FTSENT *entry) *************** *** 843,856 **** struct statfs sb; static int val_type, val_flags; char *p, save[2] = {0,0}; if ((plan->flags & F_MTMASK) == F_MTUNKNOWN) return 0; /* Only check when we cross mount point. */ if (first || curdev != entry->fts_statp->st_dev) { - curdev = entry->fts_statp->st_dev; - /* * Statfs follows symlinks; find wants the link's filesystem, * not where it points. --- 843,855 ---- struct statfs sb; static int val_type, val_flags; char *p, save[2] = {0,0}; + int e; if ((plan->flags & F_MTMASK) == F_MTUNKNOWN) return 0; /* Only check when we cross mount point. */ if (first || curdev != entry->fts_statp->st_dev) { /* * Statfs follows symlinks; find wants the link's filesystem, * not where it points. *************** *** 868,881 **** } else p = NULL; ! if (statfs(entry->fts_accpath, &sb)) ! err(1, "%s", entry->fts_accpath); if (p) { p[0] = save[0]; p[1] = save[1]; } first = 0; /* --- 867,887 ---- } else p = NULL; ! e = statfs(entry->fts_accpath, &sb); if (p) { p[0] = save[0]; p[1] = save[1]; } + if (e) { + if (errno != EACCES) + err(1, "%s", entry->fts_accpath); + else + return 0; + } + + curdev = entry->fts_statp->st_dev; first = 0; /* >Release-Note: >Audit-Trail: >Unformatted: