Date: Fri, 31 Oct 2008 00:39:26 GMT From: Ben Jackson <ben@ben.com> To: freebsd-gnats-submit@FreeBSD.org Subject: bin/128493: find exits if -fstype test fails with EACCES Message-ID: <200810310039.m9V0dQPN020086@www.freebsd.org> Resent-Message-ID: <200810310040.m9V0e015000216@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>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:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200810310039.m9V0dQPN020086>