diff options
author | Damien Miller <djm@mindrot.org> | 2005-12-13 19:29:02 +1100 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2005-12-13 19:29:02 +1100 |
commit | d27b947178df3689bfb7fdfb62a5f1337ef73481 (patch) | |
tree | c8678325c355b3602bdabca16da1baa8707818eb /sshconnect.c | |
parent | 6dbdb6afeec1820b2799c2693fc8e8b364be8228 (diff) |
- reyk@cvs.openbsd.org 2005/12/06 22:38:28
[auth-options.c auth-options.h channels.c channels.h clientloop.c]
[misc.c misc.h readconf.c readconf.h scp.c servconf.c servconf.h]
[serverloop.c sftp.c ssh.1 ssh.c ssh_config ssh_config.5 sshconnect.c]
[sshconnect.h sshd.8 sshd_config sshd_config.5]
Add support for tun(4) forwarding over OpenSSH, based on an idea and
initial channel code bits by markus@. This is a simple and easy way to
use OpenSSH for ad hoc virtual private network connections, e.g.
administrative tunnels or secure wireless access. It's based on a new
ssh channel and works similar to the existing TCP forwarding support,
except that it depends on the tun(4) network interface on both ends of
the connection for layer 2 or layer 3 tunneling. This diff also adds
support for LocalCommand in the ssh(1) client.
ok djm@, markus@, jmc@ (manpages), tested and discussed with others
Diffstat (limited to 'sshconnect.c')
-rw-r--r-- | sshconnect.c | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/sshconnect.c b/sshconnect.c index 2245a8af6..64ffec240 100644 --- a/sshconnect.c +++ b/sshconnect.c | |||
@@ -13,7 +13,7 @@ | |||
13 | */ | 13 | */ |
14 | 14 | ||
15 | #include "includes.h" | 15 | #include "includes.h" |
16 | RCSID("$OpenBSD: sshconnect.c,v 1.170 2005/10/30 08:52:18 djm Exp $"); | 16 | RCSID("$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 | ||
@@ -1034,3 +1034,39 @@ warn_changed_key(Key *host_key) | |||
1034 | 1034 | ||
1035 | xfree(fp); | 1035 | xfree(fp); |
1036 | } | 1036 | } |
1037 | |||
1038 | /* | ||
1039 | * Execute a local command | ||
1040 | */ | ||
1041 | int | ||
1042 | ssh_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 | } | ||