GNU bug report logs - #24818
Clean up socket files set up by --listen=/path/to/socket-file

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: guile; Reported by: Christopher Allan Webber <cwebber@HIDDEN>; Keywords: patch; dated Sat, 29 Oct 2016 16:39:02 UTC; Maintainer for guile is bug-guile@HIDDEN.
Added tag(s) patch. Request was from Christopher Allan Webber <cwebber@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 29 Oct 2016 16:38:44 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Oct 29 12:38:44 2016
Received: from localhost ([127.0.0.1]:36767 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1c0Wea-00044k-1V
	for submit <at> debbugs.gnu.org; Sat, 29 Oct 2016 12:38:44 -0400
Received: from eggs.gnu.org ([208.118.235.92]:51552)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <cwebber@HIDDEN>) id 1c0WeY-00044R-Fz
 for submit <at> debbugs.gnu.org; Sat, 29 Oct 2016 12:38:43 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <cwebber@HIDDEN>) id 1c0WeS-0003fs-Cb
 for submit <at> debbugs.gnu.org; Sat, 29 Oct 2016 12:38:37 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50 autolearn=disabled
 version=3.3.2
Received: from lists.gnu.org ([2001:4830:134:3::11]:55339)
 by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32)
 (Exim 4.71) (envelope-from <cwebber@HIDDEN>)
 id 1c0WeS-0003fi-9C
 for submit <at> debbugs.gnu.org; Sat, 29 Oct 2016 12:38:36 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:42493)
 by lists.gnu.org with esmtp (Exim 4.71)
 (envelope-from <cwebber@HIDDEN>) id 1c0WeQ-000097-ST
 for bug-guile@HIDDEN; Sat, 29 Oct 2016 12:38:36 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <cwebber@HIDDEN>) id 1c0WeM-0003da-7d
 for bug-guile@HIDDEN; Sat, 29 Oct 2016 12:38:34 -0400
Received: from dustycloud.org ([50.116.34.160]:55276)
 by eggs.gnu.org with esmtp (Exim 4.71)
 (envelope-from <cwebber@HIDDEN>) id 1c0WeM-0003dN-1H
 for bug-guile@HIDDEN; Sat, 29 Oct 2016 12:38:30 -0400
Received: from oolong (localhost [127.0.0.1])
 by dustycloud.org (Postfix) with ESMTPS id 28F3B265F2
 for <bug-guile@HIDDEN>; Sat, 29 Oct 2016 12:38:29 -0400 (EDT)
User-agent: mu4e 0.9.16; emacs 25.1.1
From: Christopher Allan Webber <cwebber@HIDDEN>
To: bug-guile@HIDDEN
Subject: Clean up socket files set up by --listen=/path/to/socket-file
Date: Sat, 29 Oct 2016 11:38:23 -0500
Message-ID: <87oa236rgg.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: multipart/signed; boundary="==-=-=";
 micalg=pgp-sha256; protocol="application/pgp-signature"
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 2001:4830:134:3::11
X-Spam-Score: -4.0 (----)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -4.0 (----)

--==-=-=
Content-Type: multipart/mixed; boundary="=-=-="

--=-=-=
Content-Type: text/plain

In light of the recent security vulnerability on using localhost + port,
I've been using socket files for live hacking.  Unfortunately, these
socket files stay around after closing guile, which means this can happen:

  $ guile --listen=/tmp/guile-socket
  scheme@(guile-user)> ,q
  $ guile --listen=/tmp/guile-socket
  ERROR: In procedure bind:
  ERROR: In procedure bind: Address already in use

That's not very nice!  I really don't like having to clean up these
files by hand.... Guile should do it for me.

