Made roots fileserver backend symlink traversal configureable

This commit is contained in:
Mickey Malone 2013-09-20 12:47:05 -05:00
parent ade3166f82
commit 237adbf3e6
3 changed files with 19 additions and 3 deletions

View file

@ -306,6 +306,13 @@
#fileserver_backend:
# - git
# - roots
#
# Uncomment the line below if you do not want the file_server to follow
# symlinks when walking the filesystem tree. This is set to True
# by default. Currently this only applies to the default roots
# fileserver_backend.
#
#fileserver_followsymlinks: False
# Git fileserver backend configuration
# When using the git fileserver backend at least one git remote needs to be

View file

@ -140,6 +140,7 @@ VALID_OPTS = {
'file_ignore_regex': bool,
'file_ignore_glob': bool,
'fileserver_backend': list,
'fileserver_followsymlinks: bool,
'max_open_files': int,
'auto_accept': bool,
'master_tops': bool,
@ -290,6 +291,7 @@ DEFAULT_MASTER_OPTS = {
'file_ignore_regex': None,
'file_ignore_glob': None,
'fileserver_backend': ['roots'],
'fileserver_followsymlinks': True,
'max_open_files': 100000,
'hash_type': 'md5',
'conf_file': os.path.join(syspaths.CONFIG_DIR, 'master'),

View file

@ -182,7 +182,10 @@ def file_list(load):
prefix = load['prefix'].strip('/')
except KeyError:
prefix = ''
for root, dirs, files in os.walk(os.path.join(path, prefix), followlinks=True):
for root, dirs, files in os.walk(os.path.join(path, prefix),
followlinks=True if __opts__['fileserver_followsymlinks']
else followlinks=False):
for fname in files:
rel_fn = os.path.relpath(
os.path.join(root, fname),
@ -205,7 +208,9 @@ def file_list_emptydirs(load):
prefix = load['prefix'].strip('/')
except KeyError:
prefix = ''
for root, dirs, files in os.walk(os.path.join(path, prefix), followlinks=True):
for root, dirs, files in os.walk(os.path.join(path, prefix),
followlinks=True if __opts__['fileserver_followsymlinks']
else followlinks=False):
if len(dirs) == 0 and len(files) == 0:
rel_fn = os.path.relpath(root, path)
if not salt.fileserver.is_file_ignored(__opts__, rel_fn):
@ -225,6 +230,8 @@ def dir_list(load):
prefix = load['prefix'].strip('/')
except KeyError:
prefix = ''
for root, dirs, files in os.walk(os.path.join(path, prefix), followlinks=True):
for root, dirs, files in os.walk(os.path.join(path, prefix),
followlinks=True if __opts__['fileserver_followsymlinks']
else followlinks=False):
ret.append(os.path.relpath(root, path))
return ret