2 * Copyright (c) 2010-2012 Todd C. Miller <Todd.Miller@courtesan.com>
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 #ifndef _SUDO_PLUGIN_INT_H
18 #define _SUDO_PLUGIN_INT_H
21 * All plugin structures start with a type and a version.
23 struct generic_plugin {
26 /* the rest depends on the type... */
30 * Backwards-compatible structures for API bumps.
32 struct policy_plugin_1_0 {
35 int (*open)(unsigned int version, sudo_conv_t conversation,
36 sudo_printf_t sudo_printf, char * const settings[],
37 char * const user_info[], char * const user_env[]);
38 void (*close)(int exit_status, int error); /* wait status or error */
39 int (*show_version)(int verbose);
40 int (*check_policy)(int argc, char * const argv[],
41 char *env_add[], char **command_info[],
42 char **argv_out[], char **user_env_out[]);
43 int (*list)(int argc, char * const argv[], int verbose,
44 const char *list_user);
45 int (*validate)(void);
46 void (*invalidate)(int remove);
47 int (*init_session)(struct passwd *pwd);
49 struct io_plugin_1_0 {
52 int (*open)(unsigned int version, sudo_conv_t conversation,
53 sudo_printf_t sudo_printf, char * const settings[],
54 char * const user_info[], int argc, char * const argv[],
55 char * const user_env[]);
56 void (*close)(int exit_status, int error);
57 int (*show_version)(int verbose);
58 int (*log_ttyin)(const char *buf, unsigned int len);
59 int (*log_ttyout)(const char *buf, unsigned int len);
60 int (*log_stdin)(const char *buf, unsigned int len);
61 int (*log_stdout)(const char *buf, unsigned int len);
62 int (*log_stderr)(const char *buf, unsigned int len);
64 struct io_plugin_1_1 {
67 int (*open)(unsigned int version, sudo_conv_t conversation,
68 sudo_printf_t sudo_printf, char * const settings[],
69 char * const user_info[], char * const command_info[],
70 int argc, char * const argv[], char * const user_env[]);
71 void (*close)(int exit_status, int error); /* wait status or error */
72 int (*show_version)(int verbose);
73 int (*log_ttyin)(const char *buf, unsigned int len);
74 int (*log_ttyout)(const char *buf, unsigned int len);
75 int (*log_stdin)(const char *buf, unsigned int len);
76 int (*log_stdout)(const char *buf, unsigned int len);
77 int (*log_stderr)(const char *buf, unsigned int len);
81 * Sudo plugin internals.
83 struct plugin_container {
84 struct plugin_container *prev; /* required */
85 struct plugin_container *next; /* required */
87 char * const *options;
90 struct generic_plugin *generic;
91 struct policy_plugin *policy;
92 struct policy_plugin_1_0 *policy_1_0;
94 struct io_plugin_1_0 *io_1_0;
95 struct io_plugin_1_1 *io_1_1;
98 TQ_DECLARE(plugin_container)
100 extern struct plugin_container_list policy_plugins;
101 extern struct plugin_container_list io_plugins;
103 int sudo_conversation(int num_msgs, const struct sudo_conv_message msgs[],
104 struct sudo_conv_reply replies[]);
105 int _sudo_printf(int msg_type, const char *fmt, ...);
107 bool sudo_load_plugins(struct plugin_container *policy_plugin,
108 struct plugin_container_list *io_plugins);
110 #endif /* _SUDO_PLUGIN_INT_H */