setup_environment(): eliminate one parameter
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
99709ab033
commit
fd686a262f
@ -1156,9 +1156,10 @@ extern int restricted_shell(const char *shell) FAST_FUNC;
|
|||||||
* SHELL=shell
|
* SHELL=shell
|
||||||
* else does nothing
|
* else does nothing
|
||||||
*/
|
*/
|
||||||
#define SETUP_ENV_CHANGEENV (1<<0)
|
#define SETUP_ENV_CHANGEENV (1 << 0)
|
||||||
#define SETUP_ENV_TO_TMP (1<<1)
|
#define SETUP_ENV_CLEARENV (1 << 1)
|
||||||
extern void setup_environment(const char *shell, int clear_env, int flags, const struct passwd *pw) FAST_FUNC;
|
#define SETUP_ENV_TO_TMP (1 << 2)
|
||||||
|
extern void setup_environment(const char *shell, int flags, const struct passwd *pw) FAST_FUNC;
|
||||||
extern int correct_password(const struct passwd *pw) FAST_FUNC;
|
extern int correct_password(const struct passwd *pw) FAST_FUNC;
|
||||||
/* Returns a malloced string */
|
/* Returns a malloced string */
|
||||||
#if !ENABLE_USE_BB_CRYPT
|
#if !ENABLE_USE_BB_CRYPT
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
|
|
||||||
#include "libbb.h"
|
#include "libbb.h"
|
||||||
|
|
||||||
void FAST_FUNC setup_environment(const char *shell, int clear_env, int flags, const struct passwd *pw)
|
void FAST_FUNC setup_environment(const char *shell, int flags, const struct passwd *pw)
|
||||||
{
|
{
|
||||||
/* Change the current working directory to be the home directory
|
/* Change the current working directory to be the home directory
|
||||||
* of the user */
|
* of the user */
|
||||||
@ -39,7 +39,7 @@ void FAST_FUNC setup_environment(const char *shell, int clear_env, int flags, co
|
|||||||
bb_error_msg("can't chdir to home directory '%s'", pw->pw_dir);
|
bb_error_msg("can't chdir to home directory '%s'", pw->pw_dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (clear_env) {
|
if (flags & SETUP_ENV_CLEARENV) {
|
||||||
const char *term;
|
const char *term;
|
||||||
|
|
||||||
/* Leave TERM unchanged. Set HOME, SHELL, USER, LOGNAME, PATH.
|
/* Leave TERM unchanged. Set HOME, SHELL, USER, LOGNAME, PATH.
|
||||||
|
@ -477,8 +477,9 @@ int login_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
tmp = pw->pw_shell;
|
tmp = pw->pw_shell;
|
||||||
if (!tmp || !*tmp)
|
if (!tmp || !*tmp)
|
||||||
tmp = DEFAULT_SHELL;
|
tmp = DEFAULT_SHELL;
|
||||||
/* setup_environment params: shell, clear_env, change_env, pw */
|
setup_environment(tmp,
|
||||||
setup_environment(tmp, !(opt & LOGIN_OPT_p), SETUP_ENV_CHANGEENV, pw);
|
(!(opt & LOGIN_OPT_p) * SETUP_ENV_CLEARENV) + SETUP_ENV_CHANGEENV,
|
||||||
|
pw);
|
||||||
|
|
||||||
motd();
|
motd();
|
||||||
|
|
||||||
|
@ -102,8 +102,10 @@ int su_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
opt_shell = pw->pw_shell;
|
opt_shell = pw->pw_shell;
|
||||||
|
|
||||||
change_identity(pw);
|
change_identity(pw);
|
||||||
/* setup_environment params: shell, clear_env, change_env, pw */
|
setup_environment(opt_shell,
|
||||||
setup_environment(opt_shell, flags & SU_OPT_l, !(flags & SU_OPT_mp), pw);
|
((flags & SU_OPT_l) / SU_OPT_l * SETUP_ENV_CLEARENV)
|
||||||
|
+ (!(flags & SU_OPT_mp) * SETUP_ENV_CHANGEENV),
|
||||||
|
pw);
|
||||||
IF_SELINUX(set_current_security_context(NULL);)
|
IF_SELINUX(set_current_security_context(NULL);)
|
||||||
|
|
||||||
/* Never returns */
|
/* Never returns */
|
||||||
|
@ -32,8 +32,9 @@ static void edit_file(const struct passwd *pas, const char *file)
|
|||||||
/* CHILD - change user and run editor */
|
/* CHILD - change user and run editor */
|
||||||
/* initgroups, setgid, setuid */
|
/* initgroups, setgid, setuid */
|
||||||
change_identity(pas);
|
change_identity(pas);
|
||||||
setup_environment(DEFAULT_SHELL, 0,
|
setup_environment(DEFAULT_SHELL,
|
||||||
SETUP_ENV_CHANGEENV | SETUP_ENV_TO_TMP, pas);
|
SETUP_ENV_CHANGEENV | SETUP_ENV_TO_TMP,
|
||||||
|
pas);
|
||||||
ptr = getenv("VISUAL");
|
ptr = getenv("VISUAL");
|
||||||
if (!ptr) {
|
if (!ptr) {
|
||||||
ptr = getenv("EDITOR");
|
ptr = getenv("EDITOR");
|
||||||
|
Loading…
Reference in New Issue
Block a user