From: Alan T. DeKok Date: Thu, 9 Feb 2012 12:28:31 +0000 (+0100) Subject: Automatically make directories X-Git-Tag: release_2_2_0~174 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e407d93dd68a778eb6ce9541cf7f91f229a75c16;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 ad60c721af2..cfb2f2f0d31 100644 --- a/src/modules/rlm_sql_log/rlm_sql_log.c +++ b/src/modules/rlm_sql_log/rlm_sql_log.c @@ -206,7 +206,7 @@ static size_t sql_utf8_escape_func(char *out, size_t outlen, const char *in) /* * Skip over UTF8 characters */ - utf8 = fr_utf8_char((uint8_t *)in); + utf8 = fr_utf8_char((const uint8_t *)in); if (utf8) { if (outlen <= utf8) { break; @@ -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",