From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <o.bektas@proxmox.com>
Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature RSA-PSS (2048 bits))
 (No client certificate requested)
 by lists.proxmox.com (Postfix) with ESMTPS id 011F6653C7
 for <pve-devel@lists.proxmox.com>; Mon,  7 Mar 2022 10:20:59 +0100 (CET)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
 by firstgate.proxmox.com (Proxmox) with ESMTP id 7536C254AE
 for <pve-devel@lists.proxmox.com>; Mon,  7 Mar 2022 10:20:58 +0100 (CET)
Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com
 [94.136.29.106])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature RSA-PSS (2048 bits))
 (No client certificate requested)
 by firstgate.proxmox.com (Proxmox) with ESMTPS id C7FA02548A
 for <pve-devel@lists.proxmox.com>; Mon,  7 Mar 2022 10:20:57 +0100 (CET)
Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1])
 by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 9F21941D6F
 for <pve-devel@lists.proxmox.com>; Mon,  7 Mar 2022 10:20:57 +0100 (CET)
From: Oguz Bektas <o.bektas@proxmox.com>
To: pve-devel@lists.proxmox.com
Date: Mon,  7 Mar 2022 10:20:43 +0100
Message-Id: <20220307092043.571640-2-o.bektas@proxmox.com>
X-Mailer: git-send-email 2.30.2
In-Reply-To: <20220307092043.571640-1-o.bektas@proxmox.com>
References: <20220307092043.571640-1-o.bektas@proxmox.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-SPAM-LEVEL: Spam detection results:  0
 AWL 0.624 Adjusted score from AWL reputation of From: address
 BAYES_00                 -1.9 Bayes spam probability is 0 to 1%
 KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment
 SPF_HELO_NONE           0.001 SPF: HELO does not publish an SPF Record
 SPF_PASS               -0.001 SPF: sender matches SPF record
 T_SCC_BODY_TEXT_LINE    -0.01 -
Subject: [pve-devel] [PATCH common 2/2] REST environment: default to
 'root@pam' for forked workers in case no user was specified
X-BeenThere: pve-devel@lists.proxmox.com
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Proxmox VE development discussion <pve-devel.lists.proxmox.com>
List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=unsubscribe>
List-Archive: <http://lists.proxmox.com/pipermail/pve-devel/>
List-Post: <mailto:pve-devel@lists.proxmox.com>
List-Help: <mailto:pve-devel-request@lists.proxmox.com?subject=help>
List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=subscribe>
X-List-Received-Date: Mon, 07 Mar 2022 09:20:59 -0000

previously we had a default of 'root@pve', which doesn't exist.
since the username is only relevant for the task logs, we can change it
to 'root@pam' without ill effects.

also add a warning in case there are other call sites that we missed
where fork_worker is called without a user variable (found call sites
only in pve-container where this was unset, namely in 'push_file' and
'pull_file').

Signed-off-by: Oguz Bektas <o.bektas@proxmox.com>
---
 src/PVE/RESTEnvironment.pm | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/PVE/RESTEnvironment.pm b/src/PVE/RESTEnvironment.pm
index 1b2af08..5352aad 100644
--- a/src/PVE/RESTEnvironment.pm
+++ b/src/PVE/RESTEnvironment.pm
@@ -492,7 +492,10 @@ sub fork_worker {
     $dtype = 'unknown' if !defined ($dtype);
     $id = '' if !defined ($id);
 
-    $user = 'root@pve' if !defined ($user);
+    if (!defined($user)) {
+	warn 'Worker user was not specified, defaulting to "root@pam"!';
+	$user = 'root@pam';
+    }
 
     my $sync = ($self->{type} eq 'cli' && !$background) ? 1 : 0;
 
-- 
2.30.2