diff --git a/server/core/adminusers.c b/server/core/adminusers.c index e20f9d1c3..53734e9cc 100644 --- a/server/core/adminusers.c +++ b/server/core/adminusers.c @@ -120,7 +120,7 @@ char fname[1024], *home; char uname[80], passwd[80]; initialise(); - sprintf(fname, "%s/passwd", get_cachedir()); + sprintf(fname, "%s/passwd", get_datadir()); if ((fp = fopen(fname, "r")) == NULL) return NULL; if ((rval = users_alloc()) == NULL) @@ -151,7 +151,7 @@ FILE *fp; char fname[1024], *home, *cpasswd; initialise(); - sprintf(fname, "%s/passwd", get_cachedir()); + sprintf(fname, "%s/passwd", get_datadir()); if (users == NULL) { @@ -244,8 +244,8 @@ char* admin_remove_user( /** * Open passwd file and remove user from the file. */ - sprintf(fname, "%s/passwd", get_cachedir()); - sprintf(fname_tmp, "%s/passwd_tmp", get_cachedir()); + sprintf(fname, "%s/passwd", get_datadir()); + sprintf(fname_tmp, "%s/passwd_tmp", get_datadir()); /** * Rewrite passwd file from memory. */ diff --git a/server/core/gateway.c b/server/core/gateway.c index 462d28e8e..3ab50609b 100644 --- a/server/core/gateway.c +++ b/server/core/gateway.c @@ -1047,6 +1047,7 @@ int main(int argc, char **argv) break; case 'D': sprintf(datadir,"%s",optarg); + maxscaledatadir = strdup(optarg); datadir_defined = true; break; case 'C': diff --git a/server/core/gwdirs.c b/server/core/gwdirs.c index 9bf0185cd..1fe8af008 100644 --- a/server/core/gwdirs.c +++ b/server/core/gwdirs.c @@ -17,3 +17,13 @@ char* get_cachedir() { return cachedir?cachedir:(char*)default_cachedir; } + + +/** + * Get the service cache directory + * @return The path to the cache directory + */ +char* get_datadir() +{ + return maxscaledatadir?maxscaledatadir:(char*)default_datadir; +} diff --git a/server/core/secrets.c b/server/core/secrets.c index b0ddc084b..2ec3e75a9 100644 --- a/server/core/secrets.c +++ b/server/core/secrets.c @@ -71,7 +71,7 @@ int fd; int len; static int reported = 0; - snprintf(secret_file, PATH_MAX, "%s/.secrets", get_cachedir()); + snprintf(secret_file, PATH_MAX, "%s/.secrets", get_datadir()); /* Try to access secrets file */ if (access(secret_file, R_OK) == -1) diff --git a/server/include/gwdirs.h.in b/server/include/gwdirs.h.in index ac8fcf4af..66e34426f 100644 --- a/server/include/gwdirs.h.in +++ b/server/include/gwdirs.h.in @@ -26,7 +26,7 @@ static const char* default_cnf_fname = "maxscale.cnf"; static const char* default_configdir = "/etc/"; static const char* default_piddir = "/var/run/maxscale/"; static const char* default_logdir = "/var/log/maxscale/"; -static const char* default_datadir = "/var/cache/maxscale/"; +static const char* default_datadir = "/var/lib/maxscale/"; static const char* default_libdir = "@CMAKE_INSTALL_PREFIX@/@MAXSCALE_LIBDIR@"; static const char* default_cachedir = "/var/cache/maxscale/"; static const char* default_langdir = "@MAXSCALE_VARDIR@/lib/maxscale/"; @@ -35,8 +35,10 @@ static char* configdir = NULL; static char* logdir = NULL; static char* libdir = NULL; static char* cachedir = NULL; +static char* maxscaledatadir = NULL; static char* langdir = NULL; char* get_libdir(); +char* get_datadir(); char* get_cachedir(); #endif diff --git a/server/modules/routing/binlog/blr_file.c b/server/modules/routing/binlog/blr_file.c index 32fbad28c..91944eea1 100644 --- a/server/modules/routing/binlog/blr_file.c +++ b/server/modules/routing/binlog/blr_file.c @@ -79,7 +79,7 @@ struct dirent *dp; if (router->binlogdir == NULL) { - strcpy(path, get_cachedir()); + strcpy(path, get_datadir()); strncat(path,"/",PATH_MAX); strncat(path, router->service->name,PATH_MAX); @@ -658,7 +658,7 @@ blr_cache_response(ROUTER_INSTANCE *router, char *response, GWBUF *buf) char path[PATH_MAX+1], *ptr; int fd; - strcpy(path,get_cachedir()); + strcpy(path,get_datadir()); strncat(path,"/",PATH_MAX); strncat(path, router->service->name, PATH_MAX); @@ -693,7 +693,7 @@ char path[PATH_MAX+1], *ptr; int fd; GWBUF *buf; - strcpy(path, get_cachedir()); + strcpy(path, get_datadir()); strncat(path, "/", PATH_MAX); strncat(path, router->service->name, PATH_MAX); strncat(path, "/.cache/", PATH_MAX);