GNOME Bugzilla – Bug 397796
[PATCH] parser for autorun.inf files
Last modified: 2007-09-14 05:45:13 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.
Created attachment 80551 [details] [review] patch
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?
Created attachment 80787 [details] [review] manager.c: gnome-vfs/open autorun files rather then executing them
(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 :-)
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)
(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.
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)
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)
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 :)
(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).
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)
(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.
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 :\
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