]> git.proxmox.com Git - pve-common.git/commitdiff
tempfile: use /tmp for fallback-tempfiles
authorWolfgang Bumiller <w.bumiller@proxmox.com>
Wed, 2 Nov 2016 11:25:51 +0000 (12:25 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Wed, 2 Nov 2016 11:47:05 +0000 (12:47 +0100)
At this point we know it's not a tmpfs (as tmpfs definitely
supports O_TMPFILE), so /tmp makes more sense than /run as
default path.

src/PVE/Tools.pm

index 0be2efee70feb9e34fa8c582ec23ea73a268d307..341f0ac1cdc63c4d18d05e9da011c13e5c927dd7 100644 (file)
@@ -1310,6 +1310,7 @@ sub tempfile {
 
     my $fh = IO::File->new($dir, $mode | O_TMPFILE, $perm);
     if (!$fh && $! == EOPNOTSUPP) {
 
     my $fh = IO::File->new($dir, $mode | O_TMPFILE, $perm);
     if (!$fh && $! == EOPNOTSUPP) {
+       $dir = '/tmp' if !defined($opts{dir});
        $dir .= "/.tmpfile.$$";
        $fh = IO::File->new($dir, $mode | O_CREAT | O_EXCL, $perm);
        unlink($dir) if $fh;
        $dir .= "/.tmpfile.$$";
        $fh = IO::File->new($dir, $mode | O_CREAT | O_EXCL, $perm);
        unlink($dir) if $fh;