From dae07b6609ade9018c330402f876e6f8a372fb54 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sun, 14 Nov 2010 12:19:15 -0500 Subject: [PATCH] Add an IncludeDotfiles configuration directive. --- src/config.go | 5 +++++ src/paths.go | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/config.go b/src/config.go index 8b0a608..93bf686 100644 --- a/src/config.go +++ b/src/config.go @@ -28,6 +28,11 @@ type Configuration struct { // A map of usernames to MD5-encoded passwords that will be allowed to log in // via a .htaccess style realm. Users map [string] string + + // Whether to include dotfiles (files that begin with a '.'). Users will still + // be able to access directories that begin with a '.', but they will not be + // included in the list. + IncludeDotfiles bool } func ReadFromFile(aPath string, config *Configuration) os.Error { diff --git a/src/paths.go b/src/paths.go index a589bb6..6a2be46 100644 --- a/src/paths.go +++ b/src/paths.go @@ -17,9 +17,11 @@ import ( "./config" ) -var gJailRoot string; +var gJailRoot string +var gConfig *config.Configuration func SetConfig(aConfig *config.Configuration) { + gConfig = aConfig gJailRoot = aConfig.JailRoot } @@ -62,6 +64,9 @@ func List(the_path string) (files vector.StringVector, err os.Error) { if info.IsDirectory() { name += "/" } + if !gConfig.IncludeDotfiles && name[0] == '.' { + continue + } files.Push(name) } return files, nil -- 2.22.5