From 87a32486e10fed0141d9c9f953b0abb47ca736ae Mon Sep 17 00:00:00 2001 From: franklahm Date: Sat, 28 Nov 2009 11:10:37 +0000 Subject: [PATCH] Better error reporting for afp_ldap.conf parsing --- libatalk/acl/ldap_config.c | 10 +++++++--- libatalk/util/logger.c | 31 ++++++++++++++++++------------- 2 files changed, 25 insertions(+), 16 deletions(-) diff --git a/libatalk/acl/ldap_config.c b/libatalk/acl/ldap_config.c index 8d17823c..c302751b 100644 --- a/libatalk/acl/ldap_config.c +++ b/libatalk/acl/ldap_config.c @@ -1,5 +1,5 @@ /* - $Id: ldap_config.c,v 1.3 2009-11-27 22:57:27 franklahm Exp $ + $Id: ldap_config.c,v 1.4 2009-11-28 11:10:37 franklahm Exp $ Copyright (c) 2009 Frank Lahm This program is free software; you can redistribute it and/or modify @@ -109,10 +109,13 @@ int acl_ldap_readconfig(char *name) } j++; } /* while j*/ - } /* else */ - } + } /* if else 0 == ldap_prefs*/ + break; + } /* if strcmp */ i++; } /* while i */ + if (ldap_prefs[i].pref == NULL) + LOG(log_error, logtype_afpd,"afp_ldap.conf: Unknown option: \"%s\"", pref); } /* EOF */ /* check if the config is sane and complete */ @@ -121,6 +124,7 @@ int acl_ldap_readconfig(char *name) while(ldap_prefs[i].pref != NULL) { if ( ldap_prefs[i].valid != 0) { + LOG(log_error, logtype_afpd,"afp_ldap.conf: Missing option: \"%s\"", ldap_prefs[i].name); ldap_config_valid = 0; break; } diff --git a/libatalk/util/logger.c b/libatalk/util/logger.c index 956775e7..58b2244f 100644 --- a/libatalk/util/logger.c +++ b/libatalk/util/logger.c @@ -349,20 +349,25 @@ 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) { - if (seteuid(OPEN_LOGS_AS_UID) == -1) { - /* XXX failing silently */ - return; + /* Is it /dev/tty ? */ + if (strcmp(file_configs[logtype].filename, "/dev/tty") == 0) { + file_configs[logtype].fd = open( file_configs[logtype].filename, O_WRONLY); + } else { + process_uid = geteuid(); + 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) { - if (seteuid(process_uid) == -1) { - LOG(log_error, logtype_logger, "can't seteuid back %s", strerror(errno)); - exit(EXITERR_SYS); + 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) { + if (seteuid(process_uid) == -1) { + LOG(log_error, logtype_logger, "can't seteuid back %s", strerror(errno)); + exit(EXITERR_SYS); + } } } -- 2.39.2