FS#6902 - mlocate requires root access for "locate"

Attached to Project: Arch Linux
Opened by Peter Morris (PeteMo) - Friday, 13 April 2007, 17:15 GMT
Last edited by James Rayner (iphitus) - Tuesday, 17 April 2007, 10:18 GMT
Task Type Bug Report
Category Packages: Extra
Status Closed
Assigned To James Rayner (iphitus)
Architecture All
Severity Low
Priority Normal
Reported Version 0.8 Voodoo
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

I believe this began with the update of mlocate to version 0.16-1 on or around April 9. Running "locate foo" as a user results in "locate: can not open `/var/lib/mlocate/mlocate.db': Permission denied". Running as root works as expected.

I installed slocate to investigate and I believe that the problem lies with the permissions/groups on the locate executable at /usr/bin/locate. The permissions for each package are as follows:
slocate: lrwxrwxrwx 1 root root 7 2007-04-13 13:03 /usr/bin/locate -> slocate

mlocate: -rwxr-sr-x 1 root slocate 30812 2007-04-08 20:12 /usr/bin/locate
This task depends upon

Closed by  James Rayner (iphitus)
Tuesday, 17 April 2007, 10:18 GMT
Reason for closing:  Fixed
Comment by Andrew Fyfe (space-m0nkey) - Friday, 13 April 2007, 23:00 GMT
Can you run 'ls -la /var/lib/mlocate'
Comment by Peter Morris (PeteMo) - Friday, 13 April 2007, 23:23 GMT
# ls -la /var/lib/mlocate
drwxr-x--- 2 root slocate 80 2007-04-13 19:19 .
drwxr-xr-x 11 root root 296 2007-04-13 19:19 ..
-rw-r----- 1 root mlocate 2303261 2007-04-13 19:19 mlocate.db
Comment by Roman Kyrylych (Romashka) - Friday, 13 April 2007, 23:29 GMT
Hm... Shouldn't mlocate.db be writeable for mlocate group? ;)
Comment by Andrew Fyfe (space-m0nkey) - Friday, 13 April 2007, 23:31 GMT
ok somethings gone foo bar :-/

'grep locate /etc/groups' please

The mlocate and slocate groups share the same gid, but slocate should have been removed from /etc/groups when you removed slocate.
Comment by Andrew Fyfe (space-m0nkey) - Friday, 13 April 2007, 23:32 GMT
Roman: No only readable, the problem is /usr/bin/locate and /var/lib/mlocate are root:slocate, they should be root:mlocate
Comment by Peter Morris (PeteMo) - Friday, 13 April 2007, 23:41 GMT
$ grep locate /etc/group
slocate:x:21:
mlocate:x:101:

I also have another machine with the older version of mlocate on it (0.15-1). There is no /var/lib/mlocate on that machine, only /var/lib/slocate. On that machine,
# ls -al /var/lib/slocate/
total 653
drwxr-x--- 2 root mlocate 80 2007-03-19 21:50 .
drwxr-xr-x 8 root root 224 2007-03-26 06:35 ..
-rw-r----- 1 root mlocate 666372 2007-03-19 21:50 slocate.db

and
$ grep locate /etc/group
mlocate:x:21:
Comment by Roman Kyrylych (Romashka) - Friday, 13 April 2007, 23:42 GMT
I think one locate group would be ok for slocate/mlocate/rlocate packages, wouldn't it?
Comment by Andrew Fyfe (space-m0nkey) - Friday, 13 April 2007, 23:47 GMT
Strange, not sure how it's ended up in this state. As far as I know it's never used /var/lib/slocate.

As root run 'groupdel slocate ; pacman -S mlocate' and agree to reinstall mlocate, this should fix the permission problems.
Comment by Andrew Fyfe (space-m0nkey) - Friday, 13 April 2007, 23:53 GMT
Roman; Your right, they all have the same gid according, might as well make it the same group name.
Comment by Peter Morris (PeteMo) - Friday, 13 April 2007, 23:56 GMT
I removed the slocate group and reinstalled mlocate. The same problem persists.
$ grep locate /etc/group
mlocate:x:101:

