After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 330176 - check for "locate -i" is broken
check for "locate -i" is broken
Status: RESOLVED FIXED
Product: gnome-utils
Classification: Deprecated
Component: gsearchtool
unspecified
Other Linux
: High major
: ---
Assigned To: gnome-utils Maintainers
gnome-utils Maintainers
Depends on:
Blocks:
 
 
Reported: 2006-02-06 21:50 UTC by Benoît Dejean
Modified: 2006-03-02 19:21 UTC
See Also:
GNOME target: 2.14.x
GNOME version: ---


Attachments
Proposed patch (12.41 KB, patch)
2006-02-18 20:34 UTC, Dennis Cranston
none Details | Review
Updated Proposed Patch (14.03 KB, patch)
2006-02-19 03:10 UTC, Dennis Cranston
committed Details | Review
here it is (1.75 KB, patch)
2006-02-24 18:12 UTC, Benoît Dejean
committed Details | Review

Description Benoît Dejean 2006-02-06 21:50:40 UTC
gsearchtool checks for "-i" option to locate

                /* check locate command for -i argument compatibility */
                g_spawn_command_line_sync ("locate -i [/]", &cmd_stdout, &cmd_stderr, NULL, NULL);

on some systems it works ... on some others, it just dumps the whole locate database. This just freezes the dialog for ages where this obviously a quick test :)

I'm using

locate --version
Secure Locate 3.0 beta r3 - Released January 6, 2006


maybe the test should be a simple "locate -i" ?

benoit@ibook >>> locate -i; echo $?
0

benoit@ibook >>> locate -X; echo $?
locate: invalid option -- X
0
Comment 1 Benoît Dejean 2006-02-06 22:11:19 UTC
  /* run locate again to check if it can find the root directory */
                        g_spawn_command_line_sync ("locate [/]", &cmd_stdout, &cmd_stderr, NULL, NULL);



