]> 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:28:31 +0000 (13:28 +0100)
src/modules/rlm_sql_log/rlm_sql_log.c

index ad60c721af2692f5a05ed672708fd24b792289b7..cfb2f2f0d318afb0f6e39e02903a89bf9a9801f8 100644 (file)
@@ -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",