unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
* [bug#47155] [PATCH] gnu: Respect DataDirectoryGroupReadable option of tor.
@ 2021-03-15 11:15 raid5atemyhomework via Guix-patches via
  2021-03-15 16:35 ` Maxime Devos
  2022-12-27 11:52 ` Jean Pierre De Jesus DIAZ via Guix-patches via
  0 siblings, 2 replies; 9+ messages in thread
From: raid5atemyhomework via Guix-patches via @ 2021-03-15 11:15 UTC (permalink / raw)
  To: 47155

Currently, if you set DataDirectoryGroupReadable 1 in your torrc, it will be respected only if tor is started up.  If you reconfigure your OS without restarting the tor service, the directory permissions are reset due to the activation code being re-run and resetting the directory permissions.

This change simply does not chmod if the directory already exists.


Thanks
raid5atemyhomework


From d6037c59e642eaafebe43996e7419e1b58fee616 Mon Sep 17 00:00:00 2001
From: raid5atemyhomework <raid5atemyhomework@protonmail.com>
Date: Mon, 15 Mar 2021 19:10:01 +0800
Subject: [PATCH] gnu: Respect DataDirectoryGroupReadable option of tor.

* gnu/services/networking.scm (tor-activation): Do not change permissions
of tor data directory if it already exists.
---
 gnu/services/networking.scm | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/gnu/services/networking.scm b/gnu/services/networking.scm
index 231a9f66c7..65d2d39f0b 100644
--- a/gnu/services/networking.scm
+++ b/gnu/services/networking.scm
@@ -881,10 +881,16 @@ HiddenServicePort ~a ~a~%"
       ;; of the "tor" group will be able to use the SOCKS socket.
       (chmod "/var/run/tor" #o750)

-      ;; Allow Tor to access the hidden services' directories.
-      (mkdir-p "/var/lib/tor")
+      ;; If the directory already exists, do not chmod it again; the user
+      ;; might have set "DataDirectoryGroupReadable 1" in the torrc.
+      ;; Without this check, a `guix system reconfigure` will cause the
+      ;; directory to lose group permissions until Tor is restarted, even
+      ;; if changes to the operating-system were unrelated to Tor.
+      (unless (file-exists? "/var/lib/tor")
+        (mkdir-p "/var/lib/tor")
+        ;; Allow only Tor and root to access the hidden services' directories.
+        (chmod "/var/lib/tor" #o700))
       (chown "/var/lib/tor" (passwd:uid %user) (passwd:gid %user))
-      (chmod "/var/lib/tor" #o700)

       ;; Make sure /var/lib is accessible to the 'tor' user.
       (chmod "/var/lib" #o755)
--
2.30.2





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

end of thread, other threads:[~2022-12-27 11:54 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-03-15 11:15 [bug#47155] [PATCH] gnu: Respect DataDirectoryGroupReadable option of tor raid5atemyhomework via Guix-patches via
2021-03-15 16:35 ` Maxime Devos
2021-03-15 23:42   ` raid5atemyhomework via Guix-patches via
2021-03-27  6:37   ` raid5atemyhomework via Guix-patches via
2021-03-27  9:45     ` Maxime Devos
2021-03-27 11:06       ` raid5atemyhomework via Guix-patches via
2021-03-27 12:13         ` Maxime Devos
2021-07-23 15:07           ` raid5atemyhomework via Guix-patches via
2022-12-27 11:52 ` Jean Pierre De Jesus DIAZ via Guix-patches via

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

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).