Charles Plessy <[email protected]> writes:
>
> Do you think you could prepare a patch ?
For the "-r" checks on mime.types and .mailcap I suggest something like
below. It would be unusual for them to be crazy, but the general
principle applies there too that "-r" is either useless, a race
condition, or pre-empts what the system can and can't do :-).
The open(...,'<',$file) bit is desirable against strange filenames.
Again unlikely, but it's easy to make it safe.
For the actual input file -r requested, I'd be very tempted to simply
remove the check
if (! -r $file) {
print STDERR "Error: no read permission for file \"$file\"\n";
$retcode = 2 if ($retcode < 2);
next;
}
The hope would be that any spawned program has sufficient error
reporting. If that can reasonably be assumed then you'd be tempted even
to remove the "-e $file" test and leave it all to the spawned program.
That'd have the advantage of letting any name etc pass through
run-mailcap unmolested. Have I missed anything?
--- run-mailcap.orig 2013-11-29 07:31:34.000000000 +1100
+++ run-mailcap 2013-11-29 07:59:03.000000000 +1100
@@ -76,10 +76,14 @@
sub ReadMimetypes {
my($file) = @_;
- return unless -r $file;
-
print STDERR " - Reading mime.types file \"$file\"...\n" if $debug;
- open(MIMETYPES,"<$file") || die "Error: could not read \"$file\" -- $!\n";
+ unless (open(MIMETYPES,'<',$file)) {
+ # Quietly ignore an unreadable file, perhaps non-existent, perhaps
+ # permission denied.
+ print STDERR " could not read \"$file\" -- $!\n" if $debug;
+ return;
+ }
+
while (<MIMETYPES>) {
chomp;
s/\#.*$//;
@@ -101,10 +105,14 @@
my($file) = @_;
my $line = "";
- return unless -r $file;
-
print STDERR " - Reading mailcap file \"$file\"...\n" if $debug;
- open(MAILCAP,"<$file") || die "Error: could not read \"$file\" -- $!\n";
+ unless (open(MAILCAP,'<',$file)) {
+ # Quietly ignore an unreadable file, perhaps non-existent, perhaps
+ # permission denied.
+ print STDERR " could not read \"$file\" -- $!\n" if $debug;
+ return;
+ }
+
while (<MAILCAP>) {
chomp;
s/^\s+// if $line;