[pve-devel] [RFC manager 1/1] api: nodes: set environment variable for shells started via the API

Fabian Ebner f.ebner at proxmox.com
Mon Sep 13 14:26:44 CEST 2021


Am 13.09.21 um 14:04 schrieb Fabian Ebner:
> so that proxmox-ve's apt hook script can detect this.
> 
> Signed-off-by: Fabian Ebner <f.ebner at proxmox.com>
> ---
>   PVE/API2/Nodes.pm | 10 +++++-----
>   1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/PVE/API2/Nodes.pm b/PVE/API2/Nodes.pm
> index e58d9c10..c57ad995 100644
> --- a/PVE/API2/Nodes.pm
> +++ b/PVE/API2/Nodes.pm
> @@ -843,13 +843,13 @@ my $sslcert;
>   
>   my $shell_cmd_map = {
>       'login' => {
> -	cmd => [ '/bin/login', '-f', 'root' ],
> +	cmd => [ '/bin/login', '-f', 'root', 'PVE_API_SHELL=1' ],
>       },
>       'upgrade' => {
> -	cmd => [ '/usr/bin/pveupgrade', '--shell' ],
> +	cmd => [ '/usr/bin/env', 'PVE_API_SHELL=1', '/usr/bin/pveupgrade', '--shell' ],
>       },
>       'ceph_install' => {
> -	cmd => [ '/usr/bin/pveceph', 'install' ],
> +	cmd => [ '/usr/bin/env', 'PVE_API_SHELL=1', '/usr/bin/pveceph', 'install' ],
>   	allow_args => 1,
>       },
>   };
> @@ -866,11 +866,11 @@ sub get_shell_command  {
>   		push @$cmd, split("\0", $args);
>   	    }
>   	} else {
> -	    $cmd = [ '/bin/login', '-f', 'root' ];
> +	    $cmd = [ '/bin/login', '-f', 'root', 'PVE_API_SHELL=1' ];
>   	}
>       } else {
>   	# non-root must always login for now, we do not have a superuser role!
> -	$cmd = [ '/bin/login' ];
> +	$cmd = [ '/bin/login', 'PVE_API_SHELL=1' ];

Sorry, I think the PVE_API_SHELL=1 gets interpreted as the username in 
this case. I'll fix that in v2 if we even go with this approach.

>       }
>       return $cmd;
>   }
> 





More information about the pve-devel mailing list