about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/libraries/dbus
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/development/libraries/dbus')
-rw-r--r--nixpkgs/pkgs/development/libraries/dbus/default.nix122
-rw-r--r--nixpkgs/pkgs/development/libraries/dbus/implement-getgrouplist.patch108
-rw-r--r--nixpkgs/pkgs/development/libraries/dbus/make-dbus-conf.nix45
-rw-r--r--nixpkgs/pkgs/development/libraries/dbus/make-session-conf.xsl36
-rw-r--r--nixpkgs/pkgs/development/libraries/dbus/make-system-conf.xsl39
5 files changed, 350 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/development/libraries/dbus/default.nix b/nixpkgs/pkgs/development/libraries/dbus/default.nix
new file mode 100644
index 000000000000..52928e1005ff
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/dbus/default.nix
@@ -0,0 +1,122 @@
+{ stdenv
+, lib
+, fetchurl
+, pkg-config
+, expat
+, enableSystemd ? lib.meta.availableOn stdenv.hostPlatform systemdMinimal
+, systemdMinimal
+, audit
+, libapparmor
+, dbus
+, docbook_xml_dtd_44
+, docbook-xsl-nons
+, xmlto
+, autoreconfHook
+, autoconf-archive
+, x11Support ? (stdenv.isLinux || stdenv.isDarwin)
+, xorg
+}:
+
+stdenv.mkDerivation rec {
+  pname = "dbus";
+  version = "1.14.6";
+
+  src = fetchurl {
+    url = "https://dbus.freedesktop.org/releases/dbus/dbus-${version}.tar.xz";
+    sha256 = "sha256-/SvfG7idw2WkZTG/9jFTbyKw0cbVzixcXlm1UmWz1ms=";
+  };
+
+  patches = lib.optional stdenv.isSunOS ./implement-getgrouplist.patch;
+
+  postPatch = ''
+    substituteInPlace bus/Makefile.am \
+      --replace 'install-data-hook:' 'disabled:' \
+      --replace '$(mkinstalldirs) $(DESTDIR)$(localstatedir)/run/dbus' ':'
+    substituteInPlace tools/Makefile.am \
+      --replace 'install-data-local:' 'disabled:' \
+      --replace 'installcheck-local:' 'disabled:'
+  '' + /* cleanup of runtime references */ ''
+    substituteInPlace ./dbus/dbus-sysdeps-unix.c \
+      --replace 'DBUS_BINDIR "/dbus-launch"' "\"$lib/bin/dbus-launch\""
+    substituteInPlace ./tools/dbus-launch.c \
+      --replace 'DBUS_DAEMONDIR"/dbus-daemon"' '"/run/current-system/sw/bin/dbus-daemon"'
+  '';
+
+  outputs = [ "out" "dev" "lib" "doc" "man" ];
+
+  strictDeps = true;
+  nativeBuildInputs = [
+    autoreconfHook
+    autoconf-archive
+    pkg-config
+    docbook_xml_dtd_44
+    docbook-xsl-nons
+    xmlto
+  ];
+
+  propagatedBuildInputs = [
+    expat
+  ];
+
+  buildInputs =
+    lib.optionals x11Support (with xorg; [
+      libX11
+      libICE
+      libSM
+    ]) ++ lib.optional enableSystemd systemdMinimal
+    ++ lib.optionals stdenv.isLinux [ audit libapparmor ];
+  # ToDo: optional selinux?
+
+  __darwinAllowLocalNetworking = true;
+
+  configureFlags = [
+    "--enable-user-session"
+    "--enable-xml-docs"
+    "--libexecdir=${placeholder "out"}/libexec"
+    "--datadir=/etc"
+    "--localstatedir=/var"
+    "--runstatedir=/run"
+    "--sysconfdir=/etc"
+    "--with-session-socket-dir=/tmp"
+    "--with-system-pid-file=/run/dbus/pid"
+    "--with-system-socket=/run/dbus/system_bus_socket"
+    "--with-systemdsystemunitdir=${placeholder "out"}/etc/systemd/system"
+    "--with-systemduserunitdir=${placeholder "out"}/etc/systemd/user"
+  ] ++ lib.optional (!x11Support) "--without-x"
+  ++ lib.optionals stdenv.isLinux [ "--enable-apparmor" "--enable-libaudit" ]
+  ++ lib.optionals enableSystemd [ "SYSTEMCTL=${systemdMinimal}/bin/systemctl" ];
+
+  NIX_CFLAGS_LINK = lib.optionalString (!stdenv.isDarwin) "-Wl,--as-needed";
+
+  enableParallelBuilding = true;
+
+  doCheck = true;
+
+  makeFlags = [
+    # Fix paths in XML catalog broken by mismatching build/install datadir.
+    "dtddir=${placeholder "out"}/share/xml/dbus-1"
+  ];
+
+  installFlags = [
+    "sysconfdir=${placeholder "out"}/etc"
+    "datadir=${placeholder "out"}/share"
+  ];
+
+  # it's executed from $lib by absolute path
+  postFixup = ''
+    moveToOutput bin/dbus-launch "$lib"
+    ln -s "$lib/bin/dbus-launch" "$out/bin/"
+  '';
+
+  passthru = {
+    dbus-launch = "${dbus.lib}/bin/dbus-launch";
+  };
+
+  meta = with lib; {
+    description = "Simple interprocess messaging system";
+    homepage = "http://www.freedesktop.org/wiki/Software/dbus/";
+    license = licenses.gpl2Plus; # most is also under AFL-2.1
+    maintainers = teams.freedesktop.members ++ (with maintainers; [ ]);
+    platforms = platforms.unix;
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/dbus/implement-getgrouplist.patch b/nixpkgs/pkgs/development/libraries/dbus/implement-getgrouplist.patch
new file mode 100644
index 000000000000..e3a4a25cb720
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/dbus/implement-getgrouplist.patch
@@ -0,0 +1,108 @@
+Compatibility patch for Illumos/Solaris and possibly other platforms.
+Implements getgrouplist when not provided by OS.
+Without it, only the user's primary group is used in authentication!
+--- 	1970-01-01 00:00:00.000000000 +0000
++++ dbus-1.6.8/dbus/getgrouplist.c	2013-02-28 13:10:51.081792722 +0000
+@@ -0,0 +1,89 @@
++/*	$OpenBSD: getgrouplist.c,v 1.12 2005/08/08 08:05:34 espie Exp $ */
++/*
++ * Copyright (c) 1991, 1993
++ *	The Regents of the University of California.  All rights reserved.
++ *
++ * Redistribution and use in source and binary forms, with or without
++ * modification, are permitted provided that the following conditions
++ * are met:
++ * 1. Redistributions of source code must retain the above copyright
++ *    notice, this list of conditions and the following disclaimer.
++ * 2. Redistributions in binary form must reproduce the above copyright
++ *    notice, this list of conditions and the following disclaimer in the
++ *    documentation and/or other materials provided with the distribution.
++ * 3. Neither the name of the University nor the names of its contributors
++ *    may be used to endorse or promote products derived from this software
++ *    without specific prior written permission.
++ *
++ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
++ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
++ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
++ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
++ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
++ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
++ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
++ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
++ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
++ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
++ * SUCH DAMAGE.
++ */
++
++/* OPENBSD ORIGINAL: lib/libc/gen/getgrouplist.c */
++
++/*
++ * get credential
++ */
++#include <sys/types.h>
++#include <string.h>
++#include <unistd.h>
++#include <grp.h>
++
++int
++getgrouplist(const char *uname, gid_t agroup, gid_t *groups, int *grpcnt)
++{
++	struct group *grp;
++	int i, ngroups;
++	int ret, maxgroups;
++	int bail;
++
++	ret = 0;
++	ngroups = 0;
++	maxgroups = *grpcnt;
++
++	/*
++	 * install primary group
++	 */
++	if (ngroups >= maxgroups) {
++		*grpcnt = ngroups;
++		return (-1);
++	}
++	groups[ngroups++] = agroup;
++
++	/*
++	 * Scan the group file to find additional groups.
++	 */
++	setgrent();
++	while ((grp = getgrent())) {
++		if (grp->gr_gid == agroup)
++			continue;
++		for (bail = 0, i = 0; bail == 0 && i < ngroups; i++)
++			if (groups[i] == grp->gr_gid)
++				bail = 1;
++		if (bail)
++			continue;
++		for (i = 0; grp->gr_mem[i]; i++) {
++			if (!strcmp(grp->gr_mem[i], uname)) {
++				if (ngroups >= maxgroups) {
++					ret = -1;
++					goto out;
++				}
++				groups[ngroups++] = grp->gr_gid;
++				break;
++			}
++		}
++	}
++out:
++	endgrent();
++	*grpcnt = ngroups;
++	return (ret);
++}
+--- dbus-1.6.8/dbus/dbus-sysdeps-unix.c.orig	2013-02-28 13:08:52.171215237 +0000
++++ dbus-1.6.8/dbus/dbus-sysdeps-unix.c	2013-02-28 13:13:52.224615146 +0000
+@@ -21,6 +21,10 @@
+  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+  *
+  */
++#ifndef HAVE_GETGROUPLIST
++#include "getgrouplist.c"
++#define HAVE_GETGROUPLIST
++#endif
+ 
+ #include <config.h>
+ 
diff --git a/nixpkgs/pkgs/development/libraries/dbus/make-dbus-conf.nix b/nixpkgs/pkgs/development/libraries/dbus/make-dbus-conf.nix
new file mode 100644
index 000000000000..125da383c8d1
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/dbus/make-dbus-conf.nix
@@ -0,0 +1,45 @@
+{ runCommand
+, writeText
+, libxslt
+, dbus
+, findXMLCatalogs
+, serviceDirectories ? []
+, suidHelper ? "/var/setuid-wrappers/dbus-daemon-launch-helper"
+, apparmor ? "disabled" # one of enabled, disabled, required
+}:
+
+/* DBus has two configuration parsers -- normal and "trivial", which is used
+ * for suid helper. Unfortunately the latter doesn't support <include>
+ * directive. That means that we can't just place our configuration to
+ * *-local.conf -- it needs to be in the main configuration file.
+ */
+runCommand "dbus-1"
+  {
+    inherit serviceDirectories suidHelper apparmor;
+    preferLocalBuild = true;
+    allowSubstitutes = false;
+
+    nativeBuildInputs = [
+      libxslt.bin
+      findXMLCatalogs
+    ];
+
+    buildInputs = [
+      dbus.out
+    ];
+  }
+  ''
+    mkdir -p $out
+
+    xsltproc --nonet \
+      --stringparam serviceDirectories "$serviceDirectories" \
+      --stringparam suidHelper "$suidHelper" \
+      --stringparam apparmor "$apparmor" \
+      ${./make-system-conf.xsl} ${dbus}/share/dbus-1/system.conf \
+      > $out/system.conf
+    xsltproc --nonet \
+      --stringparam serviceDirectories "$serviceDirectories" \
+      --stringparam apparmor "$apparmor" \
+      ${./make-session-conf.xsl} ${dbus}/share/dbus-1/session.conf \
+      > $out/session.conf
+  ''
diff --git a/nixpkgs/pkgs/development/libraries/dbus/make-session-conf.xsl b/nixpkgs/pkgs/development/libraries/dbus/make-session-conf.xsl
new file mode 100644
index 000000000000..a744905cdd39
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/dbus/make-session-conf.xsl
@@ -0,0 +1,36 @@
+<?xml version="1.0"?>
+
+<!--
+  This script copies the original system.conf from the dbus
+  distribution, but sets paths from $serviceDirectories parameter
+  and suid helper from $suidHelper parameter.
+-->
+
+<xsl:stylesheet version="1.0"
+                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+                xmlns:str="http://exslt.org/strings"
+                extension-element-prefixes="str"
+                >
+
+  <xsl:output method='xml' encoding="UTF-8" doctype-system="busconfig.dtd" />
+
+  <xsl:param name="serviceDirectories" />
+  <xsl:param name="apparmor" />
+
+  <xsl:template match="/busconfig">
+    <busconfig>
+      <!-- We leave <standard_session_servicedirs/> because it includes XDG dirs and therefore user Nix profile. -->
+      <xsl:copy-of select="child::node()[name() != 'include' and name() != 'servicedir' and name() != 'includedir']" />
+
+      <!-- configure AppArmor -->
+      <apparmor mode="{$apparmor}"/>
+
+      <xsl:for-each select="str:tokenize($serviceDirectories)">
+        <servicedir><xsl:value-of select="." />/share/dbus-1/services</servicedir>
+        <includedir><xsl:value-of select="." />/etc/dbus-1/session.d</includedir>
+        <includedir><xsl:value-of select="." />/share/dbus-1/session.d</includedir>
+      </xsl:for-each>
+    </busconfig>
+  </xsl:template>
+
+</xsl:stylesheet>
diff --git a/nixpkgs/pkgs/development/libraries/dbus/make-system-conf.xsl b/nixpkgs/pkgs/development/libraries/dbus/make-system-conf.xsl
new file mode 100644
index 000000000000..06233e764e16
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/dbus/make-system-conf.xsl
@@ -0,0 +1,39 @@
+<?xml version="1.0"?>
+
+<!--
+  This script copies the original system.conf from the dbus
+  distribution, but sets paths from $serviceDirectories parameter
+  and suid helper from $suidHelper parameter.
+-->
+
+<xsl:stylesheet version="1.0"
+                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+                xmlns:str="http://exslt.org/strings"
+                extension-element-prefixes="str"
+                >
+
+  <xsl:output method='xml' encoding="UTF-8" doctype-system="busconfig.dtd" />
+
+  <xsl:param name="serviceDirectories" />
+  <xsl:param name="suidHelper" />
+  <xsl:param name="apparmor" />
+
+  <xsl:template match="/busconfig">
+    <busconfig>
+      <xsl:copy-of select="child::node()[name() != 'include' and name() != 'standard_system_servicedirs' and name() != 'servicehelper' and name() != 'servicedir' and name() != 'includedir']" />
+
+      <!-- configure AppArmor -->
+      <apparmor mode="{$apparmor}"/>
+
+      <!-- set suid helper -->
+      <servicehelper><xsl:value-of select="$suidHelper" /></servicehelper>
+
+      <xsl:for-each select="str:tokenize($serviceDirectories)">
+        <servicedir><xsl:value-of select="." />/share/dbus-1/system-services</servicedir>
+        <includedir><xsl:value-of select="." />/etc/dbus-1/system.d</includedir>
+        <includedir><xsl:value-of select="." />/share/dbus-1/system.d</includedir>
+      </xsl:for-each>
+    </busconfig>
+  </xsl:template>
+
+</xsl:stylesheet>