~ubuntu-branches/ubuntu/raring/sudo/raring

« back to all changes in this revision

Viewing changes to include/sudo_plugin.h

  • Committer: Package Import Robot
  • Author(s): Tyler Hicks
  • Date: 2012-07-16 14:01:42 UTC
  • mfrom: (1.3.22 sid)
  • Revision ID: package-import@ubuntu.com-20120716140142-b0tgau0k6nid4mrf
Tags: 1.8.5p2-1ubuntu1
* Merge from debian/testing (LP: #1024154), remaining changes:
  - debian/patches/keep_home_by_default.patch:
    + Set HOME in initial_keepenv_table.
  - debian/rules:
    + compile with --without-lecture --with-tty-tickets (Ubuntu specific)
    + install man/man8/sudo_root.8 in both flavours (Ubuntu specific)
    + install apport hooks
    + The ubuntu-sudo-as-admin-successful.patch was taken upstream by
      Debian however it requires a --enable-admin-flag configure flag to
      actually enable it in both flavours.
  - debian/control:
    + Mark Debian Vcs-* as XS-Debian-Vcs-*
    + update debian/control
  - debian/sudoers:
    + grant admin group sudo access
  - debian/source_sudo.py, debian/sudo-ldap.dirs, debian/sudo.dirs:
    + add usr/share/apport/package-hooks
  - debian/sudo.pam:
    + Use pam_env to read /etc/environment and /etc/default/locale
      environment files. Reading ~/.pam_environment is not permitted due to
      security reasons.
* Dropped changes:
  - debian/patches/lp927828-fix-abort-in-pam-modules-when-timestamp-valid.patch
    + Fixed upstream in 1.8.5
  - debian/patches/CVE-2012-2337.patch:
    + Fixed upstream in 1.8.4p5
  - debian/patches/pam_env_merge.patch:
    + Feature released upstream in 1.8.5
  - debian/{sudo,sudo-ldap}.{preinst,postinst,postrm}:
    + Drop Ubuntu-specific sudoers file migration code because the only
      upgrade path to quantal is from precise. All necessary sudoers file
      migration will have already been done by the time this version of the
      sudo package is installed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * Copyright (c) 2009-2011 Todd C. Miller <Todd.Miller@courtesan.com>
 
2
 * Copyright (c) 2009-2012 Todd C. Miller <Todd.Miller@courtesan.com>
3
3
 *
4
4
 * Permission to use, copy, modify, and distribute this software for any
5
5
 * purpose with or without fee is hereby granted, provided that the above
19
19
 
20
20
/* API version major/minor */
21
21
#define SUDO_API_VERSION_MAJOR 1
22
 
#define SUDO_API_VERSION_MINOR 1
 
22
#define SUDO_API_VERSION_MINOR 2
23
23
#define SUDO_API_MKVERSION(x, y) ((x << 16) | y)
24
24
#define SUDO_API_VERSION SUDO_API_MKVERSION(SUDO_API_VERSION_MAJOR, SUDO_API_VERSION_MINOR)
25
25
 
29
29
#define SUDO_API_VERSION_SET_MAJOR(vp, n) do { \
30
30
    *(vp) = (*(vp) & 0x0000ffff) | ((n) << 16); \
31
31
} while(0)
32
 
#define SUDO_VERSION_SET_MINOR(vp, n) do { \
 
32
#define SUDO_API_VERSION_SET_MINOR(vp, n) do { \
33
33
    *(vp) = (*(vp) & 0xffff0000) | (n); \
34
34
} while(0)
35
35
 
40
40
#define SUDO_CONV_ERROR_MSG         0x0003  /* error message */
41
41
#define SUDO_CONV_INFO_MSG          0x0004  /* informational message */
42
42
#define SUDO_CONV_PROMPT_MASK       0x0005  /* mask user input */
 
43
#define SUDO_CONV_DEBUG_MSG         0x0006  /* debugging message */
43
44
#define SUDO_CONV_PROMPT_ECHO_OK    0x1000  /* flag: allow echo if no tty */
44
45
    int msg_type;
45
46
    int timeout;
54
55
        struct sudo_conv_reply replies[]);
55
56
typedef int (*sudo_printf_t)(int msg_type, const char *fmt, ...);
56
57
 
 
58
/*
 
59
 * Hooks allow a plugin to hook into specific sudo and/or libc functions.
 
60
 */
 
61
 
 
62
/* Hook functions typedefs. */
 
63
typedef int (*sudo_hook_fn_t)();
 
64
typedef int (*sudo_hook_fn_setenv_t)(const char *name, const char *value, int overwrite, void *closure);
 
65
typedef int (*sudo_hook_fn_putenv_t)(char *string, void *closure);
 
66
typedef int (*sudo_hook_fn_getenv_t)(const char *name, char **value, void *closure);
 
