Bugzilla – Attachment 2926 Details for
Bug 2660
Create mux socket for regress in temp directory
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Create mux socket for regress in temp directory
0001-Create-mux-socket-for-regress-in-temp-directory.patch (text/plain), 4.50 KB, created by
Colin Watson
on 2017-01-03 23:19:37 AEDT
(
hide
)
Description:
Create mux socket for regress in temp directory
Filename:
MIME Type:
Creator:
Colin Watson
Created:
2017-01-03 23:19:37 AEDT
Size:
4.50 KB
patch
obsolete
>From 3e81288d8092b7fe2ed5c68fecae572fe914156d Mon Sep 17 00:00:00 2001 >From: Colin Watson <cjwatson@debian.org> >Date: Tue, 3 Jan 2017 12:09:42 +0000 >Subject: [PATCH] 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. >--- > Makefile.in | 5 +++++ > regress/forwarding.sh | 4 ++-- > regress/mkdtemp.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++ > regress/multiplex.sh | 3 ++- > regress/test-exec.sh | 11 ++++++++++ > 5 files changed, 79 insertions(+), 3 deletions(-) > create mode 100644 regress/mkdtemp.c > >diff --git a/Makefile.in b/Makefile.in >index e10f3742..ccb18cd8 100644 >--- a/Makefile.in >+++ b/Makefile.in >@@ -457,6 +457,10 @@ regress/check-perm$(EXEEXT): $(srcdir)/regress/check-perm.c $(REGRESSLIBS) > $(CC) $(CFLAGS) $(CPPFLAGS) -o $@ $(srcdir)/regress/check-perm.c \ > $(LDFLAGS) -lssh -lopenbsd-compat -lssh -lopenbsd-compat $(LIBS) > >+regress/mkdtemp$(EXEEXT): $(srcdir)/regress/mkdtemp.c $(REGRESSLIBS) >+ $(CC) $(CFLAGS) $(CPPFLAGS) -o $@ $(srcdir)/regress/mkdtemp.c \ >+ $(LDFLAGS) -lssh -lopenbsd-compat -lssh -lopenbsd-compat $(LIBS) >+ > UNITTESTS_TEST_HELPER_OBJS=\ > regress/unittests/test_helper/test_helper.o \ > regress/unittests/test_helper/fuzz.o >@@ -555,6 +559,7 @@ regress-binaries: regress/modpipe$(EXEEXT) \ > regress/setuid-allowed$(EXEEXT) \ > regress/netcat$(EXEEXT) \ > regress/check-perm$(EXEEXT) \ >+ regress/mkdtemp$(EXEEXT) \ > regress/unittests/sshbuf/test_sshbuf$(EXEEXT) \ > regress/unittests/sshkey/test_sshkey$(EXEEXT) \ > regress/unittests/bitmap/test_bitmap$(EXEEXT) \ >diff --git a/regress/forwarding.sh b/regress/forwarding.sh >index 2539db9b..6184fc08 100644 >--- a/regress/forwarding.sh >+++ b/regress/forwarding.sh >@@ -10,8 +10,8 @@ start_sshd > base=33 > last=$PORT > fwd="" >-CTL=$OBJ/ctl-sock >-rm -f $CTL >+make_tmpdir >+CTL=$TMP/ctl-sock > > for j in 0 1 2; do > for i in 0 1 2; do >diff --git a/regress/mkdtemp.c b/regress/mkdtemp.c >new file mode 100644 >index 00000000..8c7d2e21 >--- /dev/null >+++ b/regress/mkdtemp.c >@@ -0,0 +1,59 @@ >+/* >+ * Copyright (c) 2017 Colin Watson <cjwatson@debian.org> >+ * >+ * Permission to use, copy, modify, and distribute this software for any >+ * purpose with or without fee is hereby granted, provided that the above >+ * copyright notice and this permission notice appear in all copies. >+ * >+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES >+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF >+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR >+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES >+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN >+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF >+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. >+ */ >+ >+/* Roughly equivalent to "mktemp -d -t TEMPLATE", but portable. */ >+ >+#include "includes.h" >+ >+#include <limits.h> >+#include <stdio.h> >+#include <stdlib.h> >+ >+#include "log.h" >+ >+static void >+usage(void) >+{ >+ fprintf(stderr, "mkdtemp template\n"); >+ exit(1); >+} >+ >+int >+main(int argc, char **argv) >+{ >+ const char *base; >+ const char *tmpdir; >+ char template[PATH_MAX]; >+ int r; >+ char *dir; >+ >+ if (argc != 2) >+ usage(); >+ base = argv[1]; >+ >+ if ((tmpdir = getenv("TMPDIR")) == NULL) >+ tmpdir = "/tmp"; >+ r = snprintf(template, sizeof(template), "%s/%s", tmpdir, base); >+ if (r < 0 || (size_t)r >= sizeof(template)) >+ fatal("template string too long"); >+ dir = mkdtemp(template); >+ if (dir == NULL) { >+ perror("mkdtemp"); >+ exit(1); >+ } >+ puts(dir); >+ return 0; >+} >diff --git a/regress/multiplex.sh b/regress/multiplex.sh >index acb9234d..0ac4065e 100644 >--- a/regress/multiplex.sh >+++ b/regress/multiplex.sh >@@ -1,7 +1,8 @@ > # $OpenBSD: multiplex.sh,v 1.27 2014/12/22 06:14:29 djm Exp $ > # Placed in the Public Domain. > >-CTL=/tmp/openssh.regress.ctl-sock.$$ >+make_tmpdir >+CTL=$TMP/ctl-sock > > tid="connection multiplexing" > >diff --git a/regress/test-exec.sh b/regress/test-exec.sh >index bfa48803..13a8e18f 100644 >--- a/regress/test-exec.sh >+++ b/regress/test-exec.sh >@@ -317,6 +317,14 @@ stop_sshd () > fi > } > >+TMP= >+ >+make_tmpdir () >+{ >+ TMP="$($OBJ/mkdtemp openssh-regress-XXXXXXXXXXXX)" || \ >+ fatal "failed to create temporary directory" >+} >+ > # helper > cleanup () > { >@@ -327,6 +335,9 @@ cleanup () > kill $SSH_PID > fi > fi >+ if [ "x$TMP" != "x" ]; then >+ rm -rf "$TMP" >+ fi > stop_sshd > } > >-- >2.11.0 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
dtucker
:
ok+
Actions:
View
|
Diff
Attachments on
bug 2660
: 2926 |
2964