return rval;
}
+char **
+env_get(void)
+{
+ return env.envp;
+}
+
/*
* Similar to setenv(3) but operates on sudo's private copy of the environment
* (not environ) and it always overwrites. The dupcheck param determines
/*
* Version of setenv(3) that uses our own environ pointer.
- * Will sync with environ as needed.
*/
int
setenv(var, val, overwrite)
/*
* Version of unsetenv(3) that uses our own environ pointer.
- * Will sync with environ as needed.
*/
#ifdef UNSETENV_VOID
void
/*
* Version of putenv(3) that uses our own environ pointer.
- * Will sync with environ as needed.
*/
int
#ifdef PUTENV_CONST
static int deserialize_info(char * const settings[], char * const user_info[]);
extern int sudo_edit(int, char **, char **);
-extern int rebuild_env(int, int);
-extern int env_init(char * const envp[]);
void validate_env_vars(struct list_member *);
void insert_env_vars(struct list_member *);
-/* XXX */
-char *fmt_string(const char *, const char *);
-
/*
* Globals
*/
static int NewArgc;
static char **NewArgv;
-/* XXX */
-extern char **environ;
-
/* error.c */
extern sigjmp_buf error_jmp;
static int sudo_mode;
-static char * const * user_env;
static int
sudoers_policy_open(unsigned int version, sudo_conv_t conversation,
/* Set login class if applicable. */
set_loginclass(sudo_user.pw);
- /* XXX */
- user_env = envp; /* stash for later */
+ /* Initialize environment functions (including replacements). */
+ env_init(envp);
return TRUE;
}
static void
sudoers_policy_close(int exit_status, int error_code)
{
+ /* We do not currently log the exit status. */
if (error_code)
warningx("unable to execute %s: %s", safe_cmnd, strerror(error_code));
}
{
static char *command_info[32]; /* XXX */
struct sudo_nss *nss;
- char **old_environ = environ;
int cmnd_status = -1, validated, pwflag = 0;
int info_len = 0;
int rval = FALSE;
if (ISSET(sudo_mode, MODE_LOGIN_SHELL))
NewArgv[0] = runas_pw->pw_shell;
- /* Set environ to contents of user_env. */
- env_init(user_env);
-
#ifdef USING_NONUNIX_GROUPS
sudo_nonunix_groupcheck_init(); /* initialise nonunix groups impl */
#endif /* USING_NONUNIX_GROUPS */
*command_infop = command_info;
*argv_out = NewArgv;
- *user_env_out = environ; /* actually our local copy */
+ *user_env_out = env_get(); /* our private copy */
rval = TRUE;
done:
- environ = old_environ;
-
return rval;
}
int sudoers_io_version(int verbose);
int sudoers_io_log_output(const char *buf, unsigned int len);
+/* env.c */
+char **env_get(void);
+int env_init(char * const envp[]);
+void rebuild_env(int, int);
+
+/* fmt_string.c */
+char *fmt_string(const char *, const char *);
+
/* Only provide extern declarations outside of sudo.c. */
#ifndef _SUDO_MAIN
extern struct sudo_user sudo_user;