multiuser_utils: Add bool chngdir option to setup_environment.
This commit is contained in:
parent
5cc11bf479
commit
eed40cb8c5
@ -172,7 +172,7 @@ authenticate_user(const char* prompt, const char* user, passwd** _passwd,
|
||||
|
||||
|
||||
status_t
|
||||
setup_environment(struct passwd* passwd, bool preserveEnvironment)
|
||||
setup_environment(struct passwd* passwd, bool preserveEnvironment, bool chngdir)
|
||||
{
|
||||
const char* term = getenv("TERM");
|
||||
if (!preserveEnvironment) {
|
||||
@ -200,12 +200,14 @@ setup_environment(struct passwd* passwd, bool preserveEnvironment)
|
||||
if (passwd->pw_uid && setuid(passwd->pw_uid) != 0)
|
||||
return errno;
|
||||
|
||||
const char* home = getenv("HOME");
|
||||
if (home == NULL)
|
||||
return B_ENTRY_NOT_FOUND;
|
||||
if (chngdir) {
|
||||
const char* home = getenv("HOME");
|
||||
if (home == NULL)
|
||||
return B_ENTRY_NOT_FOUND;
|
||||
|
||||
if (chdir(home) != 0)
|
||||
return errno;
|
||||
if (chdir(home) != 0)
|
||||
return errno;
|
||||
}
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
@ -22,7 +22,8 @@ status_t authenticate_user(const char* prompt, passwd* passwd, spwd* spwd,
|
||||
status_t authenticate_user(const char* prompt, const char* user,
|
||||
passwd** _passwd, spwd** _spwd, int maxTries, bool useStdio);
|
||||
|
||||
status_t setup_environment(struct passwd* passwd, bool preserveEnvironment);
|
||||
status_t setup_environment(struct passwd* passwd, bool preserveEnvironment,
|
||||
bool chngdir = true);
|
||||
|
||||
|
||||
#endif // MULTIUSER_UTILS_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user