From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 20709139082 for ; Sun, 22 Jan 2017 17:59:52 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 867F8E0EFE; Sun, 22 Jan 2017 17:59:46 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 67576E0EFE for ; Sun, 22 Jan 2017 17:59:41 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 8AD6B34168D for ; Sun, 22 Jan 2017 17:59:35 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id CB2542CBD for ; Sun, 22 Jan 2017 17:59:32 +0000 (UTC) From: "Mike Frysinger" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Mike Frysinger" Message-ID: <1484982502.71c10be3f18e5d9a702503947173191a202db01a.vapier@gentoo> Subject: [gentoo-commits] proj/pax-utils:master commit in: / X-VCS-Repository: proj/pax-utils X-VCS-Files: security.c X-VCS-Directories: / X-VCS-Committer: vapier X-VCS-Committer-Name: Mike Frysinger X-VCS-Revision: 71c10be3f18e5d9a702503947173191a202db01a X-VCS-Branch: master Date: Sun, 22 Jan 2017 17:59:32 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: e6461867-6ad2-4b23-acdf-f4920cfbd34f X-Archives-Hash: 3d525384f58e4e3c05643bac1c00b6d5 commit: 71c10be3f18e5d9a702503947173191a202db01a Author: Mike Frysinger gentoo org> AuthorDate: Sat Jan 21 07:08:22 2017 +0000 Commit: Mike Frysinger gentoo org> CommitDate: Sat Jan 21 07:08:22 2017 +0000 URL: https://gitweb.gentoo.org/proj/pax-utils.git/commit/?id=71c10be3 security: fix building on much older systems Basically wrap all defines in ifdefs or add fallback stubs. URL: https://bugs.gentoo.org/606184 security.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/security.c b/security.c index 8019860..a86f375 100644 --- a/security.c +++ b/security.c @@ -9,6 +9,23 @@ #ifdef __linux__ +/* Older versions of Linux might not have these. */ +#ifndef CLONE_NEWIPC +#define CLONE_NEWIPC 0 +#endif +#ifndef CLONE_NEWNET +#define CLONE_NEWNET 0 +#endif +#ifndef CLONE_NEWNS +#define CLONE_NEWNS 0 +#endif +#ifndef CLONE_NEWPID +#define CLONE_NEWPID 0 +#endif +#ifndef CLONE_NEWUTS +#define CLONE_NEWUTS 0 +#endif + #ifdef __SANITIZE_ADDRESS__ /* ASAN does some weird stuff. */ # define ALLOW_PIDNS 0 @@ -229,7 +246,7 @@ void security_init_pid(void) { int flags; - if (!ALLOW_PIDNS) + if (!ALLOW_PIDNS || CLONE_NEWPID == 0) return; flags = ns_unshare(CLONE_NEWPID); @@ -248,13 +265,19 @@ void security_init(bool allow_forking) allow_forking = true; /* Drop all possible caps for us and our children. */ +#ifdef PR_SET_NO_NEW_PRIVS /* New to linux-3.5 */ prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0); +#endif +#ifdef PR_SET_SECUREBITS /* New to linux-2.6.26 */ +# ifdef SECBIT_KEEP_CAPS_LOCKED /* New to linux-2.6.33 (all SECBIT_xxx) */ prctl(PR_SET_SECUREBITS, SECBIT_KEEP_CAPS_LOCKED | SECBIT_NO_SETUID_FIXUP | SECBIT_NO_SETUID_FIXUP_LOCKED | SECBIT_NOROOT | SECBIT_NOROOT_LOCKED, 0, 0, 0); +# endif +#endif /* None of the pax tools need access to these features. */ flags = CLONE_NEWIPC | CLONE_NEWUTS;