this other is also broken
Comment 2 Dennis Cranston 2006-02-07 00:13:04 UTC
Maybe the bug is in secure locate 3.0 beta r3?  Why is locate returning the entire database?  The command is "locate [/]" not "locate /*".
Comment 3 Benoît Dejean 2006-02-07 11:03:11 UTC
"The command is "locate [/]" not "locate /*"."

what the purpose of "locate [/]" ? is that meant to be "locate -r '^/$'" ?

locate by default does not uses regex AFAIK 
Comment 4 Dennis Cranston 2006-02-08 00:08:18 UTC
"is that meant to be "locate -r '^/$'" ?"  Yes.

This might be a good alternative, but I need to verify that the other flavors of locate can handle the '-r' argument.
Comment 5 Benoît Dejean 2006-02-08 13:51:29 UTC
Btw, slocate seems slower than locate on my computers. On my fastest machine (P4 3GHZ) i get :

benoit@damn:~$ time locate.notslocate -i [/]
/

real    0m0.084s
user    0m0.082s
sys     0m0.003s
benoit@damn:~$ time slocate -i -r '^/$'
/

real    0m0.200s
user    0m0.184s
sys     0m0.004s



but on my ppc 1GHZ

benoit@ibook >>> time locate.notslocate -i [/]
/

real    0m0.353s
user    0m0.341s
sys     0m0.006s

benoit@ibook >>> time slocate -i -r '^/$'
/

real    0m2.474s
user    0m2.328s
sys     0m0.044s


So this blocking test make the UI hang :/
Comment 6 Dennis Cranston 2006-02-08 16:55:08 UTC
So, what is the best/fastest way to determine if the installed locate command supports the '-i' argument?  

$ locate --help | grep "\-\-ignore-case"; echo $?

The above is fast, but probably not accurate.  I'd like to see the man pages for the various flavors of locate.  Specifically, the man pages for Solaris, HP, and AIX.
Comment 7 Benoît Dejean 2006-02-08 18:23:50 UTC
locate --help | grep "\-\-ignore-case"; echo $? doesn't work with slocate :)

Is there any locate/slocate that does not have -i ?
Comment 8 Sebastien Bacher 2006-02-12 21:22:45 UTC
Ubuntu bug about that: https://launchpad.net/products/gnome-utils/+bug/30313
Comment 9 Dennis Cranston 2006-02-13 00:13:12 UTC
"Is there any locate/slocate that does not have -i ?"  
I would like to see the man pages for the AIX, Solaris, and HP versions of locate, but I believe the answer is yes.
Comment 10 Benoît Dejean 2006-02-16 08:58:45 UTC
I don't have locate on my AIX 4.3 and 5.2 :)
Comment 11 Vincent Untz 2006-02-18 08:41:35 UTC
Rising priority. It basically means the search tool can not be used on some systems.
Comment 12 Dennis Cranston 2006-02-18 18:05:51 UTC
I have a work-in-progress patch that I need to cleanup.  I want to check it into HEAD sometime this weekend.
Comment 13 Dennis Cranston 2006-02-18 20:34:46 UTC
Created attachment 59666 [details] [review]
Proposed patch

Benoît,
I changed the calls to the locate command to be asynchronous.  Can you apply the attached patch and see if this helps?
Comment 14 Dennis Cranston 2006-02-19 03:10:22 UTC
Created attachment 59677 [details] [review]
Updated Proposed Patch
Comment 15 Vincent Untz 2006-02-19 11:05:31 UTC
Seems to work for me.
Comment 16 Dennis Cranston 2006-02-19 18:48:23 UTC
Thanks Vincent.  I applied the patch to CVS.
Comment 17 Benoît Dejean 2006-02-20 11:17:48 UTC
I'll test this tonight. But AFAICS, it doesn't fix anything as you read everything  from locate stdout, which takes a very long time ...
Comment 18 Benoît Dejean 2006-02-20 11:19:15 UTC
else if (string->len > 0) {
+					if (string->str[0] == '/') {
+						gsearch->is_locate_database_available = TRUE;
+					}
+					broken_pipe = TRUE;
+					break;
+				}


ok, i was wrong, you're reading only the first line. all right then ?
Comment 19 Dennis Cranston 2006-02-20 20:08:18 UTC
Right, the idea was to read the first line of output and then kill the locate process.
Comment 20 Benoît Dejean 2006-02-21 08:28:18 UTC
do you really need to kill it ? closing the pipe should be enough no ?
Comment 21 Dennis Cranston 2006-02-21 17:02:16 UTC
Yes, I really need to kill it; otherwise, the command could continue to run in the background and eat up CPU time.
Comment 22 Benoît Dejean 2006-02-21 19:26:00 UTC
slocate -i / | head

i don't think head is killing slocate, isn't it ?
Comment 23 Benoît Dejean 2006-02-21 19:30:29 UTC
i mean that slocate receive a broken pipe signal and dies/handles it like a charm
Comment 24 Dennis Cranston 2006-02-21 19:42:21 UTC
I just do not know if the behavior you are describing is guaranteed when using glib's IO channels.  I did not find documentation in glib's docs to verify it.  http://developer.gnome.org/doc/API/2.0/glib/glib-IO-Channels.html
Comment 25 Benoît Dejean 2006-02-22 18:32:51 UTC
well, just close(2) the reader end of the pipe, and the writer receives a SIGPIPE. That's not related to IO channels. That's the way pipes works.
Comment 26 Dennis Cranston 2006-02-22 20:14:18 UTC
Feel free to attach a patch.  Thanks.
Comment 27 Benoît Dejean 2006-02-24 18:12:39 UTC
Created attachment 60071 [details] [review]
here it is

I'm not sure the wait is needed at all, but that's no harm.

Btw, when i do a simple search for "AUTHORS", i see that '/usr/bin/locate -i /home/luc/**AUTHORS*' is spawned. Are these '**' OK ?
Comment 28 Benoît Dejean 2006-03-02 14:57:11 UTC
ping ?
Comment 29 Dennis Cranston 2006-03-02 19:18:39 UTC
Oops.  Your patch was applied to cvs about a week ago.  I am not worried about the '**' since it is really the same thing as a single '*'.  ;-)