Ticket #52257: patch-improve-systembus.diff

File patch-improve-systembus.diff, 6.9 KB (added by RJVB (René Bertin), 8 years ago)
  • bus/Makefile.am

    diff --git bus/Makefile.am bus/Makefile.am
    index 268c6f0..a50ce77 100644
    CONFIG_IN_FILES= \ 
    4444        legacy-config/session.conf.in           \
    4545        legacy-config/system.conf.in            \
    4646        org.freedesktop.dbus-session.plist.in   \
     47        org.freedesktop.dbus-system.plist.in    \
    4748        example-system-enable-stats.conf.in     \
    4849        example-session-disable-stats.conf.in   \
    4950        $(NULL)
    examples_DATA = \ 
    6566if DBUS_ENABLE_LAUNCHD
    6667agentdir=$(LAUNCHD_AGENT_DIR)
    6768agent_DATA=org.freedesktop.dbus-session.plist
     69daemondir=$(LAUNCHD_DAEMON_DIR)
     70daemon_DATA=org.freedesktop.dbus-system.plist
    6871endif
    6972
    7073XML_SOURCES=config-loader-expat.c
  • new file us/org.freedesktop.dbus-system.plist.in

    diff --git bus/org.freedesktop.dbus-system.plist.in bus/org.freedesktop.dbus-system.plist.in
    new file mode 100644
    index 0000000..5af48b5
    - +  
     1<?xml version='1.0' encoding='UTF-8'?>
     2<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
     3"http://www.apple.com/DTDs/PropertyList-1.0.dtd" >
     4<plist version='1.0'>
     5<dict>
     6        <key>Label</key>
     7        <string>org.freedesktop.dbus-system</string>
     8        <key>ProgramArguments</key>
     9        <array>
     10                <string>@DBUS_DAEMONDIR@/dbus-daemon</string>
     11                <string>--system</string>
     12                <string>--nofork</string>
     13        </array>
     14        <key>KeepAlive</key><true/>
     15        <key>Disabled</key><true/>
     16        <key>Sockets</key>
     17        <dict>
     18                <key>system_bus_socket</key>
     19                <dict>
     20                        <key>SockPathName</key>
     21                        <string>@DBUS_SYSTEM_SOCKET@</string>
     22                </dict>
     23        </dict>
     24</dict>
     25</plist>
  • configure.ac

    diff --git configure.ac configure.ac
    index 460b32b..4f748ca 100644
    LT_LANG([Windows Resource]) 
    9393# Set some internal variables depending on the platform for later use.
    9494dbus_win=no
    9595dbus_cygwin=no
     96dbus_darwin=no
    9697dbus_unix=no
    9798case "${host}" in
    9899    *-mingw32ce*)
    case "${host}" in 
    106107        dbus_cygwin=yes
    107108        dbus_unix=yes
    108109        ;;
     110    *darwin*)
     111        dbus_darwin=yes
     112        dbus_unix=yes
     113        ;;
    109114    *)
    110115        dbus_unix=yes
    111116       ;;
    fi 
    139144
    140145# For best security, assume that all non-Windows platforms can do
    141146# credentials-passing.
    142 AS_IF([test "$dbus_win" = yes],
     147AS_IF([test "$dbus_win" = yes || test "$dbus_darwin" = yes],
    143148    [DBUS_SESSION_CONF_MAYBE_AUTH_EXTERNAL="<!--<auth>EXTERNAL</auth>-->"],
    144149    [DBUS_SESSION_CONF_MAYBE_AUTH_EXTERNAL="<auth>EXTERNAL</auth>"])
    145150AC_SUBST([DBUS_SESSION_CONF_MAYBE_AUTH_EXTERNAL])
    AC_ARG_WITH(system-pid-file, AS_HELP_STRING([--with-system-pid-file=[pidfile]],[ 
    196201AC_ARG_WITH(system-socket, AS_HELP_STRING([--with-system-socket=[filename]],[UNIX domain socket for systemwide daemon]))
    197202AC_ARG_WITH(console-auth-dir, AS_HELP_STRING([--with-console-auth-dir=[dirname]],[directory to check for console ownerhip]))
    198203AC_ARG_WITH(console-owner-file, AS_HELP_STRING([--with-console-owner-file=[filename]],[file whose owner determines current console owner]))
    199 AC_ARG_WITH(launchd-agent-dir, AS_HELP_STRING([--with-launchd-agent-dir=[dirname]],[directory to put the launchd agent (default: /Library/LaunchAgents)]))
     204AC_ARG_WITH(launchd-agent-dir, AS_HELP_STRING([--with-launchd-agent-dir=[dirname]],[directory to put the launchd agent (session bus) (default: /Library/LaunchAgents)]))
     205AC_ARG_WITH(launchd-daemon-dir, AS_HELP_STRING([--with-launchd-daemon-dir=[dirname]],[directory to put the launchd daemon (system bus) (default: /Library/LaunchDaemons)]))
    200206AC_ARG_WITH(dbus_user, AS_HELP_STRING([--with-dbus-user=<user>],[User for running the DBUS daemon (messagebus)]))
    201207AC_ARG_WITH([test_user],
    202208  [AS_HELP_STRING([--with-test-user=<user>],
    fi 
    11391145
    11401146AC_SUBST(LAUNCHD_AGENT_DIR)
    11411147
     1148#### Directory to place launchd daemon file
     1149if test "x$with_launchd_daemon_dir" = "x"; then
     1150   LAUNCHD_DAEMON_DIR="/Library/LaunchDaemons"
     1151else
     1152   LAUNCHD_DAEMON_DIR="$with_launchd_daemon_dir"
     1153fi
     1154
     1155AC_SUBST(LAUNCHD_DAEMON_DIR)
     1156
    11421157dnl console owner file
    11431158if test x$enable_console_owner_file = xno ; then
    11441159    have_console_owner_file=no;
    bus/example-session-disable-stats.conf 
    18491864bus/messagebus
    18501865bus/messagebus-config
    18511866bus/org.freedesktop.dbus-session.plist
     1867bus/org.freedesktop.dbus-system.plist
    18521868bus/rc.messagebus
    18531869bus/dbus.service
    18541870bus/dbus.socket
    echo " 
    19381954"
    19391955if test x$have_launchd = xyes; then
    19401956        echo "        launchd agent dir:        ${LAUNCHD_AGENT_DIR}"
     1957        echo "        launchd daemon dir:       ${LAUNCHD_DAEMON_DIR}"
    19411958fi
    19421959echo
    19431960
  • dbus/dbus-bus.c

    diff --git dbus/dbus-bus.c dbus/dbus-bus.c
    index 0fd4831..83bbd0e 100644
    out: 
    518524    _DBUS_ASSERT_ERROR_IS_SET (error);
    519525
    520526  _DBUS_UNLOCK (bus);
     527#ifdef DBUS_ENABLE_LAUNCHD
     528  _dbus_verbose ("internal_bus_get(type=%d,private=%d) : found and registered connection to %s",
     529         type, private, address);
     530#endif
    521531  return connection;
    522532}
    523533
  • dbus/dbus-sysdeps-unix.c

    diff --git dbus/dbus-sysdeps-unix.c dbus/dbus-sysdeps-unix.c
    index 1f964b5..5691c5a 100644
    _dbus_lookup_launchd_socket (DBusString *socket_path, 
    39283928
    39293929  _DBUS_ASSERT_ERROR_IS_CLEAR (error);
    39303930
     3931  const char *fromEnv = getenv (launchd_env_var);
     3932  dbus_bool_t hasEnvVar = (fromEnv && *fromEnv);
     3933
    39313934  if (_dbus_check_setuid ())
    39323935    {
    3933       dbus_set_error_const (error, DBUS_ERROR_NOT_SUPPORTED,
    3934                             "Unable to find launchd socket when setuid");
    3935       return FALSE;
    3936     }
     3936      if (!hasEnvVar)
     3937        {
     3938          dbus_set_error_const (error, DBUS_ERROR_NOT_SUPPORTED,
     3939                                "Unable to find launchd socket when setuid");
     3940          return FALSE;
     3941        }
    39373942
    3938   i = 0;
    3939   argv[i] = "launchctl";
    3940   ++i;
    3941   argv[i] = "getenv";
    3942   ++i;
    3943   argv[i] = (char*)launchd_env_var;
    3944   ++i;
    3945   argv[i] = NULL;
    3946   ++i;
     3943      i = 0;
     3944      argv[i] = "launchctl";
     3945      ++i;
     3946      argv[i] = "getenv";
     3947      ++i;
     3948      argv[i] = (char*)launchd_env_var;
     3949      ++i;
     3950      argv[i] = NULL;
     3951      ++i;
    39473952
    3948   _dbus_assert (i == _DBUS_N_ELEMENTS (argv));
     3953      _dbus_assert (i == _DBUS_N_ELEMENTS (argv));
     3954
     3955      if (!_read_subprocess_line_argv(argv[0], TRUE, argv, socket_path, error) && !hasEnvVar)
     3956        {
     3957          return FALSE;
     3958        }
     3959      else
     3960        {
     3961          // prefer the value obtained from launchctl
     3962          hasEnvVar = FALSE;
     3963        }
     3964    }
    39493965
    3950   if (!_read_subprocess_line_argv(argv[0], TRUE, argv, socket_path, error))
     3966  if (hasEnvVar)
    39513967    {
    3952       return FALSE;
     3968      _dbus_string_append (socket_path, fromEnv);
     3969      return TRUE;
    39533970    }
    39543971
    39553972  /* no error, but no result either */
    _dbus_lookup_session_address_launchd (DBusString *address, DBusError *error) 
    39753992  dbus_bool_t valid_socket;
    39763993  DBusString socket_path;
    39773994
    3978   if (_dbus_check_setuid ())
    3979     {
    3980       dbus_set_error_const (error, DBUS_ERROR_NOT_SUPPORTED,
    3981                             "Unable to find launchd socket when setuid");
    3982       return FALSE;
    3983     }
    3984 
    39853995  if (!_dbus_string_init (&socket_path))
    39863996    {
    39873997      _DBUS_SET_OOM (error);