From 7fc77c67a232425e6e4237b13d407b74dbafa7cf Mon Sep 17 00:00:00 2001 From: DL6ER Date: Wed, 7 Nov 2018 16:21:00 +0100 Subject: [PATCH] Search for readable config file in alternative location in case the default path is not available. Signed-off-by: DL6ER --- FTL.h | 1 + config.c | 3 ++- memory.c | 3 +++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/FTL.h b/FTL.h index 7a8c977e..7b939f17 100644 --- a/FTL.h +++ b/FTL.h @@ -93,6 +93,7 @@ enum { BLOCKING_DISABLED, BLOCKING_ENABLED, BLOCKING_UNKNOWN }; // Static structs typedef struct { const char* conf; + const char* conf2; const char* log; const char* pid; const char* port; diff --git a/config.c b/config.c index 5522732f..cd88370a 100644 --- a/config.c +++ b/config.c @@ -21,7 +21,8 @@ void read_FTLconf(void) FILE *fp; char * buffer; - if((fp = fopen(FTLfiles.conf, "r")) == NULL) + if(((fp = fopen(FTLfiles.conf, "r")) == NULL) && + ((fp = fopen(FTLfiles.conf2, "r")) == NULL)) { logg("Notice: Found no readable FTL config file"); logg(" Using default settings"); diff --git a/memory.c b/memory.c index b611d3fd..f2cf5096 100644 --- a/memory.c +++ b/memory.c @@ -11,7 +11,10 @@ #include "FTL.h" FTLFileNamesStruct FTLfiles = { + // Default path for config file (regular installations) "/etc/pihole/pihole-FTL.conf", + // Alternative path for config file (snap installations) + "/var/snap/pihole/common/etc/pihole/pihole-FTL.conf", "/var/log/pihole-FTL.log", "/var/run/pihole-FTL.pid", "/var/run/pihole-FTL.port",