Bug 245189

Summary: slocate/updatedb removes existing database before creating new one
Product: Red Hat Enterprise Linux 4 Reporter: James Pearson <james-p>
Component: slocateAssignee: Miloslav Trmač <mitr>
Status: CLOSED WONTFIX QA Contact: Brock Organ <borgan>
Severity: low Docs Contact:
Priority: low    
Version: 4.4   
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-06-20 16:00:09 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:

Description James Pearson 2007-06-21 15:14:57 UTC
Description of problem:

slocate replaces an existing slocate database with an empty file before creating
a new database

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

2.7-13.el4.6

How reproducible:

Every time

Steps to Reproduce:
1. Run slocate -u
2.
3.
  
Actual results:

Any existing database is replaced with a zero length file while a new database
is being built with a temporary (different) name

Expected results:

Replace existing database with the new one after the new database has been built

Additional info:

On a (very) large filesystem, it might take a while to re-generate an slocate
database - while the new database is being created, searches on the database
fail as the database is empty.

From the source, the first thing it does is:

    ret_val = creat(path, S_IRWXU|S_IRGRP);
    if(ret_val==-1)
        report_error(FATAL,QUIET,"%s: parse_create_path: could not create
database: %s: %s\n", progname,path,strerror(errno));

i.e. the creat() creates a new empty database file (truncates any existing file)

It then goes on to build a new database using a temporary file name - once it
has finished, it replaces this empty file with the new database.

As the creat() is only used to check that the database file can be created,
there are other ways to check this without trashing the existing file - e.g.
something like:

    ret_val = open(path, O_WRONLY|O_CREAT, S_IRWXU|S_IRGRP);
    if(ret_val==-1)
       report_error(...);
    else
       close(ret_val);

Comment 1 Miloslav Trmač 2007-06-25 17:03:09 UTC
Thanks for your report.

If you are a RHEL customer and have an active support entitlement, please
contact official Red Hat Support at https://www.redhat.com/apps/support/ to
allow correct prioritization of this issue.


Comment 3 James Pearson 2007-06-28 10:17:50 UTC
I'm not really concerned about the prioritization of this issue - as I've
already 'fixed' it for my own use.

I've already given this ticket a 'low' severity, so it is up to you if want to
fix it or not.

Comment 4 RHEL Program Management 2008-02-01 19:06:36 UTC
This request was evaluated by Red Hat Product Management for
inclusion, but this component is not scheduled to be updated in
the current Red Hat Enterprise Linux release. If you would like
this request to be reviewed for the next minor release, ask your
support representative to set the next rhel-x.y flag to "?".

Comment 5 Jiri Pallich 2012-06-20 16:00:09 UTC
Thank you for submitting this issue for consideration in Red Hat Enterprise Linux. The release for which you requested us to review is now End of Life. 
Please See https://access.redhat.com/support/policy/updates/errata/

If you would like Red Hat to re-consider your feature request for an active release, please re-open the request via appropriate support channels and provide additional supporting details about the importance of this issue.