Group :: System/Servers
RPM: pve-manager
Main Changelog Spec Patches Sources Download Gear Bugs and FR Repocop
Patch: pve-container-altlinux-lxc.patch
Download
Download
--- pve-container/src/PVE/LXC/Config.pm.altlinux-lxc 2021-09-27 08:46:45.403297787 +0000
+++ pve-container/src/PVE/LXC/Config.pm 2021-09-27 08:48:45.053716328 +0000
@@ -445,7 +445,7 @@ my $confdesc = {
ostype => {
optional => 1,
type => 'string',
- enum => [qw(debian devuan ubuntu centos fedora opensuse archlinux alpine gentoo unmanaged)],
+ enum => [qw(debian devuan ubuntu centos fedora opensuse archlinux alpine gentoo altlinux unmanaged)],
description => "OS type. This is used to setup configuration inside the container, and corresponds to lxc setup scripts in /usr/share/lxc/config/<ostype>.common.conf. Value 'unmanaged' can be used to skip and OS specific setup.",
},
console => {
--- pve-container/src/PVE/LXC/Setup.pm.altlinux-lxc 2021-08-05 14:12:00.000000000 +0000
+++ pve-container/src/PVE/LXC/Setup.pm 2021-09-27 08:46:45.403297787 +0000
@@ -16,6 +16,7 @@ use PVE::LXC::Setup::ArchLinux;
use PVE::LXC::Setup::Alpine;
use PVE::LXC::Setup::Gentoo;
use PVE::LXC::Setup::Devuan;
+use PVE::LXC::Setup::ALTLinux;
my $plugins = {
debian => 'PVE::LXC::Setup::Debian',
@@ -27,6 +28,7 @@ my $plugins = {
archlinux => 'PVE::LXC::Setup::ArchLinux',
alpine => 'PVE::LXC::Setup::Alpine',
gentoo => 'PVE::LXC::Setup::Gentoo',
+ altlinux => 'PVE::LXC::Setup::ALTLinux',
};
# a map to allow supporting related distro flavours
@@ -62,6 +64,8 @@ my $autodetect_type = sub {
return "devuan";
} elsif (-f "$rootdir/etc/SuSE-brand" || -f "$rootdir/etc/SuSE-release") {
return "opensuse";
+ } elsif (-f "$rootdir/etc/altlinux-release") {
+ return "altlinux";
} elsif (-f "$rootdir/etc/fedora-release") {
return "fedora";
} elsif (-f "$rootdir/etc/centos-release" || -f "$rootdir/etc/redhat-release") {
@@ -257,7 +261,12 @@ sub rewrite_ssh_host_keys {
my $plugin = $self->{plugin};
my $rootdir = $self->{rootdir};
- return if ! -d "$rootdir/etc/ssh";
+ my $sshdir = "/etc/ssh";
+ if ( ! -d "$rootdir$sshdir" ) {
+ if ( ! -d "$rootdir/etc/openssh" ) {
+ return;
+ } $sshdir = "/etc/openssh";
+ }
my $keynames = {
rsa => 'ssh_host_rsa_key',
@@ -287,8 +296,8 @@ sub rewrite_ssh_host_keys {
my $cmd = ['ssh-keygen', '-f', $file, '-t', $keytype,
'-N', '', '-E', 'sha256', '-C', $ssh_comment];
PVE::Tools::run_command($cmd, outfunc => $keygen_outfunc);
- $keyfiles->{"/etc/ssh/$basename"} = [PVE::Tools::file_get_contents($file), 0600];
- $keyfiles->{"/etc/ssh/$basename.pub"} = [PVE::Tools::file_get_contents("$file.pub"), 0644];
+ $keyfiles->{"$sshdir/$basename"} = [PVE::Tools::file_get_contents($file), 0600];
+ $keyfiles->{"$sshdir/$basename.pub"} = [PVE::Tools::file_get_contents("$file.pub"), 0644];
unlink $file;
unlink "$file.pub";
}
--- pve-container/src/PVE/LXC/Setup/ALTLinux.pm.altlinux-lxc 2021-09-27 08:46:45.403297787 +0000
+++ pve-container/src/PVE/LXC/Setup/ALTLinux.pm 2021-09-27 08:46:45.403297787 +0000
@@ -0,0 +1,60 @@
+package PVE::LXC::Setup::ALTLinux;
+
+use strict;
+use warnings;
+use Digest::SHA;
+use Crypt::Eksblowfish::Bcrypt;
+use PVE::LXC::Setup::Base;
+use base qw(PVE::LXC::Setup::Base);
+
+sub new {
+ my ($class, $conf, $rootdir) = @_;
+ my $ostype = "altlinux";
+ my $version = PVE::Tools::file_read_firstline("$rootdir/etc/$ostype-release");
+ my $self = { conf => $conf, rootdir => $rootdir, version => $version };
+ $conf->{ostype} = $ostype;
+ return bless $self, $class;
+}
+
+sub setup_init {
+ my ($self, $conf) = @_;
+
+ $self->fixup_old_getty();
+
+ $self->setup_container_getty_service($conf);
+}
+
+sub setup_network {
+ my ($self, $conf) = @_;
+ $self->setup_systemd_networkd($conf);
+}
+
+sub template_fixup {
+ my ($self, $conf) = @_;
+ $self->setup_securetty($conf, qw(pts/0 console lxc/console lxc/tty1 lxc/tty2));
+}
+
+sub set_user_password {
+ my ($self, $conf, $user, $opt_password) = @_;
+
+ my $shadowfile = "/etc/tcb/$user/shadow";
+ return if !$self->ct_file_exists($shadowfile);
+
+ if (defined($opt_password)) {
+ if ($opt_password !~ m/^\$/) {
+ my $salt = Crypt::Eksblowfish::Bcrypt::en_base64(substr(Digest::SHA::sha1_base64(time), 0, 16));
+ $opt_password = Crypt::Eksblowfish::Bcrypt::bcrypt($opt_password, '$2a$08$'.$salt);
+ };
+ } else {
+ $opt_password = '*';
+ }
+
+ my $data = $user . ":" . $opt_password . ":" . (int(time()/86400)) . "::::::\n";
+
+ my $st = $self->ct_stat($shadowfile) || die "unable to stat file - $!";
+ $self->ct_file_set_contents($shadowfile, $data);
+ chmod $st->mode, $shadowfile;
+ chown $st->uid, $st->gid, $shadowfile;
+}
+
+1;
--- pve-container/src/PVE/LXC/Setup/Makefile.altlinux-lxc 2021-08-05 14:12:00.000000000 +0000
+++ pve-container/src/PVE/LXC/Setup/Makefile 2021-09-27 08:46:45.403297787 +0000
@@ -1,4 +1,4 @@
-SOURCES=Base.pm Debian.pm Ubuntu.pm CentOS.pm Fedora.pm SUSE.pm ArchLinux.pm Alpine.pm Gentoo.pm Devuan.pm
+SOURCES=Base.pm Debian.pm Ubuntu.pm CentOS.pm Fedora.pm SUSE.pm ArchLinux.pm Alpine.pm Gentoo.pm Devuan.pm ALTLinux.pm
.PHONY: install
install: