git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #12341 from drvink/gale-package

gale: init at 1.1happy

commit23d1012932ef073fc318ec99aadae3079fc9b8a3 authorlethalman <lucabru@src.gnome.org> dateThu 14 Jan 2016, 09:56 (11 years ago) parentf917a7fe7ba7fb
6 files changed+557
nixos/modules/misc/ids.nix+2 nixos/modules/module-list.nix+1 nixos/modules/services/networking/gale.nix+182 pkgs/applications/networking/instant-messengers/gale/default.nix+31 pkgs/applications/networking/instant-messengers/gale/gale-install.in.patch+339 pkgs/top-level/all-packages.nix+2
nixos/modules/misc/ids.nix+2
@@ -244,6 +244,7 @@
244244 postsrsd = 220;
245245 opendkim = 221;
246246 dspam = 222;
247+ gale = 223;
247248
248249 # When adding a uid, make sure it doesn't match an existing gid. And don't use uids above 399!
249250
@@ -465,6 +466,7 @@
465466 postsrsd = 220;
466467 opendkim = 221;
467468 dspam = 222;
469+ gale = 223;
468470
469471 # When adding a gid, make sure it doesn't match an existing
470472 # uid. Users and groups with the same name should have equal
nixos/modules/module-list.nix+1
@@ -301,6 +301,7 @@
301301 ./services/networking/firewall.nix
302302 ./services/networking/flashpolicyd.nix
303303 ./services/networking/freenet.nix
304+ ./services/networking/gale.nix
304305 ./services/networking/gateone.nix
305306 ./services/networking/git-daemon.nix
306307 ./services/networking/gnunet.nix
nixos/modules/services/networking/gale.nixnew file+182
@@ -0,0 +1,182 @@
1+{ config, lib, pkgs, ... }:
2+
3+with lib;
4+
5+let
6+ cfg = config.services.gale;
7+ # we convert the path to a string to avoid it being copied to the nix store,
8+ # otherwise users could read the private key as all files in the store are
9+ # world-readable
10+ keyPath = toString cfg.keyPath;
11+ # ...but we refer to the pubkey file using a path so that we can ensure the
12+ # config gets rebuilt if the public key changes (we can assume the private key
13+ # will never change without the public key having changed)
14+ gpubFile = cfg.keyPath + "/${cfg.domain}.gpub";
15+ home = "/var/lib/gale";
16+ keysPrepared = cfg.keyPath != null && lib.pathExists cfg.keyPath;
17+in
18+{
19+ options = {
20+ services.gale = {
21+ enable = mkEnableOption "the Gale messaging daemon";
22+
23+ user = mkOption {
24+ default = "gale";
25+ type = types.str;
26+ description = "Username for the Gale daemon.";
27+ };
28+
29+ group = mkOption {
30+ default = "gale";
31+ type = types.str;
32+ description = "Group name for the Gale daemon.";
33+ };
34+
35+ setuidWrapper = mkOption {
36+ default = null;
37+ description = "Configuration for the Gale gksign setuid wrapper.";
38+ };
39+
40+ domain = mkOption {
41+ default = "";
42+ type = types.str;
43+ description = "Domain name for the Gale system.";
44+ };
45+
46+ keyPath = mkOption {
47+ default = null;
48+ type = types.nullOr types.path;
49+ description = ''
50+ Directory containing the key pair for this Gale domain. The expected
51+ filename will be taken from the domain option with ".gpri" and ".gpub"
52+ appended.
53+ '';
54+ };
55+
56+ extraConfig = mkOption {
57+ type = types.lines;
58+ default = "";
59+ description = ''
60+ Additional text to be added to <filename>/etc/gale/conf</filename>.
61+ '';
62+ };
63+ };
64+ };
65+
66+ config = mkMerge [
67+ (mkIf cfg.enable {
68+ assertions = [{
69+ assertion = cfg.domain != "";
70+ message = "A domain must be set for Gale.";
71+ }];
72+
73+ warnings = mkIf (!keysPrepared) [
74+ "You must run gale-install in order to generate a domain key."
75+ ];
76+
77+ system.activationScripts.gale = mkIf cfg.enable (
78+ stringAfter [ "users" "groups" ] ''
79+ chmod -R 755 ${home}
80+ mkdir -m 0777 -p ${home}/auth/cache
81+ mkdir -m 1777 -p ${home}/auth/local # GALE_DOMAIN.gpub
82+ mkdir -m 0700 -p ${home}/auth/private # ROOT.gpub
83+ mkdir -m 0755 -p ${home}/auth/trusted # ROOT
84+ mkdir -m 0700 -p ${home}/.gale
85+ mkdir -m 0700 -p ${home}/.gale/auth
86+ mkdir -m 0700 -p ${home}/.gale/auth/private # GALE_DOMAIN.gpri
87+
88+ ln -sf ${pkgs.gale}/etc/gale/auth/trusted/ROOT "${home}/auth/trusted/ROOT"
89+ chown -R ${cfg.user}:${cfg.group} ${home}
90+ ''
91+ );
92+
93+ environment = {
94+ etc = {
95+ "gale/auth".source = home + "/auth"; # symlink /var/lib/gale/auth
96+ "gale/conf".text = ''
97+ GALE_USER ${cfg.user}
98+ GALE_DOMAIN ${cfg.domain}
99+ ${cfg.extraConfig}
100+ '';
101+ };
102+
103+ systemPackages = [ pkgs.gale ];
104+ };
105+
106+ users.extraUsers = [{
107+ name = cfg.user;
108+ description = "Gale daemon";
109+ uid = config.ids.uids.gale;
110+ group = cfg.group;
111+ home = home;
112+ createHome = true;
113+ }];
114+
115+ users.extraGroups = [{
116+ name = cfg.group;
117+ gid = config.ids.gids.gale;
118+ }];
119+ })
120+ (mkIf (cfg.enable && keysPrepared) {
121+ assertions = [
122+ {
123+ assertion = cfg.keyPath != null
124+ && lib.pathExists (cfg.keyPath + "/${cfg.domain}.gpub");
125+ message = "Couldn't find a Gale public key for ${cfg.domain}.";
126+ }
127+ {
128+ assertion = cfg.keyPath != null
129+ && lib.pathExists (cfg.keyPath + "/${cfg.domain}.gpri");
130+ message = "Couldn't find a Gale private key for ${cfg.domain}.";
131+ }
132+ ];
133+
134+ services.gale.setuidWrapper = {
135+ program = "gksign";
136+ source = "${pkgs.gale}/bin/gksign";
137+ owner = cfg.user;
138+ group = cfg.group;
139+ setuid = true;
140+ setgid = false;
141+ };
142+
143+ security.setuidOwners = [ cfg.setuidWrapper ];
144+
145+ systemd.services.gale-galed = {
146+ description = "Gale messaging daemon";
147+ wantedBy = [ "multi-user.target" ];
148+ wants = [ "gale-gdomain.service" ];
149+ after = [ "network.target" ];
150+
151+ preStart = ''
152+ install -m 0640 ${keyPath}/${cfg.domain}.gpri "${home}/.gale/auth/private/"
153+ install -m 0644 ${gpubFile} "${home}/.gale/auth/private/${cfg.domain}.gpub"
154+ install -m 0644 ${gpubFile} "${home}/auth/local/${cfg.domain}.gpub"
155+ chown -R ${cfg.user}:${cfg.group} ${home}
156+ '';
157+
158+ serviceConfig = {
159+ Type = "forking";
160+ ExecStart = "@${pkgs.gale}/bin/galed galed";
161+ User = cfg.user;
162+ Group = cfg.group;
163+ PermissionsStartOnly = true;
164+ };
165+ };
166+
167+ systemd.services.gale-gdomain = {
168+ description = "Gale AKD daemon";
169+ wantedBy = [ "multi-user.target" ];
170+ requires = [ "gale-galed.service" ];
171+ after = [ "gale-galed.service" ];
172+
173+ serviceConfig = {
174+ Type = "forking";
175+ ExecStart = "@${pkgs.gale}/bin/gdomain gdomain";
176+ User = cfg.user;
177+ Group = cfg.group;
178+ };
179+ };
180+ })
181+ ];
182+}
pkgs/applications/networking/instant-messengers/gale/default.nixnew file+31
@@ -0,0 +1,31 @@
1+{ stdenv, fetchFromGitHub, adns, boehmgc, openssl, automake, m4, autoconf
2+, libtool, pkgconfig }:
3+
4+stdenv.mkDerivation {
5+ name = "gale-1.1happy";
6+
7+ src = fetchFromGitHub {
8+ owner = "grawity";
9+ repo = "gale";
10+ rev = "b34a67288e8bd6f0b51b60abb704858172a3665c";
11+ sha256 = "19mcisxxqx70m059rqwv7wpmp94fgyckzjwywpmdqd7iwvppnsqf";
12+ };
13+
14+ nativeBuildInputs = [ m4 libtool automake autoconf ];
15+ buildInputs = [ boehmgc openssl adns pkgconfig ];
16+
17+ patches = [ ./gale-install.in.patch ];
18+
19+ preConfigure = ''
20+ substituteInPlace configure.ac --replace \$\{sysconfdir\} /etc
21+ ./bootstrap
22+ '';
23+ configureArgs = [ "--sysconfdir=/etc" ];
24+
25+ meta = with stdenv.lib; {
26+ homepage = "http://gale.org/";
27+ description = "chat/messaging system (server and client)";
28+ platforms = platforms.all;
29+ license = licenses.gpl2Plus;
30+ };
31+}
pkgs/applications/networking/instant-messengers/gale/gale-install.in.patchnew file+339
@@ -0,0 +1,339 @@
1+diff --git a/gale-install.in b/gale-install.in
2+index 50e8ad8..eec0ed2 100644
3+--- a/gale-install.in
4++++ b/gale-install.in
5+@@ -29,22 +29,78 @@ testkey_stdin() {
6+ gkinfo -x 2>/dev/null | qgrep "^Public key: <$1>"
7+ }
8+
9+-if [ -n "$GALE_SYS_DIR" ]; then
10+- SYS_DIR="$GALE_SYS_DIR"
11+-elif [ -n "$sysconfdir" ]; then
12+- SYS_DIR="$sysconfdir/gale"
13++INST_SYS_DIR="$sysconfdir/gale"
14++
15++if [ `id -u` -eq 0 ]; then
16++ is_root=yes
17++ SYS_DIR=/etc/gale
18++else
19++ is_root=no
20++ SYS_DIR="$HOME/.gale"
21++fi
22++
23++if [ -f /etc/NIXOS ]; then
24++ is_nixos=yes
25++else
26++ is_nixos=no
27++fi
28++
29++if [ -u /var/setuid-wrappers/gksign ]; then
30++ cat <<EOM
31++
32++Gale appears to have already been set up via the NixOS module system (check
33++/etc/nixos/configuration.nix).
34++
35++EOM
36++
37++ exit 0
38++fi
39++
40++if [ $is_root = yes ]; then
41++ cat <<EOM
42++
43++You are running gale-install as root, so I'm going to assume you want to set up
44++Gale for system-wide use. Unfortunately, Gale expects to be able to run the
45++"gksign" program via setuid, and we can't change gksign's permissions once it's
46++already been installed because the Nix store is immutable by design.
47++
48++EOM
49++
50++ if [ $is_nixos = no ]; then
51++ cat <<EOM
52++
53++This isn't a NixOS system. Gale can only be installed for a single user on
54++non-NixOS systems. If you want a system-wide installation, you'll have to
55++install Gale the old-fashioned way. Sorry.
56++
57++EOM
58++
59++ exit 1
60++ fi
61++ cat <<EOM
62++
63++This script will generate a domain key for you, and after you get it signed, you
64++can finish the setup process by configuring Gale via the NixOS module system
65++(i.e. /etc/nixos/configuration.nix).
66++
67++EOM
68++
69+ else
70+- echo "Error: cannot locate Gale system configuration directory."
71+- exit 1
72++ cat <<EOM
73++
74++Hi. You are running gale-install as a normal user, so I'm going to assume you
75++want to set up Gale for your own (i.e. non-system-wide) use.
76++
77++EOM
78++
79+ fi
80+
81+-CONF="$SYS_DIR/conf"
82+ umask 022
83+-PATH="$bindir:$sbindir:$PATH:/usr/ucb"
84++PATH="$bindir:$sbindir:$PATH"
85+ export PATH
86+
87+-if [ -f "$CONF" ]; then
88+- exec 3<"$CONF"
89++if [ -n "$SYS_DIR" ] && [ -f "$SYS_DIR/conf" ]; then
90++ exec 3<"$SYS_DIR/conf"
91+
92+ while read var value <&3 ; do
93+ case "$var" in
94+@@ -58,52 +114,14 @@ if [ -f "$CONF" ]; then
95+ exec 3<&-
96+ fi
97+
98+-USER="`whoami`"
99+-if [ -z "$USER" ]; then
100+- echo "Error: cannot determine your username."
101+- exit 1
102+-fi
103+-
104+-# -----------------------------------------------------------------------------
105+-# check directory structure
106+-
107+-if [ ! -d "$SYS_DIR" ]; then
108+- echo "Error: Invalid SYS_DIR: \"$SYS_DIR\"."
109+- exit 1
110+-fi
111+-
112+ # -----------------------------------------------------------------------------
113+-# get settings for important variables: user, domain, server
114++# get settings for important variables: domain, server
115+
116+-[ -n "$CONF_GALE_USER" ] && GALE_USER="$CONF_GALE_USER"
117+ [ -n "$CONF_GALE_DOMAIN" ] && GALE_DOMAIN="$CONF_GALE_DOMAIN"
118+ [ -n "$CONF_GALE_SERVER" ] && GALE_SERVER="$CONF_GALE_SERVER"
119+
120+-if [ -z "$GALE_USER" ]; then
121+-cat << EOM
122+-
123+-Hi. You need to denote a user to own the Gale domain secret key. You must
124+-trust this user with Gale authentication for your domain; the "gksign" program
125+-will run as this user. I recommend using a special "gale" user; if you don't
126+-have administrative privileges here, you'll probably have to use your own
127+-account. I do not recommend the use of "root".
128+-
129+-No harm done if you stop this script now to set up such a user.
130+-
131+-EOM
132+-
133+- printf "Enter the Gale username: "
134+- read GALE_USER
135+- if [ -z "$GALE_USER" ]; then
136+- echo "Error: Invalid username or no home dir: \"$GALE_USER\"."
137+- exit 1
138+- fi
139+-else
140+- echo "Using \"$GALE_USER\" as the Gale owner."
141+-fi
142+-
143+ if [ -z "$GALE_DOMAIN" ] ; then
144+-cat << EOM
145++ cat << EOM
146+
147+ You need to identify the name of your Gale domain for two purposes:
148+
149+@@ -140,97 +158,56 @@ else
150+ fi
151+
152+ # -----------------------------------------------------------------------------
153+-# create configuration file
154+-
155+-if [ ! -f "$CONF" ]; then
156+-cat > "$CONF" <<EOM
157+-# $CONF -- created by Gale installer; edit to suit.
158+-EOM
159++# create configuration file (if this is a single-user setup)
160++
161++if [ $is_root = no ]; then
162++ CONF="$SYS_DIR/conf"
163++
164++ if [ ! -d "$SYS_DIR" ]; then
165++ run mkdir -m 0700 -p "$SYS_DIR"
166++ run mkdir -m 0700 -p "$SYS_DIR/auth"
167++ run mkdir -m 0755 -p "$SYS_DIR/auth/trusted"
168++ run cp -f "$INST_SYS_DIR/auth/trusted/ROOT" "$SYS_DIR/auth/trusted"
169++ run mkdir -m 0700 -p "$SYS_DIR/auth/private"
170++ run mkdir -p "$SYS_DIR/auth/local" "$SYS_DIR/auth/cache"
171++ fi
172+
173+-cat <<EOM
174++ if [ ! -f "$CONF" ]; then
175++ cat <<EOM
176+
177+ *** Creating "$CONF".
178+ Examine and edit this file to your taste and local needs.
179+ If you want to recreate it from scratch, remove it and re-run this.
180+-EOM
181+-fi
182+-
183+-[ -n "$CONF_GALE_USER" ] || cat >> "$CONF" <<EOM
184+
185+-# The user who owns the domain secret key. (Used in installation and upgrade)
186+-GALE_USER $GALE_USER
187+ EOM
188+
189+-[ -n "$CONF_GALE_DOMAIN" ] || cat >> "$CONF" << EOM
190++ cat > "$CONF" <<EOF
191++# $CONF -- created by Gale installer; edit to suit.
192+
193+ # The authentication domain to use. (Mandatory)
194+ GALE_DOMAIN $GALE_DOMAIN
195+-EOM
196+-
197+-# -----------------------------------------------------------------------------
198+-# make gksign setuid
199++EOF
200+
201+-gksign="$sbindir/gksign"
202+-readlink="`which readlink 2>/dev/null`"
203+-[ -x "$readlink" ] && gksignlink="`"$readlink" "$gksign" 2>/dev/null`"
204+-[ -f "$gksignlink" ] && gksign="$gksignlink"
205+-
206+-echo ""
207+-if copy chown "$GALE_USER" "$gksign" ; then
208+- :
209+-else
210+- echo "*** We need to chown $GALE_USER '$gksign'."
211+- echo " Please run this script as a user that can do so,"
212+- echo " or do so yourself and re-run this script."
213+- exit 1
214++ fi
215+ fi
216+-run chmod 4755 "$gksign"
217+
218+-# -----------------------------------------------------------------------------
219+-# create a domain, if necessary
220++if [ $is_root = no ]; then
221++ GALE_SYS_DIR="$SYS_DIR"
222++ export GALE_SYS_DIR
223+
224+-echo ""
225+-if test -u "$gksign" || copy chmod u+s "$gksign" ; then
226+- :
227++ testkey "$GALE_DOMAIN" && exit 0
228++ echo "*** You lack a signed key for your domain, \"$GALE_DOMAIN\"."
229++ GALE="$SYS_DIR"
230+ else
231+- echo "*** We need to chmod u+s '$gksign'."
232+- echo " Please run this script as a user that can do so,"
233+- echo " or do so yourself and re-run this script."
234+- exit 1
235+-fi
236+-
237+-testkey "$GALE_DOMAIN" && exit 0
238+-echo "*** You lack a signed key for your domain, \"$GALE_DOMAIN\"."
239+-
240+-if [ "x$GALE_USER" != "x$USER" ]; then
241+-cat <<EOM
242+-Become user "$GALE_USER" (you are now "$USER") and run this script again
243+-to create a new domain; contact your domain administrator if you wish to
244+-become part of an existing domain.
245+-EOM
246+- exit 1
247+-fi
248+-
249+-if [ -z "$HOME" ]; then
250+- cd
251+- HOME="`pwd`"
252+- echo "Warning: \$HOME not set, assuming \"$HOME\"."
253+-fi
254+-
255+-GALE="$HOME/.gale"
256+-mkdir -p "$GALE"
257+-if [ ! -w "$GALE" ]; then
258+- echo "Error: Cannot create \"$GALE\"."
259+- exit 1
260++ GALE="`pwd`"
261+ fi
262+
263+ unsigned="$GALE/$GALE_DOMAIN.unsigned"
264+ signer="`echo "$GALE_DOMAIN" | sed 's%^[^.@:/]*[.@:/]%%'`"
265+ [ -z "$signer" ] && signer="ROOT"
266+
267+-if [ -f "$unsigned" ]; then
268+-
269+-cat << EOM
270++if [ $is_root = no ] && [ -f "$unsigned" ]; then
271++ cat << EOM
272+
273+ Okay, so we've already been here. Last time, I created the file
274+ "$unsigned" for you to have signed.
275+@@ -275,16 +252,12 @@ EOM
276+ exit 1
277+ fi
278+
279+-cat << EOM
280+-
281+-The domain should be properly configured now. Assuming users can access a
282+-version of "gksign" setuid to "$GALE_USER" (this user), they should be
283+-able to start running clients and generating IDs for themselves.
284++ cat << EOM
285+
286+-The installation process is complete!
287++The domain should be properly configured now. The installation process is
288++complete!
289+
290+ EOM
291+-
292+ exit 0
293+ fi
294+
295+@@ -300,7 +273,10 @@ printf "Enter the description: "
296+ read descr
297+
298+ echo "We will generate the key now. Have patience."
299+-gkgen -r "$GALE/auth/private/$GALE_DOMAIN.gpri" \
300++if [ $is_root = no ]; then
301++ install_gpri=auth/private/
302++fi
303++gkgen -r "$GALE/${install_gpri}$GALE_DOMAIN.gpri" \
304+ -u "$unsigned" "$GALE_DOMAIN" /"$descr" || exit 1
305+
306+ cat << EOM
307+@@ -311,8 +284,29 @@ the owner of the "$signer" domain through appropriate means.
308+ Take care to preseve the file's binary data; you may need to uuencode it.
309+
310+ Assuming they trust you with your subdomain, they should pass the key through
311+-"gksign" as a filter, returning the signed output to you. When you have this
312+-signed key file available, re-run this script, and we will move on to the
313+-next step.
314++"gksign" as a filter, returning the signed output to you.
315++
316++EOM
317++
318++if [ $is_nixos = yes ]; then
319++ cat <<EOM
320++
321++When you have this signed key file available, you can finish the setup process
322++by placing the private key and signed public key in a directory (they will be
323++copied) and setting "services.gale.keyPath" in /etc/nixos/configuration.nix.
324+
325+ EOM
326++else
327++ cat <<EOM
328++
329++When you have this signed key file available, re-run this script, and we will
330++move on to the next step.
331++
332++*** IMPORTANT ***
333++You must set GALE_SYS_DIR="$GALE_SYS_DIR" in your environment before re-running
334++this script and before running any Gale programs once setup is finished! Make
335++sure to set it now, and consider setting it via your shell initialization files
336++so that you don't forget to do it next login.
337++
338++EOM
339++fi
pkgs/top-level/all-packages.nix+2
@@ -15380,6 +15380,8 @@ let
1538015380
1538115381 gajim = callPackage ../applications/networking/instant-messengers/gajim { };
1538215382
15383+ gale = callPackage ../applications/networking/instant-messengers/gale { };
15384+
1538315385 gammu = callPackage ../applications/misc/gammu { };
1538415386
1538515387 gensgs = callPackage_i686 ../misc/emulators/gens-gs { };