|Summary:||[libexec] [patch] /usr/libexec/locate.updatedb (and therefore locate(1)) does not work inside a jail|
|Product:||Base System||Reporter:||Devin Teske <dteske>|
|Component:||kern||Assignee:||freebsd-bugs mailing list <bugs>|
|Severity:||Affects Only Me||CC:||gonzo, wosch|
Description Devin Teske 2012-10-16 23:40:01 UTC
Executing 'locate' in a jail returns "locate: database too small: /var/db/locate.database" The database file is 0 length: -r--r--r-- 1 nobody wheel 0 Aug 20 04:15 /var/db/locate.database The script /usr/libexec/locate.updatedb is responsible for generating the locate(1) database (above file). Executing '/usr/libexec/locate.updatedb' in a jail returns "/usr/libexec/locate.updatedb: empty variable FILESYSTEMS". One might be fooled into thinking this is a configuration issue with /etc/locate.rc but it is not. The root-cause is that /usr/libexec/locate.updatedb uses the lsvfs(1) command to get a list of local/non-synthetic filesystem types (and uses this as the default-value for $FILESYSTEMS). Within a jail, the lsvfs(1) output is redacted (see below): Filesystem Refs Flags -------------------------------- ----- --------------- 1 29542 0 0 4 12342 0 0 7 115 0 0 10 This redacted output results in a NULL default-value for $FILESYSTEMS, resulting in the odd, but true, fatal error message "/usr/libexec/locate.updatedb: empty variable FILESYSTEMS". ASIDE: The value of $FILESYSTEMS is used by /usr/libexec/locate.updatedb, enumerated to find(1) as a list of "-fstype" arguments when generating the locate(1) database. It then uses this list to build a series of "-fstype" excludes to pass to find(1) when generating the locate(1) database. Fix: At the low-level, the problem is two-fold: 1. lsvfs(1) as-used by /usr/libexec/locate.updatedb returns a redacted list within a jail 2. find(1)'s "-fstype" flag does not work within a jail. At the high-level, the problem is simpler to solve: 1. Make /usr/libexec/locate.updatedb not use lsvfs(1) or the "-fstype" flag of find(1) when running in a jail. A patch has been attached that applys the above-described "high-level" change, allowing /usr/libexec/locate.db to function properly within a jail (thus allowing locate(1) to work as-expected within a jail). Patch attached with submission follows: How-To-Repeat: Execute 'locate' in a jail. Get the following error: locate: database too small: /var/db/locate.database Naturally, try and generate /var/db/locate.database by then executing: /usr/libexec/locate.updatedb Only to get the following fatal error: /usr/libexec/locate.updatedb: empty variable FILESYSTEMS NOTE: The error is misleading and caused by a bug. Please read "Full Description" for further explanation.
Comment 1 Devin Teske 2013-03-11 19:17:01 UTC
The previously attached patch didn't work for me on a virgin jail setup. I've revised/updated it. Could still use a formal looking at by the respective authors however (read: not intended for commit yet) _____________ The information contained in this message is proprietary and/or confidential. If you are not the intended recipient, please: (i) delete the message and all copies; (ii) do not disclose, distribute or use the message in any manner; and (iii) notify the sender immediately. In addition, please be aware that any message addressed to our domain is subject to archiving and review by persons other than the intended recipient. Thank you.
Comment 2 Eitan Adler 2018-05-20 23:51:02 UTC
For bugs matching the following conditions: - Status == In Progress - Assignee == "bugs@FreeBSD.org" - Last Modified Year <= 2017 Do - Set Status to "Open"
Comment 3 Oleksandr Tymoshenko 2019-01-19 05:53:45 UTC
Devin, is this patch still relevant?