Debian Bug report logs - #563726
tar: futimens() with a bad file descriptor (AT_FDCWD)

version graph

Package: tar; Maintainer for tar is Bdale Garbee <bdale@gag.com>; Source for tar is src:tar (PTS, buildd, popcon).

Reported by: Guillaume Ayoub <guillaume.ayoub@kozea.fr>

Date: Mon, 4 Jan 2010 21:33:01 UTC

Severity: important

Tags: patch

Found in version tar/1.22-2

Done: bdale@gag.com (Bdale Garbee)

Bug is archived. No further changes may be made.

Toggle useless messages

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to debian-bugs-dist@lists.debian.org, GNU Libc Maintainers <debian-glibc@lists.debian.org>:
Bug#563726; Package libc6. (Mon, 04 Jan 2010 21:33:04 GMT) (full text, mbox, link).


Acknowledgement sent to Guillaume Ayoub <guillaume.ayoub@kozea.fr>:
New Bug report received and forwarded. Copy sent to GNU Libc Maintainers <debian-glibc@lists.debian.org>. (Mon, 04 Jan 2010 21:33:04 GMT) (full text, mbox, link).


Message #5 received at submit@bugs.debian.org (full text, mbox, reply):

From: Guillaume Ayoub <guillaume.ayoub@kozea.fr>
To: Debian Bug Tracking System <submit@bugs.debian.org>
Subject: libc6-2.10.2-3 may break utime on folders
Date: Mon, 4 Jan 2010 22:28:06 +0100
Package: libc6
Version: 2.10.2-3
Severity: important


Hello,

Just after upgrading libc6 from 2.10.2-2 to 2.10.2-3, utime calls fail for
folders (not for regular files). This breaks main programs such as tar, dpkg,
touch and postfix.

Here are 2 examples:

