Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 427426 - app-misc/run-mailcap - run-mailcap unlinks tmplink before an app has a chance to read a file
Summary: app-misc/run-mailcap - run-mailcap unlinks tmplink before an app has a chance...
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: AMD64 Linux
: Normal normal (vote)
Assignee: No maintainer - Look at if you want to take care of it
Keywords: NeedPatch
Depends on:
Reported: 2012-07-21 01:44 UTC by unknown
Modified: 2013-10-12 20:56 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Note You need to log in before you can comment on or make changes to this bug.
Description unknown 2012-07-21 01:44:46 UTC
run-mailcap unlinks temporary symlink before an application has a chance to read a file through that symlink.

If some jpeg (or other) file has non-latin characters (or shell meta-characters) in its name, and one is running
$ run-mailcap <filename>
run-mailcap creates a link to this file and passes it to the corresponding application (say, gwenview). Here are the lines 455-474 from /usr/bin/run-mailcap:

if ($file =~ m![^ a-z0-9,.:/@%^+=_-]!i) {
        $match =~ m/nametemplate=(.*?)\s*($|;)/;
        my $prefix = $1;
        my $linked = 0;
        while (!$linked) {
                $tmplink = TempFile($prefix);
                if ($file =~ m!^/!) {
                        $linked = symlink($file,$tmplink);
                } else {
                        my $pwd = `/bin/pwd`;
                        $linked = symlink("$pwd/$file",$tmplink);
        print STDERR " - filename contains shell meta-characters; aliased to '$tmplink'\n" if $debug;
        $comm =~ s/([^%])%s/$1$tmplink/g;
} else {
        $comm =~ s/([^%])%s/$1$file/g;

However, later on run-mailcap unlinks that file (line 511):

unlink $tmplink if $tmplink;

That creates the race condition: an application has a little time to read a file before it was deleted. On my system gwenview constantly reports: "Error loading fileASASJG73".

Reproducible: Always

Steps to Reproduce:
1. run $ run-mailcap <filename.jpg> on a jpeg file that has unicode characters or shell meta-characters in its name.
2. see if associated application (gwenview in my case) can find the file.

Actual Results:  
gwenview reports "Error loading fileXXXXXX"

Expected Results:  
gwenview should be able to read a file through the symbolic link and display it.

$ equery l run-mailcap

 * Searching for run-mailcap...

[IP-] [  ] app-misc/run-mailcap-3.39_p1:0
Comment 1 Pacho Ramos gentoo-dev 2012-07-25 17:14:50 UTC
+*run-mailcap-3.52_p1 (25 Jul 2012)
+  25 Jul 2012; Pacho Ramos <> +run-mailcap-3.52_p1.ebuild:
+  Version bump.

Try with new version please
Comment 2 unknown 2012-07-30 14:15:18 UTC
3.52_p1, bug is not fixed.
Comment 3 Pacho Ramos gentoo-dev 2012-07-30 18:15:09 UTC
You need to report this to upstream then:;dist=unstable

(product is mime-support)

And post link here, thanks