Changeset - e00778ef4b37
[Not reviewed]
0 1 0
HanzZ - 13 years ago 2013-01-20 21:32:09
hanzz.k@gmail.com
Create backend directory as root before setuid/setgid, otherwise we don't have permissions to do that
1 file changed with 9 insertions and 1 deletions:
0 comments (0 inline, 0 general)
src/logging.cpp
Show inline comments
 
@@ -88,14 +88,17 @@ private:
 
};
 

	
 
static intercept_stream* intercepter_cout;
 
static intercept_stream* intercepter_cerr;
 

	
 

	
 
static void initLogging(Config *config, std::string key) {
 
static void initLogging(Config *config, std::string key, bool only_create_dir = false) {
 
	if (CONFIG_STRING(config, key).empty()) {
 
		if (only_create_dir) {
 
			return;
 
		}
 
		root = log4cxx::Logger::getRootLogger();
 
#ifdef _MSC_VER
 
		root->addAppender(new ConsoleAppender(new PatternLayout(L"%d %-5p %c: %m%n")));
 
#else
 
		root->addAppender(new ConsoleAppender(new PatternLayout("%d %-5p %c: %m%n")));
 
#endif
 
@@ -154,12 +157,16 @@ static void initLogging(Config *config, std::string key) {
 
			}
 
			catch (const boost::filesystem::filesystem_error &e) {
 
				std::cerr << "Can't create logging directory directory " << boost::filesystem::path(dir).parent_path().string() << ": " << e.what() << ".\n";
 
			}
 
		}
 

	
 
		if (only_create_dir) {
 
			return;
 
		}
 

	
 
		log4cxx::PropertyConfigurator::configure(p);
 

	
 
		// Change owner of main log file
 
#ifndef WIN32
 
	if (!CONFIG_STRING(config, "service.group").empty() && !CONFIG_STRING(config, "service.user").empty()) {
 
		struct group *gr;
 
@@ -187,12 +194,13 @@ void initBackendLogging(Config *config) {
 

	
 
	redirect_stderr();
 
}
 

	
 
void initMainLogging(Config *config) {
 
	initLogging(config, "logging.config");
 
	initLogging(config, "logging.backend_config", true);
 
}
 

	
 
void redirect_stderr() {
 
	 intercepter_cerr = new intercept_stream(std::cerr, "cerr");
 
	 intercepter_cout = new intercept_stream(std::cout, "cout");
 
}
0 comments (0 inline, 0 general)