From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 08881673C0 for ; Wed, 26 Aug 2020 10:31:58 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id F4191E048 for ; Wed, 26 Aug 2020 10:31:27 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [212.186.127.180]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id D2347E034 for ; Wed, 26 Aug 2020 10:31:26 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 9D09A448A6 for ; Wed, 26 Aug 2020 10:31:26 +0200 (CEST) From: Thomas Lamprecht To: pbs-devel@lists.proxmox.com Date: Wed, 26 Aug 2020 10:31:13 +0200 Message-Id: <20200826083113.23822-2-t.lamprecht@proxmox.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200826083113.23822-1-t.lamprecht@proxmox.com> References: <20200826083113.23822-1-t.lamprecht@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.088 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [proxmox-backup-proxy.rs] Subject: [pbs-devel] applied: [PATCH backup 2/2] bin/backup-proxy: assert that daemon runs as backup user/group X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 26 Aug 2020 08:31:58 -0000 Because if not, the backups it creates have bogus permissions and may seem like they got broken once the daemon is started again with the correct user/group. Signed-off-by: Thomas Lamprecht --- src/bin/proxmox-backup-proxy.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/bin/proxmox-backup-proxy.rs b/src/bin/proxmox-backup-proxy.rs index dd7904c3..dd081dfe 100644 --- a/src/bin/proxmox-backup-proxy.rs +++ b/src/bin/proxmox-backup-proxy.rs @@ -23,6 +23,15 @@ use proxmox_backup::api2::pull::do_sync_job; fn main() -> Result<(), Error> { proxmox_backup::tools::setup_safe_path_env(); + let backup_uid = proxmox_backup::backup::backup_user()?.uid; + let backup_gid = proxmox_backup::backup::backup_group()?.gid; + let running_uid = nix::unistd::Uid::effective(); + let running_gid = nix::unistd::Gid::effective(); + + if running_uid != backup_uid || running_gid != backup_gid { + bail!("proxy not running as backup user or group (got uid {} gid {})", running_uid, running_gid); + } + proxmox_backup::tools::runtime::main(run()) } -- 2.27.0