emacs-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#39211: closed ([PATCH 1/1] 00-repl-server.test: don't use fixed path


From: GNU bug Tracking System
Subject: bug#39211: closed ([PATCH 1/1] 00-repl-server.test: don't use fixed path for socket)
Date: Fri, 06 Mar 2020 14:45:02 +0000

Your message dated Fri, 06 Mar 2020 15:44:20 +0100
with message-id <address@hidden>
and subject line Re: bug#39211: [PATCH 1/1] 00-repl-server.test: don't use 
fixed path for socket
has caused the debbugs.gnu.org bug report #39211,
regarding [PATCH 1/1] 00-repl-server.test: don't use fixed path for socket
to be marked as done.

(If you believe you have received this mail in error, please contact
address@hidden.)


-- 
39211: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=39211
GNU Bug Tracking System
Contact address@hidden with problems
--- Begin Message --- Subject: [PATCH 1/1] 00-repl-server.test: don't use fixed path for socket Date: Mon, 20 Jan 2020 21:22:14 -0600
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




--- End Message ---
--- Begin Message --- Subject: Re: bug#39211: [PATCH 1/1] 00-repl-server.test: don't use fixed path for socket Date: Fri, 06 Mar 2020 15:44:20 +0100 User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux)
Rob Browning <address@hidden> 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’.


--- End Message ---

reply via email to

[Prev in Thread] Current Thread [Next in Thread]