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 12888924D7 for ; Mon, 12 Sep 2022 16:01:03 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 108916232 for ; Mon, 12 Sep 2022 16:01:03 +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 for ; Mon, 12 Sep 2022 16:01:01 +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 9B81742DB4 for ; Mon, 12 Sep 2022 16:01:01 +0200 (CEST) Message-ID: <49d3280a-3144-1411-3911-1f2138476116@proxmox.com> Date: Mon, 12 Sep 2022 16:01:00 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:105.0) Gecko/20100101 Thunderbird/105.0 Content-Language: en-GB To: Proxmox VE development discussion , Leo Nunner References: <20220912122539.85794-1-l.nunner@proxmox.com> <1662985982.t6rahmo5l4.astroid@nora.none> From: Thomas Lamprecht In-Reply-To: <1662985982.t6rahmo5l4.astroid@nora.none> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-SPAM-LEVEL: Spam detection results: 0 AWL 2.048 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 NICE_REPLY_A -4.101 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 T_SCC_BODY_TEXT_LINE -0.01 - Subject: Re: [pve-devel] [PATCH v2 container] fix #4192: revamp check for systemd version X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 12 Sep 2022 14:01:03 -0000 Am 12/09/2022 um 14:41 schrieb Fabian Gr=C3=BCnbichler: >> Instead of iterating through several folders, it might just be easier = to >> check the ldd output of /sbin/init and getting the version from there.= >> Furthermore, the regex for checking the version has been adapted so th= at >> it's more precise. > ldd is not suited for this purpose for security reasons, since /sbin/in= it=20 > is a user/attacker-controlled binary in this case and we are only in a = > chroot while doing the setup, not really containerized. given a crafted= =20 > container template/backup archive/.. this could execute arbitrary code.= >=20 > it's manpage suggests using >=20 > objdump -p /path/to/binary >=20 > and looking at the lines with "NEEDED", which seems to me should be fin= e=20 > for what we want to achieve here =F0=9F=98=84 >=20 tbf, I suggested using something like ldd here, but I mostly meant if we = actually need to further extend this than simply checking three instead of two pat= hs. But I actually like the much shorter code, so from that POV it could be a= nicer option, but it makes us dependent on actually executing code from the CT = archive, which also assumes the availability of something like ldd or objdump, whi= ch may not be the case in all templates? Two small nits w.r.t. to the v2 still inline. Am 12/09/2022 um 14:25 schrieb Leo Nunner: > + my $version =3D undef; > + PVE::Tools::run_command( > + [ > + 'ldd', > + '/sbin/init' > + ], you can put the array ref in one line, e.g., with Fabian relayed manpage suggestion it'd be fine to do: [ 'objdump', '-p', '/sbin/init' ], > + outfunc =3D> sub { > + my $line =3D shift; > + if ($line =3D~ /^\s*libsystemd-shared-(\d+)(?:\.[a-zA-Z0-9]*)?\.s= o/) { > + $version =3D $1; > + }}, > + errmsg =3D> "ldd on /sbin/init failed" above is missing a trailing comma, which would ensure that any possible a= ddition of an option in the future won't need to touch an unrelated line. > + ); > + > + return $version; > }