From: contact.ng0@cryptolab.net
To: guix-devel@gnu.org
Cc: ng0 <ng0@we.make.ritual.n0.is>
Subject: [PATCH] gnu: services: Add gnunet-service.
Date: Wed, 18 Jan 2017 16:50:35 +0000 [thread overview]
Message-ID: <20170118165035.4142-2-contact.ng0@cryptolab.net> (raw)
In-Reply-To: <20170118165035.4142-1-contact.ng0@cryptolab.net>
From: ng0 <ng0@we.make.ritual.n0.is>
---
doc/guix.texi | 36 +++++++++++++
gnu/services/networking.scm | 126 +++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 161 insertions(+), 1 deletion(-)
diff --git a/doc/guix.texi b/doc/guix.texi
index a212666af..3e2e50ed9 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -9043,6 +9043,42 @@ Boolean values @var{ipv4?} and @var{ipv6?} determine whether to use IPv4/IPv6
sockets.
@end deffn
+@cindex GNUnet
+@cindex gnunet
+@subsubheading GNUnet Service
+
+@deffn {Scheme Variable} gnunet-service-type
+This is the type of the @uref{https://gnunet.org, GNUnet}
+service, whose value should be an @code{gnunet-configuration} object
+as in this example:
+
+@example
+(service gnunet-service-type
+ (gnunet-configuration
+ (config-file (local-file "./gnunet.conf"))))
+@end example
+@end deffn
+
+@deftp {Data Type} gnunet-configuration
+Data type representing the configuration of GNUnet.
+
+@table @asis
+@item @code{package} (default: @var{gnunet})
+Package object of the GNUnet service.
+
+@item @code{config-file} (default: @var{%default-gnunet-file})
+File-like object of the GNUnet configuration file to use. For NAT is
+assumes by default that you are behind a NAT (@var{BEHIND_NAT = YES})
+and enables UPNP (@var{ENABLE_UPNP = YES}).
+The hostlist is configured with the options @var{-b} (bootstrap using
+configured hostlist servers) and @var{-e} (enable learning advertised hostlists).
+Read the configuration files in @var{"~/.guix-profile/share/gnunet/config.d/"}
+for more information. These files also set the defaults when you don't set
+any explicit values to override them.
+
+@end table
+@end deftp
+
@node X Window
@subsubsection X Window
diff --git a/gnu/services/networking.scm b/gnu/services/networking.scm
index ac011f128..a9a03ce40 100644
--- a/gnu/services/networking.scm
+++ b/gnu/services/networking.scm
@@ -3,6 +3,7 @@
;;; Copyright © 2015 Mark H Weaver <mhw@netris.org>
;;; Copyright © 2016 Efraim Flashner <efraim@flashner.co.il>
;;; Copyright © 2016 John Darrington <jmd@gnu.org>
+;;; Copyright © 2017 ng0 <contact.ng0@cryptolab.net>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -27,6 +28,7 @@
#:use-module (gnu system pam)
#:use-module (gnu packages admin)
#:use-module (gnu packages connman)
+ #:use-module (gnu packages gnunet)
#:use-module (gnu packages linux)
#:use-module (gnu packages tor)
#:use-module (gnu packages messaging)
@@ -66,7 +68,12 @@
wicd-service
network-manager-service
connman-service
- wpa-supplicant-service-type))
+ wpa-supplicant-service-type
+
+ gnunet-configuration
+ gnunet-configuration?
+ gnunet-service-type
+ %default-gnunet-config-file))
;;; Commentary:
;;;
@@ -786,4 +793,121 @@ configure networking."
(service-extension dbus-root-service-type list)
(service-extension profile-service-type list)))))
+\f
+;;; GNUnet
+;;;
+;;;
+
+(define-record-type* <gnunet-configuration>
+ gnunet-configuration make-gnunet-configuration
+ gnunet-configuration?
+ (package gnunet-configuration-package
+ (default gnunet))
+ (config-file gnunet-configuration-config-file
+ (default %default-gnunet-config-file)))
+
+(define %default-gnunet-config-file
+ (plain-file "gnunet.conf" "
+[PATHS]
+SERVICEHOME = /var/lib/gnunet
+GNUNET_CONFIG_HOME = /var/lib/gnunet
+
+[arm]
+SYSTEM_ONLY = YES
+USER_ONLY = NO
+
+[nat]
+BEHIND_NAT = YES
+ENABLE_UPNP = YES
+
+[hostlist]
+OPTIONS = -b -e
+"))
+
+(define gnunet-shepherd-service
+ (match-lambda
+ (($ <gnunet-configuration> package config-file)
+ (list (shepherd-service
+ (provision '(gnunet))
+ (requirement '(user-processes loopback networking))
+ (documentation "Run the GNUnet service.")
+ (start
+ (let ((gnunet
+ (file-append package "/lib/gnunet/libexec/gnunet-service-arm")))
+ #~(make-forkexec-constructor
+ (list #$gnunet "-c" #$config-file)
+ #:pid-file "/var/run/gnunet.pid"
+ #:user "gnunet"
+ #:group "gnunet"
+ #:log-file "/var/lib/gnunet/gnunet.log")))
+ (stop
+ #~(make-kill-destructor)))))))
+
+(define %gnunet-accounts
+ (list (user-group
+ (name "gnunetdns")
+ (system? #t))
+ (user-group
+ (name "gnunet")
+ (system? #t))
+ (user-account
+ (name "gnunet")
+ (group "gnunet")
+ (system? #t)
+ (comment "GNUnet system user")
+ (home-directory "/var/empty")
+ (shell (file-append shadow "/sbin/nologin")))))
+
+(define gnunet-activation
+ (match-lambda
+ (($ <gnunet-configuration> package config-file)
+ (let ((gnunet
+ (file-append package "/lib/gnunet/libexec/gnunet-service-arm")))
+ #~(begin
+ (use-modules (guix build utils))
+ (define %user (getpw "gnunet"))
+ (mkdir-p "/var/lib/gnunet/")
+ (chown "/var/lib/gnunet" (passwd:uid %user) (passwd:gid %user))
+ ;;(chmod "/var/lib/gnunet/" #o755)
+ (mkdir-p "/var/lib/gnunet/.local/share/gnunet")
+ (mkdir-p "/var/lib/gnunet/.cache/gnunet")
+ (mkdir-p "/var/lib/gnunet/hostlist")
+ (mkdir-p "/var/lib/gnunet/.config/gnunet")
+ (chown "/var/lib/gnunet/.local/share/gnunet" (passwd:uid %user) (passwd:gid %user))
+ (chown "/var/lib/gnunet/.cache/gnunet" (passwd:uid %user) (passwd:gid %user))
+ (chown "/var/lib/gnunet/hostlist" (passwd:uid %user) (passwd:gid %user))
+ ;;(chown "/var/lib/gnunet/gnunet.conf" (passwd:uid %user) (passwd:gid %user))
+ (chown "/var/lib/gnunet/.config/gnunet" (passwd:uid %user) (passwd:gid %user)))))))
+ ;;(chmod "/var/lib/gnunet/.config/gnunet" #o755)
+ ;;(chmod "/var/lib/gnunet/.cache/gnunet" #o755)
+ ;;(chmod "/var/lib/gnunet/.local/share/gnunet" #o755))))))
+
+;; SUID_ROOT_HELPERS="exit nat-server nat-client transport-bluetooth transport-wlan vpn"
+;; set chmod u+s for those above.
+;; chmodown_execbin ${libexec}/gnunet-helper-dns 4750 root:gnunetdns
+;; chmodown_execbin ${libexec}/gnunet-service-dns 2750 gnunet:gnunetdns
+(define gnunet-setuid-programs
+ (match-lambda
+ (($ <gnunet-configuration> package)
+ (list (file-append package "/lib/gnunet/libexec/gnunet-helper-exit")
+ (file-append package "/lib/gnunet/libexec/gnunet-helper-nat-server")
+ (file-append package "/lib/gnunet/libexec/gnunet-helper-nat-client")
+ (file-append package "/lib/gnunet/libexec/gnunet-helper-transport-bluetooth")
+ (file-append package "/lib/gnunet/libexec/gnunet-helper-transport-wlan")
+ (file-append package "/lib/gnunet/libexec/gnunet-helper-vpn")))))
+
+(define gnunet-service-type
+ (service-type
+ (name 'gnunet)
+ (extensions (list (service-extension account-service-type
+ (const %gnunet-accounts))
+ (service-extension activation-service-type
+ gnunet-activation)
+ (service-extension profile-service-type
+ (compose list gnunet-configuration-package))
+ (service-extension setuid-program-service-type
+ gnunet-setuid-programs)
+ (service-extension shepherd-root-service-type
+ gnunet-shepherd-service)))))
+
;;; networking.scm ends here
--
2.11.0
next prev parent reply other threads:[~2017-01-18 16:50 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-18 16:50 Services: gnunet. (require help) contact.ng0
2017-01-18 16:50 ` contact.ng0 [this message]
2017-01-20 13:26 ` Ludovic Courtès
2017-01-21 12:04 ` ng0
2017-01-21 22:50 ` Chris Marusich
2017-01-23 11:53 ` ng0
2017-01-23 12:08 ` Ricardo Wurmus
2017-02-24 21:48 ` ng0
2017-02-24 21:53 ` ng0
-- strict thread matches above, loose matches on Subject: below --
2016-12-19 19:30 gnunet-service, first draft in need of review ng0
2016-12-19 19:30 ` [PATCH] gnu: services: Add gnunet-service ng0
2016-12-21 9:10 ` Ludovic Courtès
2016-12-21 14:57 ` ng0
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170118165035.4142-2-contact.ng0@cryptolab.net \
--to=contact.ng0@cryptolab.net \
--cc=guix-devel@gnu.org \
--cc=ng0@we.make.ritual.n0.is \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.