Wrapper for running functions executed with AES encryption :param function func: The function to run :return: The result of the master function that was called
(self, func, load)
| 2990 | return self.masterapi.revoke_auth(load) |
| 2991 | |
| 2992 | def run_func(self, func, load): |
| 2993 | """ |
| 2994 | Wrapper for running functions executed with AES encryption |
| 2995 | |
| 2996 | :param function func: The function to run |
| 2997 | :return: The result of the master function that was called |
| 2998 | """ |
| 2999 | # Don't honor private functions |
| 3000 | if func.startswith("__"): |
| 3001 | # TODO: return some error? Seems odd to return {} |
| 3002 | return {}, {"fun": "send"} |
| 3003 | # Run the func |
| 3004 | if hasattr(self, func): |
| 3005 | try: |
| 3006 | start = time.time() |
| 3007 | ret = getattr(self, func)(load) |
| 3008 | log.trace( |
| 3009 | "Master function call %s took %s seconds", func, time.time() - start |
| 3010 | ) |
| 3011 | except Exception: # pylint: disable=broad-except |
| 3012 | ret = "" |
| 3013 | log.error("Error in function %s:\n", func, exc_info=True) |
| 3014 | else: |
| 3015 | log.error( |
| 3016 | "Received function %s which is unavailable on the master, " |
| 3017 | "returning False", |
| 3018 | func, |
| 3019 | ) |
| 3020 | return False, {"fun": "send"} |
| 3021 | # Don't encrypt the return value for the _return func |
| 3022 | # (we don't care about the return value, so why encrypt it?) |
| 3023 | if func == "_return": |
| 3024 | return ret, {"fun": "send"} |
| 3025 | if func == "_pillar" and "id" in load: |
| 3026 | if load.get("ver") != "2" and self.opts["pillar_version"] == 1: |
| 3027 | # Authorized to return old pillar proto |
| 3028 | return ret, {"fun": "send"} |
| 3029 | return ret, {"fun": "send_private", "key": "pillar", "tgt": load["id"]} |
| 3030 | # Encrypt the return |
| 3031 | return ret, {"fun": "send"} |
| 3032 | |
| 3033 | def destroy(self): |
| 3034 | if self.masterapi is not None: |
no test coverage detected