67
typedef int (*sudo_hook_fn_unsetenv_t)(const char *name, void *closure);
 
68
 
 
69
/* Hook structure definition. */
 
70
struct sudo_hook {
 
71
    int hook_version;
 
72
    int hook_type;
 
73
    sudo_hook_fn_t hook_fn;
 
74
    void *closure;
 
75
};
 
76
 
 
77
/* Hook API version major/minor */
 
78
#define SUDO_HOOK_VERSION_MAJOR 1
 
79
#define SUDO_HOOK_VERSION_MINOR 0
 
80
#define SUDO_HOOK_MKVERSION(x, y) ((x << 16) | y)
 
81
#define SUDO_HOOK_VERSION SUDO_HOOK_MKVERSION(SUDO_HOOK_VERSION_MAJOR, SUDO_HOOK_VERSION_MINOR)
 
82
 
 
83
/* Getters and setters for hook API version */
 
84
#define SUDO_HOOK_VERSION_GET_MAJOR(v) ((v) >> 16)
 
85
#define SUDO_HOOK_VERSION_GET_MINOR(v) ((v) & 0xffff)
 
86
#define SUDO_HOOK_VERSION_SET_MAJOR(vp, n) do { \
 
87
    *(vp) = (*(vp) & 0x0000ffff) | ((n) << 16); \
 
88
} while(0)
 
89
#define SUDO_HOOK_VERSION_SET_MINOR(vp, n) do { \
 
90
    *(vp) = (*(vp) & 0xffff0000) | (n); \
 
91
} while(0)
 
92
 
 
93
/*
 
94
 * Hook function return values.
 
95
 */
 
96
#define SUDO_HOOK_RET_ERROR     -1      /* error */
 
97
#define SUDO_HOOK_RET_NEXT      0       /* go to the next hook in the list */
 
98
#define SUDO_HOOK_RET_STOP      1       /* stop hook processing for this type */
 
99
 
 
100
/*
 
101
 * Hooks for setenv/unsetenv/putenv/getenv.
 
102
 * This allows the plugin to be notified when a PAM module modifies
 
103
 * the environment so it can update the copy of the environment that
 
104
 * is passed to execve().
 
105
 */
 
106
#define SUDO_HOOK_SETENV        1
 
107
#define SUDO_HOOK_UNSETENV      2
 
108
#define SUDO_HOOK_PUTENV        3
 
109
#define SUDO_HOOK_GETENV        4
 
110
 
57
111
/* Policy plugin type and defines */
58
112
struct passwd;
59
113
struct policy_plugin {
62
116
    unsigned int version; /* always SUDO_API_VERSION */
63
117
    int (*open)(unsigned int version, sudo_conv_t conversation,
64
118
        sudo_printf_t sudo_printf, char * const settings[],
65
 
        char * const user_info[], char * const user_env[]);
 
119
        char * const user_info[], char * const user_env[],
 
120
        char * const plugin_plugins[]);
66
121
    void (*close)(int exit_status, int error); /* wait status or error */
67
122
    int (*show_version)(int verbose);
68
123
    int (*check_policy)(int argc, char * const argv[],
72
127
        const char *list_user);
73
128
    int (*validate)(void);
74
129
    void (*invalidate)(int remove);
75
 
    int (*init_session)(struct passwd *pwd);
 
130
    int (*init_session)(struct passwd *pwd, char **user_env_out[]);
 
131
    void (*register_hooks)(int version, int (*register_hook)(struct sudo_hook *hook));
 
132
    void (*deregister_hooks)(int version, int (*deregister_hook)(struct sudo_hook *hook));
76
133
};
77
134
 
78
135
/* I/O plugin type and defines */
83
140
    int (*open)(unsigned int version, sudo_conv_t conversation,
84
141
        sudo_printf_t sudo_printf, char * const settings[],
85
142
        char * const user_info[], char * const command_info[],
86
 
        int argc, char * const argv[], char * const user_env[]);
 
143
        int argc, char * const argv[], char * const user_env[],
 
144
        char * const plugin_plugins[]);
87
145
    void (*close)(int exit_status, int error); /* wait status or error */
88
146
    int (*show_version)(int verbose);
89
147
    int (*log_ttyin)(const char *buf, unsigned int len);
91
149
    int (*log_stdin)(const char *buf, unsigned int len);
92
150
    int (*log_stdout)(const char *buf, unsigned int len);
93
151
    int (*log_stderr)(const char *buf, unsigned int len);
 
152
    void (*register_hooks)(int version, int (*register_hook)(struct sudo_hook *hook));
 
153
    void (*deregister_hooks)(int version, int (*deregister_hook)(struct sudo_hook *hook));
94
154
};
95
155
 
96
156
/* Sudoers group plugin version major/minor */