$ ls -l
drwxr-xr-x 2 user users 4096 jan.  4 17:22 test_directory
-rw-r--r-- 1 user users    0 jan.  4 17:22 test_file
$touch test_file
$touch test_directory
touch: setting times of `test_directory': Bad file descriptor

$aptitude upgrade
(...)
tar: ./postrm: Cannot utime: Bad file descriptor
tar: ./postinst: Cannot utime: Bad file descriptor
tar: ./md5sums: Cannot utime: Bad file descriptor
tar: ./shlibs: Cannot utime: Bad file descriptor
tar: ./control: Cannot utime: Bad file descriptor
tar: ./symbols: Cannot utime: Bad file descriptor
tar: .: Cannot utime: Bad file descriptor
tar: Exiting with failure status due to previous errors
dpkg-deb: subprocess tar returned error exit status 2

Downgrading /lib/libc-2.10.2.so to version 2.10.2-2 fixes the bug.

I have an ext3 partition with a lot of free space. Note that I have an old
kernel (2.6.21.1).


-- System Information:
Debian Release: squeeze/sid
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: i386 (i686)

Kernel: Linux 2.6.21.1dedibox-r7
Locale: LANG=fr_FR.UTF-8, LC_CTYPE=fr_FR.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages libc6 depends on:
ii  libc-bin                      2.10.2-3   Embedded GNU C Library: Binaries
ii  libgcc1                       1:4.4.2-8  GCC support library

Versions of packages libc6 recommends:
pn  libc6-i686                    <none>     (no description available)

Versions of packages libc6 suggests:
ii  debconf [debconf-2.0]         1.5.28     Debian configuration management sy
pn  glibc-doc                     <none>     (no description available)
ii  locales                       2.10.2-3   Embedded GNU C Library: National L

-- debconf information excluded




Information forwarded to debian-bugs-dist@lists.debian.org, GNU Libc Maintainers <debian-glibc@lists.debian.org>:
Bug#563726; Package libc6. (Mon, 04 Jan 2010 22:51:08 GMT) (full text, mbox, link).


Acknowledgement sent to Guillaume Ayoub <guillaume.ayoub@kozea.fr>:
Extra info received and forwarded to list. Copy sent to GNU Libc Maintainers <debian-glibc@lists.debian.org>. (Mon, 04 Jan 2010 22:51:08 GMT) (full text, mbox, link).


Message #10 received at 563726@bugs.debian.org (full text, mbox, reply):

From: Guillaume Ayoub <guillaume.ayoub@kozea.fr>
To: 563726@bugs.debian.org
Subject: More information
Date: Mon, 4 Jan 2010 23:49:09 +0100
More information can be found at:
http://www.mail-archive.com/debian-user@lists.debian.org/msg562576.html

As Sven says, the bug is caused by debian/patches/any/cvs-futimens.diff,
reporting the 'bad file descriptor' error. Without this patch, futimens()
failed silently, as utimensat() has been added in kernel 2.6.22.

Useful links:
- eglibc 2.10 futimens.c original code:
  http://www.eglibc.org/cgi-bin/viewcvs.cgi/branches/eglibc-2_10/libc/sysdeps/unix/sysv/linux/futimens.c?view=markup
- upstream patch in eglibc trunk backported in Debian:
  http://www.eglibc.org/cgi-bin/viewcvs.cgi/trunk/libc/sysdeps/unix/sysv/linux/futimens.c?r1=text&tr1=2244&r2=text&tr2=9570&diff_format=h




Information forwarded to debian-bugs-dist@lists.debian.org, GNU Libc Maintainers <debian-glibc@lists.debian.org>:
Bug#563726; Package libc6. (Mon, 04 Jan 2010 23:36:03 GMT) (full text, mbox, link).


Acknowledgement sent to Aurelien Jarno <aurelien@aurel32.net>:
Extra info received and forwarded to list. Copy sent to GNU Libc Maintainers <debian-glibc@lists.debian.org>. (Mon, 04 Jan 2010 23:36:03 GMT) (full text, mbox, link).


Message #15 received at 563726@bugs.debian.org (full text, mbox, reply):

From: Aurelien Jarno <aurelien@aurel32.net>
To: Guillaume Ayoub <guillaume.ayoub@kozea.fr>, 563726@bugs.debian.org
Subject: Re: Bug#563726: More information
Date: Tue, 5 Jan 2010 00:31:34 +0100
On Mon, Jan 04, 2010 at 11:49:09PM +0100, Guillaume Ayoub wrote:
> More information can be found at:
> http://www.mail-archive.com/debian-user@lists.debian.org/msg562576.html
> 
> As Sven says, the bug is caused by debian/patches/any/cvs-futimens.diff,
> reporting the 'bad file descriptor' error. Without this patch, futimens()
> failed silently, as utimensat() has been added in kernel 2.6.22.

The patch is actually correct, it makes futimens() conform to POSIX [1],
and reject bad descriptors. The fact that the kernel has utimensat() or 
not should not change anything here. I'll investigate that more in
details tomorrow.

[1] http://www.opengroup.org/onlinepubs/9699919799/functions/utimensat.html

-- 
Aurelien Jarno	                        GPG: 1024D/F1BCDB73
aurelien@aurel32.net                 http://www.aurel32.net




Forcibly Merged 563724 563726. Request was from Aurelien Jarno <aurel32@debian.org> to control@bugs.debian.org. (Mon, 04 Jan 2010 23:36:05 GMT) (full text, mbox, link).


Information forwarded to debian-bugs-dist@lists.debian.org, GNU Libc Maintainers <debian-glibc@lists.debian.org>:
Bug#563726; Package libc6. (Tue, 05 Jan 2010 02:48:10 GMT) (full text, mbox, link).


Acknowledgement sent to Guillaume Ayoub <guillaume.ayoub@kozea.fr>:
Extra info received and forwarded to list. Copy sent to GNU Libc Maintainers <debian-glibc@lists.debian.org>. (Tue, 05 Jan 2010 02:48:10 GMT) (full text, mbox, link).


Message #22 received at 563726@bugs.debian.org (full text, mbox, reply):

From: Guillaume Ayoub <guillaume.ayoub@kozea.fr>
To: 563726@bugs.debian.org
Subject: More information
Date: Mon, 4 Jan 2010 23:33:32 +0100
More information can be found at:
http://www.mail-archive.com/debian-user@lists.debian.org/msg562576.html

As Sven says, the bug is caused by debian/patches/any/cvs-futimens.diff,
reporting the 'bad file descriptor' error. Without this patch, futimens()
failed silently, as utimensat() has been added in kernel 2.6.22.

Useful links:
- eglibc 2.10 futimens.c original code:
  http://www.eglibc.org/cgi-bin/viewcvs.cgi/branches/eglibc-2_10/libc/sysdeps/unix/sysv/linux/futimens.c?view=markup
- upstream patch in eglibc trunk backported in Debian:
  http://www.eglibc.org/cgi-bin/viewcvs.cgi/trunk/libc/sysdeps/unix/sysv/linux/futimens.c?r1=text&tr1=2244&r2=text&tr2=9570&diff_format=h




Forcibly Merged 563724 563726 563754. Request was from Aurelien Jarno <aurel32@debian.org> to control@bugs.debian.org. (Tue, 05 Jan 2010 06:06:03 GMT) (full text, mbox, link).


Information forwarded to debian-bugs-dist@lists.debian.org, GNU Libc Maintainers <debian-glibc@lists.debian.org>:
Bug#563726; Package libc6. (Tue, 05 Jan 2010 07:45:03 GMT) (full text, mbox, link).


Acknowledgement sent to Christian Marillat <marillat@debian.org>:
Extra info received and forwarded to list. Copy sent to GNU Libc Maintainers <debian-glibc@lists.debian.org>. (Tue, 05 Jan 2010 07:45:03 GMT) (full text, mbox, link).


Message #29 received at 563726@bugs.debian.org (full text, mbox, reply):

From: Christian Marillat <marillat@debian.org>
To: 563726@bugs.debian.org
Subject: libc6-2.10.2-3 may break utime on folders
Date: Tue, 05 Jan 2010 08:41:26 +0100
Hi,

I'm also able to reproduce this bug on a Sparc machine and a 2.6.18
kernel (latest kernel doesn't boot).

Christian




Changed Bug title to 'futimens() is not POSIX compliant' from 'libc6-2.10.2-3 may break utime on folders' Request was from Aurelien Jarno <aurelien@aurel32.net> to control@bugs.debian.org. (Tue, 05 Jan 2010 09:15:14 GMT) (full text, mbox, link).


Disconnected #563724 from all other report(s). Request was from Aurelien Jarno <aurelien@aurel32.net> to control@bugs.debian.org. (Tue, 05 Jan 2010 10:09:06 GMT) (full text, mbox, link).


Bug reassigned from package 'libc6' to 'tar'. Request was from Aurelien Jarno <aurelien@aurel32.net> to control@bugs.debian.org. (Tue, 05 Jan 2010 10:09:08 GMT) (full text, mbox, link).


Bug No longer marked as found in versions eglibc/2.10.2-3. Request was from Aurelien Jarno <aurelien@aurel32.net> to control@bugs.debian.org. (Tue, 05 Jan 2010 10:09:10 GMT) (full text, mbox, link).


Changed Bug title to 'tar: call futimens() with a bad file descriptor (AT_FDCWD)' from 'futimens() is not POSIX compliant' Request was from Aurelien Jarno <aurelien@aurel32.net> to control@bugs.debian.org. (Tue, 05 Jan 2010 10:09:12 GMT) (full text, mbox, link).


Severity set to 'important' from 'normal' Request was from Aurelien Jarno <aurelien@aurel32.net> to control@bugs.debian.org. (Tue, 05 Jan 2010 10:09:13 GMT) (full text, mbox, link).


Bug reassigned from package 'tar' to 'coreutils'. Request was from Aurelien Jarno <aurelien@aurel32.net> to control@bugs.debian.org. (Tue, 05 Jan 2010 10:09:16 GMT) (full text, mbox, link).


Added indication that bug 563726 blocks 563724 Request was from Aurelien Jarno <aurelien@aurel32.net> to control@bugs.debian.org. (Tue, 05 Jan 2010 10:09:18 GMT) (full text, mbox, link).


Changed Bug title to 'tacoreutils:all futimens() with a bad file descriptor (AT_FDCWD)' from 'tar: call futimens() with a bad file descriptor (AT_FDCWD)' Request was from Aurelien Jarno <aurel32@debian.org> to control@bugs.debian.org. (Tue, 05 Jan 2010 11:12:04 GMT) (full text, mbox, link).


Bug reassigned from package 'coreutils' to 'tar'. Request was from Aurelien Jarno <aurel32@debian.org> to control@bugs.debian.org. (Tue, 05 Jan 2010 11:12:08 GMT) (full text, mbox, link).


Changed Bug title to 'tar: futimens() with a bad file descriptor (AT_FDCWD)' from 'tacoreutils:all futimens() with a bad file descriptor (AT_FDCWD)' Request was from Aurelien Jarno <aurel32@debian.org> to control@bugs.debian.org. (Tue, 05 Jan 2010 11:21:02 GMT) (full text, mbox, link).


Bug reassigned from package 'tar' to 'coreutils'. Request was from Aurelien Jarno <aurel32@debian.org> to control@bugs.debian.org. (Tue, 05 Jan 2010 11:21:09 GMT) (full text, mbox, link).


Changed Bug title to 'coreutils: futimens() with a bad file descriptor (AT_FDCWD)' from 'tar: futimens() with a bad file descriptor (AT_FDCWD)' Request was from Aurelien Jarno <aurel32@debian.org> to control@bugs.debian.org. (Tue, 05 Jan 2010 11:21:12 GMT) (full text, mbox, link).


Disconnected #563754 from all other report(s). Request was from Aurelien Jarno <aurel32@debian.org> to control@bugs.debian.org. (Tue, 05 Jan 2010 11:27:07 GMT) (full text, mbox, link).


Bug reassigned from package 'coreutils' to 'tar'. Request was from Aurelien Jarno <aurel32@debian.org> to control@bugs.debian.org. (Tue, 05 Jan 2010 11:30:14 GMT) (full text, mbox, link).


Changed Bug title to 'tar: futimens() with a bad file descriptor (AT_FDCWD)' from 'coreutils: futimens() with a bad file descriptor (AT_FDCWD)' Request was from Aurelien Jarno <aurel32@debian.org> to control@bugs.debian.org. (Tue, 05 Jan 2010 11:30:16 GMT) (full text, mbox, link).


Information forwarded to debian-bugs-dist@lists.debian.org, Bdale Garbee <bdale@gag.com>:
Bug#563726; Package tar. (Tue, 05 Jan 2010 11:45:06 GMT) (full text, mbox, link).


Acknowledgement sent to Aurelien Jarno <aurelien@aurel32.net>:
Extra info received and forwarded to list. Copy sent to Bdale Garbee <bdale@gag.com>. (Tue, 05 Jan 2010 11:45:06 GMT) (full text, mbox, link).


Message #66 received at 563726@bugs.debian.org (full text, mbox, reply):

From: Aurelien Jarno <aurelien@aurel32.net>
To: 563726@bugs.debian.org, Bdale Garbee <bdale@gag.com>
Cc: control@bugs.debian.org
Subject: Patch
Date: Tue, 5 Jan 2010 12:41:33 +0100
tag 563726 + patch
thanks

This patch makes sure that futimens is only called with a valid file
descriptor. It may looks a lot of changes, but they are only due to
indentation. The only added line is the "if (fd >= 0)", which makes sure
that futimens() is not called with AT_FDCWD as the first argument. In
that case POSIX 2008 mandates that -1 is returned with errno set to 
EBADF.

--- tar-1.22.orig/lib/utimens.c
+++ tar-1.22/lib/utimens.c
@@ -120,16 +120,17 @@
     }
 #endif
 #if HAVE_FUTIMENS
-  {
-    int result = futimens (fd, timespec);
+  if (fd >= 0)
+    {
+      int result = futimens (fd, timespec);
 # ifdef __linux__
-    /* Work around the same bug as above.  */
-    if (0 < result)
-      errno = ENOSYS;
+      /* Work around the same bug as above.  */
+      if (0 < result)
+        errno = ENOSYS;
 # endif
-    if (result == 0 || errno != ENOSYS)
-      return result;
-  }
+      if (result == 0 || errno != ENOSYS)
+        return result;
+    }
 #endif
 
   /* The platform lacks an interface to set file timestamps with

-- 
Aurelien Jarno                          GPG: 1024D/F1BCDB73
aurelien@aurel32.net                 http://www.aurel32.net




Added tag(s) patch. Request was from Aurelien Jarno <aurelien@aurel32.net> to control@bugs.debian.org. (Tue, 05 Jan 2010 11:45:09 GMT) (full text, mbox, link).


Information forwarded to debian-bugs-dist@lists.debian.org, Bdale Garbee <bdale@gag.com>:
Bug#563726; Package tar. (Tue, 05 Jan 2010 15:21:18 GMT) (full text, mbox, link).


Acknowledgement sent to Guillaume Ayoub <guillaume.ayoub@kozea.fr>:
Extra info received and forwarded to list. Copy sent to Bdale Garbee <bdale@gag.com>. (Tue, 05 Jan 2010 15:21:18 GMT) (full text, mbox, link).


Message #73 received at 563726@bugs.debian.org (full text, mbox, reply):

From: Guillaume Ayoub <guillaume.ayoub@kozea.fr>
To: 563726@bugs.debian.org
Cc: Bdale Garbee <bdale@gag.com>, Aurelien Jarno <aurelien@aurel32.net>
Subject: Patch test
Date: Tue, 5 Jan 2010 16:15:48 +0100
I tested the patch on my machine.

- applied on tar, it fixed tar;
- applied on coreutils, it fixed touch.

Everything seems to work now (postfix, apt-get, dpkg, etc.), but other
softwares calling futimens() may be affected.

Thanks a lot for your work,
-- 
Guillaume Ayoub




Information forwarded to debian-bugs-dist@lists.debian.org, Bdale Garbee <bdale@gag.com>:
Bug#563726; Package tar. (Tue, 05 Jan 2010 15:21:19 GMT) (full text, mbox, link).


Acknowledgement sent to Guillaume Ayoub <guillaume.ayoub@kozea.fr>:
Extra info received and forwarded to list. Copy sent to Bdale Garbee <bdale@gag.com>. (Tue, 05 Jan 2010 15:21:20 GMT) (full text, mbox, link).


Information forwarded to debian-bugs-dist@lists.debian.org, Bdale Garbee <bdale@gag.com>:
Bug#563726; Package tar. (Tue, 05 Jan 2010 15:39:08 GMT) (full text, mbox, link).


Acknowledgement sent to Aurelien Jarno <aurelien@aurel32.net>:
Extra info received and forwarded to list. Copy sent to Bdale Garbee <bdale@gag.com>. (Tue, 05 Jan 2010 15:39:08 GMT) (full text, mbox, link).


Message #83 received at 563726@bugs.debian.org (full text, mbox, reply):

From: Aurelien Jarno <aurelien@aurel32.net>
To: Guillaume Ayoub <guillaume.ayoub@kozea.fr>
Cc: 563726@bugs.debian.org, Bdale Garbee <bdale@gag.com>
Subject: Re: Patch test
Date: Tue, 5 Jan 2010 16:36:22 +0100
On Tue, Jan 05, 2010 at 04:15:48PM +0100, Guillaume Ayoub wrote:
> I tested the patch on my machine.
> 
> - applied on tar, it fixed tar;
> - applied on coreutils, it fixed touch.
> 
> Everything seems to work now (postfix, apt-get, dpkg, etc.), but other
> softwares calling futimens() may be affected.
> 

This is a bug, and they will need to be fixed too. Even with the current
code, no error is returned, but it still means a file that should have
had the timestamp update actually does not have it.

-- 
Aurelien Jarno	                        GPG: 1024D/F1BCDB73
aurelien@aurel32.net                 http://www.aurel32.net




Information forwarded to debian-bugs-dist@lists.debian.org, Bdale Garbee <bdale@gag.com>:
Bug#563726; Package tar. (Tue, 05 Jan 2010 21:18:03 GMT) (full text, mbox, link).


Acknowledgement sent to Jim Meyering <jim@meyering.net>:
Extra info received and forwarded to list. Copy sent to Bdale Garbee <bdale@gag.com>. (Tue, 05 Jan 2010 21:18:03 GMT) (full text, mbox, link).


Message #88 received at 563726@bugs.debian.org (full text, mbox, reply):

From: Jim Meyering <jim@meyering.net>
To: Ondřej Vašík <ondrej.vasik@gmail.com>
Cc: 563726@bugs.debian.org, bug-gnulib@gnu.org
Subject: Re: [Bug 552320] Handling AT_FDCWD as EBADF in glibc's utimens() causes tar failures
Date: Tue, 05 Jan 2010 22:07:34 +0100
bugzilla@redhat.com wrote:
> https://bugzilla.redhat.com/show_bug.cgi?id=552320
>
> Ondrej Vasik <ovasik@redhat.com> changed:
>
>            What    |Removed                     |Added
> ----------------------------------------------------------------------------
>                  CC|                            |jim@meyering.net
>             Summary|new tar is unable to open   |Handling AT_FDCWD as EBADF
>                    |archives created with old   |in glibc's utimens() causes
>                    |tar                         |tar failures
>
> --- Comment #5 from Ondrej Vasik <ovasik@redhat.com>  2010-01-05 14:29:13 EDT ---
> Ah - even the latest gnulib doesn't handle this new recent change - so touch
> from coreutils might be affected as well as mentioned in debian bugzilla from
> comment #4. Therefore adding coreutils/gnulib upstream maintainer into CC.
>
> Jim, what do you think? Is the patch from
> http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=563726#66 good way to go and
> should be applied to gnulib/coreutils-8.3 to prevent touch (or better said
> futimens() with AT_FDCWD file descriptor) failures after glibc update?

Hi Ondrej,

Thanks for the heads up.  Good timing.
That does indeed look like a bug, and Aurelien Jarno's fix seems right.

Here's "git diff -w" output:

diff --git a/lib/utimens.c b/lib/utimens.c
index 4df1646..6b7716f 100644
--- a/lib/utimens.c
+++ b/lib/utimens.c
@@ -264,6 +264,7 @@ fdutimens (char const *file, int fd, struct timespec const timespec[2])
         }
 # endif /* HAVE_UTIMENSAT */
 # if HAVE_FUTIMENS
+      if (0 <= fd)
       {
         result = futimens (fd, ts);
 #  ifdef __linux__





I expect to push the following to gnulib in the morning:

From e7d83f123f5eed312523252c066510b5de0f7cd1 Mon Sep 17 00:00:00 2001
From: Aurelien Jarno <aurelien@aurel32.net>
Date: Tue, 5 Jan 2010 21:31:41 +0100
Subject: [PATCH] utimens (fdutimens): ignore a negative FD, per contract

* lib/utimens.c (fdutimens) [HAVE_FUTIMENS]: Call futimens only
when we have a valid file descriptor.  Otherwise, using a brand
new glibc (with just-patched futimes that now fails with EBADF)
would cause this function to fail with ENOSYS.
Reported by Guillaume Ayoub in http://bugs.debian.org/563726.
See also http://bugzilla.redhat.com/552320
---
 ChangeLog     |   10 ++++++++++
 lib/utimens.c |   23 ++++++++++++-----------
 2 files changed, 22 insertions(+), 11 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 2857d3d..80ba5cd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2010-01-05  Aurelien Jarno  <aurelien@aurel32.net>
+
+	utimens (fdutimens): ignore a negative FD, per contract
+	* lib/utimens.c (fdutimens) [HAVE_FUTIMENS]: Call futimens only
+	when we have a valid file descriptor.  Otherwise, using a brand
+	new glibc (with just-patched futimes that now fails with EBADF)
+	would cause this function to fail with ENOSYS.
+	Reported by Guillaume Ayoub in http://bugs.debian.org/563726.
+	See also http://bugzilla.redhat.com/552320
+
 2010-01-05  Jim Meyering  <meyering@redhat.com>

 	maint: remove useless inclusions of "xalloc.h"
diff --git a/lib/utimens.c b/lib/utimens.c
index 4df1646..6b7716f 100644
--- a/lib/utimens.c
+++ b/lib/utimens.c
@@ -264,19 +264,20 @@ fdutimens (char const *file, int fd, struct timespec const timespec[2])
         }
 # endif /* HAVE_UTIMENSAT */
 # if HAVE_FUTIMENS
-      {
-        result = futimens (fd, ts);
+      if (0 <= fd)
+	{
+	  result = futimens (fd, ts);
 #  ifdef __linux__
-        /* Work around the same bug as above.  */
-        if (0 < result)
-          errno = ENOSYS;
+	  /* Work around the same bug as above.  */
+	  if (0 < result)
+	    errno = ENOSYS;
 #  endif /* __linux__ */
-        if (result == 0 || errno != ENOSYS)
-          {
-            utimensat_works_really = 1;
-            return result;
-          }
-      }
+	  if (result == 0 || errno != ENOSYS)
+	    {
+	      utimensat_works_really = 1;
+	      return result;
+	    }
+	}
 # endif /* HAVE_FUTIMENS */
     }
   utimensat_works_really = -1;
--
1.6.6.387.g2649b1




Information forwarded to debian-bugs-dist@lists.debian.org, Bdale Garbee <bdale@gag.com>:
Bug#563726; Package tar. (Wed, 06 Jan 2010 03:18:04 GMT) (full text, mbox, link).


Acknowledgement sent to Eric Blake <ebb9@byu.net>:
Extra info received and forwarded to list. Copy sent to Bdale Garbee <bdale@gag.com>. (Wed, 06 Jan 2010 03:18:04 GMT) (full text, mbox, link).


Message #93 received at 563726@bugs.debian.org (full text, mbox, reply):

From: Eric Blake <ebb9@byu.net>
To: Jim Meyering <jim@meyering.net>
Cc: Ondr(ej Vas(ík <ondrej.vasik@gmail.com>, 563726@bugs.debian.org, bug-gnulib@gnu.org
Subject: Re: [Bug 552320] Handling AT_FDCWD as EBADF in glibc's utimens() causes tar failures
Date: Tue, 05 Jan 2010 20:15:31 -0700
[Message part 1 (text/plain, inline)]
According to Jim Meyering on 1/5/2010 2:07 PM:
>> https://bugzilla.redhat.com/show_bug.cgi?id=552320
> Thanks for the heads up.  Good timing.
> That does indeed look like a bug, and Aurelien Jarno's fix seems right.

I can confirm that the fix is correct.

> 
> I expect to push the following to gnulib in the morning:
> 
>>From e7d83f123f5eed312523252c066510b5de0f7cd1 Mon Sep 17 00:00:00 2001
> From: Aurelien Jarno <aurelien@aurel32.net>
> Date: Tue, 5 Jan 2010 21:31:41 +0100
> Subject: [PATCH] utimens (fdutimens): ignore a negative FD, per contract
> 
> * lib/utimens.c (fdutimens) [HAVE_FUTIMENS]: Call futimens only
> when we have a valid file descriptor.  Otherwise, using a brand
> new glibc (with just-patched futimes that now fails with EBADF)

s/futimes/futimens/ (ChangeLog and commit message)

> +++ b/lib/utimens.c
> @@ -264,19 +264,20 @@ fdutimens (char const *file, int fd, struct timespec const timespec[2])
>          }
>  # endif /* HAVE_UTIMENSAT */
>  # if HAVE_FUTIMENS
> -      {
> -        result = futimens (fd, ts);
> +      if (0 <= fd)
> +	{

Why the TAB?  We just got rid of those in gnulib.

-- 
Don't work too hard, make some time for fun as well!

Eric Blake             ebb9@byu.net

[signature.asc (application/pgp-signature, attachment)]

Information forwarded to debian-bugs-dist@lists.debian.org, Bdale Garbee <bdale@gag.com>:
Bug#563726; Package tar. (Wed, 06 Jan 2010 06:51:05 GMT) (full text, mbox, link).


Acknowledgement sent to Jim Meyering <jim@meyering.net>:
Extra info received and forwarded to list. Copy sent to Bdale Garbee <bdale@gag.com>. (Wed, 06 Jan 2010 06:51:05 GMT) (full text, mbox, link).


Message #98 received at 563726@bugs.debian.org (full text, mbox, reply):

From: Jim Meyering <jim@meyering.net>
To: Eric Blake <ebb9@byu.net>
Cc: Ondr(ej Vas(ík <ondrej.vasik@gmail.com>, 563726@bugs.debian.org, bug-gnulib@gnu.org
Subject: Re: [Bug 552320] Handling AT_FDCWD as EBADF in glibc's utimens() causes tar failures
Date: Wed, 06 Jan 2010 07:47:42 +0100
Eric Blake wrote:
...
> s/futimes/futimens/ (ChangeLog and commit message)

Thanks!

>> +++ b/lib/utimens.c
>> @@ -264,19 +264,20 @@ fdutimens (char const *file, int fd, struct timespec const timespec[2])
>>          }
>>  # endif /* HAVE_UTIMENSAT */
>>  # if HAVE_FUTIMENS
>> -      {
>> -        result = futimens (fd, ts);
>> +      if (0 <= fd)
>> +	{
>
> Why the TAB?  We just got rid of those in gnulib.

My emacs code had not been informed about gnulib's change,
so I actually inserted them as I wrote that patch.




Information forwarded to debian-bugs-dist@lists.debian.org, goswin-v-b@web.de, Bdale Garbee <bdale@gag.com>:
Bug#563726; Package tar. (Wed, 10 Feb 2010 13:21:03 GMT) (full text, mbox, link).


Acknowledgement sent to Goswin von Brederlow <goswin-v-b@web.de>:
Extra info received and forwarded to list. Copy sent to goswin-v-b@web.de, Bdale Garbee <bdale@gag.com>. (Wed, 10 Feb 2010 13:21:03 GMT) (full text, mbox, link).


Message #103 received at 563726@bugs.debian.org (full text, mbox, reply):

From: Goswin von Brederlow <goswin-v-b@web.de>
To: Debian Bug Tracking System <563726@bugs.debian.org>
Subject: Should open file if fd < 0 and futimesat() is ENOSYS
Date: Wed, 10 Feb 2010 14:19:25 +0100
Package: tar
Version: 1.22-2
Severity: normal

Hi,

first let me say that this bug is pretty anoying as it makes it
impossible to bootstrap a recent Debian or Ubuntu here. Please make
sure this gets fixed for Squeeze and Ubuntu Lucid.

Now, looking at the source and strace I see that tar first tries
utimensat(AT_FDCWD, file, timespec, 0) and recieves ENOSYS.

Then it falls through to calling futimens (fd, timespec) recieving
EBADFD and failing.


The patch in the bugreport adds

+      if (0 <= fd)

That limits the fallback to cases that do have an FD, which is not the
case here. For otheres, which here is the case, it then falls back to
utimes which has less resolution for the timestamp.

Why not open the file, call futimens(new_fd, timespec) and close it
again?

MfG
	Goswin

-- System Information:
Debian Release: squeeze/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (500, 'stable'), (1, 'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.31.5-book-1 (SMP w/2 CPU cores)
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)
Shell: /bin/sh linked to /bin/bash

Versions of packages tar depends on:
ii  libc6                         2.10.2-5   Embedded GNU C Library: Shared lib

tar recommends no packages.

Versions of packages tar suggests:
ii  bzip2                         1.0.5-4    high-quality block-sorting file co
pn  ncompress                     <none>     (no description available)

-- no debconf information




Reply sent to bdale@gag.com (Bdale Garbee):
You have taken responsibility. (Tue, 16 Mar 2010 19:51:11 GMT) (full text, mbox, link).


Notification sent to Guillaume Ayoub <guillaume.ayoub@kozea.fr>:
Bug acknowledged by developer. (Tue, 16 Mar 2010 19:51:11 GMT) (full text, mbox, link).


Message #108 received at 563726-done@bugs.debian.org (full text, mbox, reply):

From: bdale@gag.com (Bdale Garbee)
To: 563726-done@bugs.debian.org
Subject: fixed
Date: Tue, 16 Mar 2010 13:48:53 -0600 (MDT)
This bug is confirmed to be fixed in 1.23-1.

Bdale




Bug archived. Request was from Debbugs Internal Request <owner@bugs.debian.org> to internal_control@bugs.debian.org. (Wed, 14 Apr 2010 07:34:11 GMT) (full text, mbox, link).


Send a report that this bug log contains spam.


Debian bug tracking system administrator <owner@bugs.debian.org>. Last modified: Sun Jan 7 09:54:50 2018; Machine Name: beach

Debian Bug tracking system

Debbugs is free software and licensed under the terms of the GNU Public License version 2. The current version can be obtained from https://bugs.debian.org/debbugs-source/.

Copyright © 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson, 2005-2017 Don Armstrong, and many other contributors.