diff options
| author | Ludovic Courtès <ludo@gnu.org> | 2014-07-12 23:14:10 +0200 |
|---|---|---|
| committer | Ludovic Courtès <ludo@gnu.org> | 2014-07-12 23:17:54 +0200 |
| commit | 927097effdab473d2a344e6de75a85ec734df5dc (patch) | |
| tree | e723e5c38bac526c859fddc6420724f1ba6ef0aa /gnu | |
| parent | 8897603ad02042f916911c406eb47f0b36d1f831 (diff) | |
services: Add Tor service.
* gnu/services/networking.scm (tor-service): New procedure.
* doc/guix.texi (Networking Services): Document it.
* build-aux/hydra/demo-os.scm: Use it. Add TOR and TORSOCKS to
'packages'.
Diffstat (limited to 'gnu')
| -rw-r--r-- | gnu/services/networking.scm | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/gnu/services/networking.scm b/gnu/services/networking.scm index 7abcd9ed15e..502b0d85f12 100644 --- a/gnu/services/networking.scm +++ b/gnu/services/networking.scm | |||
| @@ -18,11 +18,14 @@ | |||
| 18 | 18 | ||
| 19 | (define-module (gnu services networking) | 19 | (define-module (gnu services networking) |
| 20 | #:use-module (gnu services) | 20 | #:use-module (gnu services) |
| 21 | #:use-module (gnu system shadow) | ||
| 21 | #:use-module (gnu packages admin) | 22 | #:use-module (gnu packages admin) |
| 22 | #:use-module (gnu packages linux) | 23 | #:use-module (gnu packages linux) |
| 24 | #:use-module (gnu packages tor) | ||
| 23 | #:use-module (guix gexp) | 25 | #:use-module (guix gexp) |
| 24 | #:use-module (guix monads) | 26 | #:use-module (guix monads) |
| 25 | #:export (static-networking-service)) | 27 | #:export (static-networking-service |
| 28 | tor-service)) | ||
| 26 | 29 | ||
| 27 | ;;; Commentary: | 30 | ;;; Commentary: |
| 28 | ;;; | 31 | ;;; |
| @@ -85,4 +88,35 @@ gateway." | |||
| 85 | #t))))) | 88 | #t))))) |
| 86 | (respawn? #f))))) | 89 | (respawn? #f))))) |
| 87 | 90 | ||
| 91 | (define* (tor-service #:key (tor tor)) | ||
| 92 | "Return a service to run the @uref{https://torproject.org,Tor} daemon. | ||
| 93 | |||
| 94 | The daemon runs with the default settings (in particular the default exit | ||
| 95 | policy) as the @code{tor} unprivileged user." | ||
| 96 | (mlet %store-monad ((torrc (text-file "torrc" "User tor\n"))) | ||
| 97 | (return | ||
| 98 | (service | ||
| 99 | (provision '(tor)) | ||
| 100 | |||
| 101 | ;; Tor needs at least one network interface to be up, hence the | ||
| 102 | ;; dependency on 'loopback'. | ||
| 103 | (requirement '(user-processes loopback)) | ||
| 104 | |||
| 105 | (start #~(make-forkexec-constructor | ||
| 106 | (list (string-append #$tor "/bin/tor") "-f" #$torrc))) | ||
| 107 | (stop #~(make-kill-destructor)) | ||
| 108 | |||
| 109 | (user-groups (list (user-group | ||
| 110 | (name "tor")))) | ||
| 111 | (user-accounts (list (user-account | ||
| 112 | (name "tor") | ||
| 113 | (group "tor") | ||
| 114 | (system? #t) | ||
| 115 | (comment "Tor daemon user") | ||
| 116 | (home-directory "/var/empty") | ||
| 117 | (shell | ||
| 118 | "/run/current-system/profile/sbin/nologin")))) | ||
| 119 | |||
| 120 | (documentation "Run the Tor anonymous network overlay."))))) | ||
| 121 | |||
| 88 | ;;; networking.scm ends here | 122 | ;;; networking.scm ends here |
