[pve-devel] [PATCH v2 common] REST environment: default to root at pam in forked workers if no user was specified

Fabian Ebner f.ebner at proxmox.com
Tue Mar 15 08:31:40 CET 2022


Am 14.03.22 um 14:50 schrieb Oguz Bektas:
> first call $rpcenv->get_user() if user was 'undef'. if that doesn't
> return then we set it to root at pam.
> 
> Signed-off-by: Oguz Bektas <o.bektas at proxmox.com>
> ---
> v1->v2:
> * do get_user() first, set to 'root at pam' as fallback
> * drop first patch for pve-container (not needed anymore)
> 
>  src/PVE/RESTEnvironment.pm | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/src/PVE/RESTEnvironment.pm b/src/PVE/RESTEnvironment.pm
> index 1b2af08..bc5b8b5 100644
> --- a/src/PVE/RESTEnvironment.pm
> +++ b/src/PVE/RESTEnvironment.pm
> @@ -492,7 +492,12 @@ sub fork_worker {
>      $dtype = 'unknown' if !defined ($dtype);
>      $id = '' if !defined ($id);
>  
> -    $user = 'root at pve' if !defined ($user);
> +    $user = $self->get_user() if !defined($user);

If you don't set $noerr when calling get_user(), the below if block is
dead code.

> +
> +    if (!defined($user)) {
> +	warn 'internal error: Worker user was not specified, defaulting to "root at pam"!';
> +	$user = 'root at pam';
> +    }
>  
>      my $sync = ($self->{type} eq 'cli' && !$background) ? 1 : 0;
>  





More information about the pve-devel mailing list