diff -Paur --no-dereference -- libdbus.upstream/bus/Makefile.in libdbus/bus/Makefile.in
--- libdbus.upstream/bus/Makefile.in
+++ libdbus/bus/Makefile.in
@@ -604,7 +604,8 @@
 	sysusers.d/meson.build tmpfiles.d/dbus.conf.in \
 	tmpfiles.d/meson.build $(NULL)
 dbusdata_DATA = session.conf $(am__append_1)
-legacydbusdata_DATA = legacy-config/session.conf $(am__append_2)
+# PATCH: Don't install empty removable configuration files in /etc.
+legacydbusdata_DATA =
 examplesdir = ${docdir}/examples
 examples_DATA = \
 	example-system-enable-stats.conf	\
@@ -1469,7 +1470,6 @@
 install-data-hook:
 	$(mkinstalldirs) $(DESTDIR)$(dbusdatadir)/session.d
 	$(mkinstalldirs) $(DESTDIR)$(dbusdatadir)/services
-@DBUS_UNIX_TRUE@	$(mkinstalldirs) $(DESTDIR)$(runstatedir)/dbus
 @DBUS_UNIX_TRUE@	$(mkinstalldirs) $(DESTDIR)$(dbusdatadir)/system.d
 @DBUS_UNIX_TRUE@	$(mkinstalldirs) $(DESTDIR)$(dbusdatadir)/system-services
 # Install dbus.socket as default implementation of a D-Bus stack.
diff -Paur --no-dereference -- libdbus.upstream/bus/activation-helper.c libdbus/bus/activation-helper.c
--- libdbus.upstream/bus/activation-helper.c
+++ libdbus/bus/activation-helper.c
@@ -48,6 +48,10 @@
 #include <dbus/dbus-marshal-validate.h>
 #include <dbus/dbus-sysdeps-unix.h>
 
+#if defined(__sortix__) && !defined(__SORTIX_HAS_INITGROUPS__)
+#define initgroups(a, b) 0
+#endif
+
 static BusDesktopFile *
 desktop_file_for_name (BusConfigParser *parser,
                        const char *name,
@@ -320,7 +324,7 @@
   if (setgid (pw->pw_gid))
     {
       dbus_set_error (error, DBUS_ERROR_SPAWN_SETUP_FAILED,
-                      "cannot setgid group %i", pw->pw_gid);
+                      "cannot setgid group %ju", (uintmax_t)pw->pw_gid);
       return FALSE;
     }
 
@@ -328,7 +332,7 @@
   if (setuid (pw->pw_uid) < 0)
     {
       dbus_set_error (error, DBUS_ERROR_SPAWN_SETUP_FAILED,
-                      "cannot setuid user %i", pw->pw_uid);
+                      "cannot setuid user %ju", (uintmax_t)pw->pw_uid);
       return FALSE;
     }
 #endif
diff -Paur --no-dereference -- libdbus.upstream/dbus/dbus-sysdeps-unix.c libdbus/dbus/dbus-sysdeps-unix.c
--- libdbus.upstream/dbus/dbus-sysdeps-unix.c
+++ libdbus/dbus/dbus-sysdeps-unix.c
@@ -2234,9 +2234,13 @@
    * we need these assertions to fail as soon as we're wrong about
    * it so we can do the porting fixups
    */
-  _DBUS_STATIC_ASSERT (sizeof (pid_t) <= sizeof (dbus_pid_t));
-  _DBUS_STATIC_ASSERT (sizeof (uid_t) <= sizeof (dbus_uid_t));
-  _DBUS_STATIC_ASSERT (sizeof (gid_t) <= sizeof (dbus_gid_t));
+  // PATCH: 32-bit Sortix has 64-bit pid_t, uid_t, and gid_t. Patching the
+  //        support into libdbus was a bit too non-trivial when I was tired and
+  //        was across the codebase, so for now let's just be buggy on too big
+  //        numbers.
+  //_DBUS_STATIC_ASSERT (sizeof (pid_t) <= sizeof (dbus_pid_t));
+  //_DBUS_STATIC_ASSERT (sizeof (uid_t) <= sizeof (dbus_uid_t));
+  //_DBUS_STATIC_ASSERT (sizeof (gid_t) <= sizeof (dbus_gid_t));
 
   uid_read = DBUS_UID_UNSET;
   primary_gid_read = DBUS_GID_UNSET;
