-static bool drop_privs(void) {
-#ifndef HAVE_MINGW
- uid_t uid = 0;
- if (switchuser) {
- struct passwd *pw = getpwnam(switchuser);
- if (!pw) {
- logger(DEBUG_ALWAYS, LOG_ERR, "unknown user `%s'", switchuser);
- return false;
- }
- uid = pw->pw_uid;
- if (initgroups(switchuser, pw->pw_gid) != 0 ||
- setgid(pw->pw_gid) != 0) {
- logger(DEBUG_ALWAYS, LOG_ERR, "System call `%s' failed: %s",
- "initgroups", strerror(errno));
- return false;
- }
-#ifndef __ANDROID__
-// Not supported in android NDK
- endgrent();
- endpwent();
-#endif
- }
- if (do_chroot) {
- tzset(); /* for proper timestamps in logs */
- if (chroot(confbase) != 0 || chdir("/") != 0) {
- logger(DEBUG_ALWAYS, LOG_ERR, "System call `%s' failed: %s",
- "chroot", strerror(errno));
- return false;
- }
- free(confbase);
- confbase = xstrdup("");
- }
- if (switchuser)
- if (setuid(uid) != 0) {
- logger(DEBUG_ALWAYS, LOG_ERR, "System call `%s' failed: %s",
- "setuid", strerror(errno));
- return false;
- }
-#endif
- return true;
-}
-
-#ifdef HAVE_MINGW
-# define setpriority(level) !SetPriorityClass(GetCurrentProcess(), (level))
-#else
-# define NORMAL_PRIORITY_CLASS 0
-# define BELOW_NORMAL_PRIORITY_CLASS 10
-# define HIGH_PRIORITY_CLASS -10
-# define setpriority(level) (setpriority(PRIO_PROCESS, 0, (level)))
-#endif
-
-int main(int argc, char **argv) {
- program_name = argv[0];
-