mirror of
http://galexander.org/git/simplesshd.git
synced 2025-07-14 06:48:05 +00:00
su is not a login shell, so if it's in the shell's filename, don't put
"-" before argv[0], but do put it in argv[1] because su accepts it as a regular parameter ("-su" was breaking busybox)
This commit is contained in:
parent
ccdb6dd87c
commit
43cd46fd0d
@ -598,19 +598,20 @@ void run_shell_command(const char* cmd, unsigned int maxfd, char* usershell) {
|
|||||||
|
|
||||||
if (cmd != NULL) {
|
if (cmd != NULL) {
|
||||||
argv[0] = baseshell;
|
argv[0] = baseshell;
|
||||||
|
argv[1] = "-c";
|
||||||
|
argv[2] = (char*)cmd;
|
||||||
|
argv[3] = NULL;
|
||||||
|
} else if (strstr(usershell, "su")) {
|
||||||
|
/* busybox requires "su" in argv[0], so don't treat it like a
|
||||||
|
* command shell */
|
||||||
|
argv[0] = baseshell;
|
||||||
|
argv[1] = "-";
|
||||||
|
argv[2] = NULL;
|
||||||
} else {
|
} else {
|
||||||
/* a login shell should be "-bash" for "/bin/bash" etc */
|
/* a login shell should be "-bash" for "/bin/bash" etc */
|
||||||
int len = strlen(baseshell) + 2; /* 2 for "-" */
|
int len = strlen(baseshell) + 2; /* 2 for "-" */
|
||||||
argv[0] = (char*)m_malloc(len);
|
argv[0] = (char*)m_malloc(len);
|
||||||
snprintf(argv[0], len, "-%s", baseshell);
|
snprintf(argv[0], len, "-%s", baseshell);
|
||||||
}
|
|
||||||
|
|
||||||
if (cmd != NULL) {
|
|
||||||
argv[1] = "-c";
|
|
||||||
argv[2] = (char*)cmd;
|
|
||||||
argv[3] = NULL;
|
|
||||||
} else {
|
|
||||||
/* construct a shell of the form "-bash" etc */
|
|
||||||
argv[1] = NULL;
|
argv[1] = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user