[pve-devel] [PATCH container] Add 'perms' option to ct_modify_file

Fabian Grünbichler f.gruenbichler at proxmox.com
Tue Apr 5 11:32:10 CEST 2016


passing this option allows the caller to (re)set the file
permissions of the modified file.
---
 src/PVE/LXC/Setup/Base.pm | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/PVE/LXC/Setup/Base.pm b/src/PVE/LXC/Setup/Base.pm
index 98f8f73..e1fd0f3 100644
--- a/src/PVE/LXC/Setup/Base.pm
+++ b/src/PVE/LXC/Setup/Base.pm
@@ -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);
 	}
     }
 }
-- 
2.1.4





More information about the pve-devel mailing list