From: arjen Date: Sat, 29 Mar 2003 07:19:37 +0000 (+0000) Subject: Bugfix: Do not read the config file in the home X-Git-Tag: AXE_0_4~4 X-Git-Url: http://www.andromeda.nl/gitweb/?p=AXE.git;a=commitdiff_plain;h=0c762b3dbe252da01696ddb941490b375b4b0390 Bugfix: Do not read the config file in the home directory if the HOME environment variable doesn't exist --- diff --git a/src/configuration.cpp b/src/configuration.cpp index 76e0338..9f2eda8 100644 --- a/src/configuration.cpp +++ b/src/configuration.cpp @@ -6,7 +6,7 @@ *********************** ** FILE NAME : configuration.cpp ** SYSTEM NAME : AXE - Andromeda X-windows Encapsulation -** VERSION NUMBER : $Revision: 1.4 $ +** VERSION NUMBER : $Revision: 1.5 $ ** ** DESCRIPTION : Implementation of configuration class ** @@ -24,7 +24,11 @@ /***************************** $Log: configuration.cpp,v $ - Revision 1.4 2002-11-23 12:48:18 arjen + Revision 1.5 2003-03-29 07:19:37 arjen + Bugfix: Do not read the config file in the home + directory if the HOME environment variable doesn't exist + + Revision 1.4 2002/11/23 12:48:18 arjen Check if a configuration file exists before feeding it to the XML parser. Revision 1.3 2002/11/02 14:35:15 arjen @@ -41,12 +45,13 @@ *****************************/ -static const char *RCSID = "$Id: configuration.cpp,v 1.4 2002-11-23 12:48:18 arjen Exp $"; +static const char *RCSID = "$Id: configuration.cpp,v 1.5 2003-03-29 07:19:37 arjen Exp $"; #include #include #include "configuration.h" + /*========================================================================= ** NAME : configuration::read ** SYNOPSIS : @@ -87,14 +92,17 @@ bool configuration::read(const String name) system = xmlParseFile(filename); } - filename = getenv("HOME"); - filename += "/."; - filename += name + ".conf"; - fd = open(filename, O_RDONLY); - if (fd > 0) + if (getenv("HOME") != NULL) { - close(fd); - user = xmlParseFile(filename); + filename = getenv("HOME"); + filename += "/."; + filename += name + ".conf"; + fd = open(filename, O_RDONLY); + if (fd > 0) + { + close(fd); + user = xmlParseFile(filename); + } } // Check the root element, which must be the application name