Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.debian.bugs.dist > #1198860

Bug#1071961: mailcap: run-mailcap doesn't properly identifies magic types

From Yair Yarom <irush@cs.huji.ac.il>
Newsgroups linux.debian.bugs.dist
Subject Bug#1071961: mailcap: run-mailcap doesn't properly identifies magic types
Date 2024-05-27 15:50 +0200
Message-ID <IIITE-gcip-3@gated-at.bofh.it> (permalink)
References <IInm9-fZja-25@gated-at.bofh.it> <IIyrf-g64B-1@gated-at.bofh.it> <IInm9-fZja-25@gated-at.bofh.it> <IIyrf-g64B-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

When executing external commands in perl, if there are no special shell
characters perl executes the command directly, but there is no
/usr/bin/command so it fails. You can see this if you try to strace the
script. If there are special characters like redirections (I've added
apostrophe in this case) perl will run it using /bin/sh instead of directly.

Regarding best practice, I don't know. Not sure what debian's coding style
dictates. Though it is interesting to check what other perl script do
instead of calling which.
Checking directly for /usr/bin/file could be considered more secure in case
someone has another 'file' in their PATH, but will make it harder to check
against different versions of 'file' (if any exists).
You could also instead check the return value of open(READER, .. ,"file")
to see if it fails.
Other options might be to use File::Which or File:LibMagic modules and have
a more perl-y solution, but it will add dependencies for the package.
Not sure what the best solution is...

HTH,


On Mon, 27 May 2024 at 05:27, Charles Plessy <plessy@debian.org> wrote:

> Le Sun, May 26, 2024 at 05:35:28PM +0300, Yair Yarom a écrit :
> >
> > The function MagicMimetype always fails because the `command -v file`
> isn't
> > executed inside a shell (rather, perl searches for the "command" binary,
> and
> > fails to find it).
>
> Thanks Yair for the patch.  I confirm it works.
>
> Can you give me a longer explanation why it works?
>
> In any case, I wonder if just searching for /usr/bin/file would make
> more sense.  What do you think about it?
>
> Have a nice day,
>
> Charles
>


-- 

  /|       |
  \/       | Yair Yarom | System Group (DevOps)
  []       | The Rachel and Selim Benin School
  [] /\    | of Computer Science and Engineering
  []//\\/  | The Hebrew University of Jerusalem
  [//  \\  | T +972-2-5494522 | F +972-2-5494522
  //    \  | irush@cs.huji.ac.il
 //        |

Back to linux.debian.bugs.dist | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

Bug#1071961: mailcap: run-mailcap doesn't properly identifies magic types Yair Yarom <irush@cs.huji.ac.il> - 2024-05-26 16:50 +0200
  Bug#1071961: mailcap: run-mailcap doesn't properly identifies magic types Charles Plessy <plessy@debian.org> - 2024-05-27 04:40 +0200
    Bug#1071961: mailcap: run-mailcap doesn't properly identifies magic types Yair Yarom <irush@cs.huji.ac.il> - 2024-05-27 15:50 +0200

csiph-web