[pve-devel] [PATCH container 2/2] setup getty: ensure the getty.target is enabled

Fabian Grünbichler f.gruenbichler at proxmox.com
Thu Jul 18 10:23:36 CEST 2019


On Wed, Jul 17, 2019 at 12:08:25PM +0200, Thomas Lamprecht wrote:
> some distro templates have this disabled (masked) by default, it
> makes sense to always ensure that it is enabled.

see below - masking and disabling are two separate things, although they
often go hand-in-hand.

> 
> Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
> ---
>  src/PVE/LXC/Setup/Base.pm | 17 +++++++++++++++++
>  1 file changed, 17 insertions(+)
> 
> diff --git a/src/PVE/LXC/Setup/Base.pm b/src/PVE/LXC/Setup/Base.pm
> index 5ec78a0..516bd68 100644
> --- a/src/PVE/LXC/Setup/Base.pm
> +++ b/src/PVE/LXC/Setup/Base.pm
> @@ -200,6 +200,8 @@ sub setup_systemd_console {
>  	    }
>  	}
>      }
> +
> +    $self->enable_getty_target();
>  }
>  
>  # A few distros as well as unprivileged containers cannot deal with the
> @@ -209,6 +211,19 @@ sub devttydir {
>      return $conf->{unprivileged} ? '' : 'lxc/';
>  }
>  
> +sub enable_getty_target {
> +    my ($self) = @_;
> +
> +    my $systemd_dir_rel = $self->ct_is_executable("/lib/systemd/systemd") ?
> +	"/lib/systemd/system" : "/usr/lib/systemd/system";
> +
> +    my $targetfile = "$systemd_dir_rel/getty.target";
> +    my $getty_target_lnk = "/etc/systemd/system/getty.target";
> +
> +    $self->ct_unlink($getty_target_lnk);
> +    $self->ct_symlink($targetfile, $getty_target_lnk);
> +}

this does not enable the target, it just unmasks it in a
non-straightforward fashion..

in practice it likely effectively enables it as well, since getty.target
is a static unit that is by default statically enabled/pulled in by
multi-user.target, so unless that standard target has been modified
unmasking == enabling.

simply removing any symlink in /etc/systemd/system/getty.target pointing
to /dev/null should have the same effect, without overruling any
replacements admins/templates might have put into place in /etc,
together with naming the sub correctly this makes it more obvious what
is going on IMHO.

> +
>  sub setup_container_getty_service {
>      my ($self, $conf) = @_;
>  
> @@ -239,6 +254,8 @@ sub setup_container_getty_service {
>  	    }
>  	}
>      }
> +
> +    $self->enable_getty_target();
>  }
>  
>  sub setup_systemd_networkd {
> -- 
> 2.20.1
> 
> 
> _______________________________________________
> pve-devel mailing list
> pve-devel at pve.proxmox.com
> https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel




More information about the pve-devel mailing list