X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=daemon.c;h=67bc6f2f68af48ac9b99caf1c7a40d08363777dd;hp=edaf7f9c7872dad1808f941d99a9fb416a9c68f4;hb=a7a37b282c4e936b2fb34c2bd7423f9f800dfd44;hpb=52f6c9ab26c8a64ec413c7b4ae8cf43ac8f628a5 diff --git a/daemon.c b/daemon.c index edaf7f9c..67bc6f2f 100644 --- a/daemon.c +++ b/daemon.c @@ -109,11 +109,14 @@ void log_welcome(const char *whoami, int loglevel) /** * give up superuser privileges * + * \param username the user to switch to + * \param groupname the group to switch to + * * This function returns immediately if not invoked with EUID zero. Otherwise, * it tries to obtain the GID of \a groupname and the UID of \a username. On * success, effective and real GID/UID and the saved set-group-ID/set-user-ID - * are all set accordingly. On errors, an appropriate message is logged and exit() - * is called to terminate the process. + * are all set accordingly. On errors, an appropriate message is logged and + * exit() is called to terminate the process. * * \sa getpwnam(3), getuid(2), setuid(2), getgrnam(2), setgid(2) */ @@ -150,7 +153,6 @@ void para_drop_privileges(const char *username, const char *groupname) PARA_INFO_LOG("%s", "dropping root privileges\n"); setuid(p->pw_uid); PARA_DEBUG_LOG("uid: %d, euid: %d\n", getuid(), geteuid()); - setuid(p->pw_uid); } /** @@ -169,13 +171,15 @@ time_t server_uptime(enum uptime set_or_get) { static time_t startuptime; time_t now; + double diff; if (set_or_get == UPTIME_SET) { time(&startuptime); return 0; } time(&now); - return (time_t) difftime(now, startuptime); + diff = difftime(now, startuptime); + return (time_t) diff; } /**