# ls -al /var/lib/mlocate/
total 2254
drwxr-x--- 2 root 21 80 2007-04-13 19:52 .
drwxr-xr-x 11 root root 296 2007-04-13 19:51 ..
-rw-r----- 1 root mlocate 2303329 2007-04-13 19:52 mlocate.db

group 21 was the slocate group id. Should it now be 101, or perhaps mlocate should be group 21?
Comment by Andrew Fyfe (space-m0nkey) - Saturday, 14 April 2007, 00:02 GMT
mlocate should be gid 21, and there should be no slocate group in /etc/groups.

Where did you get the mlocate package from?
Comment by Peter Morris (PeteMo) - Saturday, 14 April 2007, 00:20 GMT
Well, slocate is gone (since I deleted the group), but mlocate is not group 21.

The mlocate package comes from http://mirror.cs.vt.edu/pub/ArchLinux/extra/os/i686
Comment by Andrew Fyfe (space-m0nkey) - Saturday, 14 April 2007, 00:31 GMT
It's the package (mlocate-0.16-1.pkg.tar.gz) that's broken not the PKGBUILD.

To fix your system run (as root)
chown root:mlocate /usr/bin/locate /var/lib/mlocate /var/lib/mlocate.db

I'll submit a patch for *locate to follow Roman's suggestion and switch to one group called locate for all *locate packages.
Comment by Peter Morris (PeteMo) - Saturday, 14 April 2007, 00:39 GMT
Thanks! Things are working properly now.

Interestingly, I removed mlocate, deleted the mlocate group, and then reinstalled mlocate. The mlocate group was then created with the correct group id, 21.
Comment by Andrew Fyfe (space-m0nkey) - Saturday, 14 April 2007, 06:14 GMT
patches to tidy up {s,m}locate, both now use the same group (locate gid 21). I've added some code to post_upgrade to fix permissions/groups.

Also there's no need to distribute an empty {s,m}locate.db, updatedb sets the correct permissions on the file when it creates/updates it, and both {s,m}locate return errors when the file is zero length.
Comment by Roman Kyrylych (Romashka) - Saturday, 14 April 2007, 10:45 GMT
see also http://bugs.archlinux.org/task/4490 - just Summary, not comments :)
Comment by Roman Kyrylych (Romashka) - Saturday, 14 April 2007, 16:56 GMT
A request to re-open the task has been made by Andrew Fyfe (space-m0nkey).
Reason for request: Can you also apply the slocate patch please.
Comment by Börje Holmberg (linfan) - Saturday, 14 April 2007, 19:23 GMT
# pacman -Sy mlocate
:: Synchronizing package databases...
testing is up to date
current is up to date
extra is up to date
unstable is up to date
community is up to date
resolving dependencies... done.
looking for inter-conflicts...
:: mlocate conflicts with slocate. Remove slocate? [Y/n]
done.

Remove: slocate

Targets: mlocate-0.16-2

Total Package Size: 0.10 MB

Proceed with installation? [Y/n]
checking package integrity... done.
warning: /etc/updatedb.conf saved as /etc/updatedb.conf.pacsave
cleaning up... done.
(1/1) checking for file conflicts [---------------------] 100%
(1/1) installing mlocate [---------------------] 100%
mlocate command is technically locate, but slocate is symlinked and still works.
You should run updatedb as root.
[root@sawernew borje4]# chown root:mlocate /usr/bin/locate /var/lib/mlocate /var/lib/mlocate.db
chown: `root:mlocate': invalid group

linfan
Comment by Andrew Fyfe (space-m0nkey) - Saturday, 14 April 2007, 19:27 GMT
There's no need to run the chown command mlocate-0.16-2 has been fixed.

The mlocate group (and slocate group once it's patched), no longer exist, they've been replaced by a single group named locate.
Comment by Börje Holmberg (linfan) - Saturday, 14 April 2007, 19:34 GMT
that meant that you manually have to remove the slocate from /etc/group - will try that
linfan
Comment by Börje Holmberg (linfan) - Saturday, 14 April 2007, 19:37 GMT
Did not work still get: updatedb
updatedb: can not find group `mlocate'

