Beispiel #1
0
    def createActionProcessorUser(self, recreate=True):
        if not config.get('action_processor', 'create_user'):
            return

        run_as_user = config.get('action_processor', 'run_as_user')
        if run_as_user.lower() == 'system':
            self._actionProcessorUserName = ''
            self._actionProcessorUserPassword = ''
            return

        if '\\' in run_as_user:
            logger.warning(
                "Ignoring domain part of user to run action processor '%s'",
                run_as_user)
            run_as_user = run_as_user.split('\\', -1)

        if not recreate and self._actionProcessorUserName and self._actionProcessorUserPassword and System.existsUser(
                username=run_as_user):
            return

        self._actionProcessorUserName = run_as_user
        logger.notice(f"Creating local user '{run_as_user}'")

        self._actionProcessorUserPassword = '******' + str(
            randomString(16)) + '!/%'
        secret_filter.add_secrets(self._actionProcessorUserPassword)

        if System.existsUser(username=run_as_user):
            System.deleteUser(username=run_as_user)
        System.createUser(username=run_as_user,
                          password=self._actionProcessorUserPassword,
                          groups=[System.getAdminGroupName()])
Beispiel #2
0
    def deleteActionProcessorUser(self):
        if not config.get('action_processor', 'delete_user'):
            return

        if not self._actionProcessorUserName:
            return

        if not System.existsUser(username=self._actionProcessorUserName):
            return

        logger.notice("Deleting local user '%s'",
                      self._actionProcessorUserName)
        System.deleteUser(username=self._actionProcessorUserName)
        self._actionProcessorUserName = ''
        self._actionProcessorUserPassword = ''