Package: coreutils Version: 8.30-1 Severity: normal Tags: patch Control: block #909612 by -1
Hi, recently (2018-11-29), glibc 2.28 was accepted in unstable. It adds a wrapper for the renameat2 syscall. That wrapper is necessary for fakechroot because fakechroot cannot intercept system calls but uses a preloaded library to intercept library calls. Up to coreutils 8.30, mv(1) uses the renameat2 syscall which makes mv(1) fail under fakechroot. See #909612. Now that glibc 2.28 offers the renameat2 library function as a wrapper to the syscall, coreutils added support for choosing the library function instead of the syscall if the former is available: https://git.savannah.gnu.org/cgit/gnulib.git/commit/?id=c50cf67bd7ff70525f3cb4074f0d9cc1f5c6cf9c I don't know if another coreutils release is likely to happen before the freeze but if it isn't please consider the attached patch which backports the commit from the gnulib git to coreutils 8.30. Without this patch, fakechroot is currently not very useful because the mv(1) tool is unusable inside fakechroot. Most prominently, apt uses mv(1) inside its postinst script, so its impossible to install apt inside fakechroot and thus one cannot setup a sensible system. Thanks! cheers, josch
diff -Nru coreutils-8.30/debian/changelog coreutils-8.30/debian/changelog --- coreutils-8.30/debian/changelog 2018-08-29 22:20:06.000000000 +0200 +++ coreutils-8.30/debian/changelog 2018-12-04 20:49:07.000000000 +0100 @@ -1,3 +1,11 @@ +coreutils (8.30-1.1) UNRELEASED; urgency=medium + + * Non-maintainer upload. + * Add patch that uses renameat2 from glibc instead of the syscall if + available (closes: #XXXXXX) + + -- Johannes 'josch' Schauer <[email protected]> Tue, 04 Dec 2018 20:49:07 +0100 + coreutils (8.30-1) unstable; urgency=low * New upstream version diff -Nru coreutils-8.30/debian/patches/prefer-renameat2-from-glibc-over-syscall.patch coreutils-8.30/debian/patches/prefer-renameat2-from-glibc-over-syscall.patch --- coreutils-8.30/debian/patches/prefer-renameat2-from-glibc-over-syscall.patch 1970-01-01 01:00:00.000000000 +0100 +++ coreutils-8.30/debian/patches/prefer-renameat2-from-glibc-over-syscall.patch 2018-12-04 20:49:07.000000000 +0100 @@ -0,0 +1,40 @@ +From: Johannes 'josch' Schauer <[email protected]> +Date: Tue, 4 Dec 2018 20:57:48 +0100 +X-Dgit-Generated: 8.30-1.1 318c43f7b611cf7d81a45a768482227ac7500832 +Subject: Prefer renameat2 from glibc over syscall if available + +This is necessary for fakechroot to be able to overwrite renameat2 which +is used by mv(1) from coreutils. See #909612 + +This patch is based on a patch by Andreas Henriksson <[email protected]> +which was accepted in gnulib git: + +https://git.savannah.gnu.org/cgit/gnulib.git/commit/?id=c50cf67bd7ff70525f3cb4074f0d9cc1f5c6cf9c + +--- + +--- coreutils-8.30.orig/lib/renameat2.c ++++ coreutils-8.30/lib/renameat2.c +@@ -77,7 +77,10 @@ renameat2 (int fd1, char const *src, int + int ret_val = -1; + int err = EINVAL; + +-#ifdef SYS_renameat2 ++#ifdef HAVE_RENAMEAT2 ++ ret_val = renameat2 (fd1, src, fd2, dst, flags); ++ err = errno; ++#elif defined SYS_renameat2 + ret_val = syscall (SYS_renameat2, fd1, src, fd2, dst, flags); + err = errno; + #elif defined RENAME_EXCL +--- coreutils-8.30.orig/m4/renameat.m4 ++++ coreutils-8.30/m4/renameat.m4 +@@ -15,7 +15,7 @@ AC_DEFUN([gl_FUNC_RENAMEAT], + AC_REQUIRE([gl_STDIO_H_DEFAULTS]) + AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) + AC_CHECK_HEADERS([linux/fs.h]) +- AC_CHECK_FUNCS_ONCE([renameat]) ++ AC_CHECK_FUNCS_ONCE([renameat renameat2]) + if test $ac_cv_func_renameat = no; then + HAVE_RENAMEAT=0 + elif test $REPLACE_RENAME = 1; then diff -Nru coreutils-8.30/debian/patches/series coreutils-8.30/debian/patches/series --- coreutils-8.30/debian/patches/series 2017-10-02 19:31:47.000000000 +0200 +++ coreutils-8.30/debian/patches/series 2018-12-04 20:49:07.000000000 +0100 @@ -3,3 +3,4 @@ 72_id_checkngroups.patch 85_timer_settime.patch 99_kfbsd_fstat_patch.patch +prefer-renameat2-from-glibc-over-syscall.patch