when i run updatedb

linfan
Comment by Börje Holmberg (linfan) - Saturday, 14 April 2007, 19:38 GMT
But if i do nano -w /etc/group and change locate:x:21: to mlocate:x:21: then it works. Is that ok?

linfan
Comment by Andrew Fyfe (space-m0nkey) - Saturday, 14 April 2007, 19:57 GMT
mlocate-0.16-2.pkg.tar.gz is broken. It is using the old mlocate.install, can somebody rebuild this package and make sure it uses the upto date PKGBUILD and mlocate.install from CVS. Thanks.
Comment by Andrew Fyfe (space-m0nkey) - Saturday, 14 April 2007, 20:00 GMT
Also the package should NOT contain var/lib/mlocate/mlocate.db, I'm not sure how this got in it's not created by the PKGBUILD anymore. The database is created the first time the user runs updatedb, updatedb will make sure it has the correct owners/permissions.
Comment by Andrew Fyfe (space-m0nkey) - Saturday, 14 April 2007, 20:31 GMT
Attached is a patch for mlocate.install to fix any broken permissions caused by previous upgrades.
Comment by Börje Holmberg (linfan) - Saturday, 14 April 2007, 21:18 GMT
there is something missing in the extra mlocate 0.16-2 package - the file system/mlocate/mlocate.db is empty.

linfan
Comment by Andrew Fyfe (space-m0nkey) - Saturday, 14 April 2007, 21:20 GMT
you need to run 'updatedb' as root.
Comment by Börje Holmberg (linfan) - Saturday, 14 April 2007, 21:57 GMT
as i already told you i get the above errors.

But I tried to download the files from the home page and there is a file called mlocate.db - but it doesn't contain anything it is blank and I cannot nano -w a file that is empty, can I? Maybe I should to nano -w mlaocate.db and type only a hash (#) and then save it.

I am confused,

linfan
Comment by Börje Holmberg (linfan) - Saturday, 14 April 2007, 22:18 GMT
Ok, i patched it but had manually to rm -rf /var/lib/mlocate* and NB! mlocate:x:21: was added to /etc/group, not simply locate:x:21:


linfan
Comment by eliott (cactus) - Sunday, 15 April 2007, 00:23 GMT
The mlocate package is borked.
I just installed the update, and it removed my old mlocate group, and put in the locate group.
mlocate appears to still want the mlocate group, however...as Börje already noted. I created the group manually (which the update had removed *sigh*) and it ran fine.

Was this package update tested at all before being pushed to extra?
I would think a cursory install and attempt to run the binary would have shown the problem...
Comment by Andrew Fyfe (space-m0nkey) - Sunday, 15 April 2007, 01:11 GMT
The package in the repository is broken. The changes do work and have been tested, but the PKGBUILD and mlocate.install bein used to create the package don't match whats in CVS.

I've built it myself and uploaded a working and tested version to http://linux.neptune-one.net/mlocate/mlocate-0.16-3-i686.pkg.tar.gz

You can find the working PKGBUILD and mlocate.install there as well.
Comment by Börje Holmberg (linfan) - Sunday, 15 April 2007, 08:21 GMT
ty, Andrew :)

Your package works fine.

The extra package just sucks - something is still wrong with that one in there.

linfan
Comment by Bob (Cotton) - Sunday, 15 April 2007, 17:50 GMT
Andrew's package works fine for me too.

Thanks.
Comment by James Rayner (iphitus) - Monday, 16 April 2007, 10:29 GMT
darn, i coulda sworn i commented here... im having no luck whatsoever with this package :/

so, i put -3 in the repos yesterday, does it work for you? Does for me.

James
Comment by Börje Holmberg (linfan) - Monday, 16 April 2007, 10:39 GMT
Ok, James, worked here now on all my three computers - p2, p4 and 32 bits amd64.

Thanks :)

Linfan
Comment by James Rayner (iphitus) - Tuesday, 17 April 2007, 10:18 GMT
closed :)

Loading...