=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/ssh/sshconnect.c,v retrieving revision 1.162.2.1 retrieving revision 1.162.2.2 diff -u -r1.162.2.1 -r1.162.2.2 --- src/usr.bin/ssh/sshconnect.c 2005/09/04 18:40:10 1.162.2.1 +++ src/usr.bin/ssh/sshconnect.c 2006/02/03 02:53:45 1.162.2.2 @@ -13,7 +13,7 @@ */ #include "includes.h" -RCSID("$OpenBSD: sshconnect.c,v 1.162.2.1 2005/09/04 18:40:10 brad Exp $"); +RCSID("$OpenBSD: sshconnect.c,v 1.162.2.2 2006/02/03 02:53:45 brad Exp $"); #include @@ -31,13 +31,12 @@ #include "readconf.h" #include "atomicio.h" #include "misc.h" - #include "dns.h" char *client_version_string = NULL; char *server_version_string = NULL; -int matching_host_key_dns = 0; +static int matching_host_key_dns = 0; /* import */ extern Options options; @@ -596,7 +595,7 @@ file_key = key_new(host_key->type); /* - * Check if the host key is present in the user\'s list of known + * Check if the host key is present in the user's list of known * hosts or in the systemwide list. */ host_file = user_hostfile; @@ -1026,4 +1025,40 @@ error("Please contact your system administrator."); xfree(fp); +} + +/* + * Execute a local command + */ +int +ssh_local_cmd(const char *args) +{ + char *shell; + pid_t pid; + int status; + + if (!options.permit_local_command || + args == NULL || !*args) + return (1); + + if ((shell = getenv("SHELL")) == NULL) + shell = _PATH_BSHELL; + + pid = fork(); + if (pid == 0) { + debug3("Executing %s -c \"%s\"", shell, args); + execl(shell, shell, "-c", args, (char *)NULL); + error("Couldn't execute %s -c \"%s\": %s", + shell, args, strerror(errno)); + _exit(1); + } else if (pid == -1) + fatal("fork failed: %.100s", strerror(errno)); + while (waitpid(pid, &status, 0) == -1) + if (errno != EINTR) + fatal("Couldn't wait for child: %s", strerror(errno)); + + if (!WIFEXITED(status)) + return (1); + + return (WEXITSTATUS(status)); }