1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
diff -urNp -x '*.orig' openssh-8.4p1.org/clientloop.c openssh-8.4p1/clientloop.c
--- openssh-8.4p1.org/clientloop.c 2020-09-27 09:25:01.000000000 +0200
+++ openssh-8.4p1/clientloop.c 2021-03-01 11:29:10.909905265 +0100
@@ -127,6 +127,9 @@ extern int fork_after_authentication_fla
/* Control socket */
extern int muxserver_sock; /* XXX use mux_client_cleanup() instead */
+/* if we process SIGPIPE */
+extern int enable_sigpipe;
+
/*
* Name of the host we are connecting to. This is the name given on the
* command line, or the Hostname specified for the user-supplied name in a
@@ -1301,6 +1304,8 @@ client_loop(struct ssh *ssh, int have_pt
ssh_signal(SIGQUIT, signal_handler);
if (ssh_signal(SIGTERM, SIG_IGN) != SIG_IGN)
ssh_signal(SIGTERM, signal_handler);
+ if (enable_sigpipe)
+ signal(SIGPIPE, signal_handler);
ssh_signal(SIGWINCH, window_change_handler);
if (have_pty)
diff -urNp -x '*.orig' openssh-8.4p1.org/ssh.0 openssh-8.4p1/ssh.0
--- openssh-8.4p1.org/ssh.0 2020-09-27 09:42:10.000000000 +0200
+++ openssh-8.4p1/ssh.0 2021-03-01 11:29:10.909905265 +0100
@@ -446,6 +446,8 @@ DESCRIPTION
-y Send log information using the syslog(3) system module. By
default this information is sent to stderr.
+ -Z Enable SIGPIPE processing.
+
ssh may additionally obtain configuration data from a per-user
configuration file and a system-wide configuration file. The file format
and configuration options are described in ssh_config(5).
diff -urNp -x '*.orig' openssh-8.4p1.org/ssh.1 openssh-8.4p1/ssh.1
--- openssh-8.4p1.org/ssh.1 2020-09-27 09:25:01.000000000 +0200
+++ openssh-8.4p1/ssh.1 2021-03-01 11:29:10.909905265 +0100
@@ -42,7 +42,7 @@
.Nd OpenSSH remote login client
.Sh SYNOPSIS
.Nm ssh
-.Op Fl 46AaCfGgKkMNnqsTtVvXxYy
+.Op Fl 46AaCfGgKkMNnqsTtVvXxYyZ
.Op Fl B Ar bind_interface
.Op Fl b Ar bind_address
.Op Fl c Ar cipher_spec
@@ -142,6 +142,11 @@ on the local machine as the source addre
of the connection.
Only useful on systems with more than one address.
.Pp
+.It Fl Z
+Enables processing of SIGPIPE. Useful when using ssh output as input for
+another process, for example in a shell script. Be careful - it may break
+port/X11 forwarding when used.
+.Pp
.It Fl C
Requests compression of all data (including stdin, stdout, stderr, and
data for forwarded X11, TCP and
diff -urNp -x '*.orig' openssh-8.4p1.org/ssh.c openssh-8.4p1/ssh.c
--- openssh-8.4p1.org/ssh.c 2020-09-27 09:25:01.000000000 +0200
+++ openssh-8.4p1/ssh.c 2021-03-01 11:29:10.909905265 +0100
@@ -190,6 +190,9 @@ struct sshbuf *command;
/* command to be executed */
struct sshbuf *command;
+/* Enable sigpipe */
+int enable_sigpipe = 0;
+
/* # of replies received for global requests */
static int forward_confirms_pending = -1;
@@ -203,7 +206,7 @@ static void
usage(void)
{
fprintf(stderr,
-"usage: ssh [-46AaCfGgKkMNnqsTtVvXxYy] [-B bind_interface]\n"
+"usage: ssh [-46AaCfGgKkMNnqsTtVvXxYyZ] [-B bind_interface]\n"
" [-b bind_address] [-c cipher_spec] [-D [bind_address:]port]\n"
" [-E log_file] [-e escape_char] [-F configfile] [-I pkcs11]\n"
" [-i identity_file] [-J [user@]host[:port]] [-L address]\n"
@@ -699,7 +699,7 @@ main(int ac, char **av)
again:
while ((opt = getopt(ac, av, "1246ab:c:e:fgi:kl:m:no:p:qstvx"
- "AB:CD:E:F:GI:J:KL:MNO:PQ:R:S:TVw:W:XYy")) != -1) { /* HUZdhjruz */
+ "AB:CD:E:F:GI:J:KL:MNO:PQ:R:S:TVw:W:XYyZ")) != -1) { /* HUZdhjruz */
switch (opt) {
case '1':
fatal("SSH protocol v.1 is no longer supported");
@@ -1066,6 +1069,9 @@ main(int ac, char **av)
case 'F':
config = optarg;
break;
+ case 'Z':
+ enable_sigpipe = 1;
+ break;
default:
usage();
}
|