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 397796 - [PATCH] parser for autorun.inf files
[PATCH] parser for autorun.inf files
Status: RESOLVED FIXED
Product: gnome-volume-manager
Classification: Deprecated
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: Gnome volume manager maintainers
Gnome volume manager maintainers
Depends on:
Blocks:
 
 
Reported: 2007-01-17 22:14 UTC by Robert Millan
Modified: 2007-09-14 05:45 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
patch (6.37 KB, patch)
2007-01-17 22:15 UTC, Robert Millan
none Details | Review
manager.c: gnome-vfs/open autorun files rather then executing them (1.01 KB, patch)
2007-01-21 00:56 UTC, Robert Millan
none Details | Review

Description Robert Millan 2007-01-17 22:14:50 UTC
I'm attaching a handler for autorun.inf files.  It'll grab the pathname from the "open" variable in "[autorun]" section and pass it to gnome_url_show ().

I think it could be useful if later such files are associated to it.

Note: I'm not used to GNOME programming and don't know well your standards. Apologises if my code doesn't follow them.  Please let me know if anything needs adjusting.
Comment 1 Robert Millan 2007-01-17 22:15:56 UTC
Created attachment 80551 [details] [review]
patch
Comment 2 Jeffrey Stedfast 2007-01-21 00:01:10 UTC
this can probably be done a lot easier using some glib or gnome parser functions. I believe glib or gnome (somewhere in the stack) there exists an old INI-style parser which used to be for gnome config files (from the old 1.x days before gconf)

