summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.in8
-rw-r--r--regress/forwarding.sh3
-rw-r--r--regress/mkdtemp.c59
-rw-r--r--regress/multiplex.sh3
-rw-r--r--regress/test-exec.sh12
5 files changed, 83 insertions, 2 deletions
diff --git a/Makefile.in b/Makefile.in
index e09e27954..c3b67aa61 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -230,6 +230,7 @@ clean: regressclean
230 rm -f *.o *.a $(TARGETS) logintest config.cache config.log 230 rm -f *.o *.a $(TARGETS) logintest config.cache config.log
231 rm -f *.out core survey 231 rm -f *.out core survey
232 rm -f regress/check-perm$(EXEEXT) 232 rm -f regress/check-perm$(EXEEXT)
233 rm -f regress/mkdtemp$(EXEEXT)
233 rm -f regress/unittests/test_helper/*.a 234 rm -f regress/unittests/test_helper/*.a
234 rm -f regress/unittests/test_helper/*.o 235 rm -f regress/unittests/test_helper/*.o
235 rm -f regress/unittests/sshbuf/*.o 236 rm -f regress/unittests/sshbuf/*.o
@@ -258,6 +259,8 @@ distclean: regressclean
258 rm -f Makefile buildpkg.sh config.h config.status 259 rm -f Makefile buildpkg.sh config.h config.status
259 rm -f survey.sh openbsd-compat/regress/Makefile *~ 260 rm -f survey.sh openbsd-compat/regress/Makefile *~
260 rm -rf autom4te.cache 261 rm -rf autom4te.cache
262 rm -f regress/check-perm
263 rm -f regress/mkdtemp
261 rm -f regress/unittests/test_helper/*.a 264 rm -f regress/unittests/test_helper/*.a
262 rm -f regress/unittests/test_helper/*.o 265 rm -f regress/unittests/test_helper/*.o
263 rm -f regress/unittests/sshbuf/*.o 266 rm -f regress/unittests/sshbuf/*.o
@@ -460,6 +463,10 @@ regress/check-perm$(EXEEXT): $(srcdir)/regress/check-perm.c $(REGRESSLIBS)
460 $(CC) $(CFLAGS) $(CPPFLAGS) -o $@ $(srcdir)/regress/check-perm.c \ 463 $(CC) $(CFLAGS) $(CPPFLAGS) -o $@ $(srcdir)/regress/check-perm.c \
461 $(LDFLAGS) -lssh -lopenbsd-compat -lssh -lopenbsd-compat $(LIBS) 464 $(LDFLAGS) -lssh -lopenbsd-compat -lssh -lopenbsd-compat $(LIBS)
462 465
466regress/mkdtemp$(EXEEXT): $(srcdir)/regress/mkdtemp.c $(REGRESSLIBS)
467 $(CC) $(CFLAGS) $(CPPFLAGS) -o $@ $(srcdir)/regress/mkdtemp.c \
468 $(LDFLAGS) -lssh -lopenbsd-compat -lssh -lopenbsd-compat $(LIBS)
469
463UNITTESTS_TEST_HELPER_OBJS=\ 470UNITTESTS_TEST_HELPER_OBJS=\
464 regress/unittests/test_helper/test_helper.o \ 471 regress/unittests/test_helper/test_helper.o \
465 regress/unittests/test_helper/fuzz.o 472 regress/unittests/test_helper/fuzz.o
@@ -568,6 +575,7 @@ regress-binaries: regress/modpipe$(EXEEXT) \
568 regress/setuid-allowed$(EXEEXT) \ 575 regress/setuid-allowed$(EXEEXT) \
569 regress/netcat$(EXEEXT) \ 576 regress/netcat$(EXEEXT) \
570 regress/check-perm$(EXEEXT) \ 577 regress/check-perm$(EXEEXT) \
578 regress/mkdtemp$(EXEEXT) \
571 regress/unittests/sshbuf/test_sshbuf$(EXEEXT) \ 579 regress/unittests/sshbuf/test_sshbuf$(EXEEXT) \
572 regress/unittests/sshkey/test_sshkey$(EXEEXT) \ 580 regress/unittests/sshkey/test_sshkey$(EXEEXT) \
573 regress/unittests/bitmap/test_bitmap$(EXEEXT) \ 581 regress/unittests/bitmap/test_bitmap$(EXEEXT) \
diff --git a/regress/forwarding.sh b/regress/forwarding.sh
index 39fccba73..7d0fae114 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=/tmp/openssh.regress.ctl-sock.$$ 13make_tmpdir
14CTL=${SSH_REGRESS_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 078a53a88..a6fad8eb8 100644
--- a/regress/multiplex.sh
+++ b/regress/multiplex.sh
@@ -1,7 +1,8 @@
1# $OpenBSD: multiplex.sh,v 1.28 2017/04/30 23:34:55 djm Exp $ 1# $OpenBSD: multiplex.sh,v 1.28 2017/04/30 23:34:55 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=${SSH_REGRESS_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 f09fe0ec4..f0e3dabfe 100644
--- a/regress/test-exec.sh
+++ b/regress/test-exec.sh
@@ -76,6 +76,9 @@ SFTP=sftp
76SFTPSERVER=/usr/libexec/openssh/sftp-server 76SFTPSERVER=/usr/libexec/openssh/sftp-server
77SCP=scp 77SCP=scp
78 78
79# Set by make_tmpdir() on demand (below).
80SSH_REGRESS_TMP=
81
79# Interop testing 82# Interop testing
80PLINK=plink 83PLINK=plink
81PUTTYGEN=puttygen 84PUTTYGEN=puttygen
@@ -322,6 +325,12 @@ stop_sshd ()
322 fi 325 fi
323} 326}
324 327
328make_tmpdir ()
329{
330 SSH_REGRESS_TMP="$($OBJ/mkdtemp openssh-regress-XXXXXXXXXXXX)" || \
331 fatal "failed to create temporary directory"
332}
333
325# helper 334# helper
326cleanup () 335cleanup ()
327{ 336{
@@ -332,6 +341,9 @@ cleanup ()
332 kill $SSH_PID 341 kill $SSH_PID
333 fi 342 fi
334 fi 343 fi
344 if [ "x$SSH_REGRESS_TMP" != "x" ]; then
345 rm -rf "$SSH_REGRESS_TMP"
346 fi
335 stop_sshd 347 stop_sshd
336} 348}
337 349