# HG changeset patch # User Michiel Broek # Date 1401222279 -7200 # Node ID 11d7cc3bdf31624b9f62065ca0f3277861a94d94 # Parent c06190a58f22058a70712f420504d5478d2d2d56 If /home/mbroek is not set, assume root user. diff -r c06190a58f22 -r 11d7cc3bdf31 thermferm/rdconfig.c --- a/thermferm/rdconfig.c Mon May 26 23:25:48 2014 +0200 +++ b/thermferm/rdconfig.c Tue May 27 22:24:39 2014 +0200 @@ -120,7 +120,11 @@ w1_therm *tmp1; rc_switch *tmp2; - mypath = xstrcpy(getenv((char *)"HOME")); + if (getenv((char *)"HOME") == NULL) { + mypath = xstrcpy((char *)"/root"); + } else { + mypath = xstrcpy(getenv((char *)"HOME")); + } mypath = xstrcat(mypath, (char *)"/mbsepi-apps/"); mypath = xstrcat(mypath, config); @@ -202,7 +206,11 @@ /* * Search config file */ - mypath = xstrcpy(getenv((char *)"HOME")); + if (getenv((char *)"HOME") == NULL) { + mypath = xstrcpy((char *)"/root"); + } else { + mypath = xstrcpy(getenv((char *)"HOME")); + } mypath = xstrcat(mypath, (char *)"/mbsepi-apps/"); mypath = xstrcat(mypath, config); if ((fp = fopen(mypath, "r")) == NULL) { @@ -220,11 +228,12 @@ mypath = xstrcpy((char *)"/usr/local/etc/mbsepi-apps/"); mypath = xstrcat(mypath, config); if ((fp = fopen(mypath, "r")) == NULL) { - syslog(LOG_NOTICE, "rdconfig: could not open %s", mypath); + syslog(LOG_NOTICE, "rdconfig: could find %s", config); return 1; } } } + syslog(LOG_NOTICE, "rdconfig: using %s", mypath); linecnt = 0; while (fgets(buf, sizeof(buf) -1, fp)) {