File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / sudo / src / sudo_plugin_int.h
Revision 1.1.1.4 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Sun Jun 15 16:12:55 2014 UTC (10 years ago) by misho
Branches: sudo, MAIN
CVS tags: v1_8_10p3_0, v1_8_10p3, HEAD
sudo v 1.8.10p3

    1: /*
    2:  * Copyright (c) 2010-2013 Todd C. Miller <Todd.Miller@courtesan.com>
    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:  */
   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: };
   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: };
   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: };
   79: 
   80: /*
   81:  * Sudo plugin internals.
   82:  */
   83: struct plugin_container {
   84:     TAILQ_ENTRY(plugin_container) entries;
   85:     const char *name;
   86:     char * const *options;
   87:     void *handle;
   88:     union {
   89: 	struct generic_plugin *generic;
   90: 	struct policy_plugin *policy;
   91: 	struct policy_plugin_1_0 *policy_1_0;
   92: 	struct io_plugin *io;
   93: 	struct io_plugin_1_0 *io_1_0;
   94: 	struct io_plugin_1_1 *io_1_1;
   95:     } u;
   96: };
   97: TAILQ_HEAD(plugin_container_list, plugin_container);
   98: 
   99: extern struct plugin_container policy_plugin;
  100: extern struct plugin_container_list io_plugins;
  101: 
  102: int sudo_conversation(int num_msgs, const struct sudo_conv_message msgs[],
  103:     struct sudo_conv_reply replies[]);
  104: int _sudo_printf(int msg_type, const char *fmt, ...);
  105: 
  106: bool sudo_load_plugins(struct plugin_container *policy_plugin,
  107:     struct plugin_container_list *io_plugins);
  108: 
  109: #endif /* _SUDO_PLUGIN_INT_H */

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>