Skip to content

Commit

Permalink
Unset SSH_ORIGINAL_COMMAND in forked slave
Browse files Browse the repository at this point in the history
If we have a SSH_ORIGINAL_COMMAND without a "--slave" in it and fork a
lokal slave which inherits the environment, we run into a fork bomb
because SSH_ORIGINAL_COMMAND will override the slaves argv making it a
master.

Under normal conditions, this can't happen because the
SSH_ORIGINAL_COMMAND from ssh-config is supposed to contain "--slave".
We can only run into that situation with configuration error or a manual
override during debugging.

Anyway, unset SSH_ORIGINAL_COMMAND in the forked slave to avoid the
situation which is difficult to analye.
  • Loading branch information
donald committed Jun 8, 2022
1 parent 4aae63e commit ea00fe4
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions cmirror.c
Original file line number Diff line number Diff line change
Expand Up @@ -1196,6 +1196,8 @@ static void master(char *master_path, char *slave_user, char *slave, char *slave
unlink(unix_socket_name);
}

unsetenv("SSH_ORIGINAL_COMMAND");

execvp(args->pdata[0], (char **)args->pdata);
die("exec %s: %m\n", args->pdata[0]);
}
Expand Down

0 comments on commit ea00fe4

Please sign in to comment.