|| config_base_dir == NULL)
return 1;
- if (strstr(file, "../") != NULL) goto err;
+ if (strstr(file, "../") != NULL)
+ return 0;
/* relative paths without "../" are ok */
if (*file != '/') return 1;
/* file must be of the format base + "/" + <1+ char filename> */
- if (strlen(file) < _config_base_dir_len + 2) goto err;
- if (strncmp(file, config_base_dir, _config_base_dir_len) != 0) goto err;
- if (*(file + _config_base_dir_len) != '/') goto err;
+ if (strlen(file) < _config_base_dir_len + 2) return 0;
+ if (strncmp(file, config_base_dir, _config_base_dir_len) != 0) return 0;
+ if (*(file + _config_base_dir_len) != '/') return 0;
return 1;
-
-err:
- if (sock != NULL && sock->fd >= 0)
- send_response(sock, RESP_ERR, "%s: %s\n", file, rrd_strerror(EACCES));
-
- return 0;
} /* }}} static int check_file_access */
/* when using a base dir, convert relative paths to absolute paths.
goto done;
}
if (!check_file_access(file, sock)) {
- rc = 0; /* assume error response sent successfully */
+ rc = send_response(sock, RESP_ERR, "%s: %s\n", file, rrd_strerror(EACCES));
goto done;
}
goto done;
}
if (!check_file_access(file, sock)) {
- rc = 0; /* assume error response sent successfully */
+ rc = send_response(sock, RESP_ERR, "%s: %s\n", file, rrd_strerror(EACCES));
goto done;
}
goto done;
}
if (!check_file_access(file, sock)) {
- rc = 0; /* assume error response sent successfully */
+ rc = send_response(sock, RESP_ERR, "%s: %s\n", file, rrd_strerror(EACCES));
goto done;
}
return -1;
}
if (!check_file_access(parsed->file, sock)) {
+ send_response(sock, RESP_ERR, "%s: %s\n", parsed->file, rrd_strerror(EACCES));
return -1; /* failure */
}
goto done;
}
if (!check_file_access(file, sock)) {
- rc = 0; /* assume error response sent successfully */
+ rc = send_response(sock, RESP_ERR, "%s: %s\n", file, rrd_strerror(EACCES));
goto done;
}
/* get data */
goto done;
}
if (!check_file_access(file, sock)) {
- rc = 0; /* assume error response sent successfully */
+ rc = send_response(sock, RESP_ERR, "%s: %s\n", file, rrd_strerror(EACCES));
goto done;
}
goto done;
}
if (!check_file_access(file, sock)) {
- rc = 0; /* assume error response sent successfully */
+ rc = send_response(sock, RESP_ERR, "%s: %s\n", file, rrd_strerror(EACCES));
goto done;
}
rrd_clear_error();
goto done;
}
if (!check_file_access(file, sock)) {
- rc = 0; /* assume error response sent successfully */
+ rc = send_response(sock, RESP_ERR, "%s: %s\n", file, rrd_strerror(EACCES));
goto done;
}
RRDD_LOG(LOG_INFO, "rrdcreate request for %s",file);