Normally when html_include cannot open the file it fails silently and things can be a bit hard to figure out from just looking at apache's log. This will be beneficial for those initially setting up their server with cgit.
Unified · Split
| @@ -11,6 +11,7 @@ · 10 unmodified lines | ||
| 11 | 11 | #include <stdlib.h> |
| 12 | 12 | #include <stdarg.h> |
| 13 | 13 | #include <string.h> |
| 14 | +#include <errno.h> | |
| 14 | 15 | |
| 15 | 16 | int htmlfd = STDOUT_FILENO; |
| 16 | 17 | |
| @@ -168,8 +169,11 @@ int html_include(const char *filename) · 151 unmodified lines | ||
| 168 | 169 | char buf[4096]; |
| 169 | 170 | size_t len; |
| 170 | 171 | |
| 171 | − if (!(f = fopen(filename, "r"))) | |
| 172 | + if (!(f = fopen(filename, "r"))) { | |
| 173 | + fprintf(stderr, "[cgit] Failed to include file %s: %s (%d).\n", | |
| 174 | + filename, strerror(errno), errno); | |
| 172 | 175 | return -1; |
| 176 | + } | |
| 173 | 177 | while((len = fread(buf, 1, 4096, f)) > 0) |
| 174 | 178 | write(htmlfd, buf, len); |
| 175 | 179 | fclose(f); |