unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
* bug#39211: [PATCH 1/1] 00-repl-server.test: don't use fixed path for socket
@ 2020-01-21  3:22 Rob Browning
  2020-01-21 16:50 ` Ludovic Courtès
  2020-03-06 14:44 ` Ludovic Courtès
  0 siblings, 2 replies; 3+ messages in thread
From: Rob Browning @ 2020-01-21  3:22 UTC (permalink / raw)
  To: 39211

Even setting aside any security concerns, this caused tests to fail if
you ran them as a given user and then ran them again as another user.

---

 It didn't look like we have anything like mkdtemp or I'd have used it
 instead.  And it looks like this might apply to, and it would be nice
 to have something like it on stable-2.2 as well.

 test-suite/tests/00-repl-server.test | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/test-suite/tests/00-repl-server.test b/test-suite/tests/00-repl-server.test
index 54f518a66..4324f7371 100644
--- a/test-suite/tests/00-repl-server.test
+++ b/test-suite/tests/00-repl-server.test
@@ -24,13 +24,25 @@
   #:use-module (web request)
   #:use-module (test-suite lib))
 
+(define (make-tempdir)
+  (let loop ((try 0)
+             (n (random:uniform)))
+    (let* ((path (string-append "/tmp/repl-server-test-" (number->string n)))
+           (dir (false-if-exception (mkdir path #o700))))
+      (cond
+       (dir path)
+       ((> try 10)
+        (error "Unable to create directory in /tmp for 00-repl-server.test"))
+       (else (loop (1+ try) (random:uniform)))))))
+
 (define (call-with-repl-server proc)
   "Set up a REPL server in a separate process and call PROC with a
 socket connected to that server."
-  (let ((sockaddr      (make-socket-address AF_UNIX "/tmp/repl-server"))
-        (client-socket (socket AF_UNIX SOCK_STREAM 0)))
-    (false-if-exception
-     (delete-file (sockaddr:path sockaddr)))
+  (let* ((tmpdir (make-tempdir))
+         (sockaddr (make-socket-address AF_UNIX (string-append tmpdir "/repl-server")))
+         (client-socket (socket AF_UNIX SOCK_STREAM 0)))
+    (false-if-exception (delete-file (sockaddr:path sockaddr)))
+    (false-if-exception (rmdir tmpdir))
 
     ;; The REPL server requires thread. The test requires fork.
     (unless (and (provided? 'threads) (provided? 'fork))
-- 
2.24.0






^ permalink raw reply related	[flat|nested] 3+ messages in thread

* bug#39211: [PATCH 1/1] 00-repl-server.test: don't use fixed path for socket
  2020-01-21  3:22 bug#39211: [PATCH 1/1] 00-repl-server.test: don't use fixed path for socket Rob Browning
@ 2020-01-21 16:50 ` Ludovic Courtès
  2020-03-06 14:44 ` Ludovic Courtès
  1 sibling, 0 replies; 3+ messages in thread
From: Ludovic Courtès @ 2020-01-21 16:50 UTC (permalink / raw)
  To: Rob Browning; +Cc: 39211

Hi Rob,

Rob Browning <rlb@defaultvalue.org> skribis:

> Even setting aside any security concerns, this caused tests to fail if
> you ran them as a given user and then ran them again as another user.

Oops, indeed.

>  It didn't look like we have anything like mkdtemp or I'd have used it
>  instead.  And it looks like this might apply to, and it would be nice
>  to have something like it on stable-2.2 as well.

I thought we had ‘mkdtemp!’ but it’s just in Guix.  :-/

Well we can go that way for now, perhaps with a FIXME comment suggesting
the use of ‘mkdtemp!’ once it’s available.

Also please make sure to include a ChangeLog-style commit log.

Apart from that it LGTM!

I think we should add ‘mkdtemp!’ to libguile in a separate commit; it’s
OK to _add_ procedures during a stable release.

Thanks,
Ludo’.





^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#39211: [PATCH 1/1] 00-repl-server.test: don't use fixed path for socket
  2020-01-21  3:22 bug#39211: [PATCH 1/1] 00-repl-server.test: don't use fixed path for socket Rob Browning
  2020-01-21 16:50 ` Ludovic Courtès
@ 2020-03-06 14:44 ` Ludovic Courtès
  1 sibling, 0 replies; 3+ messages in thread
From: Ludovic Courtès @ 2020-03-06 14:44 UTC (permalink / raw)
  To: Rob Browning; +Cc: 39211-done

Rob Browning <rlb@defaultvalue.org> skribis:

> Even setting aside any security concerns, this caused tests to fail if
> you ran them as a given user and then ran them again as another user.
>
> ---
>
>  It didn't look like we have anything like mkdtemp or I'd have used it
>  instead.  And it looks like this might apply to, and it would be nice
>  to have something like it on stable-2.2 as well.
>
>  test-suite/tests/00-repl-server.test | 20 ++++++++++++++++----
>  1 file changed, 16 insertions(+), 4 deletions(-)

I believe what you pushed as ddcab06f20525d975503d8d9611e02021fb0dff1
fixes this issue, so I’m closing it now.

Thanks,
Ludo’.





^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-03-06 14:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-01-21  3:22 bug#39211: [PATCH 1/1] 00-repl-server.test: don't use fixed path for socket Rob Browning
2020-01-21 16:50 ` Ludovic Courtès
2020-03-06 14:44 ` Ludovic Courtès

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).