From: Alan T. DeKok Date: Thu, 9 Feb 2012 12:28:31 +0000 (+0100) Subject: Automatically make directories X-Git-Tag: release_3_0_0_beta0~320 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1090807fc12def268f83a78d541f0143533b6b7b;p=thirdparty%2Ffreeradius-server.git Automatically make directories --- diff --git a/src/modules/rlm_sql_log/rlm_sql_log.c b/src/modules/rlm_sql_log/rlm_sql_log.c index 7ec5eeba20c..9dff1a048e4 100644 --- a/src/modules/rlm_sql_log/rlm_sql_log.c +++ b/src/modules/rlm_sql_log/rlm_sql_log.c @@ -361,7 +361,7 @@ static int sql_log_write(rlm_sql_log_t *inst, REQUEST *request, const char *line FILE *fp; int locked = 0; struct stat st; - char path[MAX_STRING_LEN]; + char *p, path[1024]; path[0] = '\0'; radius_xlat(path, sizeof(path), inst->path, request, NULL); @@ -369,6 +369,13 @@ static int sql_log_write(rlm_sql_log_t *inst, REQUEST *request, const char *line return RLM_MODULE_FAIL; } + p = strrchr(path, '/'); + if (p) { + *p = '\0'; + rad_mkdir(path, 0644); + *p = '/'; + } + while (!locked) { if ((fd = open(path, O_WRONLY | O_APPEND | O_CREAT, 0666)) < 0) { radlog_request(L_ERR, 0, request, "Couldn't open file %s: %s",