Annotation of embedaddon/sudo/src/sudo_plugin_int.h, revision 1.1.1.3
1.1 misho 1: /*
1.1.1.3 ! misho 2: * Copyright (c) 2010-2013 Todd C. Miller <Todd.Miller@courtesan.com>
1.1 misho 3: *
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.
7: *
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.
15: */
16:
17: #ifndef _SUDO_PLUGIN_INT_H
18: #define _SUDO_PLUGIN_INT_H
19:
20: /*
21: * All plugin structures start with a type and a version.
22: */
23: struct generic_plugin {
24: unsigned int type;
25: unsigned int version;
26: /* the rest depends on the type... */
27: };
28:
29: /*
30: * Backwards-compatible structures for API bumps.
31: */
1.1.1.2 misho 32: struct policy_plugin_1_0 {
33: unsigned int type;
34: unsigned int version;
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);
48: };
1.1 misho 49: struct io_plugin_1_0 {
50: unsigned int type;
51: unsigned int version;
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);
63: };
1.1.1.2 misho 64: struct io_plugin_1_1 {
65: unsigned int type;
66: unsigned int version;
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);
78: };
1.1 misho 79:
80: /*
81: * Sudo plugin internals.
82: */
83: struct plugin_container {
84: struct plugin_container *prev; /* required */
85: struct plugin_container *next; /* required */
86: const char *name;
1.1.1.2 misho 87: char * const *options;
1.1 misho 88: void *handle;
89: union {
90: struct generic_plugin *generic;
91: struct policy_plugin *policy;
1.1.1.2 misho 92: struct policy_plugin_1_0 *policy_1_0;
1.1 misho 93: struct io_plugin *io;
94: struct io_plugin_1_0 *io_1_0;
1.1.1.2 misho 95: struct io_plugin_1_1 *io_1_1;
1.1 misho 96: } u;
97: };
98: TQ_DECLARE(plugin_container)
99:
1.1.1.3 ! misho 100: extern struct plugin_container policy_plugin;
1.1 misho 101: extern struct plugin_container_list io_plugins;
102:
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, ...);
106:
1.1.1.2 misho 107: bool sudo_load_plugins(struct plugin_container *policy_plugin,
1.1 misho 108: struct plugin_container_list *io_plugins);
109:
110: #endif /* _SUDO_PLUGIN_INT_H */
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>