+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <atalk/util.h>
#include <atalk/logger.h>
-
-#define OPEN_LOGS_AS_UID 0
+#include <atalk/unix.h>
#define COUNT_ARRAY(array) (sizeof((array))/sizeof((array)[0]))
static void log_setup(const char *filename, enum loglevels loglevel, enum logtypes logtype)
{
- uid_t process_uid;
-
if (loglevel == 0) {
/* Disable */
if (type_configs[logtype].set) {
free(tmp);
} else {
- process_uid = geteuid();
- if (process_uid) {
- if (seteuid(OPEN_LOGS_AS_UID) == -1) {
- process_uid = 0;
- }
- }
+ become_root();
type_configs[logtype].fd = open(filename,
O_CREAT | O_WRONLY | O_APPEND,
S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
- if (process_uid) {
- if (seteuid(process_uid) == -1) {
- LOG(log_error, logtype_logger, "can't seteuid back %s", strerror(errno));
- exit(EXITERR_SYS);
- }
- }
+ become_root();
}
/* Check for error opening/creating logfile */