From: reyk Date: Sat, 2 Aug 2014 09:46:51 +0000 (+0000) Subject: scandir(3)-based directory auto index didn't work on NFS because the X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=657ff3049600bf9ab53c42092ff7d90f1f521ea9;p=openbsd scandir(3)-based directory auto index didn't work on NFS because the file system is not filling in d_type properly. Using st_mode from the stat call fixes the problem, eg. S_ISDIR(st.st_mode) instead of dp->d_type == DT_DIR. Pointed out by pelikan@ --- diff --git a/usr.sbin/httpd/server_file.c b/usr.sbin/httpd/server_file.c index 7084c9f3d77..f6fffd0e886 100644 --- a/usr.sbin/httpd/server_file.c +++ b/usr.sbin/httpd/server_file.c @@ -1,4 +1,4 @@ -/* $OpenBSD: server_file.c,v 1.22 2014/07/31 17:55:09 reyk Exp $ */ +/* $OpenBSD: server_file.c,v 1.23 2014/08/02 09:46:51 reyk Exp $ */ /* * Copyright (c) 2006 - 2014 Reyk Floeter @@ -277,14 +277,14 @@ server_file_index(struct httpd *env, struct client *clt) if (dp->d_name[0] == '.' && !(dp->d_name[1] == '.' && dp->d_name[2] == '\0')) { /* ignore hidden files starting with a dot */ - } else if (dp->d_type == DT_DIR) { + } else if (S_ISDIR(st.st_mode)) { namewidth -= 1; /* trailing slash */ if (evbuffer_add_printf(evb, "%s/%*s%s%20s\n", dp->d_name, dp->d_name, MAX(namewidth, 0), " ", tmstr, "-") == -1) skip = 1; - } else if (dp->d_type == DT_REG) { + } else if (S_ISREG(st.st_mode)) { if (evbuffer_add_printf(evb, "%s%*s%s%20llu\n", dp->d_name, dp->d_name,