From patchwork Sun Feb 14 04:41:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Lipnitskiy X-Patchwork-Id: 1440261 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.openwrt.org (client-ip=2001:8b0:10b:1231::1; helo=merlin.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=merlin.20170209 header.b=0G4IB/yJ; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=CZgjp3Fg; dkim-atps=neutral Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DdZNg4WFgz9s1l for ; Sun, 14 Feb 2021 15:42:59 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=z5CVmXxxz08lLCj0UE4tFKe3MrRgAivvtwEJAXGdOY0=; b=0G4IB/yJzQ1RVbid2SJdI1Pgo RT8bP4S8y7pMLM2jp3UeRr2Y36ZP2Tf35VL4c0brG0fmVO9hQIYtbQ6h4pXywzSzICZkkhYIOfELZ jkmAMk4lcR8dMHvaaSILC0aSN5STa36IsWEBqjZXfelC5Y9zjiyiycacvZc7L5DI1+wzF2vIAfT7c 3FWP7tK8yslHJJ1VAbzr5ydQd2Vem0tfKCG2o6mPQC4r6PAobmPnkt5FFwSJT+RXOpm6b73uN9UY7 vsN2vbciM0jEENga2ftxeU1yMI6fUjHKYqospHE5MH9viatMfsPwi4ZoOwGimL1RBjphq5CoGbUAz urbP5wGBw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1lB9Dm-00040m-Ls; Sun, 14 Feb 2021 04:41:22 +0000 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1lB9Dg-0003ze-PU for openwrt-devel@lists.openwrt.org; Sun, 14 Feb 2021 04:41:20 +0000 Received: by mail-pl1-x631.google.com with SMTP id a16so1903285plh.8 for ; Sat, 13 Feb 2021 20:41:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=VhYu8jsLiYdL4yCuVbxyw+0NM8Bp2uSufuhiT0d/ICU=; b=CZgjp3Fg4+h/4N4twTiHPd4YgQYN4mJXjZYMfZe18Z2OudR1GKZ2R+ICiY/DaFGf5Z 9iadytTHlZTnOVgz2ormAihkYdSyTJ5sC8xqswR/WC5RlvsKvAgFMvoteOOpweTOCLrA OxrGzkEm9lufyaoowXG++IpLYufp4Anw1DHPMBSIAEusEvZIflgsokXOWaiUfKKXqdGF uz2THesValAgi6jemc1WqKqAfi6/s6o2NiY5vya1JLALMTl10J3jbJKwhR1Oa/HY6iRP Qyh1TwajJN3qcW9MNencErCE6t74/mMPBMGaebVhqNNh5Cv0vIM2fMVGKF6/YMvAnTb5 bPyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=VhYu8jsLiYdL4yCuVbxyw+0NM8Bp2uSufuhiT0d/ICU=; b=d+Oi8lpsUiEPJDh5+NVvEu1itP1Djdma2148iqB3BUiBaHmIUktgpgU3Rxktr8nRVO EqAV5u5+Pct7fahkkV+T9uqV1TC7vmPXybsXrAOWOVCkGbCJtdanaIFhG+Qrggt2q584 ft1FKLLgBcdvfm0Z7uuvfLdzlpMjCwvqTD91k1HXxV9/Xkvn3GzRcS07CjuU99DEnY1A Zq4Jxsz4ApqzJT3RCs0ptPx/8NH8mBE8tRPdpH+mTrdpkqQ9SU033VW/uZP0fQfPiI2l vShvrOY78UKC4ylrMfaJ+4gF0vLI4FuzFnyv2Hr0iOvgXrgg8ngn85NFmM1TX+eznDC9 Uiyw== X-Gm-Message-State: AOAM530LsgEP6VAhizUBhYQWS7eH9e9237nmaA9ZNm9kLgbw+yCHITCW 9NUBAKp+MTMlHJ/TpNlgChdq6Gbf/aYtEHTp X-Google-Smtp-Source: ABdhPJxttSggKRAD/B7NInNHUWY0TFLosCeW2nkNCnBt2Uaf+6ehishK5drar8+XFuDs1Hc86eUk1g== X-Received: by 2002:a17:90a:bb0c:: with SMTP id u12mr2882072pjr.234.1613277673937; Sat, 13 Feb 2021 20:41:13 -0800 (PST) Received: from z640-arch.lan ([2602:61:7377:4400::678]) by smtp.gmail.com with ESMTPSA id d133sm13159809pfd.6.2021.02.13.20.41.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 13 Feb 2021 20:41:13 -0800 (PST) From: Ilya Lipnitskiy To: openwrt-devel Subject: [PATCH v3] fakeroot: fix to work with glibc 2.33 Date: Sat, 13 Feb 2021 20:41:03 -0800 Message-Id: <20210214044103.76491-1-ilya.lipnitskiy@gmail.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210212054210.684510-1-ilya.lipnitskiy@gmail.com> References: <20210212054210.684510-1-ilya.lipnitskiy@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210213_234116_889496_6BBD6C08 X-CRM114-Status: GOOD ( 16.93 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:631 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [ilya.lipnitskiy[at]gmail.com] -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Philip Prindeville , Ilya Lipnitskiy , Felix Fietkau Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org The following commit removed _STAT_VER definitions from glibc: https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=8ed005daf0ab03e142500324a34087ce179ae78e That subsequently broke fakeroot: https://bugs.archlinux.org/task/69572 https://bugzilla.redhat.com/show_bug.cgi?id=1889862#c13 https://forum.openwrt.org/t/unable-to-build-toolchain-fakeroot-fails-perhaps-others-after-it/87966 Make the patch based on Jan Pazdziora's suggestion from here: https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org/message/SMQ3RYXEYTVZH6PLQMKNB3NM4XLPMNZO/ Add wrappers for newly exported symbols in glibc. Apply patch from Debian to fix warnings in fts_read and fts_children: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=676428 https://sources.debian.org/patches/fakeroot/1.25.3-1.1/eglibc-fts-without-LFS/ Fix __xmknod{,at} dev pointer argument. Switch default to assume * and not the absence of *. On glibc 2.33+, there is no definition for these functions in header files, so the compile test doesn't work. But, we can default to using the pointer (as is the case with newer glibc), and use the header file on older platforms to fail the test and use no pointer. Tested on my x86_64 Arch Linux machine, fakeroot unit tests pass. Also tested by building various .ipks and examining the tar contents, to ensure that the owner uid/gid was 0/0. Signed-off-by: Ilya Lipnitskiy --- .../300-glibc-2.33-compatibility.patch | 145 ++++++++++++++++++ 1 file changed, 145 insertions(+) create mode 100644 tools/fakeroot/patches/300-glibc-2.33-compatibility.patch diff --git a/tools/fakeroot/patches/300-glibc-2.33-compatibility.patch b/tools/fakeroot/patches/300-glibc-2.33-compatibility.patch new file mode 100644 index 0000000000..a460cace0c --- /dev/null +++ b/tools/fakeroot/patches/300-glibc-2.33-compatibility.patch @@ -0,0 +1,145 @@ +--- a/libfakeroot.c ++++ b/libfakeroot.c +@@ -90,6 +90,16 @@ + #define SEND_GET_XATTR64(a,b,c) send_get_xattr64(a,b) + #endif + ++#ifndef _STAT_VER ++ #if defined (__aarch64__) ++ #define _STAT_VER 0 ++ #elif defined (__x86_64__) ++ #define _STAT_VER 1 ++ #else ++ #define _STAT_VER 3 ++ #endif ++#endif ++ + /* + These INT_* (which stands for internal) macros should always be used when + the fakeroot library owns the storage of the stat variable. +@@ -1358,6 +1368,54 @@ int renameat(int olddir_fd, const char * + #endif /* HAVE_FSTATAT */ + + ++#if defined(__GLIBC__) && __GLIBC_PREREQ(2,33) ++/* Glibc 2.33 exports symbols for these functions in the shared lib */ ++ int lstat(const char *file_name, struct stat *statbuf) { ++ return WRAP_LSTAT LSTAT_ARG(_STAT_VER, file_name, statbuf); ++ } ++ int stat(const char *file_name, struct stat *st) { ++ return WRAP_STAT STAT_ARG(_STAT_VER, file_name, st); ++ } ++ int fstat(int fd, struct stat *st) { ++ return WRAP_FSTAT FSTAT_ARG(_STAT_VER, fd, st); ++ } ++ ++ #ifdef HAVE_FSTATAT ++ int fstatat(int dir_fd, const char *path, struct stat *st, int flags) { ++ return WRAP_FSTATAT FSTATAT_ARG(_STAT_VER, dir_fd, path, st, flags); ++ } ++ #endif ++ ++ #ifdef STAT64_SUPPORT ++ int lstat64(const char *file_name, struct stat64 *st) { ++ return WRAP_LSTAT64 LSTAT64_ARG(_STAT_VER, file_name, st); ++ } ++ int stat64(const char *file_name, struct stat64 *st) { ++ return WRAP_STAT64 STAT64_ARG(_STAT_VER, file_name, st); ++ } ++ int fstat64(int fd, struct stat64 *st) { ++ return WRAP_FSTAT64 FSTAT64_ARG(_STAT_VER, fd, st); ++ } ++ ++ #ifdef HAVE_FSTATAT ++ int fstatat64(int dir_fd, const char *path, struct stat64 *st, int flags) { ++ return WRAP_FSTATAT64 FSTATAT64_ARG(_STAT_VER, dir_fd, path, st, flags); ++ } ++ #endif ++ #endif ++ ++ int mknod(const char *pathname, mode_t mode, dev_t dev) { ++ return WRAP_MKNOD MKNOD_ARG(_STAT_VER, pathname, mode, &dev); ++ } ++ ++ #if defined(HAVE_FSTATAT) && defined(HAVE_MKNODAT) ++ int mknodat(int dir_fd, const char *pathname, mode_t mode, dev_t dev) { ++ return WRAP_MKNODAT MKNODAT_ARG(_STAT_VER, dir_fd, pathname, mode, &dev); ++ } ++ #endif ++#endif /* GLIBC_PREREQ */ ++ ++ + #ifdef FAKEROOT_FAKENET + pid_t fork(void) + { +@@ -2024,11 +2082,7 @@ FTSENT *fts_read(FTS *ftsp) { + || r->fts_info == FTS_NS || r->fts_info == FTS_NSOK)) + r->fts_statp = NULL; /* Otherwise fts_statp may be a random pointer */ + if(r && r->fts_statp) { /* Should we bother checking fts_info here? */ +-# if defined(STAT64_SUPPORT) && !defined(__APPLE__) +- SEND_GET_STAT64(r->fts_statp, _STAT_VER); +-# else + SEND_GET_STAT(r->fts_statp, _STAT_VER); +-# endif + } + + return r; +@@ -2047,11 +2101,7 @@ FTSENT *fts_children(FTS *ftsp, int opti + first=next_fts_children(ftsp, options); + for(r = first; r; r = r->fts_link) { + if(r && r->fts_statp) { /* Should we bother checking fts_info here? */ +-# if defined(STAT64_SUPPORT) && !defined(__APPLE__) +- SEND_GET_STAT64(r->fts_statp, _STAT_VER); +-# else + SEND_GET_STAT(r->fts_statp, _STAT_VER); +-# endif + } + } + +@@ -2483,7 +2533,7 @@ int statx (int dirfd, const char *path, + + #ifdef LIBFAKEROOT_DEBUGGING + if (fakeroot_debug) { +- fprintf(stderr, "statx fd %d\n", fd); ++ fprintf(stderr, "statx fd %d\n", dirfd); + } + #endif /* LIBFAKEROOT_DEBUGGING */ + r=INT_NEXT_FSTATAT(dirfd, path, &st, flags); +--- a/configure.ac ++++ b/configure.ac +@@ -184,13 +184,13 @@ AC_MSG_CHECKING([for type of arg of __xm + ]], [[ + int __xmknod ( int ver, + const char *pathname , +- mode_t mode , dev_t dev); ++ mode_t mode , dev_t *dev); + ]])],[ +- AC_DEFINE(XMKNOD_FRTH_ARG,) +- AC_MSG_RESULT([no extra *]) +- ],[ + AC_DEFINE(XMKNOD_FRTH_ARG,[*]) + AC_MSG_RESULT([needs *]) ++ ],[ ++ AC_DEFINE(XMKNOD_FRTH_ARG,) ++ AC_MSG_RESULT([no extra *]) + + ]) + +@@ -211,13 +211,13 @@ AC_MSG_CHECKING([for type of arg of __xm + int __xmknodat ( int ver, + int dirfd, + const char *pathname , +- mode_t mode , dev_t dev); ++ mode_t mode , dev_t *dev); + ]])],[ +- AC_DEFINE(XMKNODAT_FIFTH_ARG,) +- AC_MSG_RESULT([no extra *]) +- ],[ + AC_DEFINE(XMKNODAT_FIFTH_ARG,[*]) + AC_MSG_RESULT([needs *]) ++ ],[ ++ AC_DEFINE(XMKNODAT_FIFTH_ARG,) ++ AC_MSG_RESULT([no extra *]) + + ]) +