Beispiel #1
0
 def check_link_path(self):
     if self.parent:
         if not path_contains(self.parent.get_path(), self.link_to_path,real_path=False):
             raise Exception('Subshare must be under the real share.')
     elif self.link_to_path:
         test_path(self.link_to_path,allow_absolute=True)
         if not paths_contain(settings.LINK_TO_DIRECTORIES,self.link_to_path):
             raise Exception('Path not allowed.')
Beispiel #2
0
    def _realpath(self, path):
#         print 'realpath'
#         print path
        parts = path.split(os.path.sep)
        share = self._get_share(path)
        realpath = os.path.realpath(os.path.join(share.get_realpath(),os.path.sep.join(parts[2:])))
        if not paths_contain(settings.DIRECTORY_WHITELIST,realpath):
            raise PermissionDenied("Encountered a path outside the whitelist")
        return realpath
Beispiel #3
0
 def check_link_path(self):
     if self.parent:
         if not path_contains(self.parent.get_path(),
                              self.link_to_path,
                              real_path=False):
             raise Exception('Subshare must be under the real share.')
     elif self.link_to_path:
         test_path(self.link_to_path, allow_absolute=True)
         if not paths_contain(settings.LINK_TO_DIRECTORIES,
                              self.link_to_path):
             raise Exception('Path not allowed.')
Beispiel #4
0
 def clean_link_to_path(self):
     path = self.cleaned_data['link_to_path']
     if path == '' or not path:
         path = None
     if path:
         try:
             test_path(path,allow_absolute=True)
         except:
             raise forms.ValidationError('Bad path: "%s"'%path)
         if not os.path.isdir(path):
             raise forms.ValidationError('Path: "%s" does not exist'%path)
         if not paths_contain(settings.LINK_TO_DIRECTORIES,path):
             raise forms.ValidationError('Path not allowed.')
     if self.the_instance:
         if self.the_instance.link_to_path and not path:
             raise forms.ValidationError('It is not possible to change a linked share to a regular share.')
         if not self.the_instance.link_to_path and path:
             raise forms.ValidationError('It is not possible to change a regular share to a linked share.')
     return path
Beispiel #5
0
 def clean_link_to_path(self):
     path = self.cleaned_data['link_to_path']
     if path == '' or not path:
         path = None
     if path:
         try:
             test_path(path, allow_absolute=True)
         except:
             raise forms.ValidationError('Bad path: "%s"' % path)
         if not os.path.isdir(path):
             raise forms.ValidationError('Path: "%s" does not exist' % path)
         if not paths_contain(settings.LINK_TO_DIRECTORIES, path):
             raise forms.ValidationError('Path not allowed.')
     if self.the_instance:
         if self.the_instance.link_to_path and not path:
             raise forms.ValidationError(
                 'It is not possible to change a linked share to a regular share.'
             )
         if not self.the_instance.link_to_path and path:
             raise forms.ValidationError(
                 'It is not possible to change a regular share to a linked share.'
             )
     return path