all lists on lists.proxmox.com
 help / color / mirror / Atom feed
* [pmg-devel] [PATCH pmg-api] API2/Nodes/termproxy: fix upgrade for new xtermjs package
@ 2020-11-25  8:57 Dominik Csapak
  2020-11-25  9:11 ` Stoiko Ivanov
  2020-11-25  9:18 ` Thomas Lamprecht
  0 siblings, 2 replies; 3+ messages in thread
From: Dominik Csapak @ 2020-11-25  8:57 UTC (permalink / raw)
  To: pmg-devel

we changed how we call upgrade (cmd param instead of upgrade)
so we have to adapt our api call

most is taken from pve

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 src/PMG/API2/Nodes.pm | 28 +++++++++++++++++++++++-----
 1 file changed, 23 insertions(+), 5 deletions(-)

diff --git a/src/PMG/API2/Nodes.pm b/src/PMG/API2/Nodes.pm
index 259f8f3..e368569 100644
--- a/src/PMG/API2/Nodes.pm
+++ b/src/PMG/API2/Nodes.pm
@@ -348,10 +348,24 @@ __PACKAGE__->register_method ({
 	    node => get_standard_option('pve-node'),
 	    upgrade => {
 		type => 'boolean',
-		description => "Run 'apt-get dist-upgrade' instead of normal shell.",
+		description => "Deprecated, use the 'cmd' property instead! Run 'apt-get dist-upgrade' instead of normal shell.",
 		optional => 1,
 		default => 0,
 	    },
+	    cmd => {
+		type => 'string',
+		description => "Run specific command or default to login.",
+		enum => ['login', 'upgrade'],
+		optional => 1,
+		default => 'login',
+	    },
+	    'cmd-opts' => {
+		type => 'string',
+		description => "Add parameters to a command. Encoded as null terminated strings.",
+		requires => 'cmd',
+		optional => 1,
+		default => '',
+	    },
 	},
     },
     returns => {
@@ -384,17 +398,21 @@ __PACKAGE__->register_method ({
 	my $family = PVE::Tools::get_host_address_family($node);
 	my $port = PVE::Tools::next_vnc_port($family);
 
+	# FIXME: remove with 7.0
+	if ($param->{upgrade}) {
+	    $param->{cmd} = 'upgrade';
+	}
+
 	my $shcmd;
 
 	if ($user eq 'root@pam') {
-	    if ($param->{upgrade}) {
-		my $upgradecmd = "pmgupgrade --shell";
-		# $upgradecmd = PVE::Tools::shellquote($upgradecmd) if $remip;
-		$shcmd = [ '/bin/bash', '-c', $upgradecmd ];
+	    if (defined($param->{cmd}) && $param->{cmd} eq 'upgrade') {
+		$shcmd = [ 'pmgupgrade', '--shell' ];
 	    } else {
 		$shcmd = [ '/bin/login', '-f', 'root' ];
 	    }
 	} else {
+	    # non-root must always login for now, we do not have a superuser role!
 	    $shcmd = [ '/bin/login' ];
 	}
 
-- 
2.20.1





^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [pmg-devel] [PATCH pmg-api] API2/Nodes/termproxy: fix upgrade for new xtermjs package
  2020-11-25  8:57 [pmg-devel] [PATCH pmg-api] API2/Nodes/termproxy: fix upgrade for new xtermjs package Dominik Csapak
@ 2020-11-25  9:11 ` Stoiko Ivanov
  2020-11-25  9:18 ` Thomas Lamprecht
  1 sibling, 0 replies; 3+ messages in thread
From: Stoiko Ivanov @ 2020-11-25  9:11 UTC (permalink / raw)
  To: Dominik Csapak; +Cc: pmg-devel

Thanks for addressing this prompty!

quickly compared the changes to the ones from pve-manager,
verified that it's currently broken, and that applying the patch fixes it.

LGTM:
Reviewed-By: Stoiko Ivanov <s.ivanov@proxmox.com>
Tested-By: Stoiko Ivanov <s.ivanov@proxmox.com>


On Wed, 25 Nov 2020 09:57:11 +0100
Dominik Csapak <d.csapak@proxmox.com> wrote:

> we changed how we call upgrade (cmd param instead of upgrade)
> so we have to adapt our api call
> 
> most is taken from pve
> 
> Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
> ---
>  src/PMG/API2/Nodes.pm | 28 +++++++++++++++++++++++-----
>  1 file changed, 23 insertions(+), 5 deletions(-)
> 
> diff --git a/src/PMG/API2/Nodes.pm b/src/PMG/API2/Nodes.pm
> index 259f8f3..e368569 100644
> --- a/src/PMG/API2/Nodes.pm
> +++ b/src/PMG/API2/Nodes.pm
> @@ -348,10 +348,24 @@ __PACKAGE__->register_method ({
>  	    node => get_standard_option('pve-node'),
>  	    upgrade => {
>  		type => 'boolean',
> -		description => "Run 'apt-get dist-upgrade' instead of normal shell.",
> +		description => "Deprecated, use the 'cmd' property instead! Run 'apt-get dist-upgrade' instead of normal shell.",
>  		optional => 1,
>  		default => 0,
>  	    },
> +	    cmd => {
> +		type => 'string',
> +		description => "Run specific command or default to login.",
> +		enum => ['login', 'upgrade'],
> +		optional => 1,
> +		default => 'login',
> +	    },
> +	    'cmd-opts' => {
> +		type => 'string',
> +		description => "Add parameters to a command. Encoded as null terminated strings.",
> +		requires => 'cmd',
> +		optional => 1,
> +		default => '',
> +	    },
>  	},
>      },
>      returns => {
> @@ -384,17 +398,21 @@ __PACKAGE__->register_method ({
>  	my $family = PVE::Tools::get_host_address_family($node);
>  	my $port = PVE::Tools::next_vnc_port($family);
>  
> +	# FIXME: remove with 7.0
> +	if ($param->{upgrade}) {
> +	    $param->{cmd} = 'upgrade';
> +	}
> +
>  	my $shcmd;
>  
>  	if ($user eq 'root@pam') {
> -	    if ($param->{upgrade}) {
> -		my $upgradecmd = "pmgupgrade --shell";
> -		# $upgradecmd = PVE::Tools::shellquote($upgradecmd) if $remip;
> -		$shcmd = [ '/bin/bash', '-c', $upgradecmd ];
> +	    if (defined($param->{cmd}) && $param->{cmd} eq 'upgrade') {
> +		$shcmd = [ 'pmgupgrade', '--shell' ];
>  	    } else {
>  		$shcmd = [ '/bin/login', '-f', 'root' ];
>  	    }
>  	} else {
> +	    # non-root must always login for now, we do not have a superuser role!
>  	    $shcmd = [ '/bin/login' ];
>  	}
>  





^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [pmg-devel] [PATCH pmg-api] API2/Nodes/termproxy: fix upgrade for new xtermjs package
  2020-11-25  8:57 [pmg-devel] [PATCH pmg-api] API2/Nodes/termproxy: fix upgrade for new xtermjs package Dominik Csapak
  2020-11-25  9:11 ` Stoiko Ivanov
@ 2020-11-25  9:18 ` Thomas Lamprecht
  1 sibling, 0 replies; 3+ messages in thread
From: Thomas Lamprecht @ 2020-11-25  9:18 UTC (permalink / raw)
  To: Dominik Csapak, pmg-devel

On 25.11.20 09:57, Dominik Csapak wrote:
> we changed how we call upgrade (cmd param instead of upgrade)
> so we have to adapt our api call
> 
> most is taken from pve
> 

oh, only saw that now, already applied a version mostly similar to this one
(but the cmd resolving also factored out like PVE)

> Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
> ---
>  src/PMG/API2/Nodes.pm | 28 +++++++++++++++++++++++-----
>  1 file changed, 23 insertions(+), 5 deletions(-)
> 
> diff --git a/src/PMG/API2/Nodes.pm b/src/PMG/API2/Nodes.pm
> index 259f8f3..e368569 100644
> --- a/src/PMG/API2/Nodes.pm
> +++ b/src/PMG/API2/Nodes.pm
> @@ -348,10 +348,24 @@ __PACKAGE__->register_method ({
>  	    node => get_standard_option('pve-node'),
>  	    upgrade => {
>  		type => 'boolean',
> -		description => "Run 'apt-get dist-upgrade' instead of normal shell.",
> +		description => "Deprecated, use the 'cmd' property instead! Run 'apt-get dist-upgrade' instead of normal shell.",
>  		optional => 1,
>  		default => 0,
>  	    },
> +	    cmd => {
> +		type => 'string',
> +		description => "Run specific command or default to login.",
> +		enum => ['login', 'upgrade'],
> +		optional => 1,
> +		default => 'login',
> +	    },
> +	    'cmd-opts' => {
> +		type => 'string',
> +		description => "Add parameters to a command. Encoded as null terminated strings.",
> +		requires => 'cmd',
> +		optional => 1,
> +		default => '',
> +	    },
>  	},
>      },
>      returns => {
> @@ -384,17 +398,21 @@ __PACKAGE__->register_method ({
>  	my $family = PVE::Tools::get_host_address_family($node);
>  	my $port = PVE::Tools::next_vnc_port($family);
>  
> +	# FIXME: remove with 7.0
> +	if ($param->{upgrade}) {
> +	    $param->{cmd} = 'upgrade';
> +	}
> +
>  	my $shcmd;
>  
>  	if ($user eq 'root@pam') {
> -	    if ($param->{upgrade}) {
> -		my $upgradecmd = "pmgupgrade --shell";
> -		# $upgradecmd = PVE::Tools::shellquote($upgradecmd) if $remip;
> -		$shcmd = [ '/bin/bash', '-c', $upgradecmd ];
> +	    if (defined($param->{cmd}) && $param->{cmd} eq 'upgrade') {
> +		$shcmd = [ 'pmgupgrade', '--shell' ];
>  	    } else {
>  		$shcmd = [ '/bin/login', '-f', 'root' ];
>  	    }
>  	} else {
> +	    # non-root must always login for now, we do not have a superuser role!
>  	    $shcmd = [ '/bin/login' ];
>  	}
>  
> 





^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-11-25  9:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-25  8:57 [pmg-devel] [PATCH pmg-api] API2/Nodes/termproxy: fix upgrade for new xtermjs package Dominik Csapak
2020-11-25  9:11 ` Stoiko Ivanov
2020-11-25  9:18 ` Thomas Lamprecht

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal