Browse Source

[mod_userdir] use stat_cache_path_isdir()

master
Glenn Strauss 9 months ago
parent
commit
347509261b
  1. 5
      src/mod_userdir.c
  2. 5
      src/t/test_mod_userdir.c

5
src/mod_userdir.c

@ -5,11 +5,11 @@
#include "buffer.h"
#include "log.h"
#include "response.h"
#include "stat_cache.h"
#include "plugin.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <stdlib.h>
#include <string.h>
@ -152,10 +152,9 @@ static handler_t mod_userdir_docroot_construct(request_st * const r, plugin_data
/* XXX: future: might add cache; getpwnam() lookup is expensive */
struct passwd *pwd = getpwnam(u);
if (pwd) {
struct stat st;
buffer_copy_string(b, pwd->pw_dir);
buffer_append_path_len(b, CONST_BUF_LEN(p->conf.path));
if (0 != stat(b->ptr, &st) || !S_ISDIR(st.st_mode)) {
if (!stat_cache_path_isdir(b)) {
return HANDLER_GO_ON;
}
}

5
src/t/test_mod_userdir.c

@ -192,6 +192,11 @@ int http_response_redirect_to_directory(request_st *r, int status) {
return 0;
}
int stat_cache_path_isdir(const buffer *name) {
UNUSED(name);
return 1;
}
int config_plugin_values_init(server *srv, void *p_d, const config_plugin_keys_t *cpk, const char *mname) {
UNUSED(srv);
UNUSED(p_d);

Loading…
Cancel
Save