From 7b110c34af97999cc42fda2f61a0ae38fc289951 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Sun, 23 Oct 2005 23:13:07 +0000 Subject: [PATCH] use seteuid() instead of setreuid(), since the latter seems to be broken on macosx git-svn-id: file:///home/lennart/svn/public/avahi/trunk@850 941a03a8-eaeb-0310-b9a0-b1bbd8fe43fe --- avahi-daemon/main.c | 12 ++++++++---- configure.ac | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/avahi-daemon/main.c b/avahi-daemon/main.c index 31bca77..7bae459 100644 --- a/avahi-daemon/main.c +++ b/avahi-daemon/main.c @@ -727,11 +727,13 @@ static int drop_root(void) { #if defined(HAVE_SETRESGID) r = setresgid(gr->gr_gid, gr->gr_gid, gr->gr_gid); +#elif defined(HAVE_SETEGID) + if ((r = setgid(gr->gr_gid)) >= 0) + r = setegid(gr->gr_gid); #elif defined(HAVE_SETREGID) r = setregid(gr->gr_gid, gr->gr_gid); #else - if ((r = setgid(gr->gr_gid)) >= 0) - r = setegid(gr->gr_gid); +#error "No API to drop priviliges" #endif if (r < 0) { @@ -741,11 +743,13 @@ static int drop_root(void) { #if defined(HAVE_SETRESUID) r = setresuid(pw->pw_uid, pw->pw_uid, pw->pw_uid); +#elif defined(HAVE_SETEUID) + if ((r = setuid(pw->pw_uid)) >= 0) + r = seteuid(pw->pw_uid); #elif defined(HAVE_SETREUID) r = setreuid(pw->pw_uid, pw->pw_uid); #else - if ((r = setuid(pw->pw_uid)) >= 0) - r = seteuid(pw->pw_uid); +#error "No API to drop priviliges" #endif if (r < 0) { diff --git a/configure.ac b/configure.ac index f4080f7..06b86f7 100644 --- a/configure.ac +++ b/configure.ac @@ -206,7 +206,7 @@ AC_FUNC_MEMCMP AC_FUNC_SELECT_ARGTYPES AC_FUNC_MALLOC AC_FUNC_REALLOC -AC_CHECK_FUNCS([gethostname memchr memmove memset mkdir select socket strchr strcspn strdup strerror strrchr strspn strstr uname setresuid setreuid strcasecmp gettimeofday putenv strncasecmp strlcpy gethostbyname]) +AC_CHECK_FUNCS([gethostname memchr memmove memset mkdir select socket strchr strcspn strdup strerror strrchr strspn strstr uname setresuid setreuid setresgid setregid strcasecmp gettimeofday putenv strncasecmp strlcpy gethostbyname seteuid setegid]) AC_FUNC_CHOWN AC_FUNC_STAT -- 2.39.5