Bug 135952

Summary: updatedb doesn't use /etc/updatedb.conf
Product: Red Hat Enterprise Linux 3 Reporter: Andrey Yushkov <ayushkov>
Component: slocateAssignee: Miloslav Trmač <mitr>
Status: CLOSED NEXTRELEASE QA Contact:
Severity: low Docs Contact:
Priority: medium    
Version: 3.0CC: bl_fedora, gdr
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 483794 (view as bug list) Environment:
Last Closed: 2005-06-11 12:22:02 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 483794    
Attachments:
Description Flags
workaround
none
test case 1 - not intended as permanent updatedb.conf
none
test case 2: not intended as a permanent updatedb.conf none

Description Andrey Yushkov 2004-10-15 20:51:23 UTC
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040510

Description of problem:
/etc/cron.daily/slocate.cron doesn't use /etc/updatedb.conf
It will be much better to configure updatedb using 
/etc/updatedb.conf instead of modifying /etc/cron.daily/slocate.cron

There was original bug 84998 against RH8.

This problem fixed at least in Fedora Core 2.

Version-Release number of selected component (if applicable):


How reproducible:
Always

Steps to Reproduce:
1.Modify /etc/updatedb.conf
2.Run /etc/cron.daily/slocate.cron

    

Additional info:

Comment 1 David Rees 2004-11-16 20:17:25 UTC
I can verify that running updatedb through
/etc/cron.daily/slocate.cron does seem to ignore PRUNEPATHS
environment variable set in /etc/updatedb.conf.

To work around this problem, I have had to modify the PRUNEPATHS
variable set in /etc/updatedb.conf to use comma-delimited paths, then
add -e ${PRUNEPATHS} as arguments to the slocate.cron script.

Comment 2 David Rees 2004-11-16 20:21:24 UTC
Forgot one step to fix, I also had to tell the slocate.cron script to
execute /etc/updatedb.conf, like FC3 does.

This bug also affects FC3 (and at least FC2 as well).

Comment 3 Devin Reade 2005-02-09 04:01:40 UTC
Created attachment 110848 [details]
workaround

A workaround that covers at least the PRUNEPATHS case.	I don't know 
if PRUNEFS is also a problem.

Comment 4 bjorn l. 2005-02-23 20:17:11 UTC
The problem appears to be that when invoked as updatedb (or with the
option -c), it reads the /etc/updatedb.conf, but it cannot parse it
well.  The /etc/cron.daily/slocate.cron implies that it executes
/etc/updatedb.conf as a script, when in fact updatedb ignores
everything executed in it.  I'd like to illustrate that with examples.

I will attach two examples of /etc/updatedb.conf, and you can try
them by doing the following:

- backup your current /etc/updatedb.conf where you can restore it later.
- note the size of the /var/lib/slocate/slocate.db file.  This is the
  size when the filesystems and paths that should be pruned are indeed
  pruned.
- For each of the following two examples of updatedb.conf, copy
  them to /etc/updatedb.conf, run /etc/cron.daily/slocate.cron, and
  note the size of the resulting /var/lib/slocate/slocate.db
- when you are done, restore your old updatedb.conf, and rerun the
  slocate.cron script to restore everything back the way it should.


Comment 5 bjorn l. 2005-02-23 20:20:57 UTC
Created attachment 111344 [details]
test case 1 - not intended as permanent updatedb.conf

Comment 6 bjorn l. 2005-02-23 20:22:17 UTC
Created attachment 111345 [details]
test case 2: not intended as a permanent updatedb.conf

Comment 7 Miloslav Trmač 2005-02-23 20:39:44 UTC
Bjorn, thanks a lot for the test cases!

I knew that sourcing updatedb.conf in slocate.cron had no effect,
but updatedb.conf was working perfectly for me.
Both the problem and its cause is obvious with your examples.

Comment 8 bjorn l. 2005-02-23 20:52:16 UTC
I see two solutions:

- Either document in /etc/updatedb.conf exactly how the updatedb program
  parses it, and delete the ". /etc/updatedb.conf" line in the 
  /etc/cron.daily/slocate.cron file, so people are not confused

  OR (preferably, in my opinion)

- Leave the /etc/updatedb.conf as a script that exports the PRUNEFS and
  PRUNEPATHS variables, and then in /etc/cron.daily/slocate.cron execute
  the following:
       /usr/bin/slocate -u -e $PRUNEPATHS -f $PRUNEFS
  instead of the current call to /usr/bin/updatedb.  Note that the -e
  and -f parameters are to comma-delimited, so either it needs to be
  that way in /etc/updatedb.conf, or you can execute the 'sed' command
  that Devin Reade proposed:
      sed -e 's/  */,/g;'`

Comment 9 Miloslav Trmač 2005-02-23 20:56:14 UTC
I prefer actually fixing the updatedb parser :)

Comment 10 Miloslav Trmač 2005-03-25 11:19:58 UTC
slocate-2.7-17, to appear in rawhide soon, ignores comments in /etc/updatedb.conf.

If there are multiple definitions of the same PRUNE* variable, the first one
is used; I think it is more important to preserve compatibility with previous
slocate versions than compatibility with GNU locate (which we stopped using
sometime around RHL 6.0).

Comment 11 bjorn l. 2005-03-29 06:58:45 UTC
The new slocate does indeed ignore comments.

You mention two clauses:
  1. ignores comments in /etc/updatedb.conf
  2. If there are multiple definitions of the same PRUNE* variable, the
     first one is used.

But even if these two clauses are met, you can still have problems.  (These
two clauses take care of the two earlier examples, but they were just
examples, not an exhaustive listing.)  The following three examples meet
the above two conditions, and a user might expect the following to work,
as they do for shell variables:

1.  PRUNEPATHS = \
    "/tmp /usr/tmp /var/tmp /afs /net /sfs /selinux /udev /mnt/floppy"

2.  PRUNEPATHS = '/tmp /usr/tmp /var/tmp /afs /net /sfs'

3.  PRUNEPATHS = "/tmp /udev /disk*"

    (for 3., assume that the system has /disk1, /disk2, etc.)


So I think that it is still worth documenting updatedb.conf someplace.
Currently, neither the updatedb.conf, nor the man pages of slocate and
updatedb mention updatedb.conf, so a user has no obvious way to
even know that the updatedb program uses that file.

My concern about documenting the format is that the format is very close to
that of setting variables in a shell, but not the same.  For example,
it is possible to use multi-line statements. But not like in example 1
above.  Instead, the following works:

PRUNEPATHS="/tmp /usr/tmp /var/tmp /afs /net /sfs
           /selinux /udev /mnt/floppy"


Comment 12 Miloslav Trmač 2005-03-29 12:42:56 UTC
OK, that is a good reason to add updatedb.conf(5), added in rawhide slocate-2.7-19.

(Note that multi-line statements working this way are probably working
only because the parser is very permissive, not by design - and it is
possible they will stop working in a new upstream slocate version.)

Comment 13 bjorn l. 2005-03-30 14:15:32 UTC
Excellent!  That's what we needed.


Comment 16 Miloslav Trmač 2005-06-11 12:22:02 UTC
This will be fixed in RHEL 5.