summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDarren Tucker <dtucker@zip.com.au>2010-01-09 22:26:23 +1100
committerDarren Tucker <dtucker@zip.com.au>2010-01-09 22:26:23 +1100
commit37c1b3d6fc9043123f33e64051ea56656a5e7ef4 (patch)
tree644c0ffdcb779ac87c50a223f39ded86570f48a3
parent838891fe85308399c4f350f8174013987b6a2f85 (diff)
- djm@cvs.openbsd.org 2010/01/09 05:04:24
[mux.c sshpty.h clientloop.c sshtty.c] quell tc[gs]etattr warnings when forcing a tty (ssh -tt), since we usually don't actually have a tty to read/set; bz#1686 ok dtucker@
-rw-r--r--ChangeLog4
-rw-r--r--clientloop.c23
-rw-r--r--mux.c7
-rw-r--r--sshpty.h6
-rw-r--r--sshtty.c23
5 files changed, 37 insertions, 26 deletions
diff --git a/ChangeLog b/ChangeLog
index 3b7fb6456..b3ae6bdb4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -16,6 +16,10 @@
16 - jmc@cvs.openbsd.org 2010/01/09 03:36:00 16 - jmc@cvs.openbsd.org 2010/01/09 03:36:00
17 [sftp-server.8] 17 [sftp-server.8]
18 bad place to forget a comma... 18 bad place to forget a comma...
19 - djm@cvs.openbsd.org 2010/01/09 05:04:24
20 [mux.c sshpty.h clientloop.c sshtty.c]
21 quell tc[gs]etattr warnings when forcing a tty (ssh -tt), since we
22 usually don't actually have a tty to read/set; bz#1686 ok dtucker@
19 23
2020091208 2420091208
21 - (dtucker) OpenBSD CVS Sync 25 - (dtucker) OpenBSD CVS Sync
diff --git a/clientloop.c b/clientloop.c
index eca87777f..5793a6e91 100644
--- a/clientloop.c
+++ b/clientloop.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: clientloop.c,v 1.215 2009/11/17 05:31:44 djm Exp $ */ 1/* $OpenBSD: clientloop.c,v 1.216 2010/01/09 05:04:24 djm Exp $ */
2/* 2/*
3 * Author: Tatu Ylonen <ylo@cs.hut.fi> 3 * Author: Tatu Ylonen <ylo@cs.hut.fi>
4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -130,6 +130,9 @@ extern int muxserver_sock;
130 */ 130 */
131extern char *host; 131extern char *host;
132 132
133/* Force TTY allocation */
134extern int force_tty_flag;
135
133/* 136/*
134 * Flag to indicate that we have received a window change signal which has 137 * Flag to indicate that we have received a window change signal which has
135 * not yet been processed. This will cause a message indicating the new 138 * not yet been processed. This will cause a message indicating the new
@@ -610,7 +613,7 @@ client_suspend_self(Buffer *bin, Buffer *bout, Buffer *berr)
610 atomicio(vwrite, fileno(stderr), buffer_ptr(berr), 613 atomicio(vwrite, fileno(stderr), buffer_ptr(berr),
611 buffer_len(berr)); 614 buffer_len(berr));
612 615
613 leave_raw_mode(); 616 leave_raw_mode(force_tty_flag);
614 617
615 /* 618 /*
616 * Free (and clear) the buffer to reduce the amount of data that gets 619 * Free (and clear) the buffer to reduce the amount of data that gets
@@ -631,7 +634,7 @@ client_suspend_self(Buffer *bin, Buffer *bout, Buffer *berr)
631 buffer_init(bout); 634 buffer_init(bout);
632 buffer_init(berr); 635 buffer_init(berr);
633 636
634 enter_raw_mode(); 637 enter_raw_mode(force_tty_flag);
635} 638}
636 639
637static void 640static void
@@ -774,7 +777,7 @@ process_cmdline(void)
774 bzero(&fwd, sizeof(fwd)); 777 bzero(&fwd, sizeof(fwd));
775 fwd.listen_host = fwd.connect_host = NULL; 778 fwd.listen_host = fwd.connect_host = NULL;
776 779
777 leave_raw_mode(); 780 leave_raw_mode(force_tty_flag);
778 handler = signal(SIGINT, SIG_IGN); 781 handler = signal(SIGINT, SIG_IGN);
779 cmd = s = read_passphrase("\r\nssh> ", RP_ECHO); 782 cmd = s = read_passphrase("\r\nssh> ", RP_ECHO);
780 if (s == NULL) 783 if (s == NULL)
@@ -877,7 +880,7 @@ process_cmdline(void)
877 880
878out: 881out:
879 signal(SIGINT, handler); 882 signal(SIGINT, handler);
880 enter_raw_mode(); 883 enter_raw_mode(force_tty_flag);
881 if (cmd) 884 if (cmd)
882 xfree(cmd); 885 xfree(cmd);
883 if (fwd.listen_host != NULL) 886 if (fwd.listen_host != NULL)
@@ -996,7 +999,7 @@ process_escapes(Channel *c, Buffer *bin, Buffer *bout, Buffer *berr,
996 * more new connections). 999 * more new connections).
997 */ 1000 */
998 /* Restore tty modes. */ 1001 /* Restore tty modes. */
999 leave_raw_mode(); 1002 leave_raw_mode(force_tty_flag);
1000 1003
1001 /* Stop listening for new connections. */ 1004 /* Stop listening for new connections. */
1002 channel_stop_listening(); 1005 channel_stop_listening();
@@ -1291,7 +1294,7 @@ client_channel_closed(int id, void *arg)
1291{ 1294{
1292 channel_cancel_cleanup(id); 1295 channel_cancel_cleanup(id);
1293 session_closed = 1; 1296 session_closed = 1;
1294 leave_raw_mode(); 1297 leave_raw_mode(force_tty_flag);
1295} 1298}
1296 1299
1297/* 1300/*
@@ -1364,7 +1367,7 @@ client_loop(int have_pty, int escape_char_arg, int ssh2_chan_id)
1364 signal(SIGWINCH, window_change_handler); 1367 signal(SIGWINCH, window_change_handler);
1365 1368
1366 if (have_pty) 1369 if (have_pty)
1367 enter_raw_mode(); 1370 enter_raw_mode(force_tty_flag);
1368 1371
1369 if (compat20) { 1372 if (compat20) {
1370 session_ident = ssh2_chan_id; 1373 session_ident = ssh2_chan_id;
@@ -1498,7 +1501,7 @@ client_loop(int have_pty, int escape_char_arg, int ssh2_chan_id)
1498 channel_free_all(); 1501 channel_free_all();
1499 1502
1500 if (have_pty) 1503 if (have_pty)
1501 leave_raw_mode(); 1504 leave_raw_mode(force_tty_flag);
1502 1505
1503 /* restore blocking io */ 1506 /* restore blocking io */
1504 if (!isatty(fileno(stdin))) 1507 if (!isatty(fileno(stdin)))
@@ -2062,7 +2065,7 @@ client_init_dispatch(void)
2062void 2065void
2063cleanup_exit(int i) 2066cleanup_exit(int i)
2064{ 2067{
2065 leave_raw_mode(); 2068 leave_raw_mode(force_tty_flag);
2066 leave_non_blocking(); 2069 leave_non_blocking();
2067 if (options.control_path != NULL && muxserver_sock != -1) 2070 if (options.control_path != NULL && muxserver_sock != -1)
2068 unlink(options.control_path); 2071 unlink(options.control_path);
diff --git a/mux.c b/mux.c
index fac43a71f..239edd5f5 100644
--- a/mux.c
+++ b/mux.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: mux.c,v 1.8 2009/08/20 23:54:28 dtucker Exp $ */ 1/* $OpenBSD: mux.c,v 1.9 2010/01/09 05:04:24 djm Exp $ */
2/* 2/*
3 * Copyright (c) 2002-2008 Damien Miller <djm@openbsd.org> 3 * Copyright (c) 2002-2008 Damien Miller <djm@openbsd.org>
4 * 4 *
@@ -82,6 +82,7 @@
82 82
83/* from ssh.c */ 83/* from ssh.c */
84extern int tty_flag; 84extern int tty_flag;
85extern int force_tty_flag;
85extern Options options; 86extern Options options;
86extern int stdin_null_flag; 87extern int stdin_null_flag;
87extern char *host; 88extern char *host;
@@ -683,7 +684,7 @@ muxclient(const char *path)
683 signal(SIGWINCH, control_client_sigrelay); 684 signal(SIGWINCH, control_client_sigrelay);
684 685
685 if (tty_flag) 686 if (tty_flag)
686 enter_raw_mode(); 687 enter_raw_mode(force_tty_flag);
687 688
688 /* 689 /*
689 * Stick around until the controlee closes the client_fd. 690 * Stick around until the controlee closes the client_fd.
@@ -708,7 +709,7 @@ muxclient(const char *path)
708 } 709 }
709 710
710 close(sock); 711 close(sock);
711 leave_raw_mode(); 712 leave_raw_mode(force_tty_flag);
712 if (i > (int)sizeof(int)) 713 if (i > (int)sizeof(int))
713 fatal("%s: master returned too much data (%d > %lu)", 714 fatal("%s: master returned too much data (%d > %lu)",
714 __func__, i, (u_long)sizeof(int)); 715 __func__, i, (u_long)sizeof(int));
diff --git a/sshpty.h b/sshpty.h
index ac9003584..cfa322480 100644
--- a/sshpty.h
+++ b/sshpty.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: sshpty.h,v 1.11 2008/05/19 15:45:07 djm Exp $ */ 1/* $OpenBSD: sshpty.h,v 1.12 2010/01/09 05:04:24 djm Exp $ */
2 2
3/* 3/*
4 * Author: Tatu Ylonen <ylo@cs.hut.fi> 4 * Author: Tatu Ylonen <ylo@cs.hut.fi>
@@ -17,8 +17,8 @@
17#include <termios.h> 17#include <termios.h>
18 18
19struct termios *get_saved_tio(void); 19struct termios *get_saved_tio(void);
20void leave_raw_mode(void); 20void leave_raw_mode(int);
21void enter_raw_mode(void); 21void enter_raw_mode(int);
22 22
23int pty_allocate(int *, int *, char *, size_t); 23int pty_allocate(int *, int *, char *, size_t);
24void pty_release(const char *); 24void pty_release(const char *);
diff --git a/sshtty.c b/sshtty.c
index 21ade4e51..d214ce3bb 100644
--- a/sshtty.c
+++ b/sshtty.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: sshtty.c,v 1.13 2008/05/19 15:45:07 djm Exp $ */ 1/* $OpenBSD: sshtty.c,v 1.14 2010/01/09 05:04:24 djm Exp $ */
2/* 2/*
3 * Author: Tatu Ylonen <ylo@cs.hut.fi> 3 * Author: Tatu Ylonen <ylo@cs.hut.fi>
4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -54,23 +54,25 @@ get_saved_tio(void)
54} 54}
55 55
56void 56void
57leave_raw_mode(void) 57leave_raw_mode(int quiet)
58{ 58{
59 if (!_in_raw_mode) 59 if (!_in_raw_mode)
60 return; 60 return;
61 if (tcsetattr(fileno(stdin), TCSADRAIN, &_saved_tio) == -1) 61 if (tcsetattr(fileno(stdin), TCSADRAIN, &_saved_tio) == -1) {
62 perror("tcsetattr"); 62 if (!quiet)
63 else 63 perror("tcsetattr");
64 } else
64 _in_raw_mode = 0; 65 _in_raw_mode = 0;
65} 66}
66 67
67void 68void
68enter_raw_mode(void) 69enter_raw_mode(int quiet)
69{ 70{
70 struct termios tio; 71 struct termios tio;
71 72
72 if (tcgetattr(fileno(stdin), &tio) == -1) { 73 if (tcgetattr(fileno(stdin), &tio) == -1) {
73 perror("tcgetattr"); 74 if (!quiet)
75 perror("tcgetattr");
74 return; 76 return;
75 } 77 }
76 _saved_tio = tio; 78 _saved_tio = tio;
@@ -86,8 +88,9 @@ enter_raw_mode(void)
86 tio.c_oflag &= ~OPOST; 88 tio.c_oflag &= ~OPOST;
87 tio.c_cc[VMIN] = 1; 89 tio.c_cc[VMIN] = 1;
88 tio.c_cc[VTIME] = 0; 90 tio.c_cc[VTIME] = 0;
89 if (tcsetattr(fileno(stdin), TCSADRAIN, &tio) == -1) 91 if (tcsetattr(fileno(stdin), TCSADRAIN, &tio) == -1) {
90 perror("tcsetattr"); 92 if (!quiet)
91 else 93 perror("tcsetattr");
94 } else
92 _in_raw_mode = 1; 95 _in_raw_mode = 1;
93} 96}