Example #1
0
    def maybe_pkexec(self):
        """
        Checks whether pkexec is available in the system, and
        returns the path if found.

        Might raise:
            NoPkexecAvailable,
            NoPolkitAuthAgentAvailable.

        :returns: a list of the paths where pkexec is to be found
        :rtype: list
        """
        if self._is_pkexec_in_system():
            if not self.is_up():
                self.launch()
                time.sleep(2)
            if self.is_up():
                pkexec_possibilities = which(self.PKEXEC_BIN)
                # leap_assert(len(pkexec_possibilities) > 0,
                #             "We couldn't find pkexec")
                if not pkexec_possibilities:
                    logger.error("We couldn't find pkexec")
                    raise Exception("We couldn't find pkexec")
                return pkexec_possibilities
            else:
                logger.warning("No polkit auth agent found. pkexec " +
                               "will use its own auth agent.")
                raise NoPolkitAuthAgentAvailable()
        else:
            logger.warning("System has no pkexec")
            raise NoPkexecAvailable()
Example #2
0
    def maybe_pkexec(self):
        """
        Checks whether pkexec is available in the system, and
        returns the path if found.

        Might raise:
            NoPkexecAvailable,
            NoPolkitAuthAgentAvailable.

        :returns: a list of the paths where pkexec is to be found
        :rtype: list
        """
        if self._is_pkexec_in_system():
            if not self.is_up():
                self.launch()
                time.sleep(2)
            if self.is_up():
                pkexec_possibilities = which(self.PKEXEC_BIN)
                # leap_assert(len(pkexec_possibilities) > 0,
                #             "We couldn't find pkexec")
                if not pkexec_possibilities:
                    logger.error("We couldn't find pkexec")
                    raise Exception("We couldn't find pkexec")
                return pkexec_possibilities
            else:
                logger.warning("No polkit auth agent found. pkexec " +
                               "will use its own auth agent.")
                raise NoPolkitAuthAgentAvailable()
        else:
            logger.warning("System has no pkexec")
            raise NoPkexecAvailable()
Example #3
0
 def _is_pkexec_in_system(self):
     """
     Checks the existence of the pkexec binary in system.
     """
     pkexec_path = which('pkexec')
     if len(pkexec_path) == 0:
         return False
     return True
Example #4
0
 def _is_pkexec_in_system(self):
     """
     Checks the existence of the pkexec binary in system.
     """
     pkexec_path = which('pkexec')
     if len(pkexec_path) == 0:
         return False
     return True