Fortunately, here's a patch that does just that!  It uses dynamic-wind
and cleans up the socket file, if it exists.  (But it doesn't break if
it doesn't!)


--=-=-=
Content-Type: text/x-patch
Content-Disposition: inline;
 filename=0001-Clean-up-socket-file-set-up-by-listen.patch
Content-Transfer-Encoding: quoted-printable

From=2012a1c24890448ec9a2d33cabff7f70f6332dbb4f Mon Sep 17 00:00:00 2001
From: Christopher Allan Webber <cwebber@HIDDEN>
Date: Sat, 29 Oct 2016 11:28:05 -0500
Subject: [PATCH] Clean up socket file set up by --listen

* module/ice-9/command-line.scm (compile-shell-switches):
  Clean up socket file set up by --listen on exit, if it exists.
=2D--
 module/ice-9/command-line.scm | 80 ++++++++++++++++++++++++---------------=
----
 1 file changed, 44 insertions(+), 36 deletions(-)

diff --git a/module/ice-9/command-line.scm b/module/ice-9/command-line.scm
index 98d3855..cdc5427 100644
=2D-- a/module/ice-9/command-line.scm
+++ b/module/ice-9/command-line.scm
@@ -199,6 +199,7 @@ If FILE begins with `-' the -s switch is mandatory.
         (user-load-compiled-path '())
         (user-extensions '())
         (interactive? #t)
+        (clean-socket-file #f)
         (inhibit-user-init? #f)
         (turn-on-debugging? #f)
         (turn-off-debugging? #f))
@@ -387,6 +388,7 @@ If FILE begins with `-' the -s switch is mandatory.
                              ((@@ (system repl server) make-tcp-server-soc=
ket) #:port ,port))
                            (error "invalid port for --listen"))))
                  ((string-prefix? "/" where) ; --listen=3D/PATH/TO/SOCKET
+                  (set! clean-socket-file where)
                   `((@@ (system repl server) spawn-server)
                     ((@@ (system repl server) make-unix-domain-server-sock=
et) #:path ,where)))
                  (else
@@ -430,42 +432,48 @@ If FILE begins with `-' the -s switch is mandatory.
       `(;; It would be nice not to load up (ice-9 control), but the
         ;; default-prompt-handler is nontrivial.
         (@ (ice-9 control) %)
=2D        (begin
=2D          ;; If we didn't end with a -c or a -s and didn't supply a -q, =
load
=2D          ;; the user's customization file.
=2D          ,@(if (and interactive? (not inhibit-user-init?))
=2D                '((load-user-init))
=2D                '())
=2D
=2D          ;; Use-specified extensions.
=2D          ,@(map (lambda (ext)
=2D                   `(set! %load-extensions (cons ,ext %load-extensions)))
=2D                 user-extensions)
=2D
=2D          ;; Add the user-specified load paths here, so they won't be in
=2D          ;; effect during the loading of the user's customization file.
=2D          ,@(map (lambda (path)
=2D                   `(set! %load-path (cons ,path %load-path)))
=2D                 user-load-path)
=2D          ,@(map (lambda (path)
=2D                   `(set! %load-compiled-path
=2D                          (cons ,path %load-compiled-path)))
=2D                 user-load-compiled-path)
=2D
=2D          ;; Put accumulated actions in their correct order.
=2D          ,@(reverse! out)
=2D
=2D          ;; Handle the `-e' switch, if it was specified.
=2D          ,@(if entry-point
=2D                `((,entry-point (command-line)))
=2D                '())
=2D          ,(if interactive?
=2D               ;; If we didn't end with a -c or a -s, start the
=2D               ;; repl.
=2D               '((@ (ice-9 top-repl) top-repl))
=2D               ;; Otherwise, after doing all the other actions
=2D               ;; prescribed by the command line, quit.
=2D               '(quit)))))
+        (dynamic-wind
+          (const #f) ; no-op
+          (lambda ()
+            ;; If we didn't end with a -c or a -s and didn't supply a -q, =
load
+            ;; the user's customization file.
+            ,@(if (and interactive? (not inhibit-user-init?))
+                  '((load-user-init))
+                  '())
+
+            ;; Use-specified extensions.
+            ,@(map (lambda (ext)
+                     `(set! %load-extensions (cons ,ext %load-extensions)))
+                   user-extensions)
+
+            ;; Add the user-specified load paths here, so they won't be in
+            ;; effect during the loading of the user's customization file.
+            ,@(map (lambda (path)
+                     `(set! %load-path (cons ,path %load-path)))
+                   user-load-path)
+            ,@(map (lambda (path)
+                     `(set! %load-compiled-path
+                            (cons ,path %load-compiled-path)))
+                   user-load-compiled-path)
+
+            ;; Put accumulated actions in their correct order.
+            ,@(reverse! out)
+
+            ;; Handle the `-e' switch, if it was specified.
+            ,@(if entry-point
+                  `((,entry-point (command-line)))
+                  '())
+            ,(if interactive?
+                 ;; If we didn't end with a -c or a -s, start the
+                 ;; repl.
+                 '((@ (ice-9 top-repl) top-repl))
+                 ;; Otherwise, after doing all the other actions
+                 ;; prescribed by the command line, quit.
+                 '(quit)))
+          (lambda ()
+            (when (and ,clean-socket-file
+                       (file-exists? ,clean-socket-file))
+              (delete-file ,clean-socket-file))))))
=20
       (if (pair? args)
           (begin
=2D-=20
2.10.1


--=-=-=--

--==-=-=
Content-Type: application/pgp-signature; name="signature.asc"

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iQIcBAEBCAAGBQJYFNB/AAoJEEvAJZJf+PTT2AgQAINjtmd/DJCMPDjWR30k92sZ
qothbxxHqaEaL7iX5n9KMrVfqKxtVZoH5RYioj/fMcn9jgrssUbZNWYIuTcFbNZC
Mx09SqRo87cSZ0PLYrP8iVeY1YhW0OJQPja3ovSnWPuL0nzQDN6BpcrOCwdcPCpI
Lp6rinvDEFYpgohTGBdtt6B9o1govLTrt78WSiF075QphAYP9qEmVKI4qvZTnZNa
OD/C/+tLQMC7do599XJ5MV9Q8srVASgO+S4fhTVyJr7bv3nMtDXbGdg3dH2hsiDe
7idPNu/zbcGHklsKphIdf/xGq7DNN0KUfmlvfC51RY1saBeA00v8GmMbbVHfotY6
OyWUkU33pmCQAf3Mt59D3mknguWhjf10DznwY/Wm7Yl3qoqvdMALEv6dhn0Gucv7
qnFwkaBtNxaBFzatDJ6p4W+CM8VQHuILYPkxYnLVcA4pbUODZk3tMaiZnHma8ejJ
LwZ6YIo77KtW+QYlnsl8iPhAuYMsFS8nzzGI8VZwRELx75MXhJTFuENrcCicFtkA
+fYE+/PerKYSok1oVqcy+rMeqpCRIbxzQrevoz/4xoXlcEEcFd7JwUx+370PCNi2
qRiP7Y1y+m+a3Wk48feV0yB1TuHfKH/HwTDh+8xWFcqqQOXjV0Cjp1jMSSwbSa55
vBEVzHVdvb8hPd3LKZyg
=r9vF
-----END PGP SIGNATURE-----
--==-=-=--




Acknowledgement sent to Christopher Allan Webber <cwebber@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-guile@HIDDEN. Full text available.
Report forwarded to bug-guile@HIDDEN:
bug#24818; Package guile. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Mon, 9 Jan 2017 22:30:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.