Commit 588efe12 authored by Magnus Svensson's avatar Magnus Svensson
Browse files

WL#4189 Create a tempdir if tmpdir path becomes too long

parent 4174c685
Loading
Loading
Loading
Loading
+14 −1
Original line number Diff line number Diff line
@@ -1024,7 +1024,20 @@ sub command_line_setup {
  # --------------------------------------------------------------------------
  # Set the "tmp" directory
  # --------------------------------------------------------------------------
  if ( ! $opt_tmpdir )
  {
    $opt_tmpdir=       "$opt_vardir/tmp" unless $opt_tmpdir;

    if (check_socket_path_length("$opt_tmpdir/testsocket.sock"))
    {
      mtr_report("Too long tmpdir path '$opt_tmpdir'",
		 " creating a shorter one...");

      # Create temporary directory in standard location for temporary files
      $opt_tmpdir= tempdir( TMPDIR => 1, CLEANUP => 1 );
      mtr_report(" - using tmpdir: '$opt_tmpdir'\n");
    }
  }
  $opt_tmpdir =~ s,/+$,,;       # Remove ending slash if any

  # --------------------------------------------------------------------------