]> git.proxmox.com Git - pve-container.git/commitdiff
Add 'perms' option to ct_modify_file
authorFabian Grünbichler <f.gruenbichler@proxmox.com>
Tue, 5 Apr 2016 09:32:10 +0000 (11:32 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Tue, 5 Apr 2016 10:27:17 +0000 (12:27 +0200)
passing this option allows the caller to (re)set the file
permissions of the modified file.

src/PVE/LXC/Setup/Base.pm

index 98f8f737cd2dc42fe466c946d9860213a005670a..e1fd0f3daa8dade2f2b7f9eb19d45f8cc75f671b 100644 (file)
@@ -521,9 +521,10 @@ sub ct_modify_file {
 
     my $head = "# --- BEGIN PVE ---\n";
     my $tail = "# --- END PVE ---\n";
+    my $perms = $options{perms};
 
     if (!$self->ct_file_exists($file)) {
-       $self->ct_file_set_contents($file, $head.$data.$tail) if $data;
+       $self->ct_file_set_contents($file, $head.$data.$tail, $perms) if $data;
        return;
     }
 
@@ -564,11 +565,11 @@ sub ct_modify_file {
        $content .= "\n";
        $data = $head.$data.$tail;
        if ($options{replace}) {
-           $self->ct_file_set_contents($file, $data);
+           $self->ct_file_set_contents($file, $data, $perms);
        } elsif ($options{prepend}) {
-           $self->ct_file_set_contents($file, $data . $content);
+           $self->ct_file_set_contents($file, $data . $content, $perms);
        } else { # append
-           $self->ct_file_set_contents($file, $content . $data);
+           $self->ct_file_set_contents($file, $content . $data, $perms);
        }
     }
 }