Пример #1
0
    def _auth_OK(self, line):
        line = line.strip()

        if not line:
            raise DBusAuthenticationFailed('Missing guid in OK message')
        
        try:
            self.guid = binascii.unhexlify( line )
        except:
            raise DBusAuthenticationFailed('Invalid guid in OK message')
        else:
            self.sendAuthMessage('BEGIN')
            self.authenticated = True
Пример #2
0
    def _auth_OK(self, line):
        line = line.strip()

        if not line:
            raise DBusAuthenticationFailed('Missing guid in OK message')

        try:
            self.guid = binascii.unhexlify(line)
        except BaseException:
            raise DBusAuthenticationFailed('Invalid guid in OK message')
        else:
            if self.unixFDSupport:
                self.sendAuthMessage(b'NEGOTIATE_UNIX_FD')
            else:
                self.sendAuthMessage(b'BEGIN')
                self.authenticated = True
Пример #3
0
 def _auth_BEGIN(self, line):
     if self.state == 'WaitingForBegin':
         self.authenticated = True
         self.guid = self.current_mech.getUserName()
         self.current_mech = None
     else:
         raise DBusAuthenticationFailed('Protocol violation')
Пример #4
0
 def _auth_AGREE_UNIX_FD(self, line):
     if self.unixFDSupport:
         self.sendAuthMessage(b'BEGIN')
         self.authenticated = True
     else:
         raise DBusAuthenticationFailed(
             'AGREE_UNIX_FD with no NEGOTIATE_UNIX_FD', )
Пример #5
0
 def reject(self):
     if self.current_mech:
         self.current_mech.cancel()
         self.current_mech = None
         
     self.reject_count += 1
     if self.reject_count > self.MAX_REJECTS_ALLOWED:
         raise DBusAuthenticationFailed('Client exceeded maximum failed authentication attempts')
     
     self.sendAuthMessage(self.reject_msg)
     self.state = 'WaitingForAuth'
Пример #6
0
 def handleAuthMessage(self, line):
     if not ' ' in line:
         cmd = line
         args = ''
     else:
         cmd, args = line.split(' ',1)
     m = getattr(self, '_auth_' + cmd, None)
     if m:
         m( args )
     else:
         raise DBusAuthenticationFailed('Invalid DBus authentcation protocol message: ' + line)
Пример #7
0
 def handleAuthMessage(self, line):
     if b' ' not in line:
         cmd = line
         args = b''
     else:
         cmd, args = line.split(b' ', 1)
     m = getattr(self, '_auth_' + cmd.decode(), None)
     if m:
         m(args)
     else:
         raise DBusAuthenticationFailed(
             'Invalid DBus authentication protocol message: ' +
             line.decode("ascii", "replace"))
Пример #8
0
 def authTryNextMethod(self):
     """
     Tries the next authentication method or raises a failure if all mechanisms
     have been tried.
     """
     if not self.authOrder:
         raise DBusAuthenticationFailed()
     
     self.authMech  = self.authOrder.pop()
         
     if self.authMech == 'DBUS_COOKIE_SHA1':
         self.sendAuthMessage('AUTH ' + self.authMech + ' ' +
                              binascii.hexlify(getpass.getuser()))
     else:
         self.sendAuthMessage('AUTH ' + self.authMech)