/*
* Copyright (C) 1997-2006 Andre Noll <maan@systemlinux.org>
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
+ * Licensed under the GPL v2. For licencing details see COPYING.
*/
/** \file daemon.c some helpers for programs that detach from the console */
return NULL;
if (!(logfile = fopen(logfile_name, "a"))) {
PARA_EMERG_LOG("can not open %s, uid: %d\n", logfile_name,
- getuid());
+ (int)getuid());
exit(EXIT_FAILURE);
}
setlinebuf(logfile);
/**
* 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)
*/
}
if (setgid(g->gr_gid) < 0) {
PARA_EMERG_LOG("failed to set group id %d (%s)\n",
- g->gr_gid, strerror(errno));
+ (int)g->gr_gid, strerror(errno));
exit(EXIT_FAILURE);
}
}
}
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);
+ PARA_DEBUG_LOG("uid: %d, euid: %d\n", (int)getuid(), (int)geteuid());
}
/**
{
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;
}
/**
*/
__malloc char *uptime_str(void)
{
- time_t t = server_uptime(UPTIME_GET);
+ long t = server_uptime(UPTIME_GET);
return make_message("%li:%02li:%02li", t / 86400,
(t / 3600) % 24, (t / 60) % 60);
}