]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Automatically make directories
authorAlan T. DeKok <aland@freeradius.org>
Thu, 9 Feb 2012 12:28:31 +0000 (13:28 +0100)
committerAlan T. DeKok <aland@freeradius.org>
Thu, 9 Feb 2012 12:29:26 +0000 (13:29 +0100)
src/modules/rlm_sql_log/rlm_sql_log.c

index 7ec5eeba20cb7979158ebc31578728fae5dfb99a..9dff1a048e42e329e4a438ea6e5506e73522d9d0 100644 (file)
@@ -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",