summaryrefslogtreecommitdiff
path: root/sshconnect.c
diff options
context:
space:
mode:
Diffstat (limited to 'sshconnect.c')
-rw-r--r--sshconnect.c43
1 files changed, 39 insertions, 4 deletions
diff --git a/sshconnect.c b/sshconnect.c
index ba7b9b71e..64ffec240 100644
--- a/sshconnect.c
+++ b/sshconnect.c
@@ -13,7 +13,7 @@
13 */ 13 */
14 14
15#include "includes.h" 15#include "includes.h"
16RCSID("$OpenBSD: sshconnect.c,v 1.168 2005/07/17 07:17:55 djm Exp $"); 16RCSID("$OpenBSD: sshconnect.c,v 1.171 2005/12/06 22:38:27 reyk Exp $");
17 17
18#include <openssl/bn.h> 18#include <openssl/bn.h>
19 19
@@ -31,13 +31,12 @@ RCSID("$OpenBSD: sshconnect.c,v 1.168 2005/07/17 07:17:55 djm Exp $");
31#include "readconf.h" 31#include "readconf.h"
32#include "atomicio.h" 32#include "atomicio.h"
33#include "misc.h" 33#include "misc.h"
34
35#include "dns.h" 34#include "dns.h"
36 35
37char *client_version_string = NULL; 36char *client_version_string = NULL;
38char *server_version_string = NULL; 37char *server_version_string = NULL;
39 38
40int matching_host_key_dns = 0; 39static int matching_host_key_dns = 0;
41 40
42/* import */ 41/* import */
43extern Options options; 42extern Options options;
@@ -604,7 +603,7 @@ check_host_key(char *host, struct sockaddr *hostaddr, Key *host_key,
604 file_key = key_new(host_key->type); 603 file_key = key_new(host_key->type);
605 604
606 /* 605 /*
607 * Check if the host key is present in the user\'s list of known 606 * Check if the host key is present in the user's list of known
608 * hosts or in the systemwide list. 607 * hosts or in the systemwide list.
609 */ 608 */
610 host_file = user_hostfile; 609 host_file = user_hostfile;
@@ -1035,3 +1034,39 @@ warn_changed_key(Key *host_key)
1035 1034
1036 xfree(fp); 1035 xfree(fp);
1037} 1036}
1037
1038/*
1039 * Execute a local command
1040 */
1041int
1042ssh_local_cmd(const char *args)
1043{
1044 char *shell;
1045 pid_t pid;
1046 int status;
1047
1048 if (!options.permit_local_command ||
1049 args == NULL || !*args)
1050 return (1);
1051
1052 if ((shell = getenv("SHELL")) == NULL)
1053 shell = _PATH_BSHELL;
1054
1055 pid = fork();
1056 if (pid == 0) {
1057 debug3("Executing %s -c \"%s\"", shell, args);
1058 execl(shell, shell, "-c", args, (char *)NULL);
1059 error("Couldn't execute %s -c \"%s\": %s",
1060 shell, args, strerror(errno));
1061 _exit(1);
1062 } else if (pid == -1)
1063 fatal("fork failed: %.100s", strerror(errno));
1064 while (waitpid(pid, &status, 0) == -1)
1065 if (errno != EINTR)
1066 fatal("Couldn't wait for child: %s", strerror(errno));
1067
1068 if (!WIFEXITED(status))
1069 return (1);
1070
1071 return (WEXITSTATUS(status));
1072}