Commit 49b79fa0 authored by Matt Johnston's avatar Matt Johnston
Browse files

Rename HAVE_FORK to USE_VFORK

It makes it a bit more obvious why there's a test there since HAVE_FORK
is the normal case.
parent c957edbe
......@@ -443,7 +443,7 @@ int spawn_command(void(*exec_fn)(void *user_data), void *exec_data,
return DROPBEAR_FAILURE;
}
#ifndef HAVE_FORK
#ifdef USE_VFORK
pid = vfork();
#else
pid = fork();
......
......@@ -130,7 +130,7 @@ do_local_cmd(arglist *a)
fprintf(stderr, " %s", a->list[i]);
fprintf(stderr, "\n");
}
#ifndef HAVE_FORK
#ifdef USE_VFORK
pid = vfork();
#else
pid = fork();
......@@ -141,7 +141,7 @@ do_local_cmd(arglist *a)
if (pid == 0) {
execvp(a->list[0], a->list);
perror(a->list[0]);
#ifndef HAVE_FORK
#ifdef USE_VFORK
_exit(1);
#else
exit(1);
......@@ -210,12 +210,12 @@ do_cmd(char *host, char *remuser, char *cmd, int *fdin, int *fdout, int argc)
/* uClinux needs to build the args here before vforking,
otherwise we do it later on. */
#ifndef HAVE_FORK
#ifdef USE_VFORK
arg_setup(host, remuser, cmd);
#endif
/* Fork a child to execute the command on the remote host using ssh. */
#ifndef HAVE_FORK
#ifdef USE_VFORK
do_cmd_pid = vfork();
#else
do_cmd_pid = fork();
......@@ -230,13 +230,13 @@ do_cmd(char *host, char *remuser, char *cmd, int *fdin, int *fdout, int argc)
close(pin[0]);
close(pout[1]);
#ifndef HAVE_FORK
#ifdef USE_VFORK
arg_setup(host, remuser, cmd);
#endif
execvp(ssh_program, args.list);
perror(ssh_program);
#ifndef HAVE_FORK
#ifdef USE_VFORK
_exit(1);
#else
exit(1);
......@@ -245,7 +245,7 @@ do_cmd(char *host, char *remuser, char *cmd, int *fdin, int *fdout, int argc)
fatal("fork: %s", strerror(errno));
}
#ifndef HAVE_FORK
#ifdef USE_VFORK
/* clean up command */
/* pop cmd */
xfree(args.list[args.num-1]);
......
......@@ -218,7 +218,7 @@ struct serversession {
/* The resolved remote address, used for lastlog etc */
char *remotehost;
#ifndef HAVE_FORK
#ifdef USE_VFORK
pid_t server_pid;
#endif
......
......@@ -658,7 +658,7 @@ static int sessioncommand(struct Channel *channel, struct ChanSess *chansess,
/* uClinux will vfork(), so there'll be a race as
connection_string is freed below. */
#ifdef HAVE_FORK
#ifndef USE_VFORK
chansess->connection_string = make_connection_string();
#endif
......@@ -670,7 +670,7 @@ static int sessioncommand(struct Channel *channel, struct ChanSess *chansess,
ret = ptycommand(channel, chansess);
}
#ifdef HAVE_FORK
#ifndef USE_VFORK
m_free(chansess->connection_string);
#endif
......@@ -745,7 +745,7 @@ static int ptycommand(struct Channel *channel, struct ChanSess *chansess) {
return DROPBEAR_FAILURE;
}
#ifndef HAVE_FORK
#ifdef USE_VFORK
pid = vfork();
#else
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
* hostkey. can't think of a workaround to clear it */
#ifdef HAVE_FORK
#ifndef USE_VFORK
/* wipe the hostkey */
sign_key_free(svr_opts.hostkey);
svr_opts.hostkey = NULL;
......
......@@ -84,7 +84,7 @@ void svr_session(int sock, int childpipe) {
/* Initialise server specific parts of the session */
svr_ses.childpipe = childpipe;
#ifndef HAVE_FORK
#ifdef USE_VFORK
svr_ses.server_pid = getpid();
#endif
svr_authinitialise();
......@@ -157,12 +157,10 @@ void svr_dropbear_exit(int exitcode, const char* format, va_list param) {
_dropbear_log(LOG_INFO, fmtbuf, param);
#ifndef HAVE_FORK
/* only the main server process should cleanup - we don't want
#ifdef USE_VFORK
/* For uclinux only the main server process should cleanup - we don't want
* forked children doing that */
if (svr_ses.server_pid == getpid())
#else
if (1)
#endif
{
/* free potential public key options */
......
......@@ -216,4 +216,10 @@
#define IS_DROPBEAR_SERVER 0
#define IS_DROPBEAR_CLIENT 0
#endif
#endif /* neither DROPBEAR_SERVER nor DROPBEAR_CLIENT */
#ifndef HAVE_FORK
#define USE_VFORK
#endif /* don't HAVE_FORK */
/* no include guard for this file */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment