diff options
-rw-r--r-- | ChangeLog | 3 | ||||
-rw-r--r-- | Makefile.in | 4 | ||||
-rw-r--r-- | sshtty.c | 96 | ||||
-rw-r--r-- | sshtty.h | 65 |
4 files changed, 165 insertions, 3 deletions
@@ -15,6 +15,7 @@ | |||
15 | - stevesk@cvs.openbsd.org 2001/04/14 17:04:42 | 15 | - stevesk@cvs.openbsd.org 2001/04/14 17:04:42 |
16 | [scp.c] | 16 | [scp.c] |
17 | 'T' handling rcp/scp sync; ok markus@ | 17 | 'T' handling rcp/scp sync; ok markus@ |
18 | - Missed sshtty.[ch] in Sync. | ||
18 | 19 | ||
19 | 20010414 | 20 | 20010414 |
20 | - Sync with OpenBSD glob.c, strlcat.c and vis.c changes | 21 | - Sync with OpenBSD glob.c, strlcat.c and vis.c changes |
@@ -5081,4 +5082,4 @@ | |||
5081 | - Wrote replacements for strlcpy and mkdtemp | 5082 | - Wrote replacements for strlcpy and mkdtemp |
5082 | - Released 1.0pre1 | 5083 | - Released 1.0pre1 |
5083 | 5084 | ||
5084 | $Id: ChangeLog,v 1.1115 2001/04/14 23:14:22 mouring Exp $ | 5085 | $Id: ChangeLog,v 1.1116 2001/04/14 23:21:50 mouring Exp $ |
diff --git a/Makefile.in b/Makefile.in index 4464194c1..2df721671 100644 --- a/Makefile.in +++ b/Makefile.in | |||
@@ -1,4 +1,4 @@ | |||
1 | # $Id: Makefile.in,v 1.166 2001/04/06 01:58:37 stevesk Exp $ | 1 | # $Id: Makefile.in,v 1.167 2001/04/14 23:21:51 mouring Exp $ |
2 | 2 | ||
3 | prefix=@prefix@ | 3 | prefix=@prefix@ |
4 | exec_prefix=@exec_prefix@ | 4 | exec_prefix=@exec_prefix@ |
@@ -46,7 +46,7 @@ TARGETS=ssh$(EXEEXT) sshd$(EXEEXT) ssh-add$(EXEEXT) ssh-keygen$(EXEEXT) ssh-keys | |||
46 | 46 | ||
47 | LIBSSH_OBJS=atomicio.o authfd.o authfile.o bufaux.o buffer.o canohost.o channels.o cipher.o cli.o compat.o compress.o crc32.o deattack.o dh.o dispatch.o mac.o hostfile.o key.o kex.o kexdh.o kexgex.o log.o match.o misc.o mpaux.o nchan.o packet.o radix.o rijndael.o entropy.o readpass.o rsa.o ssh-dss.o ssh-rsa.o tildexpand.o ttymodes.o uidswap.o uuencode.o xmalloc.o | 47 | LIBSSH_OBJS=atomicio.o authfd.o authfile.o bufaux.o buffer.o canohost.o channels.o cipher.o cli.o compat.o compress.o crc32.o deattack.o dh.o dispatch.o mac.o hostfile.o key.o kex.o kexdh.o kexgex.o log.o match.o misc.o mpaux.o nchan.o packet.o radix.o rijndael.o entropy.o readpass.o rsa.o ssh-dss.o ssh-rsa.o tildexpand.o ttymodes.o uidswap.o uuencode.o xmalloc.o |
48 | 48 | ||
49 | SSHOBJS= ssh.o sshconnect.o sshconnect1.o sshconnect2.o readconf.o clientloop.o | 49 | SSHOBJS= ssh.o sshconnect.o sshconnect1.o sshconnect2.o sshtty.o readconf.o clientloop.o |
50 | 50 | ||
51 | SSHDOBJS= sshd.o auth.o auth1.o auth2.o auth-chall.o auth2-chall.o auth-rhosts.o auth-options.o auth-krb4.o auth-pam.o auth2-pam.o auth-passwd.o auth-rsa.o auth-rh-rsa.o auth-sia.o sshpty.o sshlogin.o loginrec.o servconf.o serverloop.o md5crypt.o session.o groupaccess.o | 51 | SSHDOBJS= sshd.o auth.o auth1.o auth2.o auth-chall.o auth2-chall.o auth-rhosts.o auth-options.o auth-krb4.o auth-pam.o auth2-pam.o auth-passwd.o auth-rsa.o auth-rh-rsa.o auth-sia.o sshpty.o sshlogin.o loginrec.o servconf.o serverloop.o md5crypt.o session.o groupaccess.o |
52 | 52 | ||
diff --git a/sshtty.c b/sshtty.c new file mode 100644 index 000000000..78498908f --- /dev/null +++ b/sshtty.c | |||
@@ -0,0 +1,96 @@ | |||
1 | /* $OpenBSD: sshtty.c,v 1.1 2001/04/14 16:33:20 stevesk Exp $ */ | ||
2 | /* | ||
3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> | ||
4 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland | ||
5 | * All rights reserved | ||
6 | * | ||
7 | * As far as I am concerned, the code I have written for this software | ||
8 | * can be used freely for any purpose. Any derived versions of this | ||
9 | * software must be clearly marked as such, and if the derived work is | ||
10 | * incompatible with the protocol description in the RFC file, it must be | ||
11 | * called by a name other than "ssh" or "Secure Shell". | ||
12 | */ | ||
13 | /* | ||
14 | * Copyright (c) 2001 Markus Friedl. All rights reserved. | ||
15 | * Copyright (c) 2001 Kevin Steves. All rights reserved. | ||
16 | * | ||
17 | * Redistribution and use in source and binary forms, with or without | ||
18 | * modification, are permitted provided that the following conditions | ||
19 | * are met: | ||
20 | * 1. Redistributions of source code must retain the above copyright | ||
21 | * notice, this list of conditions and the following disclaimer. | ||
22 | * 2. Redistributions in binary form must reproduce the above copyright | ||
23 | * notice, this list of conditions and the following disclaimer in the | ||
24 | * documentation and/or other materials provided with the distribution. | ||
25 | * | ||
26 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | ||
27 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | ||
28 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | ||
29 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
30 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
31 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
32 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
33 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
34 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||
35 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
36 | */ | ||
37 | |||
38 | #include "includes.h" | ||
39 | |||
40 | #include "sshtty.h" | ||
41 | #include "log.h" | ||
42 | |||
43 | static struct termios _saved_tio; | ||
44 | static int _in_raw_mode = 0; | ||
45 | |||
46 | int | ||
47 | in_raw_mode(void) | ||
48 | { | ||
49 | return _in_raw_mode; | ||
50 | } | ||
51 | |||
52 | struct termios | ||
53 | get_saved_tio(void) | ||
54 | { | ||
55 | return _saved_tio; | ||
56 | } | ||
57 | |||
58 | void | ||
59 | leave_raw_mode(void) | ||
60 | { | ||
61 | if (!_in_raw_mode) | ||
62 | return; | ||
63 | if (tcsetattr(fileno(stdin), TCSADRAIN, &_saved_tio) == -1) | ||
64 | perror("tcsetattr"); | ||
65 | else | ||
66 | _in_raw_mode = 0; | ||
67 | |||
68 | fatal_remove_cleanup((void (*) (void *)) leave_raw_mode, NULL); | ||
69 | } | ||
70 | |||
71 | void | ||
72 | enter_raw_mode(void) | ||
73 | { | ||
74 | struct termios tio; | ||
75 | |||
76 | if (tcgetattr(fileno(stdin), &tio) == -1) { | ||
77 | perror("tcgetattr"); | ||
78 | return; | ||
79 | } | ||
80 | _saved_tio = tio; | ||
81 | tio.c_iflag |= IGNPAR; | ||
82 | tio.c_iflag &= ~(ISTRIP | INLCR | IGNCR | ICRNL | IXON | IXANY | IXOFF); | ||
83 | tio.c_lflag &= ~(ISIG | ICANON | ECHO | ECHOE | ECHOK | ECHONL); | ||
84 | #ifdef IEXTEN | ||
85 | tio.c_lflag &= ~IEXTEN; | ||
86 | #endif | ||
87 | tio.c_oflag &= ~OPOST; | ||
88 | tio.c_cc[VMIN] = 1; | ||
89 | tio.c_cc[VTIME] = 0; | ||
90 | if (tcsetattr(fileno(stdin), TCSADRAIN, &tio) == -1) | ||
91 | perror("tcsetattr"); | ||
92 | else | ||
93 | _in_raw_mode = 1; | ||
94 | |||
95 | fatal_add_cleanup((void (*) (void *)) leave_raw_mode, NULL); | ||
96 | } | ||
diff --git a/sshtty.h b/sshtty.h new file mode 100644 index 000000000..e29385e35 --- /dev/null +++ b/sshtty.h | |||
@@ -0,0 +1,65 @@ | |||
1 | /* $OpenBSD: sshtty.h,v 1.1 2001/04/14 16:33:20 stevesk Exp $ */ | ||
2 | /* | ||
3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> | ||
4 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland | ||
5 | * All rights reserved | ||
6 | * | ||
7 | * As far as I am concerned, the code I have written for this software | ||
8 | * can be used freely for any purpose. Any derived versions of this | ||
9 | * software must be clearly marked as such, and if the derived work is | ||
10 | * incompatible with the protocol description in the RFC file, it must be | ||
11 | * called by a name other than "ssh" or "Secure Shell". | ||
12 | */ | ||
13 | /* | ||
14 | * Copyright (c) 2001 Markus Friedl. All rights reserved. | ||
15 | * Copyright (c) 2001 Kevin Steves. All rights reserved. | ||
16 | * | ||
17 | * Redistribution and use in source and binary forms, with or without | ||
18 | * modification, are permitted provided that the following conditions | ||
19 | * are met: | ||
20 | * 1. Redistributions of source code must retain the above copyright | ||
21 | * notice, this list of conditions and the following disclaimer. | ||
22 | * 2. Redistributions in binary form must reproduce the above copyright | ||
23 | * notice, this list of conditions and the following disclaimer in the | ||
24 | * documentation and/or other materials provided with the distribution. | ||
25 | * | ||
26 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | ||
27 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | ||
28 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | ||
29 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
30 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
31 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
32 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
33 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
34 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||
35 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
36 | */ | ||
37 | |||
38 | #ifndef SSHTTY_H | ||
39 | #define SSHTTY_H | ||
40 | |||
41 | #include <termios.h> | ||
42 | |||
43 | /* | ||
44 | * Accessor function indicating whether we are in raw mode. Set by | ||
45 | * enter_raw_mode() and leave_raw_mode(). | ||
46 | */ | ||
47 | int in_raw_mode(void); | ||
48 | |||
49 | /* | ||
50 | * Return terminal modes, as saved by enter_raw_mode(). | ||
51 | */ | ||
52 | struct termios get_saved_tio(void); | ||
53 | |||
54 | /* | ||
55 | * Returns the user's terminal to normal mode if it had been | ||
56 | * put in raw mode. | ||
57 | */ | ||
58 | void leave_raw_mode(void); | ||
59 | |||
60 | /* | ||
61 | * Puts the user's terminal in raw mode. | ||
62 | */ | ||
63 | void enter_raw_mode(void); | ||
64 | |||
65 | #endif | ||