summaryrefslogtreecommitdiff
path: root/regress
diff options
context:
space:
mode:
authorColin Watson <cjwatson@debian.org>2017-01-03 12:09:42 +0000
committerColin Watson <cjwatson@debian.org>2017-01-16 15:02:54 +0000
commit6ca09916439a58f0789deb79960ee5defc05a946 (patch)
tree2dfc8dc5a56ce659c62c7120fb001671e94ba3b4 /regress
parent166f04046035ffca27c820649df360eaa5dd1b99 (diff)
Create mux socket for regress in temp directory
In some setups, creating the socket under OBJ may result in a path that is too long for a Unix domain socket. Add a helper to let us portably create a temporary directory instead. Bug: https://bugzilla.mindrot.org/show_bug.cgi?id=2660 Last-Update: 2017-01-03 Patch-Name: regress-mktemp.patch
Diffstat (limited to 'regress')
-rw-r--r--regress/forwarding.sh3
-rw-r--r--regress/mkdtemp.c59
-rw-r--r--regress/multiplex.sh3
-rw-r--r--regress/test-exec.sh11
4 files changed, 74 insertions, 2 deletions
diff --git a/regress/forwarding.sh b/regress/forwarding.sh
index a1a4b13f2..592de7bc3 100644
--- a/regress/forwarding.sh
+++ b/regress/forwarding.sh
@@ -10,7 +10,8 @@ start_sshd
10base=33 10base=33
11last=$PORT 11last=$PORT
12fwd="" 12fwd=""
13CTL=$OBJ/ctl-sock 13make_tmpdir
14CTL=$TMP/ctl-sock
14 15
15for j in 0 1 2; do 16for j in 0 1 2; do
16 for i in 0 1 2; do 17 for i in 0 1 2; do
diff --git a/regress/mkdtemp.c b/regress/mkdtemp.c
new file mode 100644
index 000000000..8c7d2e219
--- /dev/null
+++ b/regress/mkdtemp.c
@@ -0,0 +1,59 @@
1/*
2 * Copyright (c) 2017 Colin Watson <cjwatson@debian.org>
3 *
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16
17/* Roughly equivalent to "mktemp -d -t TEMPLATE", but portable. */
18
19#include "includes.h"
20
21#include <limits.h>
22#include <stdio.h>
23#include <stdlib.h>
24
25#include "log.h"
26
27static void
28usage(void)
29{
30 fprintf(stderr, "mkdtemp template\n");
31 exit(1);
32}
33
34int
35main(int argc, char **argv)
36{
37 const char *base;
38 const char *tmpdir;
39 char template[PATH_MAX];
40 int r;
41 char *dir;
42
43 if (argc != 2)
44 usage();
45 base = argv[1];
46
47 if ((tmpdir = getenv("TMPDIR")) == NULL)
48 tmpdir = "/tmp";
49 r = snprintf(template, sizeof(template), "%s/%s", tmpdir, base);
50 if (r < 0 || (size_t)r >= sizeof(template))
51 fatal("template string too long");
52 dir = mkdtemp(template);
53 if (dir == NULL) {
54 perror("mkdtemp");
55 exit(1);
56 }
57 puts(dir);
58 return 0;
59}
diff --git a/regress/multiplex.sh b/regress/multiplex.sh
index acb9234d9..0ac4065e7 100644
--- a/regress/multiplex.sh
+++ b/regress/multiplex.sh
@@ -1,7 +1,8 @@
1# $OpenBSD: multiplex.sh,v 1.27 2014/12/22 06:14:29 djm Exp $ 1# $OpenBSD: multiplex.sh,v 1.27 2014/12/22 06:14:29 djm Exp $
2# Placed in the Public Domain. 2# Placed in the Public Domain.
3 3
4CTL=/tmp/openssh.regress.ctl-sock.$$ 4make_tmpdir
5CTL=$TMP/ctl-sock
5 6
6tid="connection multiplexing" 7tid="connection multiplexing"
7 8
diff --git a/regress/test-exec.sh b/regress/test-exec.sh
index bfa48803b..13a8e18f3 100644
--- a/regress/test-exec.sh
+++ b/regress/test-exec.sh
@@ -317,6 +317,14 @@ stop_sshd ()
317 fi 317 fi
318} 318}
319 319
320TMP=
321
322make_tmpdir ()
323{
324 TMP="$($OBJ/mkdtemp openssh-regress-XXXXXXXXXXXX)" || \
325 fatal "failed to create temporary directory"
326}
327
320# helper 328# helper
321cleanup () 329cleanup ()
322{ 330{
@@ -327,6 +335,9 @@ cleanup ()
327 kill $SSH_PID 335 kill $SSH_PID
328 fi 336 fi
329 fi 337 fi
338 if [ "x$TMP" != "x" ]; then
339 rm -rf "$TMP"
340 fi
330 stop_sshd 341 stop_sshd
331} 342}
332 343