mirror of
https://github.com/clearml/dropbear
synced 2025-06-16 19:28:49 +00:00
check for fork() and not __uClinux__
This commit is contained in:
parent
33ae2be52e
commit
c957edbe75
@ -616,7 +616,7 @@ AC_PROG_GCC_TRADITIONAL
|
|||||||
AC_FUNC_MEMCMP
|
AC_FUNC_MEMCMP
|
||||||
AC_FUNC_SELECT_ARGTYPES
|
AC_FUNC_SELECT_ARGTYPES
|
||||||
AC_TYPE_SIGNAL
|
AC_TYPE_SIGNAL
|
||||||
AC_CHECK_FUNCS([dup2 getspnam getusershell memset putenv select socket strdup clearenv strlcpy strlcat daemon basename _getpty getaddrinfo freeaddrinfo getnameinfo])
|
AC_CHECK_FUNCS([dup2 getspnam getusershell memset putenv select socket strdup clearenv strlcpy strlcat daemon basename _getpty getaddrinfo freeaddrinfo getnameinfo fork])
|
||||||
|
|
||||||
AC_SEARCH_LIBS(basename, gen, AC_DEFINE(HAVE_BASENAME))
|
AC_SEARCH_LIBS(basename, gen, AC_DEFINE(HAVE_BASENAME))
|
||||||
|
|
||||||
|
2
dbutil.c
2
dbutil.c
@ -443,7 +443,7 @@ int spawn_command(void(*exec_fn)(void *user_data), void *exec_data,
|
|||||||
return DROPBEAR_FAILURE;
|
return DROPBEAR_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __uClinux__
|
#ifndef HAVE_FORK
|
||||||
pid = vfork();
|
pid = vfork();
|
||||||
#else
|
#else
|
||||||
pid = fork();
|
pid = fork();
|
||||||
|
55
scp.c
55
scp.c
@ -130,22 +130,22 @@ do_local_cmd(arglist *a)
|
|||||||
fprintf(stderr, " %s", a->list[i]);
|
fprintf(stderr, " %s", a->list[i]);
|
||||||
fprintf(stderr, "\n");
|
fprintf(stderr, "\n");
|
||||||
}
|
}
|
||||||
#ifdef __uClinux__
|
#ifndef HAVE_FORK
|
||||||
pid = vfork();
|
pid = vfork();
|
||||||
#else
|
#else
|
||||||
pid = fork();
|
pid = fork();
|
||||||
#endif /* __uClinux__ */
|
#endif
|
||||||
if (pid == -1)
|
if (pid == -1)
|
||||||
fatal("do_local_cmd: fork: %s", strerror(errno));
|
fatal("do_local_cmd: fork: %s", strerror(errno));
|
||||||
|
|
||||||
if (pid == 0) {
|
if (pid == 0) {
|
||||||
execvp(a->list[0], a->list);
|
execvp(a->list[0], a->list);
|
||||||
perror(a->list[0]);
|
perror(a->list[0]);
|
||||||
#ifdef __uClinux__
|
#ifndef HAVE_FORK
|
||||||
_exit(1);
|
_exit(1);
|
||||||
#else
|
#else
|
||||||
exit(1);
|
exit(1);
|
||||||
#endif /* __uClinux__ */
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
do_cmd_pid = pid;
|
do_cmd_pid = pid;
|
||||||
@ -171,6 +171,16 @@ do_local_cmd(arglist *a)
|
|||||||
* assigns the input and output file descriptors on success.
|
* assigns the input and output file descriptors on success.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
static void
|
||||||
|
arg_setup(char *host, char *remuser, char *cmd)
|
||||||
|
{
|
||||||
|
replacearg(&args, 0, "%s", ssh_program);
|
||||||
|
if (remuser != NULL)
|
||||||
|
addargs(&args, "-l%s", remuser);
|
||||||
|
addargs(&args, "%s", host);
|
||||||
|
addargs(&args, "%s", cmd);
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
do_cmd(char *host, char *remuser, char *cmd, int *fdin, int *fdout, int argc)
|
do_cmd(char *host, char *remuser, char *cmd, int *fdin, int *fdout, int argc)
|
||||||
{
|
{
|
||||||
@ -200,20 +210,16 @@ do_cmd(char *host, char *remuser, char *cmd, int *fdin, int *fdout, int argc)
|
|||||||
|
|
||||||
/* uClinux needs to build the args here before vforking,
|
/* uClinux needs to build the args here before vforking,
|
||||||
otherwise we do it later on. */
|
otherwise we do it later on. */
|
||||||
#ifdef __uClinux__
|
#ifndef HAVE_FORK
|
||||||
replacearg(&args, 0, "%s", ssh_program);
|
arg_setup(host, remuser, cmd);
|
||||||
if (remuser != NULL)
|
#endif
|
||||||
addargs(&args, "-l%s", remuser);
|
|
||||||
addargs(&args, "%s", host);
|
|
||||||
addargs(&args, "%s", cmd);
|
|
||||||
#endif /* __uClinux__ */
|
|
||||||
|
|
||||||
/* Fork a child to execute the command on the remote host using ssh. */
|
/* Fork a child to execute the command on the remote host using ssh. */
|
||||||
#ifdef __uClinux__
|
#ifndef HAVE_FORK
|
||||||
do_cmd_pid = vfork();
|
do_cmd_pid = vfork();
|
||||||
#else
|
#else
|
||||||
do_cmd_pid = fork();
|
do_cmd_pid = fork();
|
||||||
#endif /* __uClinux__ */
|
#endif
|
||||||
|
|
||||||
if (do_cmd_pid == 0) {
|
if (do_cmd_pid == 0) {
|
||||||
/* Child. */
|
/* Child. */
|
||||||
@ -224,27 +230,22 @@ do_cmd(char *host, char *remuser, char *cmd, int *fdin, int *fdout, int argc)
|
|||||||
close(pin[0]);
|
close(pin[0]);
|
||||||
close(pout[1]);
|
close(pout[1]);
|
||||||
|
|
||||||
#ifndef __uClinux__
|
#ifndef HAVE_FORK
|
||||||
replacearg(&args, 0, "%s", ssh_program);
|
arg_setup(host, remuser, cmd);
|
||||||
if (remuser != NULL)
|
#endif
|
||||||
addargs(&args, "-l%s", remuser);
|
|
||||||
addargs(&args, "%s", host);
|
|
||||||
addargs(&args, "%s", cmd);
|
|
||||||
#endif /* __uClinux__ */
|
|
||||||
|
|
||||||
execvp(ssh_program, args.list);
|
execvp(ssh_program, args.list);
|
||||||
perror(ssh_program);
|
perror(ssh_program);
|
||||||
#ifndef __uClinux__
|
#ifndef HAVE_FORK
|
||||||
exit(1);
|
|
||||||
#else
|
|
||||||
_exit(1);
|
_exit(1);
|
||||||
#endif /* __uClinux__ */
|
#else
|
||||||
|
exit(1);
|
||||||
|
#endif
|
||||||
} else if (do_cmd_pid == -1) {
|
} else if (do_cmd_pid == -1) {
|
||||||
fatal("fork: %s", strerror(errno));
|
fatal("fork: %s", strerror(errno));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef HAVE_FORK
|
||||||
#ifdef __uClinux__
|
|
||||||
/* clean up command */
|
/* clean up command */
|
||||||
/* pop cmd */
|
/* pop cmd */
|
||||||
xfree(args.list[args.num-1]);
|
xfree(args.list[args.num-1]);
|
||||||
@ -260,7 +261,7 @@ do_cmd(char *host, char *remuser, char *cmd, int *fdin, int *fdout, int argc)
|
|||||||
args.list[args.num-1]=NULL;
|
args.list[args.num-1]=NULL;
|
||||||
args.num--;
|
args.num--;
|
||||||
}
|
}
|
||||||
#endif /* __uClinux__ */
|
#endif
|
||||||
|
|
||||||
/* Parent. Close the other side, and return the local side. */
|
/* Parent. Close the other side, and return the local side. */
|
||||||
close(pin[0]);
|
close(pin[0]);
|
||||||
|
@ -218,7 +218,7 @@ struct serversession {
|
|||||||
/* The resolved remote address, used for lastlog etc */
|
/* The resolved remote address, used for lastlog etc */
|
||||||
char *remotehost;
|
char *remotehost;
|
||||||
|
|
||||||
#ifdef __uClinux__
|
#ifndef HAVE_FORK
|
||||||
pid_t server_pid;
|
pid_t server_pid;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -658,7 +658,7 @@ static int sessioncommand(struct Channel *channel, struct ChanSess *chansess,
|
|||||||
|
|
||||||
/* uClinux will vfork(), so there'll be a race as
|
/* uClinux will vfork(), so there'll be a race as
|
||||||
connection_string is freed below. */
|
connection_string is freed below. */
|
||||||
#ifndef __uClinux__
|
#ifdef HAVE_FORK
|
||||||
chansess->connection_string = make_connection_string();
|
chansess->connection_string = make_connection_string();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -670,7 +670,7 @@ static int sessioncommand(struct Channel *channel, struct ChanSess *chansess,
|
|||||||
ret = ptycommand(channel, chansess);
|
ret = ptycommand(channel, chansess);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef __uClinux__
|
#ifdef HAVE_FORK
|
||||||
m_free(chansess->connection_string);
|
m_free(chansess->connection_string);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -745,7 +745,7 @@ static int ptycommand(struct Channel *channel, struct ChanSess *chansess) {
|
|||||||
return DROPBEAR_FAILURE;
|
return DROPBEAR_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __uClinux__
|
#ifndef HAVE_FORK
|
||||||
pid = vfork();
|
pid = vfork();
|
||||||
#else
|
#else
|
||||||
pid = fork();
|
pid = fork();
|
||||||
@ -865,7 +865,7 @@ static void execchild(void *user_data) {
|
|||||||
|
|
||||||
/* with uClinux we'll have vfork()ed, so don't want to overwrite the
|
/* with uClinux we'll have vfork()ed, so don't want to overwrite the
|
||||||
* hostkey. can't think of a workaround to clear it */
|
* hostkey. can't think of a workaround to clear it */
|
||||||
#ifndef __uClinux__
|
#ifdef HAVE_FORK
|
||||||
/* wipe the hostkey */
|
/* wipe the hostkey */
|
||||||
sign_key_free(svr_opts.hostkey);
|
sign_key_free(svr_opts.hostkey);
|
||||||
svr_opts.hostkey = NULL;
|
svr_opts.hostkey = NULL;
|
||||||
|
@ -84,7 +84,7 @@ void svr_session(int sock, int childpipe) {
|
|||||||
|
|
||||||
/* Initialise server specific parts of the session */
|
/* Initialise server specific parts of the session */
|
||||||
svr_ses.childpipe = childpipe;
|
svr_ses.childpipe = childpipe;
|
||||||
#ifdef __uClinux__
|
#ifndef HAVE_FORK
|
||||||
svr_ses.server_pid = getpid();
|
svr_ses.server_pid = getpid();
|
||||||
#endif
|
#endif
|
||||||
svr_authinitialise();
|
svr_authinitialise();
|
||||||
@ -157,7 +157,7 @@ void svr_dropbear_exit(int exitcode, const char* format, va_list param) {
|
|||||||
|
|
||||||
_dropbear_log(LOG_INFO, fmtbuf, param);
|
_dropbear_log(LOG_INFO, fmtbuf, param);
|
||||||
|
|
||||||
#ifdef __uClinux__
|
#ifndef HAVE_FORK
|
||||||
/* only the main server process should cleanup - we don't want
|
/* only the main server process should cleanup - we don't want
|
||||||
* forked children doing that */
|
* forked children doing that */
|
||||||
if (svr_ses.server_pid == getpid())
|
if (svr_ses.server_pid == getpid())
|
||||||
|
Loading…
Reference in New Issue
Block a user