From 847fac2252e1320f8fdf55179ccf95a70fb532d2 Mon Sep 17 00:00:00 2001 From: didg Date: Mon, 19 Oct 2009 11:53:30 +0000 Subject: [PATCH] logger, test return code for seteuid --- libatalk/util/logger.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/libatalk/util/logger.c b/libatalk/util/logger.c index 7f18279b..b124142b 100644 --- a/libatalk/util/logger.c +++ b/libatalk/util/logger.c @@ -26,8 +26,10 @@ Netatalk 2001 (c) #include #include #include +#include #include +#include #define LOGGER_C #include @@ -294,13 +296,21 @@ void log_setup(const char *filename, enum loglevels loglevel, enum logtypes logt /* Open log file as OPEN_LOGS_AS_UID*/ process_uid = geteuid(); - if (process_uid) - seteuid(OPEN_LOGS_AS_UID); + if (process_uid) { + if (seteuid(OPEN_LOGS_AS_UID) == -1) { + /* XXX failing silently */ + return; + } + } file_configs[logtype].fd = open( file_configs[logtype].filename, O_CREAT | O_WRONLY | O_APPEND, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); - if (process_uid) - seteuid(process_uid); + if (process_uid) { + if (seteuid(process_uid) == -1) { + LOG(log_error, logtype_logger, "can't seteuid back %s", strerror(errno)); + exit(EXITERR_SYS); + } + } /* Check for error opening/creating logfile */ if (-1 == file_configs[logtype].fd) { -- 2.39.2