[pve-devel] [PATCH container] setup: check if securetty exists

Thomas Lamprecht t.lamprecht at proxmox.com
Wed May 11 13:18:09 CEST 2016


If securetty does not exists yet (e.g. some Alpine 3.2 templates do
that) this leads to an die on CT creation, although we do not need
an existing securetty file as we can generate it.

Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
---
 src/PVE/LXC/Setup/Base.pm | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/PVE/LXC/Setup/Base.pm b/src/PVE/LXC/Setup/Base.pm
index 490c3bb..6674e13 100644
--- a/src/PVE/LXC/Setup/Base.pm
+++ b/src/PVE/LXC/Setup/Base.pm
@@ -278,8 +278,13 @@ sub setup_securetty {
     my ($self, $conf, @add) = @_;
 
     my $filename = "/etc/securetty";
-    my $data = $self->ct_file_get_contents($filename);
-    chomp $data; $data .= "\n";
+    my $data = '';
+
+    if ($self->ct_file_exists($filename)) {
+	$data = $self->ct_file_get_contents($filename);
+	chomp $data; $data .= "\n";
+    }
+
     foreach my $dev (@add) {
 	if ($data !~ m!^\Q$dev\E\s*$!m) {
 	    $data .= "$dev\n"; 
-- 
2.1.4





More information about the pve-devel mailing list