PR #104 have more 2 commits

This commit is contained in:
Sérgio M. Basto 2022-12-25 21:20:12 +00:00
parent 33a34e0741
commit 4dccfa4918
5 changed files with 515 additions and 593 deletions

463
104.patch
View File

@ -1,7 +1,7 @@
From 11589e1037372c5ad719e1e46d7462fd196caa56 Mon Sep 17 00:00:00 2001
From: Johannes Schauer Marin Rodrigues <josch@mister-muffin.de>
Date: Thu, 24 Jun 2021 10:38:28 +0200
Subject: [PATCH 1/7] src/lckpwdf.c: create an empty /etc/.pwd.lock
Subject: [PATCH 1/9] src/lckpwdf.c: create an empty /etc/.pwd.lock
---
src/lckpwdf.c | 25 +++++++++++++++++++++++++
@ -53,7 +53,7 @@ index dc0e68b5..66a058de 100644
From 3cdb9b5426ef508c9220b4b0316954e3b7dff9ac Mon Sep 17 00:00:00 2001
From: Hajime Yoshimori <lugia.kun@gmail.com>
Date: Fri, 1 May 2020 21:14:32 +0900
Subject: [PATCH 2/7] check return value of dladdr
Subject: [PATCH 2/9] check return value of dladdr
https://github.com/dex4er/fakechroot/pull/70
---
@ -157,7 +157,7 @@ index 00000000..fc7f9397
From 63c2cbed6dca6196940b439736ca2c069cb9358b Mon Sep 17 00:00:00 2001
From: Ilya Lipnitskiy <ilya.lipnitskiy@gmail.com>
Date: Mon, 22 Feb 2021 21:44:07 -0800
Subject: [PATCH 3/7] tmpnam.c: fix heap overflow
Subject: [PATCH 3/9] tmpnam.c: fix heap overflow
https://github.com/dex4er/fakechroot/pull/85
@ -183,7 +183,7 @@ index ce60817a..917ee6b7 100644
From be3a291ef37ace606ec2845f6c1b645b981805cb Mon Sep 17 00:00:00 2001
From: Ilya Lipnitskiy <ilya.lipnitskiy@gmail.com>
Date: Mon, 22 Feb 2021 21:46:36 -0800
Subject: [PATCH 4/7] declare missing bufs, remove ver from lstat
Subject: [PATCH 4/9] declare missing bufs, remove ver from lstat
https://github.com/dex4er/fakechroot/pull/85
@ -279,7 +279,7 @@ index aac9c75f..a360f66f 100644
From 26f69c2c3120b9b059209c7566850ef5187de56a Mon Sep 17 00:00:00 2001
From: Ilya Lipnitskiy <ilya.lipnitskiy@gmail.com>
Date: Mon, 22 Feb 2021 21:47:09 -0800
Subject: [PATCH 5/7] fix glibc 2.33+ compatibility
Subject: [PATCH 5/9] fix glibc 2.33+ compatibility
https://github.com/dex4er/fakechroot/pull/85
@ -495,7 +495,7 @@ index a360f66f..993ce808 100644
From 5366e9a366b213b879abf0f0a3aeb3409d3b57ed Mon Sep 17 00:00:00 2001
From: neok-m4700 <neok-m4700@users.noreply.github.com>
Date: Wed, 24 Feb 2021 17:36:57 +0100
Subject: [PATCH 6/7] wrap fstatat and fstatat64
Subject: [PATCH 6/9] wrap fstatat and fstatat64
https://github.com/dex4er/fakechroot/pull/86
---
@ -634,7 +634,7 @@ index 00000000..18633725
From bc7ef087c17a475ec03768053fa22c2193ae7fc2 Mon Sep 17 00:00:00 2001
From: Johannes Schauer Marin Rodrigues <josch@mister-muffin.de>
Date: Wed, 24 Aug 2022 08:26:04 +0200
Subject: [PATCH 7/7] Wrap all functions accessing /etc/passwd, /etc/group and
Subject: [PATCH 7/9] Wrap all functions accessing /etc/passwd, /etc/group and
/etc/shadow
Starting with glibc 2.32 the compat nss module for getpwnam calls
@ -1098,3 +1098,452 @@ index ee35fc26..d857a195 100755
'libpcre*.so.*' \
'libpthread.so.*' \
'libreadline.so.*' \
From 543e9d3b322aeb7539b0146299feeaeb147180e0 Mon Sep 17 00:00:00 2001
From: Johannes Schauer Marin Rodrigues <josch@mister-muffin.de>
Date: Tue, 1 Nov 2022 00:47:56 +0100
Subject: [PATCH 8/9] add test/t/rm.t (will fail under glibc 2.34 unless
__stat64_time64 functions are wrapped)
---
test/Makefile.am | 1 +
test/t/rm.t | 25 +++++++++++++++++++++++++
2 files changed, 26 insertions(+)
create mode 100644 test/t/rm.t
diff --git a/test/Makefile.am b/test/Makefile.am
index a1ec743d..88e740e5 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -29,6 +29,7 @@ TESTS = \
t/pwd.t \
t/readlink.t \
t/realpath.t \
+ t/rm.t \
t/socket-af_unix.t \
t/statfs.t \
t/statvfs.t \
diff --git a/test/t/rm.t b/test/t/rm.t
new file mode 100755
index 00000000..9ecf88c9
--- /dev/null
+++ b/test/t/rm.t
@@ -0,0 +1,25 @@
+#!/bin/sh
+
+srcdir=${srcdir:-.}
+. $srcdir/common.inc.sh
+
+prepare 2
+
+for chroot in chroot fakechroot; do
+
+ if [ $chroot = "chroot" ] && ! is_root; then
+ skip $(( $tap_plan / 2 )) "not root"
+ else
+
+ mkdir -p $testtree/dir-$chroot
+ echo 'something' > $testtree/dir-$chroot/file
+
+ $srcdir/$chroot.sh $testtree /bin/sh -c "rm -r /dir-$chroot"
+ test -e $testtree/dir-$chroot && not
+ ok "$chroot rm -r /dir-$chroot:" $t
+
+ fi
+
+done
+
+cleanup
From e9329c3b0cf98c361b96944cadeec2a1d689d2ca Mon Sep 17 00:00:00 2001
From: Johannes Schauer Marin Rodrigues <josch@mister-muffin.de>
Date: Tue, 1 Nov 2022 00:48:23 +0100
Subject: [PATCH 9/9] support glibc 2.34 by wrapping __{f,l,}stat{at,}64_time64
and__utime{nsat,s,}64
These functions are only wrapped on 32 bit platforms like i386, armel or
armhf. On 64 bit platforms, the corresponding HAVE_* macros will not be
defined.
* __fstatat64_time64
* __lstat64_time64
* __stat64_time64
* __utime64
* __utimensat64
* __utimes64
---
configure.ac | 6 +++++
src/Makefile.am | 6 +++++
src/__fstatat64_time64.c | 44 ++++++++++++++++++++++++++++++++++++
src/__lstat64_time64.c | 49 ++++++++++++++++++++++++++++++++++++++++
src/__stat64_time64.c | 47 ++++++++++++++++++++++++++++++++++++++
src/__utime64.c | 41 +++++++++++++++++++++++++++++++++
src/__utimensat64.c | 42 ++++++++++++++++++++++++++++++++++
src/__utimes64.c | 42 ++++++++++++++++++++++++++++++++++
8 files changed, 277 insertions(+)
create mode 100644 src/__fstatat64_time64.c
create mode 100644 src/__lstat64_time64.c
create mode 100644 src/__stat64_time64.c
create mode 100644 src/__utime64.c
create mode 100644 src/__utimensat64.c
create mode 100644 src/__utimes64.c
diff --git a/configure.ac b/configure.ac
index 5b3053e1..26c06116 100644
--- a/configure.ac
+++ b/configure.ac
@@ -158,11 +158,13 @@ ACX_CHECK_FTS_NAME_TYPE
# Checks for library functions.
AC_CHECK_FUNCS(m4_normalize([
__chk_fail
+ __fstatat64_time64
__fxstat64
__fxstatat
__fxstatat64
__getcwd_chk
__getwd_chk
+ __lstat64_time64
__lxstat
__lxstat64
__open
@@ -175,7 +177,11 @@ AC_CHECK_FUNCS(m4_normalize([
__realpath_chk
__readlink_chk
__readlinkat_chk
+ __stat64_time64
__statfs
+ __utime64
+ __utimensat64
+ __utimes64
__xmknod
__xmknodat
__xstat
diff --git a/src/Makefile.am b/src/Makefile.am
index 6e9d9ae1..55193a96 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,9 +1,11 @@
pkglib_LTLIBRARIES = libfakechroot.la
libfakechroot_la_SOURCES = \
+ __fstatat64_time64.c \
__fxstatat.c \
__fxstatat64.c \
__getcwd_chk.c \
__getwd_chk.c \
+ __lstat64_time64.c \
__lxstat.c \
__lxstat64.c \
__lxstat64.h \
@@ -18,7 +20,11 @@ libfakechroot_la_SOURCES = \
__readlinkat_chk.c \
__realpath_chk.c \
__realpath_chk.h \
+ __stat64_time64.c \
__statfs.c \
+ __utime64.c \
+ __utimensat64.c \
+ __utimes64.c \
__xmknod.c \
__xmknodat.c \
__xstat.c \
diff --git a/src/__fstatat64_time64.c b/src/__fstatat64_time64.c
new file mode 100644
index 00000000..47a401f2
--- /dev/null
+++ b/src/__fstatat64_time64.c
@@ -0,0 +1,44 @@
+/*
+ libfakechroot -- fake chroot environment
+ Copyright (c) 2010, 2021 Piotr Roszatycki <dexter@debian.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+
+#include <config.h>
+
+#ifdef HAVE___FSTATAT64_TIME64
+
+#define _ATFILE_SOURCE
+#define _POSIX_C_SOURCE 200809L
+#include <sys/stat.h>
+#include <limits.h>
+#include "libfakechroot.h"
+
+struct __stat64_t64;
+
+wrapper(__fstatat64_time64, int, (int dirfd, const char *pathname, struct __stat64_t64 *buf, int flags))
+{
+ char fakechroot_abspath[FAKECHROOT_PATH_MAX];
+ char fakechroot_buf[FAKECHROOT_PATH_MAX];
+ debug("__fstatat64_time64(%d, \"%s\", &buf, %d)", dirfd, pathname, flags);
+ expand_chroot_path_at(dirfd, pathname);
+ return nextcall(__fstatat64_time64)(dirfd, pathname, buf, flags);
+}
+
+#else
+typedef int empty_translation_unit;
+#endif
diff --git a/src/__lstat64_time64.c b/src/__lstat64_time64.c
new file mode 100644
index 00000000..1637b9c6
--- /dev/null
+++ b/src/__lstat64_time64.c
@@ -0,0 +1,49 @@
+/*
+ libfakechroot -- fake chroot environment
+ Copyright (c) 2010, 2021 Piotr Roszatycki <dexter@debian.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+
+#include <config.h>
+
+#ifdef HAVE___lstat64_time64
+
+#define _ATFILE_SOURCE
+#define _POSIX_C_SOURCE 200809L
+#include <sys/stat.h>
+#include <limits.h>
+#include "libfakechroot.h"
+
+struct __stat64_t64;
+
+wrapper(__lstat64_time64, int, (const char *filename, struct __stat64_t64 *buf))
+{
+ char fakechroot_abspath[FAKECHROOT_PATH_MAX];
+ char fakechroot_buf[FAKECHROOT_PATH_MAX];
+ char resolved[FAKECHROOT_PATH_MAX];
+ debug("__lstat64_time64(\"%s\", &buf)", filename);
+ if (rel2abs(filename, resolved) == NULL) {
+ return -1;
+ }
+ filename = resolved;
+ expand_chroot_path(filename);
+ return nextcall(__lstat64_time64)(filename, buf);
+}
+
+#else
+typedef int empty_translation_unit;
+#endif
diff --git a/src/__stat64_time64.c b/src/__stat64_time64.c
new file mode 100644
index 00000000..1b65345e
--- /dev/null
+++ b/src/__stat64_time64.c
@@ -0,0 +1,47 @@
+/*
+ libfakechroot -- fake chroot environment
+ Copyright (c) 2010-2015 Piotr Roszatycki <dexter@debian.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+
+#include <config.h>
+
+#ifdef HAVE___STAT64_TIME64
+
+#define _BSD_SOURCE
+#define _LARGEFILE64_SOURCE
+#define _DEFAULT_SOURCE
+#include <sys/stat.h>
+#include <limits.h>
+#include <stdlib.h>
+
+#include "libfakechroot.h"
+
+struct __stat64_t64;
+
+wrapper(__stat64_time64, int, (const char * file_name, struct __stat64_t64 * buf))
+{
+ char fakechroot_abspath[FAKECHROOT_PATH_MAX];
+ char fakechroot_buf[FAKECHROOT_PATH_MAX];
+ debug("__stat64_time64(\"%s\", &buf)", file_name);
+ expand_chroot_path(file_name);
+ return nextcall(__stat64_time64)(file_name, buf);
+}
+
+#else
+typedef int empty_translation_unit;
+#endif
diff --git a/src/__utime64.c b/src/__utime64.c
new file mode 100644
index 00000000..65d6e831
--- /dev/null
+++ b/src/__utime64.c
@@ -0,0 +1,41 @@
+/*
+ libfakechroot -- fake chroot environment
+ Copyright (c) 2010, 2013 Piotr Roszatycki <dexter@debian.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+
+#include <config.h>
+
+#ifdef HAVE___UTIME64
+
+#define _ATFILE_SOURCE
+#define _POSIX_C_SOURCE 200809L
+#include <utime.h>
+#include "libfakechroot.h"
+
+wrapper(__utime64, int, (const char * filename, const struct utimbuf * buf))
+{
+ char fakechroot_abspath[FAKECHROOT_PATH_MAX];
+ char fakechroot_buf[FAKECHROOT_PATH_MAX];
+ debug("__utime64(\"%s\", &buf)", filename);
+ expand_chroot_path(filename);
+ return nextcall(__utime64)(filename, buf);
+}
+
+#else
+typedef int empty_translation_unit;
+#endif
diff --git a/src/__utimensat64.c b/src/__utimensat64.c
new file mode 100644
index 00000000..3973d64c
--- /dev/null
+++ b/src/__utimensat64.c
@@ -0,0 +1,42 @@
+/*
+ libfakechroot -- fake chroot environment
+ Copyright (c) 2010, 2013 Piotr Roszatycki <dexter@debian.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+
+#include <config.h>
+
+#ifdef HAVE___UTIMENSAT64
+
+#define _ATFILE_SOURCE
+#define _POSIX_C_SOURCE 200809L
+#include <sys/time.h>
+#include "libfakechroot.h"
+
+
+wrapper(__utimensat64, int, (int dirfd, const char * pathname, const struct timespec times [2], int flags))
+{
+ char fakechroot_abspath[FAKECHROOT_PATH_MAX];
+ char fakechroot_buf[FAKECHROOT_PATH_MAX];
+ debug("utimeat(%d, \"%s\", &buf, %d)", dirfd, pathname, flags);
+ expand_chroot_path_at(dirfd, pathname);
+ return nextcall(__utimensat64)(dirfd, pathname, times, flags);
+}
+
+#else
+typedef int empty_translation_unit;
+#endif
diff --git a/src/__utimes64.c b/src/__utimes64.c
new file mode 100644
index 00000000..03e57d16
--- /dev/null
+++ b/src/__utimes64.c
@@ -0,0 +1,42 @@
+/*
+ libfakechroot -- fake chroot environment
+ Copyright (c) 2010, 2013 Piotr Roszatycki <dexter@debian.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+
+#include <config.h>
+
+#ifdef HAVE___UTIMES64
+
+#define _ATFILE_SOURCE
+#define _POSIX_C_SOURCE 200809L
+
+#include <sys/time.h>
+#include "libfakechroot.h"
+
+wrapper(__utimes64, int, (const char * filename, UTIMES_TYPE_ARG2(tv)))
+{
+ char fakechroot_abspath[FAKECHROOT_PATH_MAX];
+ char fakechroot_buf[FAKECHROOT_PATH_MAX];
+ debug("__utimes64(\"%s\", &tv)", filename);
+ expand_chroot_path(filename);
+ return nextcall(__utimes64)(filename, tv);
+}
+
+#else
+typedef int empty_translation_unit;
+#endif

401
85.diff
View File

@ -1,401 +0,0 @@
diff --git a/configure.ac b/configure.ac
index f8cdb32..5b3053e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -75,6 +75,26 @@ ACX_CHECK_C_ATTRIBUTE_VISIBILITY
# Checks for libraries.
AC_CHECK_LIB([dl], [dlsym])
+AH_TEMPLATE([NEW_GLIBC], [glibc >= 2.33])
+AC_MSG_CHECKING([for glibc 2.33+])
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+ #include <sys/stat.h>
+ ]], [[
+#ifdef __GLIBC__
+#if !__GLIBC_PREREQ(2,33)
+#error glibc<2.33
+#endif
+#else
+#error not glibc
+#endif
+ ]])],[
+ AC_DEFINE(NEW_GLIBC,1)
+ AC_MSG_RESULT([yes])
+ ],[
+ AC_DEFINE(NEW_GLIBC,0)
+ AC_MSG_RESULT([no])
+ ])
+
# Checks for header files.
AC_HEADER_DIRENT
AC_HEADER_STDC
@@ -198,6 +218,8 @@ AC_CHECK_FUNCS(m4_normalize([
freopen64
fstat
fstat64
+ fstatat
+ fstatat64
fts_children
fts_open
fts_read
diff --git a/src/Makefile.am b/src/Makefile.am
index 6066345..eb311c0 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -61,6 +61,8 @@ libfakechroot_la_SOURCES = \
fopen64.c \
freopen.c \
freopen64.c \
+ fstatat.c \
+ fstatat64.c \
fts.c \
fts64.c \
ftw.c \
diff --git a/src/fstatat.c b/src/fstatat.c
new file mode 100644
index 0000000..ca7578b
--- /dev/null
+++ b/src/fstatat.c
@@ -0,0 +1,42 @@
+/*
+ libfakechroot -- fake chroot environment
+ Copyright (c) 2010, 2021 Piotr Roszatycki <dexter@debian.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+
+#include <config.h>
+
+#ifdef HAVE_FSTATAT
+
+#define _ATFILE_SOURCE
+#define _POSIX_C_SOURCE 200809L
+#include <sys/stat.h>
+#include <limits.h>
+#include "libfakechroot.h"
+
+wrapper(fstatat, int, (int dirfd, const char *pathname, struct stat *buf, int flags))
+{
+ char fakechroot_abspath[FAKECHROOT_PATH_MAX];
+ char fakechroot_buf[FAKECHROOT_PATH_MAX];
+ debug("fstatat(%d, \"%s\", &buf, %d)", dirfd, pathname, flags);
+ expand_chroot_path_at(dirfd, pathname);
+ return nextcall(fstatat)(dirfd, pathname, buf, flags);
+}
+
+#else
+typedef int empty_translation_unit;
+#endif
diff --git a/src/fstatat64.c b/src/fstatat64.c
new file mode 100644
index 0000000..1863372
--- /dev/null
+++ b/src/fstatat64.c
@@ -0,0 +1,43 @@
+/*
+ libfakechroot -- fake chroot environment
+ Copyright (c) 2010, 2021 Piotr Roszatycki <dexter@debian.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+
+#include <config.h>
+
+#ifdef HAVE_FSTATAT64
+
+#define _ATFILE_SOURCE
+#define _POSIX_C_SOURCE 200809L
+#define _LARGEFILE64_SOURCE
+#include <sys/stat.h>
+#include <limits.h>
+#include "libfakechroot.h"
+
+wrapper(fstatat64, int, (int dirfd, const char *pathname, struct stat64 *buf, int flags))
+{
+ char fakechroot_abspath[FAKECHROOT_PATH_MAX];
+ char fakechroot_buf[FAKECHROOT_PATH_MAX];
+ debug("fstatat64(%d, \"%s\", &buf, %d)", dirfd, pathname, flags);
+ expand_chroot_path_at(dirfd, pathname);
+ return nextcall(fstatat64)(dirfd, pathname, buf, flags);
+}
+
+#else
+typedef int empty_translation_unit;
+#endif
diff --git a/src/ftw.c b/src/ftw.c
index 92fc126..a9abc85 100644
--- a/src/ftw.c
+++ b/src/ftw.c
@@ -185,7 +185,7 @@ int rpl_lstat (const char *, struct stat *);
# define NFTW_NEW_NAME __new_nftw
# define INO_T ino_t
# define STAT stat
-# ifdef _LIBC
+# if defined(_LIBC) && !NEW_GLIBC
# define LXSTAT __lxstat
# define XSTAT __xstat
# define FXSTATAT __fxstatat
diff --git a/src/ftw64.c b/src/ftw64.c
index 7cc8cdf..cee1f2b 100644
--- a/src/ftw64.c
+++ b/src/ftw64.c
@@ -18,6 +18,8 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
+#include "config.h"
+
#define __FTW64_C
#define FTW_NAME ftw64
#define NFTW_NAME nftw64
@@ -25,9 +27,15 @@
#define NFTW_NEW_NAME __new_nftw64
#define INO_T ino64_t
#define STAT stat64
-#define LXSTAT __lxstat64
-#define XSTAT __xstat64
-#define FXSTATAT __fxstatat64
+#if NEW_GLIBC
+# define LXSTAT(V,f,sb) lstat64 (f,sb)
+# define XSTAT(V,f,sb) stat64 (f,sb)
+# define FXSTATAT(V,d,f,sb,m) fstatat64 (d, f, sb, m)
+#else
+# define LXSTAT __lxstat64
+# define XSTAT __xstat64
+# define FXSTATAT __fxstatat64
+#endif
#define FTW_FUNC_T __ftw64_func_t
#define NFTW_FUNC_T __nftw64_func_t
diff --git a/src/libfakechroot.h b/src/libfakechroot.h
index 4cf199f..64ff15f 100644
--- a/src/libfakechroot.h
+++ b/src/libfakechroot.h
@@ -200,6 +200,21 @@
# endif
#endif
+#ifndef _STAT_VER
+ #if defined (__aarch64__)
+ #define _STAT_VER 0
+ #elif defined (__powerpc__) && __WORDSIZE == 64
+ #define _STAT_VER 1
+ #elif defined (__riscv) && __riscv_xlen==64
+ #define _STAT_VER 0
+ #elif defined (__s390x__)
+ #define _STAT_VER 1
+ #elif defined (__x86_64__)
+ #define _STAT_VER 1
+ #else
+ #define _STAT_VER 3
+ #endif
+#endif
typedef void (*fakechroot_wrapperfn_t)(void);
diff --git a/src/lstat.c b/src/lstat.c
index 3f6d819..fa38323 100644
--- a/src/lstat.c
+++ b/src/lstat.c
@@ -20,7 +20,7 @@
#include <config.h>
-#ifndef HAVE___LXSTAT
+#if !defined(HAVE___LXSTAT) || NEW_GLIBC
#include <sys/stat.h>
#include <unistd.h>
@@ -28,9 +28,11 @@
#include "lstat.h"
-wrapper(lstat, int, (int ver, const char * filename, struct stat * buf))
+wrapper(lstat, int, (const char * filename, struct stat * buf))
{
- debug("lstat(%d, \"%s\", &buf)", ver, filename);
+ char fakechroot_abspath[FAKECHROOT_PATH_MAX];
+ char fakechroot_buf[FAKECHROOT_PATH_MAX];
+ debug("lstat(\"%s\", &buf)", filename);
if (!fakechroot_localdir(filename)) {
if (filename != NULL) {
@@ -40,7 +42,7 @@ wrapper(lstat, int, (int ver, const char * filename, struct stat * buf))
}
}
- return lstat_rel(ver, filename, buf);
+ return lstat_rel(filename, buf);
}
diff --git a/src/lstat.h b/src/lstat.h
index 751c1ea..c46a2b9 100644
--- a/src/lstat.h
+++ b/src/lstat.h
@@ -24,9 +24,9 @@
#include <config.h>
#include "libfakechroot.h"
-#ifndef HAVE___LXSTAT
+#if !defined(HAVE___LXSTAT) || NEW_GLIBC
-wrapper_proto(lstat, int, (int, const char *, struct stat *));
+wrapper_proto(lstat, int, (const char *, struct stat *));
int lstat_rel(const char *, struct stat *);
diff --git a/src/lstat64.c b/src/lstat64.c
index b6212fc..a332d7c 100644
--- a/src/lstat64.c
+++ b/src/lstat64.c
@@ -20,7 +20,7 @@
#include <config.h>
-#if defined(HAVE_LSTAT64) && !defined(HAVE___LXSTAT64)
+#if defined(HAVE_LSTAT64) && (!defined(HAVE___LXSTAT64) || NEW_GLIBC)
#define _LARGEFILE64_SOURCE
#define _BSD_SOURCE
diff --git a/src/mknod.c b/src/mknod.c
index 52fd33b..aeb750b 100644
--- a/src/mknod.c
+++ b/src/mknod.c
@@ -20,7 +20,7 @@
#include <config.h>
-#ifndef HAVE___XMKNOD
+#if !defined(HAVE___XMKNOD) || NEW_GLIBC
#include <sys/stat.h>
#include "libfakechroot.h"
@@ -28,6 +28,8 @@
wrapper(mknod, int, (const char * pathname, mode_t mode, dev_t dev))
{
+ char fakechroot_abspath[FAKECHROOT_PATH_MAX];
+ char fakechroot_buf[FAKECHROOT_PATH_MAX];
debug("mknod(\"%s\", 0%o, %ld)", pathname, mode, dev);
expand_chroot_path(pathname);
return nextcall(mknod)(pathname, mode, dev);
diff --git a/src/mknodat.c b/src/mknodat.c
index 732a22b..3239b35 100644
--- a/src/mknodat.c
+++ b/src/mknodat.c
@@ -20,7 +20,7 @@
#include <config.h>
-#if defined(HAVE_MKNODAT) && !defined(HAVE___XMKNODAT)
+#if defined(HAVE_MKNODAT) && (!defined(HAVE___XMKNODAT) || NEW_GLIBC)
#define _ATFILE_SOURCE
#include <sys/stat.h>
diff --git a/src/stat.c b/src/stat.c
index 7845662..5ef57ba 100644
--- a/src/stat.c
+++ b/src/stat.c
@@ -20,7 +20,7 @@
#include <config.h>
-#ifndef HAVE___XSTAT
+#if !defined(HAVE___XSTAT) || NEW_GLIBC
#define _BSD_SOURCE
#define _DEFAULT_SOURCE
@@ -33,6 +33,8 @@
wrapper(stat, int, (const char * file_name, struct stat * buf))
{
+ char fakechroot_abspath[FAKECHROOT_PATH_MAX];
+ char fakechroot_buf[FAKECHROOT_PATH_MAX];
debug("stat(\"%s\", &buf)", file_name);
expand_chroot_path(file_name);
return nextcall(stat)(file_name, buf);
diff --git a/src/stat64.c b/src/stat64.c
index aac9c75..993ce80 100644
--- a/src/stat64.c
+++ b/src/stat64.c
@@ -20,7 +20,7 @@
#include <config.h>
-#if defined(HAVE_STAT64) && !defined(HAVE___XSTAT64)
+#if defined(HAVE_STAT64) && (!defined(HAVE___XSTAT64) || NEW_GLIBC)
#define _BSD_SOURCE
#define _LARGEFILE64_SOURCE
@@ -34,6 +34,8 @@
wrapper(stat64, int, (const char * file_name, struct stat64 * buf))
{
+ char fakechroot_abspath[FAKECHROOT_PATH_MAX];
+ char fakechroot_buf[FAKECHROOT_PATH_MAX];
debug("stat64(\"%s\", &buf)", file_name);
expand_chroot_path(file_name);
return nextcall(stat64)(file_name, buf);
diff --git a/src/tmpnam.c b/src/tmpnam.c
index ce60817..917ee6b 100644
--- a/src/tmpnam.c
+++ b/src/tmpnam.c
@@ -42,7 +42,7 @@ wrapper(tmpnam, char *, (char * s))
expand_chroot_path(ptr);
- ptr2 = malloc(strlen(ptr));
+ ptr2 = malloc(strlen(ptr) + 1);
if (ptr2 == NULL) return NULL;
strcpy(ptr2, ptr);
diff --git a/test/archlinux.sh b/test/archlinux.sh
index f9b77a0..98ea182 100755
--- a/test/archlinux.sh
+++ b/test/archlinux.sh
@@ -79,7 +79,7 @@ rm -rf "$destdir"
ls -l "$tarball"
mkdir -p "$destdir"
-tar zx --strip-components=1 --directory="$destdir" -f $tarball
+fakeroot tar zx --strip-components=1 --directory="$destdir" -f $tarball
rm -f "$destdir/etc/mtab"
echo "rootfs / rootfs rw 0 0" > "$destdir/etc/mtab"
@@ -88,7 +88,8 @@ sed -ni '/^[ \t]*CheckSpace/ !p' "$destdir/etc/pacman.conf"
sed -i "s/^[ \t]*SigLevel[ \t].*/SigLevel = Never/" "$destdir/etc/pacman.conf"
echo "Server = $mirror/\$repo/os/$arch" >> "$destdir/etc/pacman.d/mirrorlist"
-run_root pacman -Sy
+# Don't use fakechroot here yet - glibc may be out of date
+fakeroot pacman -Sy --noconfirm --root "$destdir" glibc
mkdir -p "$destdir/tmp/hello"
cat > "$destdir/tmp/hello/PKGBUILD" << 'END'

51
93.diff Normal file
View File

@ -0,0 +1,51 @@
diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml
new file mode 100644
index 00000000..38ec05a1
--- /dev/null
+++ b/.github/workflows/c-cpp.yml
@@ -0,0 +1,32 @@
+name: C/C++ CI
+
+on:
+ push:
+ branches: [ fix-dist-check ]
+ pull_request:
+ branches: [ master ]
+
+jobs:
+ build:
+
+ runs-on: ubuntu-latest
+
+ steps:
+ - uses: actions/checkout@v2
+ - name: configure
+ run: |
+ for t in autogen.sh configure
+ do sh "$t"
+ done
+ - name: make
+ run: make
+ - name: make check
+ run: make check
+ - name: make distcheck
+ run: make distcheck
+ continue-on-error: true
+ - name: upload test log
+ uses: actions/upload-artifact@v2.2.3
+ with:
+ name: test-log
+ path: fakechroot-2.20.2/_build/sub/test/test-suite.log
diff --git a/test/bin/fakechroot b/test/bin/fakechroot
index 315cb100..122c991c 100755
--- a/test/bin/fakechroot
+++ b/test/bin/fakechroot
@@ -1,7 +1,7 @@
#!/bin/sh
pwd=`dirname $0`
-abs_top_srcdir=${abs_top_srcdir:-`cd "$pwd/../.." 2>/dev/null && pwd -P`}
+abs_top_srcdir=${abs_top_srcdir:-`cd ".." 2>/dev/null && pwd -P`}
PATH="/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin"
export PATH

178
93.patch
View File

@ -1,178 +0,0 @@
From e6ce10f50726ac926b9e90710117e8be6c8c8074 Mon Sep 17 00:00:00 2001
From: Christopher Yeleighton <ne01026@shark.2a.pl>
Date: Thu, 29 Apr 2021 15:06:53 +0200
Subject: [PATCH 1/7] build action
---
.github/workflows/c-cpp.yml | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
create mode 100644 .github/workflows/c-cpp.yml
diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml
new file mode 100644
index 00000000..e3233268
--- /dev/null
+++ b/.github/workflows/c-cpp.yml
@@ -0,0 +1,23 @@
+name: C/C++ CI
+
+on:
+ push:
+ branches: [ master ]
+ pull_request:
+ branches: [ master ]
+
+jobs:
+ build:
+
+ runs-on: ubuntu-latest
+
+ steps:
+ - uses: actions/checkout@v2
+ - name: configure
+ run: ./configure
+ - name: make
+ run: make
+ - name: make check
+ run: make check
+ - name: make distcheck
+ run: make distcheck
From aedcacc4c3703d34d829a3d77cf8382d445b6429 Mon Sep 17 00:00:00 2001
From: Christopher Yeleighton <ne01026@shark.2a.pl>
Date: Thu, 29 Apr 2021 15:08:54 +0200
Subject: [PATCH 2/7] autogen.sh
---
.github/workflows/c-cpp.yml | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml
index e3233268..ac02906d 100644
--- a/.github/workflows/c-cpp.yml
+++ b/.github/workflows/c-cpp.yml
@@ -14,7 +14,10 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: configure
- run: ./configure
+ run: |
+ for t in autogen.sh configure
+ do sh "$t"
+ done
- name: make
run: make
- name: make check
From 1cb53cfadf5f1dff1d46d27716e35b53c89cdb9d Mon Sep 17 00:00:00 2001
From: Christopher Yeleighton <ne01026@shark.2a.pl>
Date: Thu, 29 Apr 2021 15:23:25 +0200
Subject: [PATCH 3/7] upload test log
---
.github/workflows/c-cpp.yml | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml
index ac02906d..0d46b938 100644
--- a/.github/workflows/c-cpp.yml
+++ b/.github/workflows/c-cpp.yml
@@ -24,3 +24,9 @@ jobs:
run: make check
- name: make distcheck
run: make distcheck
+ continue-on-error: true
+ - name: upload test log
+ uses: actions/upload-artifact@v2.2.3
+ with:
+ name: test-log
+ path: test/test-suite.log
From bca711379020d17a26a3c2c313a11aa28c6d9653 Mon Sep 17 00:00:00 2001
From: Christopher Yeleighton <ne01026@shark.2a.pl>
Date: Fri, 30 Apr 2021 09:16:01 +0200
Subject: [PATCH 4/7] path: fakechroot-2.20.2/_build/sub/
---
.github/workflows/c-cpp.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml
index 0d46b938..cc65f078 100644
--- a/.github/workflows/c-cpp.yml
+++ b/.github/workflows/c-cpp.yml
@@ -29,4 +29,4 @@ jobs:
uses: actions/upload-artifact@v2.2.3
with:
name: test-log
- path: test/test-suite.log
+ path: fakechroot-2.20.2/_build/sub/test/test-suite.log
From 953fed82a2fff84c7f7ebed09eee1cddeb8578a3 Mon Sep 17 00:00:00 2001
From: Christopher Yeleighton <ne01026@shark.2a.pl>
Date: Fri, 30 Apr 2021 09:18:08 +0200
Subject: [PATCH 5/7] branches: [ fix-dist-check ]
---
.github/workflows/c-cpp.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml
index cc65f078..38ec05a1 100644
--- a/.github/workflows/c-cpp.yml
+++ b/.github/workflows/c-cpp.yml
@@ -2,7 +2,7 @@ name: C/C++ CI
on:
push:
- branches: [ master ]
+ branches: [ fix-dist-check ]
pull_request:
branches: [ master ]
From e1a5c99000d932df43125fd444d82691948680fd Mon Sep 17 00:00:00 2001
From: Christopher Yeleighton <ne01026@shark.2a.pl>
Date: Fri, 30 Apr 2021 10:19:10 +0200
Subject: [PATCH 6/7] cd "../.."
---
test/bin/fakechroot | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/test/bin/fakechroot b/test/bin/fakechroot
index 315cb100..4904d33e 100755
--- a/test/bin/fakechroot
+++ b/test/bin/fakechroot
@@ -1,7 +1,7 @@
#!/bin/sh
pwd=`dirname $0`
-abs_top_srcdir=${abs_top_srcdir:-`cd "$pwd/../.." 2>/dev/null && pwd -P`}
+abs_top_srcdir=${abs_top_srcdir:-`cd "../.." 2>/dev/null && pwd -P`}
PATH="/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin"
export PATH
From a854440ba208892435f00461024a0a0cfb7168c1 Mon Sep 17 00:00:00 2001
From: Christopher Yeleighton <ne01026@shark.2a.pl>
Date: Fri, 30 Apr 2021 10:22:10 +0200
Subject: [PATCH 7/7] cd ".."
---
test/bin/fakechroot | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/test/bin/fakechroot b/test/bin/fakechroot
index 4904d33e..122c991c 100755
--- a/test/bin/fakechroot
+++ b/test/bin/fakechroot
@@ -1,7 +1,7 @@
#!/bin/sh
pwd=`dirname $0`
-abs_top_srcdir=${abs_top_srcdir:-`cd "../.." 2>/dev/null && pwd -P`}
+abs_top_srcdir=${abs_top_srcdir:-`cd ".." 2>/dev/null && pwd -P`}
PATH="/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin"
export PATH

View File

@ -1,6 +1,6 @@
Name: fakechroot
Version: 2.20.1
Release: 12%{?dist}
Release: 13%{?dist}
Summary: Gives a fake chroot environment
License: LGPLv2+
URL: https://github.com/dex4er/fakechroot
@ -9,12 +9,9 @@ Patch1: https://github.com/dex4er/fakechroot/commit/b42d1fb9538f680af2f3
Patch2: https://github.com/dex4er/fakechroot/pull/80.patch
Patch3: https://github.com/dex4er/fakechroot/pull/100.patch
Patch4: https://github.com/dex4er/fakechroot/pull/104.patch
Patch5: https://github.com/dex4er/fakechroot/pull/93.patch
Patch9: fix_test_on_32bits.patch
Patch5: https://github.com/dex4er/fakechroot/pull/93.diff
#Patch9: fix_test_on_32bits.patch
Requires: %{name}-libs%{?_isa} = %{version}-%{release}
BuildRequires: autoconf
BuildRequires: automake
BuildRequires: libtool
@ -22,9 +19,10 @@ BuildRequires: make
BuildRequires: gcc
# Required for manpage
BuildRequires: /usr/bin/pod2man
BuildRequires: gdbm-libs
# BuildRequires: gdbm-libs
# ldd.fakechroot
Requires: /usr/bin/objdump
Requires: %{name}-libs%{?_isa} = %{version}-%{release}
%description
fakechroot runs a command in an environment were is additionally
@ -83,6 +81,9 @@ find %{buildroot}%{_libdir} -name '*.la' -delete -print
%{_libdir}/%{name}/
%changelog
* Sun Dec 25 2022 Sérgio Basto <sergio@serjux.com> - 2.20.1-13
- PR #104 have more 2 commits
* Sat Oct 29 2022 Sérgio Basto <sergio@serjux.com> - 2.20.1-12
- All changes to fakechroot we carry in Debian for glibc >= 2.34 #104
check return value of dladdr #70