summaryrefslogtreecommitdiff
path: root/debian/patches/regress-mktemp.patch
diff options
context:
space:
mode:
Diffstat (limited to 'debian/patches/regress-mktemp.patch')
-rw-r--r--debian/patches/regress-mktemp.patch167
1 files changed, 167 insertions, 0 deletions
diff --git a/debian/patches/regress-mktemp.patch b/debian/patches/regress-mktemp.patch
new file mode 100644
index 000000000..2d9b436f5
--- /dev/null
+++ b/debian/patches/regress-mktemp.patch
@@ -0,0 +1,167 @@
1From cc50ca70e3b438577c33a85147e2a68666deaad9 Mon Sep 17 00:00:00 2001
2From: Colin Watson <cjwatson@debian.org>
3Date: Tue, 3 Jan 2017 12:09:42 +0000
4Subject: Create mux socket for regress in temp directory
5
6In some setups, creating the socket under OBJ may result in a path that
7is too long for a Unix domain socket. Add a helper to let us portably
8create a temporary directory instead.
9
10Bug: https://bugzilla.mindrot.org/show_bug.cgi?id=2660
11Last-Update: 2017-01-03
12
13Patch-Name: regress-mktemp.patch
14---
15 Makefile.in | 5 +++++
16 regress/forwarding.sh | 3 ++-
17 regress/mkdtemp.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++
18 regress/multiplex.sh | 3 ++-
19 regress/test-exec.sh | 11 ++++++++++
20 5 files changed, 79 insertions(+), 2 deletions(-)
21 create mode 100644 regress/mkdtemp.c
22
23diff --git a/Makefile.in b/Makefile.in
24index a6eb81ec..a00347e2 100644
25--- a/Makefile.in
26+++ b/Makefile.in
27@@ -459,6 +459,10 @@ regress/check-perm$(EXEEXT): $(srcdir)/regress/check-perm.c $(REGRESSLIBS)
28 $(CC) $(CFLAGS) $(CPPFLAGS) -o $@ $(srcdir)/regress/check-perm.c \
29 $(LDFLAGS) -lssh -lopenbsd-compat -lssh -lopenbsd-compat $(LIBS)
30
31+regress/mkdtemp$(EXEEXT): $(srcdir)/regress/mkdtemp.c $(REGRESSLIBS)
32+ $(CC) $(CFLAGS) $(CPPFLAGS) -o $@ $(srcdir)/regress/mkdtemp.c \
33+ $(LDFLAGS) -lssh -lopenbsd-compat -lssh -lopenbsd-compat $(LIBS)
34+
35 UNITTESTS_TEST_HELPER_OBJS=\
36 regress/unittests/test_helper/test_helper.o \
37 regress/unittests/test_helper/fuzz.o
38@@ -557,6 +561,7 @@ regress-binaries: regress/modpipe$(EXEEXT) \
39 regress/setuid-allowed$(EXEEXT) \
40 regress/netcat$(EXEEXT) \
41 regress/check-perm$(EXEEXT) \
42+ regress/mkdtemp$(EXEEXT) \
43 regress/unittests/sshbuf/test_sshbuf$(EXEEXT) \
44 regress/unittests/sshkey/test_sshkey$(EXEEXT) \
45 regress/unittests/bitmap/test_bitmap$(EXEEXT) \
46diff --git a/regress/forwarding.sh b/regress/forwarding.sh
47index a1a4b13f..592de7bc 100644
48--- a/regress/forwarding.sh
49+++ b/regress/forwarding.sh
50@@ -10,7 +10,8 @@ start_sshd
51 base=33
52 last=$PORT
53 fwd=""
54-CTL=$OBJ/ctl-sock
55+make_tmpdir
56+CTL=$TMP/ctl-sock
57
58 for j in 0 1 2; do
59 for i in 0 1 2; do
60diff --git a/regress/mkdtemp.c b/regress/mkdtemp.c
61new file mode 100644
62index 00000000..8c7d2e21
63--- /dev/null
64+++ b/regress/mkdtemp.c
65@@ -0,0 +1,59 @@
66+/*
67+ * Copyright (c) 2017 Colin Watson <cjwatson@debian.org>
68+ *
69+ * Permission to use, copy, modify, and distribute this software for any
70+ * purpose with or without fee is hereby granted, provided that the above
71+ * copyright notice and this permission notice appear in all copies.
72+ *
73+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
74+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
75+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
76+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
77+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
78+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
79+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
80+ */
81+
82+/* Roughly equivalent to "mktemp -d -t TEMPLATE", but portable. */
83+
84+#include "includes.h"
85+
86+#include <limits.h>
87+#include <stdio.h>
88+#include <stdlib.h>
89+
90+#include "log.h"
91+
92+static void
93+usage(void)
94+{
95+ fprintf(stderr, "mkdtemp template\n");
96+ exit(1);
97+}
98+
99+int
100+main(int argc, char **argv)
101+{
102+ const char *base;
103+ const char *tmpdir;
104+ char template[PATH_MAX];
105+ int r;
106+ char *dir;
107+
108+ if (argc != 2)
109+ usage();
110+ base = argv[1];
111+
112+ if ((tmpdir = getenv("TMPDIR")) == NULL)
113+ tmpdir = "/tmp";
114+ r = snprintf(template, sizeof(template), "%s/%s", tmpdir, base);
115+ if (r < 0 || (size_t)r >= sizeof(template))
116+ fatal("template string too long");
117+ dir = mkdtemp(template);
118+ if (dir == NULL) {
119+ perror("mkdtemp");
120+ exit(1);
121+ }
122+ puts(dir);
123+ return 0;
124+}
125diff --git a/regress/multiplex.sh b/regress/multiplex.sh
126index acb9234d..0ac4065e 100644
127--- a/regress/multiplex.sh
128+++ b/regress/multiplex.sh
129@@ -1,7 +1,8 @@
130 # $OpenBSD: multiplex.sh,v 1.27 2014/12/22 06:14:29 djm Exp $
131 # Placed in the Public Domain.
132
133-CTL=/tmp/openssh.regress.ctl-sock.$$
134+make_tmpdir
135+CTL=$TMP/ctl-sock
136
137 tid="connection multiplexing"
138
139diff --git a/regress/test-exec.sh b/regress/test-exec.sh
140index bfa48803..13a8e18f 100644
141--- a/regress/test-exec.sh
142+++ b/regress/test-exec.sh
143@@ -317,6 +317,14 @@ stop_sshd ()
144 fi
145 }
146
147+TMP=
148+
149+make_tmpdir ()
150+{
151+ TMP="$($OBJ/mkdtemp openssh-regress-XXXXXXXXXXXX)" || \
152+ fatal "failed to create temporary directory"
153+}
154+
155 # helper
156 cleanup ()
157 {
158@@ -327,6 +335,9 @@ cleanup ()
159 kill $SSH_PID
160 fi
161 fi
162+ if [ "x$TMP" != "x" ]; then
163+ rm -rf "$TMP"
164+ fi
165 stop_sshd
166 }
167