332
static int stat_cache_lstat(server *srv, char *dname, struct stat *lst) {
333
if (lstat(dname, lst) == 0) {
334
return S_ISLNK(lst->st_mode) ? 0 : 1;
337
log_error_write(srv, __FILE__, __LINE__, "sss",
339
dname, strerror(errno));
452
466
* - open() + fstat() on a named-pipe results in a (intended) hang.
453
* - stat() if regualar file + open() to see if we can read from it is better
467
* - stat() if regular file + open() to see if we can read from it is better
457
470
if (-1 == stat(name->ptr, &st)) {
458
471
return HANDLER_ERROR;
509
522
* and keeping the file open for the rest of the time. But this can
510
523
* only be done at network level.
525
+ * per default it is not a symlink
513
if (S_ISLNK(st.st_mode) && !con->conf.follow_symlink) {
514
return HANDLER_ERROR;
530
if (stat_cache_lstat(srv, name->ptr, &lst) == 0) {
531
#ifdef DEBUG_STAT_CACHE
532
log_error_write(srv, __FILE__, __LINE__, "sb",
533
"found symlink", name);
539
* we assume "/" can not be symlink, so
540
* skip the symlink stuff if our path is /
542
else if ((name->used > 2)) {
545
dname = strndup(name->ptr, name->used);
546
while ((s_cur = strrchr(dname,'/'))) {
548
if (dname == s_cur) {
549
#ifdef DEBUG_STAT_CACHE
550
log_error_write(srv, __FILE__, __LINE__, "s", "reached /");
554
#ifdef DEBUG_STAT_CACHE
555
log_error_write(srv, __FILE__, __LINE__, "sss",
556
"checking if", dname, "is a symlink");
558
if (stat_cache_lstat(srv, dname, &lst) == 0) {
560
#ifdef DEBUG_STAT_CACHE
561
log_error_write(srv, __FILE__, __LINE__, "ss",
562
"found symlink", dname);
517
571
if (S_ISREG(st.st_mode)) {
518
572
/* determine mimetype */
519
573
buffer_reset(sce->content_type);