2 # Determine whether we need the chown wrapper. chown should accept
3 # arguments of -1 for uid and gid, and it should dereference symlinks.
4 # If it doesn't, arrange to use the replacement function.
7 AC_DEFUN([gl_FUNC_CHOWN],
9 AC_REQUIRE([AC_TYPE_UID_T])
10 AC_REQUIRE([AC_FUNC_CHOWN])
11 AC_REQUIRE([gl_FUNC_CHOWN_FOLLOWS_SYMLINK])
13 if test $ac_cv_func_chown_works = yes; then
14 AC_DEFINE(CHOWN_FAILS_TO_HONOR_ID_OF_NEGATIVE_ONE, 1,
15 [Define if chown is not POSIX compliant regarding IDs of -1.])
18 # If chown has either of the above problems, then we need the wrapper.
19 if test $ac_cv_func_chown_works$gl_cv_func_chown_follows_symlink = yesyes; then
23 AC_DEFINE(chown, rpl_chown,
24 [Define to rpl_chown if the replacement function should be used.])
29 # Determine whether chown follows symlinks (it should).
30 AC_DEFUN([gl_FUNC_CHOWN_FOLLOWS_SYMLINK],
33 [whether chown(2) dereferences symlinks],
34 gl_cv_func_chown_follows_symlink,
36 AC_RUN_IFELSE([AC_LANG_SOURCE([[
46 char const *dangling_symlink = "conftest.dangle";
48 unlink (dangling_symlink);
49 if (symlink ("conftest.no-such", dangling_symlink))
52 /* Exit successfully on a conforming system,
53 i.e., where chown must fail with ENOENT. */
54 exit ( ! (chown (dangling_symlink, getuid (), getgid ()) != 0
58 [gl_cv_func_chown_follows_symlink=yes],
59 [gl_cv_func_chown_follows_symlink=no],
60 [gl_cv_func_chown_follows_symlink=no]
65 if test $gl_cv_func_chown_follows_symlink = no; then
66 AC_DEFINE(CHOWN_MODIFIES_SYMLINK, 1,
67 [Define if chown modifies symlinks.])
71 # Prerequisites of lib/chown.c.
72 AC_DEFUN([gl_PREREQ_CHOWN],
74 AC_CHECK_HEADERS_ONCE(unistd.h fcntl.h)
75 AC_CHECK_FUNC([fchown], , [AC_LIBOBJ(fchown-stub)])