Esempio n. 1
0
 def authorize (self, channel, username, password):
     try:
         pw_name, pw_passwd, pw_uid, pw_gid, pw_gecos, pw_dir, pw_shell = pwd.getpwnam (username)
     except (KeyError,TypeError):
         return 0, 'No such user.', None
     if pw_passwd == '*':
         raise SystemError, "unable to fetch encrypted password. not running as root?"
     else:
         if crypt.crypt (password, pw_passwd) == pw_passwd:
             # XXX think about this
             #channel.read_only = 0
             #channel.read_only = 1
             if self.root:
                 root = self.root(pw_name)
             else:
                 root = '/'
             if self.wd:
                 wd = self.wd(pw_name)
             else:
                 wd = pw_dir
             fs = filesys.schizophrenic_unix_filesystem (
                 root,
                 wd,
                 persona = (pw_name, pw_uid, pw_gid)
                 )
             return 1, 'Login successful.', fs
         else:
             return 0, 'Password invalid.', None
Esempio n. 2
0
 def authorize(self, channel, username, password):
     import crypt
     import pwd
     try:
         info = pwd.getpwnam(username)
     except KeyError:
         return 0, 'No such user.', None
     mangled = info[1]
     if crypt.crypt(password, mangled[:2]) == mangled:
         channel.read_only = 0
         fs = filesys.schizophrenic_unix_filesystem('/',
                                                    info[5],
                                                    persona=(info[2],
                                                             info[3]))
         return 1, 'Login successful.', fs
     else:
         return 0, 'Password invalid.', None
Esempio n. 3
0
 def authorize (self, channel, username, password):
     import crypt
     import pwd
     try:
         info = pwd.getpwnam (username)
     except KeyError:
         return 0, 'No such user.', None
     mangled = info[1]
     if crypt.crypt (password, mangled[:2]) == mangled:
         channel.read_only = 0
         fs = filesys.schizophrenic_unix_filesystem (
                 '/',
                 info[5],
                 persona = (info[2], info[3])
                 )
         return 1, 'Login successful.', fs
     else:
         return 0, 'Password invalid.', None