more error reporting when the file is not found.
Costa Tsaousis (ktsaou) committed
May 1, 2014 at 21:12 UTC
d79c71315e9fef31ae751842171e856ce1adb3eb
1 file changed
+5
-5
netdata.c
+5
-5
@@ -2055,14 +2055,14 @@ int mysendfile(struct web_client *w, char *filename)
2055
// check if the file exists
2056
struct stat stat;
2057
if(lstat(webfilename, &stat) != 0) {
2058
- error("%llu: File '%s' is not found.", w->id, filename);
2058
+ error("%llu: File '%s' is not found.", w->id, webfilename);
2059
web_buffer_printf(w->data, "File '%s' does not exist, or is not accessible.", filename);
2060
return 404;
2061
}
2062
2063
// check if the file is owned by us
2064
if(stat.st_uid != getuid() && stat.st_uid != geteuid()) {
2065
- error("%llu: File '%s' is owned by user %d (I run as user %d). Access Denied.", w->id, filename, stat.st_uid, getuid());
2065
+ error("%llu: File '%s' is owned by user %d (I run as user %d). Access Denied.", w->id, webfilename, stat.st_uid, getuid());
2066
web_buffer_printf(w->data, "Access to file '%s' is not permitted.", filename);
2067
return 403;
2068
}
@@ -2073,13 +2073,13 @@ int mysendfile(struct web_client *w, char *filename)
2073
w->ifd = w->ofd;
2074
2075
if(errno == EBUSY || errno == EAGAIN) {
2076
- error("%llu: File '%s' is busy, sending 307 Moved Temporarily to force retry.", w->id, filename);
2076
+ error("%llu: File '%s' is busy, sending 307 Moved Temporarily to force retry.", w->id, webfilename);
2077
snprintf(w->response_header, MAX_HTTP_HEADER_SIZE, "Location: /" WEB_PATH_FILE "/%s\r\n", filename);
2078
web_buffer_printf(w->data, "The file '%s' is currently busy. Please try again later.", filename);
2079
return 307;
2080
}
2081
else {
2082
- error("%llu: Cannot open file '%s'.", w->id, filename);
2082
+ error("%llu: Cannot open file '%s'.", w->id, webfilename);
2083
web_buffer_printf(w->data, "Cannot open file '%s'.", filename);
2084
return 404;
2085
}
@@ -2101,7 +2101,7 @@ int mysendfile(struct web_client *w, char *filename)
2101
else if(strstr(filename, ".eot") != NULL) w->data->contenttype = CT_APPLICATION_VND_MS_FONTOBJ;
2102
else w->data->contenttype = CT_APPLICATION_OCTET_STREAM;
2103
2104
- debug(D_WEB_CLIENT_ACCESS, "%llu: Sending file '%s' (%ld bytes, ifd %d, ofd %d).", w->id, filename, stat.st_size, w->ifd, w->ofd);
2104
+ debug(D_WEB_CLIENT_ACCESS, "%llu: Sending file '%s' (%ld bytes, ifd %d, ofd %d).", w->id, webfilename, stat.st_size, w->ifd, w->ofd);
2105
2106
w->mode = WEB_CLIENT_MODE_FILECOPY;
2107
w->wait_receive = 1;