[core] report file path when mkstemp() fails (fixes #2802)

x-ref:
  "Could the error-log be improved a tiny bit in regards to "Permission denied" errors"
  https://redmine.lighttpd.net/issues/2802
personal/stbuehler/mod-csrf
Glenn Strauss 6 years ago
parent 8cf6e908d3
commit 162e754d0d
  1. 21
      src/chunk.c
  2. 2
      src/mod_authn_gssapi.c

@ -459,7 +459,7 @@ void chunkqueue_steal(chunkqueue *dest, chunkqueue *src, off_t len) {
}
}
static chunk *chunkqueue_get_append_tempfile(chunkqueue *cq) {
static chunk *chunkqueue_get_append_tempfile(server *srv, chunkqueue *cq) {
chunk *c;
buffer *template = buffer_init_string("/var/tmp/lighttpd-upload-XXXXXX");
int fd = -1;
@ -483,11 +483,19 @@ static chunk *chunkqueue_get_append_tempfile(chunkqueue *cq) {
}
if (fd < 0) {
/* (report only the last error to mkstemp()
* if multiple temp dirs attempted) */
log_error_write(srv, __FILE__, __LINE__, "sbs",
"opening temp-file failed:",
template, strerror(errno));
buffer_free(template);
return NULL;
}
if (0 != fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) | O_APPEND)) {
/* (should not happen; fd is regular file) */
log_error_write(srv, __FILE__, __LINE__, "sbs",
"fcntl():", template, strerror(errno));
close(fd);
buffer_free(template);
return NULL;
@ -549,16 +557,7 @@ int chunkqueue_append_mem_to_tempfile(server *srv, chunkqueue *dest, const char
dst_c = NULL;
}
if (NULL == dst_c && NULL == (dst_c = chunkqueue_get_append_tempfile(dest))) {
/* we don't have file to write to,
* EACCES might be one reason.
*
* Instead of sending 500 we send 413 and say the request is too large
*/
log_error_write(srv, __FILE__, __LINE__, "ss",
"opening temp-file failed:", strerror(errno));
if (NULL == dst_c && NULL == (dst_c = chunkqueue_get_append_tempfile(srv, dest))) {
return -1;
}

@ -220,7 +220,7 @@ static int mod_authn_gssapi_create_krb5_ccache(server *srv, connection *con, plu
/* coverity[secure_temp : FALSE] */
int fd = mkstemp(ccname);
if (fd < 0) {
log_error_write(srv, __FILE__, __LINE__, "ss", "mkstemp():", strerror(errno));
log_error_write(srv, __FILE__, __LINE__, "sss", "mkstemp():", ccname, strerror(errno));
buffer_free(kccname);
return -1;
}

Loading…
Cancel
Save