2 * Copyright (c) 2010-2011 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 io_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[], int argc, char * const argv[],
38 char * const user_env[]);
39 void (*close)(int exit_status, int error);
40 int (*show_version)(int verbose);
41 int (*log_ttyin)(const char *buf, unsigned int len);
42 int (*log_ttyout)(const char *buf, unsigned int len);
43 int (*log_stdin)(const char *buf, unsigned int len);
44 int (*log_stdout)(const char *buf, unsigned int len);
45 int (*log_stderr)(const char *buf, unsigned int len);
49 * Sudo plugin internals.
53 struct plugin_info *prev; /* required */
54 struct plugin_info *next; /* required */
56 const char *symbol_name;
58 TQ_DECLARE(plugin_info)
60 struct plugin_container {
61 struct plugin_container *prev; /* required */
62 struct plugin_container *next; /* required */
66 struct generic_plugin *generic;
67 struct policy_plugin *policy;
69 struct io_plugin_1_0 *io_1_0;
72 TQ_DECLARE(plugin_container)
74 extern struct plugin_container_list policy_plugins;
75 extern struct plugin_container_list io_plugins;
77 int sudo_conversation(int num_msgs, const struct sudo_conv_message msgs[],
78 struct sudo_conv_reply replies[]);
79 int _sudo_printf(int msg_type, const char *fmt, ...);
81 int sudo_load_plugins(const char *conf_file,
82 struct plugin_container *policy_plugin,
83 struct plugin_container_list *io_plugins);
85 #endif /* _SUDO_PLUGIN_INT_H */