also, from reading the patch... I'm not sure I see how this code gets invoked?
Comment 3 Robert Millan 2007-01-21 00:56:05 UTC
Created attachment 80787 [details] [review]
manager.c: gnome-vfs/open autorun files rather then executing them
Comment 4 Robert Millan 2007-01-21 01:06:45 UTC
(In reply to comment #2)
> this can probably be done a lot easier using some glib or gnome parser
> functions. I believe glib or gnome (somewhere in the stack) there exists an old
> INI-style parser which used to be for gnome config files (from the old 1.x days
> before gconf)

Ah, nice.  I found this:

  http://developer.gnome.org/doc/API/2.2/glib/glib-Key-value-file-parser.html

but unfortunately it doesn't seem to be fully .INI compliant:

  "This syntax is obviously inspired by the .ini files commonly met on Windows, but there are some important differences"

The most important of them seems to be the last one (about case sensitiveness).

> also, from reading the patch... I'm not sure I see how this code gets invoked?

This is what I have in mind (but, of course, it's just a suggestion):

  - Adding a mime type for MS autorun files.  I proposed text/x-ms-autorun:

      http://bugs.freedesktop.org/show_bug.cgi?id=9674

  - Adding "autorun.inf" to the list in /desktop/gnome/volume_manager/autorun_path.

  - Modifying src/manager.c to use gnome-vfs calls to "open" autorun files rather than executing them.  AFAICT this shouldn't break existing use of autorun.sh et al.

  - Setting our program (gnome-volume-autorun?) as the default handler for text/x-ms-autorun files.  I believe adding an *.desktop file would do it but I haven't got that to work yet (any hints?).

Or if you prefer, we could just cut it straight and run our parser code from manager.c itself :-)
Comment 5 Jeffrey Stedfast 2007-02-02 20:16:35 UTC
I think you may be on the right track with having a helper program do it (by making it the default handler for text/x-ms-autorun files) - I am liking this approach a lot - it keeps manager.c simpler and imho allows for better extensibility.

it's unfortunate that the glib parser isn't fully compatible with the Windows INI stuff... :(

as far as you not being able to get it working, sadly I'm no expert on that either and I have no idea why it isn't... I'd suggest sending an email to maybe th gnome-vfs mailing list or something? Maybe they might have some ideas...


will gnome_url_show() work for executing runnable programs? I didn't know it'd do that... pretty cool if it does (I thought it only opened web browsers, text viewers, etc)
Comment 6 Robert Millan 2007-02-02 21:22:11 UTC
(In reply to comment #5)
> I think you may be on the right track with having a helper program do it (by
> making it the default handler for text/x-ms-autorun files) - I am liking this
> approach a lot - it keeps manager.c simpler and imho allows for better
> extensibility.

Except that my proposal to add text/x-ms-autorun has been rejected.  See:

  http://bugs.freedesktop.org/show_bug.cgi?id=9674

but that doesn't prevent g-v-m from running my parser directly on autorun.inf files, without any file association happening at this point.

> it's unfortunate that the glib parser isn't fully compatible with the Windows
> INI stuff... :(
> 
> as far as you not being able to get it working, sadly I'm no expert on that
> either and I have no idea why it isn't... I'd suggest sending an email to maybe
> th gnome-vfs mailing list or something? Maybe they might have some ideas...

Proposed.  See:  http://bugzilla.gnome.org/show_bug.cgi?id=403728

> will gnome_url_show() work for executing runnable programs? I didn't know it'd
> do that... pretty cool if it does (I thought it only opened web browsers, text
> viewers, etc)

At least it works for win32 executables whose MIME type is associated with wine.  For real executables I haven't tested, but that's not very useful anyway.
Comment 7 Jeffrey Stedfast 2007-09-11 14:30:36 UTC
I actually forgot all about this patch when I was up at my uncle's this past weekend trying to help him out with Linux on a system for my Grandmother... we were trying to install a bunch of her Windows games (Mahjongg and Sudoku stuff mostly)

anyways, this stuff is in svn now, altho might not make it in for 2.20 (got an email complaining I broke code freeze...gah, I never seem to get around to g-v-m hacking until after the freezes :p)
Comment 8 Robert Millan 2007-09-11 21:03:03 UTC
Cool, thank you

So which approach did you use?  Is it completely done now, or is there a missing piece somewhere else?  (MIME stuff, etc)
Comment 9 Jeffrey Stedfast 2007-09-12 01:06:02 UTC
I actually just hacked up a simple .inf parser that jumps to the section/key specified and extracts the value. Nothing sophisticated...

The ugliest part of my implementation is actually outside the .inf parser, in the logic that constructs the unix path from the value since Windows paths are case insensitive (basically parsed out each individual component of the path and scanned for a dirent with a case-insensitive name match), plus it can apparently also contain arguments.

I didn't go the route of adding a mime-type, I just invoked the exe manually from within manager.c, seemed simpler at the time :)
Comment 10 Robert Millan 2007-09-12 07:40:41 UTC
(In reply to comment #9)
> I actually just hacked up a simple .inf parser that jumps to the section/key
> specified and extracts the value. Nothing sophisticated...
> 
> The ugliest part of my implementation is actually outside the .inf parser, in
> the logic that constructs the unix path from the value since Windows paths are
> case insensitive (basically parsed out each individual component of the path
> and scanned for a dirent with a case-insensitive name match), plus it can
> apparently also contain arguments.

Nice

> I didn't go the route of adding a mime-type, I just invoked the exe manually
> from within manager.c, seemed simpler at the time :)

But you know that autorun.inf can be used to open any file type, right?  There's no need to inflict on it any knowledge of *.exe or wine, one can just gnome-vfs/open them (and wine has already a working mime setup).
Comment 11 Jeffrey Stedfast 2007-09-12 16:07:59 UTC
hmmm, you sure wine has a working mime setup for all distros (or, at least all the more common ones ubuntu, rh, suse, etc)?

I don't think I had any luck double-clicking .exe's in nautilus on ubuntu 7.04 (which is all I've tested) until I specified "Open With... wine"

I'll double-check this tonight.

anyways, current svn works with anything in autorun.inf's afaik now

(I just invoke gnome-open on anything that is not a unix/win executable)
Comment 12 Robert Millan 2007-09-12 16:38:27 UTC
(In reply to comment #11)
> hmmm, you sure wine has a working mime setup for all distros (or, at least all
> the more common ones ubuntu, rh, suse, etc)?

It's working in Debian.  Other distros I don't know, but Ubuntu at least probably inherits that magic from us.  Anyway, if mime for win32 executables isn't setup, that's not a GVM problem IMHO;  it should be fixed in the appropiate place.

> anyways, current svn works with anything in autorun.inf's afaik now
> 
> (I just invoke gnome-open on anything that is not a unix/win executable)

Great.  Thanks a lot for your effort.
Comment 13 Jeffrey Stedfast 2007-09-13 13:55:55 UTC
this is the error I get when double-clicking an exe on a cd:

Cannot open /media/cdrom0/Installer.exe: No application suitable for automatic installation is available for handling this kind of file.

and that's with wine installed :\
Comment 14 Robert Millan 2007-09-14 05:45:13 UTC
See if adding one (or all) of these solve the problem:

==> /usr/share/applications/wine.desktop <==
[Desktop Entry]
Type=Application
Encoding=UTF-8
Name=WINE
GenericName=Wine Win32 API Emulator
GenericName[ru]=Эмулятор Win32 API
Comment=Launch your Windows programs
Comment[ru]=Программа для запуска приложений для ОС Windows
NoDisplay=true
TryExec=wine
Exec=wine %f
Terminal=false
Categories=Emulator;
MimeType=application/x-ms-dos-executable;application/x-msdos-program;application/x-msdownload;application/exe;application/x-exe;application/dos-exe;vms/exe;application/x-winexe;application/msdos-windows;application/x-msdos-program;application/x-zip-compressed
Icon=wine

==> /usr/share/mime-info/wine.mime <==
application/x-msdos-program
        ext: exe com

==> /usr/share/mime-info/wine.keys <==
application/x-msdos-program:
        open=wine %f
        icon-filename=/usr/share/pixmaps/wine.xpm