Skip to content

Commit

Permalink
Fix issue with chrooted paths
Browse files Browse the repository at this point in the history
git-svn-id: svn://cherokee-project.com/cherokee/trunk@4934 5dc97367-97f1-0310-9951-d761b3857238
  • Loading branch information
taher committed Apr 23, 2010
1 parent 846ab20 commit 8d75aa2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion admin/PageGeneral.py
Expand Up @@ -58,7 +58,7 @@
("server!bind!.*!port", validations.is_tcp_port),
("server!bind!.*!interface", validations.is_ip),
("server!bind!.*!tls", validations.is_boolean),
("server!chroot", validations.is_local_dir_exists),
("server!chroot", validations.is_chroot_dir_exists),
("new_port", validations.is_new_tcp_port)
]

Expand Down
4 changes: 2 additions & 2 deletions admin/util.py
Expand Up @@ -255,10 +255,10 @@ def lists_differ (a, b):
return False


def get_real_path (name):
def get_real_path (name, nochroot=False):
"""Get real path accounting for chrooted environments"""
chroot = CTK.cfg.get_val('server!chroot')
if chroot:
if chroot and not nochroot:
fullname = os.path.normpath (chroot + os.path.sep + name)
else:
fullname = name
Expand Down
7 changes: 5 additions & 2 deletions admin/validations.py
Expand Up @@ -151,9 +151,12 @@ def is_ipv6 (value):
raise ValueError, _('Malformed IPv6')
return value

def is_chroot_dir_exists (value):
return is_local_dir_exists (value, nochroot=True)

def is_local_dir_exists (value, nochroot=False):
value = is_path (value)
path = get_real_path (value)
path = get_real_path (value, nochroot)

if not os.path.exists(path):
raise ValueError, _('Path does not exist')
Expand All @@ -165,7 +168,7 @@ def is_local_dir_exists (value, nochroot=False):

def is_local_file_exists (value, nochroot=False):
value = is_path (value)
path = get_real_path (value)
path = get_real_path (value, nochroot)

if not os.path.exists(path):
raise ValueError, _('Path does not exist')
Expand Down

0 comments on commit 8d75aa2

Please sign in to comment.