Ejemplo n.º 1
0
    def __init__(self, *args, **kwargs):
        """ Class initializer. """
        from x84.bbs import get_ini
        self.log = logging.getLogger(__name__)

        # root file folder,
        self.root = get_ini(section='sftp', key='root')

        # default file mode for uploaded files,
        _base = 8  # (value is octal!)
        self.mode = int(get_ini(
            section='sftp', key='uploads_filemode') or '644', _base)

        # allow anonymous login where enabled, otherwise use the
        # given `username' authenticated by ssh
        from x84.bbs.userbase import get_user, User
        _ssh_session = kwargs.pop('ssh_session')
        self.user = (User(u'anonymous') if _ssh_session.anonymous
                     else get_user(_ssh_session.username))
        self.flagged = set()

        SFTPServerInterface.__init__(self, *args, **kwargs)
Ejemplo n.º 2
0
Archivo: sftp.py Proyecto: tehmaze/x84
    def __init__(self, *args, **kwargs):
        from x84.bbs import get_ini
        self.log = logging.getLogger(__name__)

        # root file folder,
        self.root = get_ini(section='sftp', key='root')

        # default file mode for uploaded files,
        _base = 8  # (value is octal!)
        self.mode = int(get_ini(
            section='sftp', key='uploads_filemode') or '644', _base)

        # allow anonymous login where enabled, otherwise use the
        # given `username' authenticated by ssh
        from x84.bbs.userbase import get_user, User
        _ssh_session = kwargs.pop('ssh_session')
        self.user = (User(u'anonymous') if _ssh_session.anonymous
                     else get_user(_ssh_session.username))

        # XXX this means if a user interactively flags files, they have to
        # re-sftp login to see them, we should fix this
        self.flagged = self.user.get('flaggedfiles', set())

        super(X84SFTPServer, self).__init__(*args, **kwargs)