Pass a pointer to user_env in to the init_session policy plugin

function so session setup can modify the user environment as needed.
For PAM authentication, merge the PAM environment with the user
environment at init_session time.  We no longer need to swap in the
user_env for environ during session init, nor do we need to disable
the env hooks at init_session time.
This commit is contained in:
Todd C. Miller
2012-03-15 09:18:36 -04:00
parent 0b1baf07ec
commit 6d10909949
11 changed files with 101 additions and 75 deletions

View File

@@ -122,6 +122,7 @@ sudo_conv_t sudo_conv;
sudo_printf_t sudo_printf;
int sudo_mode;
static int sudo_version;
static char *prev_user;
static char *runas_user;
static char *runas_group;
@@ -146,15 +147,16 @@ sudoers_policy_open(unsigned int version, sudo_conv_t conversation,
struct sudo_nss *nss;
debug_decl(sudoers_policy_open, SUDO_DEBUG_PLUGIN)
/* Plugin args are only specified for API version 1.2 and higher. */
if (version < SUDO_API_MKVERSION(1, 2))
args = NULL;
sudo_version = version;
if (!sudo_conv)
sudo_conv = conversation;
if (!sudo_printf)
sudo_printf = plugin_printf;
/* Plugin args are only specified for API version 1.2 and higher. */
if (sudo_version < SUDO_API_MKVERSION(1, 2))
args = NULL;
if (sigsetjmp(error_jmp, 1)) {
/* called via error(), errorx() or log_error() */
rewind_perms();
@@ -281,16 +283,20 @@ sudoers_policy_close(int exit_status, int error_code)
* and before uid/gid changes occur.
*/
static int
sudoers_policy_init_session(struct passwd *pwd)
sudoers_policy_init_session(struct passwd *pwd, char **user_env[])
{
debug_decl(sudoers_policy_init, SUDO_DEBUG_PLUGIN)
/* user_env is only specified for API version 1.2 and higher. */
if (sudo_version < SUDO_API_MKVERSION(1, 2))
user_env = NULL;
if (sigsetjmp(error_jmp, 1)) {
/* called via error(), errorx() or log_error() */
return -1;
}
debug_return_bool(sudo_auth_begin_session(pwd));
debug_return_bool(sudo_auth_begin_session(pwd, user_env));
}
static int