@@ -2969,9 +2973,9 @@
    * we need these assertions to fail as soon as we're wrong about
    * it so we can do the porting fixups
    */
-  _DBUS_STATIC_ASSERT (sizeof (pid_t) <= sizeof (dbus_pid_t));
-  _DBUS_STATIC_ASSERT (sizeof (uid_t) <= sizeof (dbus_uid_t));
-  _DBUS_STATIC_ASSERT (sizeof (gid_t) <= sizeof (dbus_gid_t));
+  //_DBUS_STATIC_ASSERT (sizeof (pid_t) <= sizeof (dbus_pid_t));
+  //_DBUS_STATIC_ASSERT (sizeof (uid_t) <= sizeof (dbus_uid_t));
+  //_DBUS_STATIC_ASSERT (sizeof (gid_t) <= sizeof (dbus_gid_t));
 
   if (!_dbus_credentials_add_pid(credentials, _dbus_getpid()))
     return FALSE;
diff -Paur --no-dereference -- libdbus.upstream/dbus/dbus-sysdeps-util-unix.c libdbus/dbus/dbus-sysdeps-util-unix.c
--- libdbus.upstream/dbus/dbus-sysdeps-util-unix.c
+++ libdbus/dbus/dbus-sysdeps-util-unix.c
@@ -67,6 +67,10 @@
 #define O_BINARY 0
 #endif
 
+#if defined(__sortix__) && !defined(__SORTIX_HAS_SETGROUPS__)
+#define setgroups(a, b) 0
+#endif
+
 /**
  * @addtogroup DBusInternalsUtils
  * @{
diff -Paur --no-dereference -- libdbus.upstream/test/Makefile.in libdbus/test/Makefile.in
--- libdbus.upstream/test/Makefile.in
+++ libdbus/test/Makefile.in
@@ -3163,6 +3163,9 @@
 	-rm -f internals/$(DEPDIR)/sysdeps.Po
 	-rm -f internals/$(DEPDIR)/syslog.Po
 	-rm -f internals/$(DEPDIR)/variant.Po
+	for F in $(in_data); do \
+		rm -f "$${F%.in}"; \
+	done
 	-rm -f Makefile
 distclean-am: clean-am distclean-compile distclean-generic \
 	distclean-tags
diff -Paur --no-dereference -- libdbus.upstream/tools/dbus-launch.c libdbus/tools/dbus-launch.c
--- libdbus.upstream/tools/dbus-launch.c
+++ libdbus/tools/dbus-launch.c
@@ -758,18 +758,15 @@
            int binary_syntax,
            int argc, char **argv, int remaining_args)
 {
-  char *envvar = NULL;
   char **args = NULL;
 
   if (runprog)
     {
       int i;
 
-      envvar = malloc (strlen ("DBUS_SESSION_BUS_ADDRESS=") +
-          strlen (bus_address) + 1);
       args = malloc (sizeof (char *) * ((argc-remaining_args)+2));
 
-      if (envvar == NULL || args == NULL)
+      if (args == NULL)
         goto oom;
 
       args[0] = xstrdup (runprog);
@@ -789,9 +786,7 @@
         }
       args[i] = NULL;
 
-      strcpy (envvar, "DBUS_SESSION_BUS_ADDRESS=");
-      strcat (envvar, bus_address);
-      putenv (envvar);
+      setenv ("DBUS_SESSION_BUS_ADDRESS", bus_address, 1);
 
       execvp (runprog, args);
       fprintf (stderr, "Couldn't exec %s: %s\n", runprog, strerror (errno));
@@ -810,9 +805,6 @@
   close (2);
   exit (0);
 oom:
-  if (envvar)
-    free (envvar);
-
   if (args)
     free (args);
 
diff -Paur --no-dereference -- libdbus.upstream/tools/dbus-print-message.c libdbus/tools/dbus-print-message.c
--- libdbus.upstream/tools/dbus-print-message.c
+++ libdbus/tools/dbus-print-message.c
@@ -31,7 +31,7 @@
 #include <sys/un.h>
 #include <unistd.h>
 #include <netinet/in.h>
-#include <netinet/ip.h>
+/* PATCH: <netinet/ip.h> is not needed */
 #include <arpa/inet.h>
 #endif
 
