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 3B2F679E38 for ; Thu, 6 May 2021 09:26:04 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 2E1B91C55C for ; Thu, 6 May 2021 09:26:04 +0200 (CEST) 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 BC2B51C54E for ; Thu, 6 May 2021 09:26:03 +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 8FFDE42864 for ; Thu, 6 May 2021 09:26:03 +0200 (CEST) To: Dietmar Maurer , "pbs-devel@lists.proxmox.com" References: <812801204.222.1620283181019@webmail.proxmox.com> From: Stefan Reiter Message-ID: <3bf5618b-42bb-099a-72e0-1de8a79272dd@proxmox.com> Date: Thu, 6 May 2021 09:26:02 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.0 MIME-Version: 1.0 In-Reply-To: <812801204.222.1620283181019@webmail.proxmox.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.016 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment NICE_REPLY_A -0.001 Looks like a legit reply (A) SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: Re: [pbs-devel] possible problem in get_user_run_dir() 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: Thu, 06 May 2021 07:26:04 -0000 On 06/05/2021 08:39, Dietmar Maurer wrote: > The code get_user_run_dir() looks wrong, because a normal user does not have > permissions required for tools::create_run_dir(). > > Please can you take a look at that? > Yes, already had an off-list discussion with Fabian about this, the problem here is that /run/proxmox-backup might not exist when this is run, but only root can create it - so far, only root calls it (despite the misleading comment), so it works, but for the future, we might want to fall back to XDG_USER_RUNTIME_DIR (doesn't always exist though), /tmp or some other guaranteed-user-writeable temp location. > --- from src/bin/proxmox_client_tools/mod.rs--- > > pub fn get_user_run_dir() -> Result { > let uid = nix::unistd::Uid::current(); > let mut path: std::path::PathBuf = buildcfg::PROXMOX_BACKUP_RUN_DIR.into(); > path.push(uid.to_string()); > tools::create_run_dir()?; > std::fs::create_dir_all(&path)?; > Ok(path) > } >