[pve-devel] [PATCH pve-container 2/3] Added PVE::LXCSetup::Base::setup_securetty
Wolfgang Bumiller
w.bumiller at proxmox.com
Fri Aug 14 12:36:28 CEST 2015
---
src/PVE/LXCSetup/ArchLinux.pm | 3 +++
src/PVE/LXCSetup/Base.pm | 14 ++++++++++++++
src/PVE/LXCSetup/Redhat.pm | 10 +---------
src/PVE/LXCSetup/Ubuntu.pm | 7 +------
4 files changed, 19 insertions(+), 15 deletions(-)
diff --git a/src/PVE/LXCSetup/ArchLinux.pm b/src/PVE/LXCSetup/ArchLinux.pm
index 90a3bf7..149558c 100644
--- a/src/PVE/LXCSetup/ArchLinux.pm
+++ b/src/PVE/LXCSetup/ArchLinux.pm
@@ -39,6 +39,9 @@ sub template_fixup {
"$rootdir/etc/systemd/system/multi-user.target.wants/systemd-networkd.service";
symlink "/usr/lib/systemd/system/systemd-networkd.socket",
"$rootdir/etc/systemd/system/socket.target.wants/systemd-networkd.socket";
+
+ # edit /etc/securetty (enable login on console)
+ $self->setup_securetty($conf, qw(pts/0));
}
sub setup_init {
diff --git a/src/PVE/LXCSetup/Base.pm b/src/PVE/LXCSetup/Base.pm
index 6574f07..2475169 100644
--- a/src/PVE/LXCSetup/Base.pm
+++ b/src/PVE/LXCSetup/Base.pm
@@ -285,7 +285,21 @@ DATA
PVE::Tools::file_set_contents($filename, $data);
}
+}
+
+sub setup_securetty {
+ my ($self, $conf, @add) = @_;
+ my $rootdir = $self->{rootdir};
+ my $filename = "$rootdir/etc/securetty";
+ my $data = PVE::Tools::file_get_contents($filename);
+ chomp $data; $data .= "\n";
+ foreach my $dev (@add) {
+ if ($data !~ m!^\Q$dev\E\s*$!m) {
+ $data .= "$dev\n";
+ }
+ }
+ PVE::Tools::file_set_contents($filename, $data);
}
my $replacepw = sub {
diff --git a/src/PVE/LXCSetup/Redhat.pm b/src/PVE/LXCSetup/Redhat.pm
index 44b9d2c..732c475 100644
--- a/src/PVE/LXCSetup/Redhat.pm
+++ b/src/PVE/LXCSetup/Redhat.pm
@@ -109,15 +109,7 @@ sub template_fixup {
PVE::Tools::file_set_contents($filename, $data);
# edit /etc/securetty (enable login on console)
- $filename = "$rootdir/etc/securetty";
- $data = PVE::Tools::file_get_contents($filename);
- chomp $data; $data .= "\n";
- foreach my $dev (qw(console tty1 tty2 tty3 tty4)) {
- if ($data !~ m!^lxc/$dev\s*$!m) {
- $data .= "lxc/$dev\n";
- }
- }
- PVE::Tools::file_set_contents($filename, $data);
+ $self->setup_securetty($conf, qw(lxc/console lxc/tty1 lxc/tty2 lxc/tty3 lxc/tty4));
}
}
diff --git a/src/PVE/LXCSetup/Ubuntu.pm b/src/PVE/LXCSetup/Ubuntu.pm
index 17d3b88..fc7bea6 100644
--- a/src/PVE/LXCSetup/Ubuntu.pm
+++ b/src/PVE/LXCSetup/Ubuntu.pm
@@ -49,12 +49,7 @@ sub template_fixup {
if ($version eq '15.04') {
# edit /etc/securetty (enable login on console)
- my $filename = "$rootdir/etc/securetty";
- my $data = PVE::Tools::file_get_contents($filename);
- if ($data !~ m!^pts/0\s*$!m) {
- $data .= "pts/0\n";
- }
- PVE::Tools::file_set_contents($filename, $data);
+ $self->setup_securetty($conf, qw(pts/0));
}
if ($version eq '12.04') {
--
2.1.4
More information about the pve-devel
mailing list