[Bug 1822064] [NEW] coreutils should use renameat2 from libc

Piotr Roszatycki piotr.roszatycki at gmail.com
Thu Mar 28 10:02:20 UTC 2019


Public bug reported:

This bug is fixed in coreutils 8.30-3 so please update the version from
Debian buster.

Patch from Debian:

$ cat prefer-renameat2-from-glibc-over-syscall.patch
From: Johannes 'josch' Schauer <josch at debian.org>
Date: Tue, 4 Dec 2018 20:57:48 +0100
X-Dgit-Generated: 8.30-1.1 2474a66055eceaf668b315d83ae7b0ae7bf9a4d5
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 <andreas at fatal.se>
which was accepted in gnulib git:

https://git.savannah.gnu.org/cgit/gnulib.git/commit/?id=c50cf67bd7ff70525f3cb4074f0d9cc1f5c6cf9c

---

--- coreutils-8.30.orig/lib/config.hin
+++ coreutils-8.30/lib/config.hin
@@ -2069,6 +2069,9 @@
 /* Define to 1 if you have the `renameat' function. */
 #undef HAVE_RENAMEAT

+/* Define to 1 if you have the `renameat2' function. */
+#undef HAVE_RENAMEAT2
+
 /* Define to 1 if you have the `rewinddir' function. */
 #undef HAVE_REWINDDIR

--- 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
+#if 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

ProblemType: Bug
DistroRelease: Ubuntu 19.04
Package: coreutils 8.30-1ubuntu1
ProcVersionSignature: Ubuntu 5.0.0-7.8-generic 5.0.0
Uname: Linux 5.0.0-7-generic x86_64
ApportVersion: 2.20.10-0ubuntu23
Architecture: amd64
CurrentDesktop: ubuntu:GNOME
Date: Thu Mar 28 10:57:32 2019
InstallationDate: Installed on 2019-03-16 (11 days ago)
InstallationMedia: Ubuntu 19.04 "Disco Dingo" - Alpha amd64 (20190305.1)
SourcePackage: coreutils
UpgradeStatus: No upgrade log present (probably fresh install)

** Affects: coreutils (Ubuntu)
     Importance: Undecided
         Status: New


** Tags: amd64 apport-bug disco

-- 
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to coreutils in Ubuntu.
https://bugs.launchpad.net/bugs/1822064

Title:
  coreutils should use renameat2 from libc

Status in coreutils package in Ubuntu:
  New

Bug description:
  This bug is fixed in coreutils 8.30-3 so please update the version
  from Debian buster.

  Patch from Debian:

  $ cat prefer-renameat2-from-glibc-over-syscall.patch
  From: Johannes 'josch' Schauer <josch at debian.org>
  Date: Tue, 4 Dec 2018 20:57:48 +0100
  X-Dgit-Generated: 8.30-1.1 2474a66055eceaf668b315d83ae7b0ae7bf9a4d5
  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 <andreas at fatal.se>
  which was accepted in gnulib git:

  https://git.savannah.gnu.org/cgit/gnulib.git/commit/?id=c50cf67bd7ff70525f3cb4074f0d9cc1f5c6cf9c

  ---

  --- coreutils-8.30.orig/lib/config.hin
  +++ coreutils-8.30/lib/config.hin
  @@ -2069,6 +2069,9 @@
   /* Define to 1 if you have the `renameat' function. */
   #undef HAVE_RENAMEAT

  +/* Define to 1 if you have the `renameat2' function. */
  +#undef HAVE_RENAMEAT2
  +
   /* Define to 1 if you have the `rewinddir' function. */
   #undef HAVE_REWINDDIR

  --- 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
  +#if 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

  ProblemType: Bug
  DistroRelease: Ubuntu 19.04
  Package: coreutils 8.30-1ubuntu1
  ProcVersionSignature: Ubuntu 5.0.0-7.8-generic 5.0.0
  Uname: Linux 5.0.0-7-generic x86_64
  ApportVersion: 2.20.10-0ubuntu23
  Architecture: amd64
  CurrentDesktop: ubuntu:GNOME
  Date: Thu Mar 28 10:57:32 2019
  InstallationDate: Installed on 2019-03-16 (11 days ago)
  InstallationMedia: Ubuntu 19.04 "Disco Dingo" - Alpha amd64 (20190305.1)
  SourcePackage: coreutils
  UpgradeStatus: No upgrade log present (probably fresh install)

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/coreutils/+bug/1822064/+subscriptions



More information about the foundations-bugs mailing list