]> git.proxmox.com Git - pve-common.git/blobdiff - data/PVE/Tools.pm
fix bug #23: add gid parameter to chown call
[pve-common.git] / data / PVE / Tools.pm
index 1daf1a272caefd8da26f86fe82896c097b2fcc33..b991ba5afef2a2592d6519fe05057f6d5fffbaf7 100644 (file)
@@ -14,6 +14,7 @@ use URI::Escape;
 use Encode;
 use Digest::SHA1;
 use Text::ParseWords;
+use String::ShellQuote;
 
 our @EXPORT_OK = qw(
 lock_file 
@@ -619,7 +620,7 @@ sub upid_open {
  
     my $outfh = IO::File->new ($filename, O_WRONLY|O_CREAT|O_EXCL, $perm) ||
        die "unable to create output file '$filename' - $!\n";
-    chown $wwwid, $outfh;
+    chown $wwwid, -1, $outfh;
 
     return $outfh;
 };
@@ -691,23 +692,7 @@ sub random_ether_addr {
 sub shellquote {
     my $str = shift;
 
-    return "''" if !defined ($str) || ($str eq '');
-    
-    die "unable to quote string containing null (\\000) bytes"
-       if $str =~ m/\x00/;
-
-    # from String::ShellQuote
-    if ($str =~ m|[^\w!%+,\-./:@^]|) {
-
-       # ' -> '\''
-       $str =~ s/'/'\\''/g;
-
-       $str = "'$str'";
-       $str =~ s/^''//;
-       $str =~ s/''$//;
-    }
-
-    return $str;
+    return String::ShellQuote::shell_quote($str);
 }
 
 # split an shell argument string into an array,