in reply to having horrors untainting a path string for moving a file

You need to untaint $ENV{PATH} because the user could change it to run his mv instead of the system one. This is particularly relevant in setuid scripts.

In this case, why don't you do

rename $a{from}, $a{to} or die("mov problem.. [$!]");

Replies are listed 'Best First'.
Re^2: having horrors untainting a path string for moving a file
by Fletch (Bishop) on Mar 14, 2006 at 18:47 UTC

    The OP mentioned this may have to work across different mount points, and rename can't do that. And this is why he can't use File::Copy's mv since under the hood that also uses rename.

      Me bad! I didn't notice that. In that case,
      File::Copy::move($a{from}, $a{to});
      or
      system('/bin/mv', $a{from}, $a{to});
      is much safer! He'll might still need to untaint $ENV{PATH} (by setting it to a known value), but there's no shell involved. mv sets the error result, so that can be used instead of capturing the output.