From 9f8fc09fc31071c606df18e58b188365194237ab Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 3 Dec 2009 11:56:03 +0000 Subject: [PATCH] * Create a user "mediawiki" and give root and wwwrun ident-based access. svn path=/nixos/trunk/; revision=18779 --- modules/services/databases/postgresql.nix | 8 ++++++++ modules/services/web-servers/apache-httpd/mediawiki.nix | 9 ++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/modules/services/databases/postgresql.nix b/modules/services/databases/postgresql.nix index 16056ab96a7b..4a51d47b038d 100644 --- a/modules/services/databases/postgresql.nix +++ b/modules/services/databases/postgresql.nix @@ -63,6 +63,7 @@ in authentication = mkOption { default = '' # Generated file; do not edit! + local all mediawiki ident mediawiki-users local all all ident sameuser host all all 127.0.0.1/32 md5 host all all ::1/128 md5 @@ -113,6 +114,13 @@ in environment.systemPackages = [postgresql]; + # !!! This should be be in the mediawiki module, obviously. + services.postgresql.identMap = + '' + mediawiki-users root mediawiki + mediawiki-users wwwrun mediawiki + ''; + jobs.postgresql = { description = "PostgreSQL server"; diff --git a/modules/services/web-servers/apache-httpd/mediawiki.nix b/modules/services/web-servers/apache-httpd/mediawiki.nix index a2f5197b3f5d..f694f1701e66 100644 --- a/modules/services/web-servers/apache-httpd/mediawiki.nix +++ b/modules/services/web-servers/apache-httpd/mediawiki.nix @@ -111,8 +111,7 @@ in }; dbUser = mkOption { - default = "wwwrun"; - example = "mediawiki"; + default = "mediawiki"; description = "The user name for accessing the database."; }; @@ -179,7 +178,11 @@ in if ! ${pkgs.postgresql}/bin/psql -l | grep -q ' ${config.dbName} ' ; then ${pkgs.postgresql}/bin/createuser --no-superuser --no-createdb --no-createrole "${config.dbUser}" || true ${pkgs.postgresql}/bin/createdb "${config.dbName}" -O "${config.dbUser}" - ${pkgs.su}/bin/su -s ${pkgs.stdenv.shell} "${config.dbUser}" -c "(echo 'CREATE LANGUAGE plpgsql;'; cat ${mediawikiRoot}/maintenance/postgres/tables.sql; echo 'CREATE TEXT SEARCH CONFIGURATION public.default ( COPY = pg_catalog.english );'; echo COMMIT) | ${pkgs.postgresql}/bin/psql ${config.dbName}" + ( echo 'CREATE LANGUAGE plpgsql;' + cat ${mediawikiRoot}/maintenance/postgres/tables.sql + echo 'CREATE TEXT SEARCH CONFIGURATION public.default ( COPY = pg_catalog.english );' + echo COMMIT + ) | ${pkgs.postgresql}/bin/psql -U "${config.dbUser}" "${config.dbName}" fi ''); }