From b5eedaac3a7d1000e4865696c5099bfd6e0136eb Mon Sep 17 00:00:00 2001 From: Paul Gardner-Stephen Date: Wed, 14 Nov 2018 13:07:51 +1030 Subject: [PATCH] add container path prefix when generating serval etc paths --- instance.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/instance.c b/instance.c index 62942239..9f520735 100644 --- a/instance.c +++ b/instance.c @@ -23,6 +23,11 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #endif #include + +#ifdef __APPLE__ +#include "TargetConditionals.h" +#endif + #include "instance.h" #include "conf.h" #include "str.h" @@ -133,6 +138,19 @@ static int vformf_path(struct __sourceloc __whence, strbuf b, const char *fhs_pa int _formf_serval_etc_path(struct __sourceloc __whence, char *buf, size_t bufsiz, const char *fmt, ...) { va_list ap; + char *base_path = SERVAL_ETC_PATH; + +#ifdef __APPLE__ +#ifdef TARGET_OS_IPHONE + // iOS device + char containerised_path[8192]; + if (getenv("HOME")) { + snprintf(containerised_path,8192,"%s/%s",getenv("HOME"),SERVAL_ETC_PATH); + base_path=containerised_path; + } +#endif +#endif + va_start(ap, fmt); int ret = vformf_path(__whence, strbuf_local(buf, bufsiz), SERVAL_ETC_PATH, NULL, fmt, ap); va_end(ap);