/*1* SPDX-License-Identifier: ISC2*3* Copyright (c) 2021-2022 Todd C. Miller <[email protected]>4*5* Permission to use, copy, modify, and distribute this software for any6* purpose with or without fee is hereby granted, provided that the above7* copyright notice and this permission notice appear in all copies.8*9* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES10* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF11* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR12* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES13* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN14* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF15* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.16*/1718#ifndef SUDO_EXEC_INTERCEPT_H19#define SUDO_EXEC_INTERCEPT_H2021enum intercept_state {22INVALID_STATE,23RECV_HELLO_INITIAL,24RECV_HELLO,25RECV_SECRET,26RECV_POLICY_CHECK,27RECV_CONNECTION,28POLICY_ACCEPT,29POLICY_REJECT,30POLICY_TEST,31POLICY_ERROR32};3334/* Closure for intercept_cb() */35struct intercept_closure {36union sudo_token_un token;37const struct command_details *details;38struct sudo_event ev;39const char *errstr;40char *command; /* dynamically allocated */41char **run_argv; /* owned by plugin */42char **run_envp; /* dynamically allocated */43uint8_t *buf; /* dynamically allocated */44uint32_t len;45uint32_t off;46int listen_sock;47enum intercept_state state;48int initial_command;49};5051void intercept_closure_reset(struct intercept_closure *closure);52bool intercept_check_policy(const char *command, int argc, char **argv, int envc, char **envp, const char *runcwd, int *oldcwd, void *closure);5354#endif /* SUDO_EXEC_INTERCEPT_H */555657