forked from github/abduco
Change default command handling to not use out of scope variable
Should fix CID 121406.
This commit is contained in:
parent
62d31e784c
commit
42bb83bbb6
17
abduco.c
17
abduco.c
|
|
@ -573,6 +573,13 @@ int main(int argc, char *argv[]) {
|
||||||
int opt;
|
int opt;
|
||||||
bool force = false;
|
bool force = false;
|
||||||
char **cmd = NULL, action = '\0';
|
char **cmd = NULL, action = '\0';
|
||||||
|
|
||||||
|
char *default_cmd[4] = { "/bin/sh", "-c", getenv("ABDUCO_CMD"), NULL };
|
||||||
|
if (!default_cmd[2]) {
|
||||||
|
default_cmd[0] = "dvtm";
|
||||||
|
default_cmd[1] = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
server.name = basename(argv[0]);
|
server.name = basename(argv[0]);
|
||||||
gethostname(server.host+1, sizeof(server.host) - 1);
|
gethostname(server.host+1, sizeof(server.host) - 1);
|
||||||
|
|
||||||
|
|
@ -615,14 +622,8 @@ int main(int argc, char *argv[]) {
|
||||||
/* if yet more trailing arguments, they must be the command */
|
/* if yet more trailing arguments, they must be the command */
|
||||||
if (optind + 1 < argc)
|
if (optind + 1 < argc)
|
||||||
cmd = &argv[optind + 1];
|
cmd = &argv[optind + 1];
|
||||||
|
else
|
||||||
if (!cmd) {
|
cmd = default_cmd;
|
||||||
char *default_cmd = getenv("ABDUCO_CMD");
|
|
||||||
if (default_cmd)
|
|
||||||
cmd = (char*[]){ "/bin/sh", "-c", default_cmd, NULL };
|
|
||||||
else
|
|
||||||
cmd = (char*[]){ "dvtm", NULL };
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!action && !server.session_name)
|
if (!action && !server.session_name)
|
||||||
exit(list_session());
|
exit(list_session());
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue