def chattr(self, path, attr): path = self._realpath(path) try: SFTPServer.set_file_attr(path, attr) except OSError as e: return SFTPServer.convert_errno(e.errno) return SFTP_OK
def chattr(self, attr): # python doesn't have equivalents to fchown or fchmod, so we have to # use the stored filename try: SFTPServer.set_file_attr(self.filename, attr) except OSError, e: return SFTPServer.convert_errno(e.errno)
def chattr(self, attr): # python doesn't have equivalents to fchown or fchmod, so we have to # use the stored filename mutter('Changing permissions on %s to %s', self.filename, attr) try: SFTPServer.set_file_attr(self.filename, attr) except OSError, e: return SFTPServer.convert_errno(e.errno)
def chattr(self, attr): # python doesn't have equivalents to fchown or fchmod, so we have to # use the stored filename try: SFTPServer.set_file_attr(self.filename, attr) return SFTP_OK except OSError as e: return SFTPServer.convert_errno(e.errno)
def mkdir(self, path, attr): path = self._realpath(path) try: os.mkdir(path) if attr is not None: SFTPServer.set_file_attr(path, attr) except OSError, e: return SFTPServer.convert_errno(e.errno)
def mkdir(self, path, attr): real_path = self._realpath(path) try: os.mkdir(real_path) self._path_modified(path) if attr is not None: SFTPServer.set_file_attr(real_path, attr) except OSError as e: return SFTPServer.convert_errno(e.errno) return SFTP_OK
def chattr(self, attr): if not self.user.is_sysop: return SFTP_PERMISSION_DENIED self.log.debug('chattr ({0!r})'.format(attr)) # python doesn't have equivalents to fchown or fchmod, so we have to # use the stored filename try: SFTPServer.set_file_attr(self.filename, attr) return SFTP_OK except OSError as err: return SFTPServer.convert_errno(err.errno)
def chattr(self, path, attr): """ This method changes the attributes of a given path path - the path attr - file attributes to be set return SFTP_OK or error """ path = self._realpath(path) try: SFTPServer.set_file_attr(path, attr) except OSError, e: return SFTPServer.convert_errno(e.errno)
def mkdir(self, path, attr): if not self.user.is_sysop or flagged_dirname in path: return SFTP_PERMISSION_DENIED self.log.debug('mkdir({0!r}, {1!r})'.format(path, attr)) path = self._realpath(path) try: os.mkdir(path) if attr is not None: SFTPServer.set_file_attr(path, attr) except OSError as err: return SFTPServer.convert_errno(err.errno) return SFTP_OK
def chattr(self, attr): """ Change attributes of the file descriptor. """ if not self.user.is_sysop: return SFTP_PERMISSION_DENIED self.log.debug('chattr ({0!r})'.format(attr)) # python doesn't have equivalents to fchown or fchmod, so we have to # use the stored filename try: SFTPServer.set_file_attr(self.filename, attr) return SFTP_OK except OSError as err: return SFTPServer.convert_errno(err.errno)
def chattr(self, attr): """ This method performs the stat attributes for the given path path - file/folder path return path SFTPAttributes or error """ # python doesn't have equivalents to fchown or fchmod, so we have to # use the stored filename try: SFTPServer.set_file_attr(self.filename, attr) return SFTP_OK except OSError, e: return SFTPServer.convert_errno(e.errno)
def mkdir(self, path, attr): """ Makea new directory. """ if not self.user.is_sysop or flagged_dirname in path: return SFTP_PERMISSION_DENIED self.log.debug('mkdir({0!r}, {1!r})'.format(path, attr)) path = self._realpath(path) try: os.mkdir(path) if attr is not None: SFTPServer.set_file_attr(path, attr) except OSError as err: return SFTPServer.convert_errno(err.errno) return SFTP_OK
def mkdir(self, path, attr): """ This method creates a dir path with passed attributes path - folder path to be created attr - attributes return SFTP_OK or error """ path = self._realpath(path) try: os.mkdir(path) if attr is not None: SFTPServer.set_file_attr(path, attr) except OSError, e: return SFTPServer.convert_errno(e.errno)
def chattr(self, path, attr): if self._is_uploaddir(path): return SFTP_PERMISSION_DENIED elif not self.user.is_sysop or \ uploads_dirname in path or \ flagged_dirname in path: return SFTP_PERMISSION_DENIED self.log.debug('chattr({0!r})'.format(path)) path = self._realpath(path) try: SFTPServer.set_file_attr(path, attr) except OSError as err: return SFTPServer.convert_errno(err.errno) return SFTP_OK
def open(self, path, flags, attr): print 'OPENING' permissions = self._get_bioshare_path_permissions(path) IS_WRITE = flags & os.O_CREAT or flags & os.O_WRONLY or flags & os.O_RDWR or flags & os.O_APPEND if not ((not IS_WRITE and Share.PERMISSION_VIEW in permissions and Share.PERMISSION_DOWNLOAD in permissions) or (IS_WRITE and Share.PERMISSION_WRITE in permissions and Share.PERMISSION_VIEW in permissions)): # if Share.PERMISSION_WRITE not in permissions: raise PermissionDenied() if flags & os.O_CREAT or flags & os.O_WRONLY or flags & os.O_RDWR or flags & os.O_APPEND: self._path_modified(path) path = self._realpath(path) try: binary_flag = getattr(os, 'O_BINARY', 0) flags |= binary_flag mode = getattr(attr, 'st_mode', None) if mode is not None: fd = os.open(path, flags, mode) else: # os.open() defaults to 0777 which is # an odd default mode for files fd = os.open(path, flags, o666) except OSError as e: return SFTPServer.convert_errno(e.errno) try: if (flags & os.O_CREAT) and (attr is not None): attr._flags &= ~attr.FLAG_PERMISSIONS SFTPServer.set_file_attr(path, attr) if flags & os.O_WRONLY: if flags & os.O_APPEND: fstr = 'ab' else: fstr = 'wb' elif flags & os.O_RDWR: if flags & os.O_APPEND: fstr = 'a+b' else: fstr = 'r+b' else: # O_RDONLY (== 0) fstr = 'rb' except Exception as e: print e.message try: f = os.fdopen(fd, fstr) except OSError as e: return SFTPServer.convert_errno(e.errno) fobj = SFTPHandle(flags,permissions=permissions) fobj.filename = path fobj.readfile = f fobj.writefile = f return fobj
def mkdir(self, path, attr): path = self._realpath(path) try: # Using getattr() in case st_mode is None or 0 # both evaluate to False if getattr(attr, 'st_mode', None): os.mkdir(path, attr.st_mode) else: os.mkdir(path) if attr is not None: attr._flags &= ~attr.FLAG_PERMISSIONS SFTPServer.set_file_attr(path, attr) except OSError, e: return SFTPServer.convert_errno(e.errno)
def chattr(self, path, attr): """ Change path's attributes. """ if self._is_uploaddir(path): return SFTP_PERMISSION_DENIED elif not self.user.is_sysop or \ uploads_dirname in path or \ flagged_dirname in path: return SFTP_PERMISSION_DENIED self.log.debug('chattr({0!r})'.format(path)) path = self._realpath(path) try: SFTPServer.set_file_attr(path, attr) except OSError as err: return SFTPServer.convert_errno(err.errno) return SFTP_OK
def open(self, path, flags, attr): """ Up/download the given path. """ self.log.debug('lstat({0!r}, {1!r}, {2!r})' .format(path, flags, attr)) path = self._realpath(path) if (flags & os.O_CREAT and (uploads_dirname not in path and not self.user.is_sysop) or (uploads_dirname in path and os.path.exists(path))): return SFTP_PERMISSION_DENIED try: binary_flag = getattr(os, 'O_BINARY', 0) flags |= binary_flag filedesc = os.open(path, flags, self.mode) except OSError as err: return SFTPServer.convert_errno(err.errno) if (flags & os.O_CREAT) and (attr is not None): attr._flags &= ~attr.FLAG_PERMISSIONS SFTPServer.set_file_attr(path, attr) if flags & os.O_WRONLY: if flags & os.O_APPEND: fstr = 'ab' else: fstr = 'wb' elif flags & os.O_RDWR: if flags & os.O_APPEND: fstr = 'a+b' else: fstr = 'r+b' else: # O_RDONLY (== 0) fstr = 'rb' try: openfile = os.fdopen(filedesc, fstr) except OSError as err: return SFTPServer.convert_errno(err.errno) fobj = X84SFTPHandle(flags, user=self.user) fobj.filename = path fobj.readfile = openfile fobj.writefile = openfile if path in self.flagged: self.flagged.remove(path) self.user['flaggedfiles'] = self.flagged return fobj
def open(self, path, flags, attr): """ Up/download the given path. """ self.log.debug('lstat({0!r}, {1!r}, {2!r})'.format(path, flags, attr)) path = self._realpath(path) if (flags & os.O_CREAT and (uploads_dirname not in path and not self.user.is_sysop) or (uploads_dirname in path and os.path.exists(path))): return SFTP_PERMISSION_DENIED try: binary_flag = getattr(os, 'O_BINARY', 0) flags |= binary_flag filedesc = os.open(path, flags, self.mode) except OSError as err: return SFTPServer.convert_errno(err.errno) if (flags & os.O_CREAT) and (attr is not None): attr._flags &= ~attr.FLAG_PERMISSIONS SFTPServer.set_file_attr(path, attr) if flags & os.O_WRONLY: if flags & os.O_APPEND: fstr = 'ab' else: fstr = 'wb' elif flags & os.O_RDWR: if flags & os.O_APPEND: fstr = 'a+b' else: fstr = 'r+b' else: # O_RDONLY (== 0) fstr = 'rb' try: openfile = os.fdopen(filedesc, fstr) except OSError as err: return SFTPServer.convert_errno(err.errno) fobj = X84SFTPHandle(flags, user=self.user) fobj.filename = path fobj.readfile = openfile fobj.writefile = openfile if path in self.flagged: self.flagged.remove(path) self.user['flaggedfiles'] = self.flagged return fobj
def open(self, path, flags, attr): path = self._realpath(path) try: binary_flag = getattr(os, 'O_BINARY', 0) flags |= binary_flag mode = getattr(attr, 'st_mode', None) if mode is not None: fd = os.open(path, flags, mode) else: # os.open() defaults to 0777 which is # an odd default mode for files fd = os.open(path, flags, 1638) # 0666 except OSError: e = sys.exc_info()[1] return SFTPServer.convert_errno(e.errno) if (flags & os.O_CREAT) and (attr is not None): attr._flags &= ~attr.FLAG_PERMISSIONS SFTPServer.set_file_attr(path, attr) if flags & os.O_WRONLY: if flags & os.O_APPEND: fstr = 'ab' else: fstr = 'wb' elif flags & os.O_RDWR: if flags & os.O_APPEND: fstr = 'a+b' else: fstr = 'r+b' else: # O_RDONLY (== 0) fstr = 'rb' try: f = os.fdopen(fd, fstr) except OSError: e = sys.exc_info()[1] return SFTPServer.convert_errno(e.errno) fobj = StubSFTPHandle(flags) fobj.filename = path fobj.readfile = f fobj.writefile = f return fobj
def open(self, path, flags, attr): path = self._realpath(path) try: binary_flag = getattr(os, "O_BINARY", 0) flags |= binary_flag mode = getattr(attr, "st_mode", None) if mode is not None: fd = os.open(path, flags, mode) else: # os.open() defaults to 0777 which is # an odd default mode for files fd = os.open(path, flags, o666) except OSError as e: return SFTPServer.convert_errno(e.errno) if (flags & os.O_CREAT) and (attr is not None): attr._flags &= ~attr.FLAG_PERMISSIONS SFTPServer.set_file_attr(path, attr) if flags & os.O_WRONLY: if flags & os.O_APPEND: fstr = "ab" else: fstr = "wb" elif flags & os.O_RDWR: if flags & os.O_APPEND: fstr = "a+b" else: fstr = "r+b" else: # O_RDONLY (== 0) fstr = "rb" try: f = os.fdopen(fd, fstr) except OSError as e: return SFTPServer.convert_errno(e.errno) fobj = StubSFTPHandle(flags) fobj.filename = path fobj.readfile = f fobj.writefile = f return fobj
def open(self, path, flags, attr): path = self._realpath(path) try: binary_flag = getattr(os, 'O_BINARY', 0) flags |= binary_flag mode = getattr(attr, 'st_mode', None) if mode is not None: fd = os.open(path, flags, mode) else: # os.open() defaults to 0777 which is # an odd default mode for files fd = os.open(path, flags, 0o666) except OSError as e: return SFTPServer.convert_errno(e.errno) if (flags & os.O_CREAT) and (attr is not None): attr._flags &= ~attr.FLAG_PERMISSIONS SFTPServer.set_file_attr(path, attr) if flags & os.O_WRONLY: if flags & os.O_APPEND: fstr = 'ab' else: fstr = 'wb' elif flags & os.O_RDWR: if flags & os.O_APPEND: fstr = 'a+b' else: fstr = 'r+b' else: # O_RDONLY (== 0) fstr = 'rb' try: f = os.fdopen(fd, fstr) except OSError as e: return SFTPServer.convert_errno(e.errno) fobj = StubSFTPHandle(flags) fobj.filename = path fobj.readfile = f fobj.writefile = f return fobj
def chattr(self, path, attr): try: SFTPServer.set_file_attr(path, attr) except OSError, e: return SFTPServer.convert_errno(e.errno)
path = self._realpath(path) try: binary_flag = getattr(os, 'O_BINARY', 0) flags |= binary_flag mode = getattr(attr, 'st_mode', None) if mode is not None: fd = os.open(path, flags, mode) else: # os.open() defaults to 0777 which is # an odd default mode for files fd = os.open(path, flags, 0666) except OSError, e: return SFTPServer.convert_errno(e.errno) if (flags & os.O_CREAT) and (attr is not None): attr._flags &= ~attr.FLAG_PERMISSIONS SFTPServer.set_file_attr(path, attr) if flags & os.O_WRONLY: if flags & os.O_APPEND: fstr = 'ab' else: fstr = 'wb' elif flags & os.O_RDWR: if flags & os.O_APPEND: fstr = 'a+b' else: fstr = 'r+b' else: # O_RDONLY (== 0) fstr = 'rb' try: f = os.fdopen(fd, fstr)