4 dnl Determine whether chown accepts arguments of -1 for uid and gid.
5 dnl If it doesn't, arrange to use the replacement function.
8 AC_DEFUN([jm_FUNC_CHOWN],
9 [AC_REQUIRE([AC_TYPE_UID_T])dnl
10 test -z "$ac_cv_header_unistd_h" \
11 && AC_CHECK_HEADERS(unistd.h)
12 AC_CACHE_CHECK([for working chown], jm_cv_func_working_chown,
14 # include <sys/types.h>
15 # include <sys/stat.h>
24 char *f = "conftest.chown";
25 struct stat before, after;
27 if (creat (f, 0600) < 0)
29 if (stat (f, &before) < 0)
31 if (chown (f, (uid_t) -1, (gid_t) -1) == -1)
33 if (stat (f, &after) < 0)
35 exit ((before.st_uid == after.st_uid
36 && before.st_gid == after.st_gid) ? 0 : 1);
39 jm_cv_func_working_chown=yes,
40 jm_cv_func_working_chown=no,
41 dnl When crosscompiling, assume chown is broken.
42 jm_cv_func_working_chown=no)
44 if test $jm_cv_func_working_chown = no; then
46 AC_DEFINE(chown, rpl_chown,
47 [Define to rpl_chown if the replacement function should be used.])