Пример #1
0
 def checkKey(self, credentials):
     """
     Retrieve files containing authorized keys and check against user
     credentials.
     """
     ouid, ogid = self._userdb.getpwnam(credentials.username)[2:4]
     for filepath in self.getAuthorizedKeysFiles(credentials):
         if not filepath.exists():
             continue
         try:
             lines = filepath.open()
         except IOError as e:
             if e.errno == errno.EACCES:
                 lines = runAsEffectiveUser(ouid, ogid, filepath.open)
             else:
                 raise
         with lines:
             for l in lines:
                 l2 = l.split()
                 if len(l2) < 2:
                     continue
                 try:
                     if _b64decodebytes(l2[1]) == credentials.blob:
                         return True
                 except binascii.Error:
                     continue
     return False
Пример #2
0
 def checkKey(self, credentials):
     """
     Retrieve files containing authorized keys and check against user
     credentials.
     """
     ouid, ogid = self._userdb.getpwnam(credentials.username)[2:4]
     for filepath in self.getAuthorizedKeysFiles(credentials):
         if not filepath.exists():
             continue
         try:
             lines = filepath.open()
         except IOError as e:
             if e.errno == errno.EACCES:
                 lines = runAsEffectiveUser(ouid, ogid, filepath.open)
             else:
                 raise
         with lines:
             for l in lines:
                 l2 = l.split()
                 if len(l2) < 2:
                     continue
                 try:
                     if _b64decodebytes(l2[1]) == credentials.blob:
                         return True
                 except binascii.Error:
                     continue
     return False