GNU bug report logs - #43415
coreutils 8.32: install: fchmod fails with EBADF

Previous Next

Package: coreutils;

Reported by: Cameron Nemo <cnemo <at> tutanota.com>

Date: Tue, 15 Sep 2020 08:13:02 UTC

Severity: normal

Full log


View this message in rfc822 format

From: Cameron Nemo <cnemo <at> tutanota.com>
To: 43415 <at> debbugs.gnu.org
Subject: bug#43415: coreutils 8.32: install: fchmod fails with EBADF
Date: Tue, 15 Sep 2020 03:31:43 +0200 (CEST)
[Message part 1 (text/plain, inline)]
Hello,

I am experiencing some curious behavior when trying to set the file mode using
the install command.

Version info: install (GNU coreutils) 8.32

Summary of behavior: fchmod to 1777 fails with EBADF

The log from strace shows the following:

    ...
    geteuid()                               = 0
    umask(000)                              = 022
    mkdirat(AT_FDCWD, "tmp", 01755)         = -1 EEXIST (File exists)
    openat(AT_FDCWD, "tmp", O_RDONLY|O_NOCTTY|O_NONBLOCK|O_LARGEFILE|O_PATH|O_DIRECTORY) = 3
    fstat(3, {st_mode=S_IFDIR|S_ISVTX|0755, st_size=40, ...}) = 0
    fchmod(3, 01777)                        = -1 EBADF (Bad file descriptor)
    fcntl(3, F_GETFD)                       = 0
    fchmodat(AT_FDCWD, "/proc/self/fd/3", 01777) = 0
    close(3)                                = 0
    ...

For some odd reason, the call to fchmod is failing with EBADF.
This is causing the chmod() function to fall back to using an fd link in /proc.

Normally (i.e. when /proc is mounted) this poses no issues.
But I am trying to use the install command in a bootstrap/chroot environment,
and having to incorporate mount and unmount logic adds a significant amount of
non-idempodent complexity.

It seems like relying on the /proc link is not ideal,
and a bug is being hidden by such behavior.
Is there any chance that this can be resolved?

Regards,
--
Cameron Nemo
[Message part 2 (text/html, inline)]

This bug report was last modified 4 years and 278 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.