From 2e639fb0f2d48e2cdac47538d46397e22e4788bf Mon Sep 17 00:00:00 2001 From: Fabian Groffen Date: Mon, 29 Oct 2007 19:54:08 +0000 Subject: [PATCH] Darwin7 doesn't have lchown implementation. We only need it for links, which on Darwin don't have an owner, so only try that when lchown is available. svn path=/main/branches/prefix/; revision=8339 --- configure.in | 14 ++++++++++++++ src/chpathtool.c | 6 ++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/configure.in b/configure.in index 5f4bd00aa..f7b4987a9 100644 --- a/configure.in +++ b/configure.in @@ -133,6 +133,20 @@ AC_TRY_LINK([ ] ) +AC_MSG_CHECKING([if lchown exists]) +AC_TRY_LINK([ + #include + #include + ], [ + lchown("", -1, -1); + ], [ + AC_DEFINE(HAVE_LCHOWN, 1, [defined when LCHOWN exists]) + AC_MSG_RESULT([yes]) + ], [ + AC_MSG_RESULT([no]) + ] +) + AC_ARG_ENABLE(tbz2tool, AC_HELP_STRING([--enable-tbz2tool],[build tbz2tool, tool for creating binpkgs (default yes)]), [case "${enableval}" in diff --git a/src/chpathtool.c b/src/chpathtool.c index 0b16bcd6b..04a170a34 100644 --- a/src/chpathtool.c +++ b/src/chpathtool.c @@ -251,7 +251,7 @@ int dirwalk(char *src, char *srcp, char *trg, char *trgp) { trg, strerror(errno)); return(-1); } - if (lchown(trg, s.st_uid, s.st_gid) != 0) { + if (chown(trg, s.st_uid, s.st_gid) != 0) { fprintf(stderr, "failed to set ownership of %s: %s\n", trg, strerror(errno)); return(-1); @@ -307,11 +307,13 @@ int dirwalk(char *src, char *srcp, char *trg, char *trgp) { src, strerror(errno)); return(-1); } +#ifdef HAVE_LCHOWN if (lchown(trg, s.st_uid, s.st_gid) != 0) { fprintf(stderr, "failed to set ownership of %s: %s\n", trg, strerror(errno)); return(-1); } +#endif } /* restore modified path */ @@ -331,7 +333,7 @@ int dirwalk(char *src, char *srcp, char *trg, char *trgp) { trg, strerror(errno)); return(-1); } - if (lchown(trg, s.st_uid, s.st_gid) != 0) { + if (chown(trg, s.st_uid, s.st_gid) != 0) { fprintf(stderr, "failed to set ownership of %s: %s\n", trg, strerror(errno)); return(-1); -- 2.26.2