diff options
Diffstat (limited to 'nixpkgs/pkgs/development/libraries/dbus')
6 files changed, 371 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..1f1eff189598 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/dbus/default.nix @@ -0,0 +1,128 @@ +{ stdenv +, lib +, fetchurl +, pkg-config +, expat +, enableSystemd ? stdenv.isLinux && !stdenv.hostPlatform.isMusl +, systemd +, audit +, libapparmor +, libX11 ? null +, libICE ? null +, libSM ? null +, x11Support ? (stdenv.isLinux || stdenv.isDarwin) +, dbus +, docbook_xml_dtd_44 +, docbook-xsl-nons +, xmlto +}: + +assert + x11Support -> + libX11 != null && libICE != null && libSM != null; + +assert enableSystemd -> systemd != null; + +stdenv.mkDerivation rec { + pname = "dbus"; + version = "1.12.20"; + + src = fetchurl { + url = "https://dbus.freedesktop.org/releases/dbus/dbus-${version}.tar.gz"; + sha256 = "1zp5gpx61v1cpqf2zwb1cidhp9xylvw49d3zydkxqk6b1qa20xpp"; + }; + + patches = [ + # 'generate.consistent.ids=1' ensures reproducible docs, for further details see + # http://docbook.sourceforge.net/release/xsl/current/doc/html/generate.consistent.ids.html + # Also applied upstream in https://gitlab.freedesktop.org/dbus/dbus/-/merge_requests/189, + # expected in version 1.14 + ./docs-reproducible-ids.patch + ] ++ (lib.optional stdenv.isSunOS ./implement-getgrouplist.patch); + + postPatch = '' + substituteInPlace tools/Makefile.in \ + --replace 'install-localstatelibDATA:' 'disabled:' \ + --replace 'install-data-local:' 'disabled:' \ + --replace 'installcheck-local:' 'disabled:' + substituteInPlace bus/Makefile.in \ + --replace '$(mkinstalldirs) $(DESTDIR)$(localstatedir)/run/dbus' ':' + '' + /* 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" ]; + + nativeBuildInputs = [ + pkg-config + docbook_xml_dtd_44 + docbook-xsl-nons + xmlto + ]; + + propagatedBuildInputs = [ + expat + ]; + + buildInputs = + lib.optionals x11Support [ + libX11 + libICE + libSM + ] ++ lib.optional enableSystemd systemd + ++ lib.optionals (!stdenv.isDarwin) [ audit libapparmor ]; + # ToDo: optional selinux? + + 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.isDarwin) [ "--enable-apparmor" "--enable-libaudit" ]; + + # Enable X11 autolaunch support in libdbus. This doesn't actually depend on X11 + # (it just execs dbus-launch in dbus.tools), contrary to what the configure script demands. + # problems building without x11Support so disabled in that case for now + NIX_CFLAGS_COMPILE = lib.optionalString x11Support "-DDBUS_ENABLE_X11_AUTOLAUNCH=1"; + NIX_CFLAGS_LINK = lib.optionalString (!stdenv.isDarwin) "-Wl,--as-needed"; + + enableParallelBuilding = true; + + doCheck = true; + + 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"; + daemon = dbus.out; + }; + + 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 = with maintainers; [ worldofpeace ]; + platforms = platforms.unix; + }; +} diff --git a/nixpkgs/pkgs/development/libraries/dbus/docs-reproducible-ids.patch b/nixpkgs/pkgs/development/libraries/dbus/docs-reproducible-ids.patch new file mode 100644 index 000000000000..2356b64d95cf --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/dbus/docs-reproducible-ids.patch @@ -0,0 +1,15 @@ +diff --color -Naur dbus-1.12.20-original/doc/Makefile.in dbus-1.12.20-hacked2/doc/Makefile.in +--- dbus-1.12.20-original/doc/Makefile.in 2020-07-02 12:10:41.000000000 +0200 ++++ dbus-1.12.20-hacked2/doc/Makefile.in 2020-11-07 09:57:15.297694773 +0100 +@@ -870,8 +870,10 @@ + .PRECIOUS: Makefile + + ++# 'generate.consistent.ids=1' ensures reproducible docs, for further details see ++# http://docbook.sourceforge.net/release/xsl/current/doc/html/generate.consistent.ids.html + @DBUS_XML_DOCS_ENABLED_TRUE@%.html: %.xml +-@DBUS_XML_DOCS_ENABLED_TRUE@ $(XMLTO) html-nochunks $< ++@DBUS_XML_DOCS_ENABLED_TRUE@ $(XMLTO) --stringparam generate.consistent.ids=1 html-nochunks $< + + @DBUS_XML_DOCS_ENABLED_TRUE@%.1: %.1.xml + @DBUS_XML_DOCS_ENABLED_TRUE@ $(XMLTO) man $< 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..ce5c0b3b5772 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/dbus/make-dbus-conf.nix @@ -0,0 +1,45 @@ +{ runCommand, writeText, libxslt, dbus +, 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; + XML_CATALOG_FILES = writeText "dbus-catalog.xml" '' + <?xml version="1.0"?> + <!DOCTYPE catalog PUBLIC + "-//OASIS//DTD Entity Resolution XML Catalog V1.0//EN" + "http://www.oasis-open.org/committees/entity/release/1.0/catalog.dtd"> + + <catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog"> + <rewriteSystem + systemIdStartString="http://www.freedesktop.org/standards/dbus/1.0/" + rewritePrefix="file://${dbus}/share/xml/dbus-1/"/> + </catalog> + ''; + nativeBuildInputs = [ libxslt.bin ]; + } + '' + 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> |