Bug#730177: The bug is in GLocalFile's query_info_finish, it doesn't throw errors on EACCES.

John Hughes john at calva.com
Fri Jan 3 16:56:58 UTC 2014


Via a twisty little list of javascript, all unreadable :-( we arrive at 
a call to query_info_async followed by query_info_finish which, when 
called to collect the information for a nonexistent file throws an 
exception, but when called to collect the information for an 
inaccessible file returns a GIName:Gio.Task object.

       JS LOG: collectFromDatadirsAsync modes
       JS LOG: _collectFromDirectoryAsync [object instance proxy GType:GLocalFile jsobj at 0x7f08f086c438 native at 0xa632e0]
       JS LOG: _collectFromDirectoryAsync [object instance proxy GType:GLocalFile jsobj at 0x7f08f086c558 native at 0xa64fa0]
       JS LOG: _collectFromDirectoryAsync [object instance proxy GType:GLocalFile jsobj at 0x7f08f086c5a0 native at 0xa64ee0]
       JS LOG: try query_info_finish on [object instance proxy GType:GLocalFile jsobj at 0x7f08f086c438 native at 0xa632e0]
       JS LOG: Caught Error when getting information for file '/usr/share/gdm/greeter/gnome-shell/modes': No such file or directory
       JS LOG: try query_info_finish on [object instance proxy GType:GLocalFile jsobj at 0x7f08f086c558 native at 0xa64fa0]
       JS LOG: res = [object instance proxy GIName:Gio.Task jsobj at 0x7f08f086c990 native at 0xa5b900]
       JS LOG: listDirAsync [object instance proxy GType:GLocalFile jsobj at 0x7f08f086c558 native at 0xa64fa0]
       JS LOG: try query_info_finish on [object instance proxy GType:GLocalFile jsobj at 0x7f08f086c5a0 native at 0xa64ee0]
       JS LOG: Caught Error when getting information for file '/usr/share/gnome-shell/modes': No such file or directory
     JS ERROR: !!!   Exception was: Gio.IOErrorEnum: Permission denied
     JS ERROR: !!!     message = '"Permission denied"'
     JS ERROR: !!!     fileName = '"/usr/share/gnome-shell/js/misc/fileUtils.js"'
     JS ERROR: !!!     lineNumber = '14'
     JS ERROR: !!!     stack = '"0 anonymous("res" = [object GObject_Object], "obj" = [object GObject_Object])@/usr/share/gnome-shell/js/misc/fileUtils.js:14


In /usr/share/gnome-shell/js/misc/fileUtils.js:

function _collectFromDirectoryAsync(dir, loadState) {
     function done() {
         loadState.numLoading--;
         if (loadState.loadedCallback &&
             loadState.numLoading == 0)
             loadState.loadedCallback(loadState.data);
     }
     log ("_collectFromDirectoryAsync " + dir);
     dir.query_info_async('standard::type', Gio.FileQueryInfoFlags.NONE,
         GLib.PRIORITY_DEFAULT, null, function(object, res) {
             try {
                 log ("try query_info_finish on " + object);
                 object.query_info_finish(res);
                 log ("res = " + res);
             } catch (e) {
                 log ("Caught " + e.message);
                 if (!e.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.NOT_FOUND))
                     log(e.message);
                 done();
                 return;
             }

             listDirAsync(dir, Lang.bind(this, function(infos) {
                 for (let i = 0; i < infos.length; i++)
                     loadState.processFile(dir.get_child(infos[i].get_name()),
                                           infos[i], loadState.data);
                 done();
             }));
         });
}

Well, it looks like the error is in gio/glocalfileinfo.c:

GFileInfo *
_g_local_file_info_get (const char             *basename,
                         const char             *path,
                         GFileAttributeMatcher  *attribute_matcher,
                         GFileQueryInfoFlags     flags,
                         GLocalParentFileInfo   *parent_info,
                         GError                **error)
{
...
   res = g_lstat (path, &statbuf);
...
   if (res == -1)
     {
       int errsv = errno;

       /* Don't bail out if we get Permission denied (SELinux?) */
       if (errsv != EACCES)
         {
           char *display_name = g_filename_display_name (path);
           g_object_unref (info);
           g_set_error (error, G_IO_ERROR,
                        g_io_error_from_errno (errsv),
                        _("Error when getting information for file '%s': %s"),
                        display_name, g_strerror (errsv));
           g_free (display_name);
           return NULL;
         }
     }


Either libglib2 needs to be fixed to not treat EACCES as special or 
fileUtils.js in gnome-shell needs to be fixed to understand the strange 
return that query_info is returning in this case



More information about the pkg-gnome-maintainers mailing list