Bug 12713 - coreutils-8.12 "make check" thinks glibc-2.13's "getcwd()" is "buggy"
Summary: coreutils-8.12 "make check" thinks glibc-2.13's "getcwd()" is "buggy"
Status: RESOLVED FIXED
Alias: None
Product: glibc
Classification: Unclassified
Component: libc (show other bugs)
Version: 2.13
: P2 normal
Target Milestone: ---
Assignee: Ulrich Drepper
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-04-28 18:07 UTC by Jason Vas Dias
Modified: 2014-06-27 13:29 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:
fweimer: security-


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jason Vas Dias 2011-04-28 18:07:36 UTC
The latest "stable coreutils release", 8.12, SKIPS a test it normally runs
as part of its 
$ make check
...
./misc/pwd-unreadable-parent: skipping test: can't use buggy system getcwd
SKIP: misc/pwd-unreadable-parent
....
Comment 1 Eric Blake 2011-04-28 19:00:18 UTC
Glibc should consider borrowing code from gnulib's getcwd() implementation, which is able to successfully determine working directories for several cases where the getcwd(2) syscall fails and where glibc currently doesn't try any harder:

http://git.savannah.gnu.org/cgit/gnulib.git/tree/lib/getcwd.c

At one point, that code was forked from glibc, but gnulib's version has added additional improvements such as the use of openat() to get an answer in O(n) rather than O(n^2) time.

Here's a sample program from gnulib that demonstrates a case of glibc giving up too easily:

http://git.savannah.gnu.org/cgit/gnulib.git/tree/tests/test-getcwd.c

You can demonstrate the glibc bug with that program (including building a needed <config.h> required by its #includes) by checking out gnulib.git, and running:

./gnulib-tool --with-tests --create-testdir --dir=path/to/dir getcwd
cd path/to/dir
./configure gl_cv_func_getcwd_path_max=yes
make check

Omit the gl_cv_func_getcwd_path_max assignment during ./configure to let gnulib detect the limitation and use its fallback wrapper around glibc's getcwd.
Comment 2 Eric Blake 2011-04-28 19:01:08 UTC
Additionally, if the Linux kernel would ever properly support open(dir,O_SEARCH), then gnulib's getcwd() wrapper would work in even more cases.
Comment 3 Ulrich Drepper 2011-05-08 18:54:10 UTC
I've updated git.