Ticket #27760: dbus_1.4.10.patch

File dbus_1.4.10.patch, 36.8 KB (added by mtalexander (Mike Alexander), 13 years ago)

Upgrade dbus to version 1.4.10

  • files/0005-dont-dup-closed-stdin.patch

     
    22===================================================================
    33--- dbus-1.2.16.orig/dbus/dbus-sysdeps-unix.c   2009-10-14 14:43:57.000000000 +0200
    44+++ dbus-1.2.16/dbus/dbus-sysdeps-unix.c        2009-10-14 14:44:39.000000000 +0200
    5 @@ -2968,7 +2968,7 @@
     5@@ -3128,7 +3128,7 @@
    66       close (1);                /* close stdout */
    77       close (2);                /* close stderr */
    88 
  • files/0003-look-up-DISPLAY-from-launchd-if-not-initialized.patch

     
    1 From e487f8a50bddd4de20a79532b0f940b8a0177e43 Mon Sep 17 00:00:00 2001
    2 From: Benjamin Reed <rangerrick@befunk.com>
    3 Date: Tue, 21 Jul 2009 10:33:32 -0400
    4 Subject: [PATCH 3/7] look up DISPLAY from launchd if not initialized
    5 
    6 ---
    7  dbus/dbus-server-launchd.c |   25 ++++++++++++++++++++++++-
    8  1 files changed, 24 insertions(+), 1 deletions(-)
    9 
    10 diff --git a/dbus/dbus-server-launchd.c b/dbus/dbus-server-launchd.c
    11 index bcfb558..52782aa 100644
    12 --- a/dbus/dbus-server-launchd.c
    13 +++ b/dbus/dbus-server-launchd.c
    14 @@ -71,9 +71,10 @@ _dbus_server_new_for_launchd (const char *launchd_env_var, DBusError * error)
    15      launch_data_t checkin_request;
    16      launch_data_t listening_fd_array, listening_fd;
    17      launch_data_t environment_dict, environment_param;
    18 -    const char *launchd_socket_path;
    19 +    const char *launchd_socket_path, *display;
    20    
    21      launchd_socket_path = _dbus_getenv (launchd_env_var);
    22 +    display = _dbus_getenv ("DISPLAY");
    23    
    24      _DBUS_ASSERT_ERROR_IS_CLEAR (error);
    25    
    26 @@ -158,6 +159,28 @@ _dbus_server_new_for_launchd (const char *launchd_env_var, DBusError * error)
    27        {
    28          _DBUS_ASSERT_ERROR_IS_SET (error);
    29          goto l_failed_0;
    30 +  if (display == NULL || *display == '\0')
    31 +    {
    32 +      environment_dict = launch_data_dict_lookup (checkin_response, LAUNCH_JOBKEY_USERENVIRONMENTVARIABLES);
    33 +      if (NULL == environment_dict)
    34 +        {
    35 +          _dbus_warn ("Unable to retrieve user environment from launchd.");
    36 +        }
    37 +      else
    38 +        {
    39 +          environment_param = launch_data_dict_lookup (environment_dict, "DISPLAY");
    40 +          if (NULL == environment_param)
    41 +            {
    42 +              _dbus_warn ("Unable to retrieve DISPLAY from launchd.");
    43 +            }
    44 +          else
    45 +            {
    46 +              display = launch_data_get_string(environment_param);
    47 +              _dbus_setenv ("DISPLAY", display);
    48 +            }
    49 +        }
    50 +    }
    51 +
    52        }
    53    
    54      server = _dbus_server_new_for_socket (&launchd_fd, 1, &address);
    55 --
    56 1.6.3.2
    57 
  • files/0004-enable-launchd.patch

     
    1 From bb7496118f9f640209b4c49c8f5691c497aad381 Mon Sep 17 00:00:00 2001
    2 From: Benjamin Reed <rangerrick@befunk.com>
    3 Date: Sun, 19 Jul 2009 11:45:34 -0400
    4 Subject: [PATCH 4/7] enable launchd
    5 
    6 This patch enables support for Mac OS X's launch daemon
    7 for startup as well as sharing of the DBus session bus
    8 environment.  It includes a LaunchAgent plist for automatic
    9 start of the session bus.
    10 ---
    11  README.launchd                            |   61 +++++++++++++++++++++++++++++
    12  bus/Makefile.am                           |    8 +++-
    13  bus/org.freedesktop.dbus-session.plist.in |   31 +++++++++++++++
    14  configure.in                              |   50 ++++++++++++++++++++++--
    15  dbus/Makefile.am                          |    2 +
    16  dbus/dbus-server-unix.c                   |   23 +++++++++++
    17  dbus/dbus-sysdeps-unix.h                  |    4 ++
    18  dbus/dbus-transport-unix.c                |   51 ++++++++++++++++++++++++
    19  8 files changed, 225 insertions(+), 5 deletions(-)
    20  create mode 100644 README.launchd
    21  create mode 100644 bus/org.freedesktop.dbus-session.plist.in
    22 
    23 diff --git a/README.launchd b/README.launchd
    24 new file mode 100644
    25 index 0000000..701e57d
    26 --- /dev/null
    27 +++ b/README.launchd
    28 @@ -0,0 +1,61 @@
    29 +Launchd[1,2] replaces init, inetd and cron on Mac OS X since 10.4 "Tiger".
    30 +dbus uses this service to provide a common session bus address for each user
    31 +and so deprecates the X11 enabled dbus-launcher.
    32 +
    33 +[1] http://developer.apple.com/MacOsX/launchd.html
    34 +[2] http://launchd.macosforge.org/
    35 +
    36 +
    37 +Setup
    38 +===
    39 +
    40 +Configure with --enable-launchd and --without-x (X11 should not harm but it's
    41 +simply not necessary any more)
    42 +After installation, to prevent a reboot, load the dbus session starter into
    43 +launchd by executing:
    44 +$ launchctl load /Library/LaunchAgents/org.freedesktop.dbus-session.plist
    45 +
    46 +You can change the launch agent dir via configure, but it's not recommended.
    47 +Make sure to execute the above line as the actual user for which you want to
    48 +use a session bus since launchd manages its agents on a per user basis.
    49 +
    50 +
    51 +How it works
    52 +===
    53 +
    54 +Launchd allocates a socket and provides the unix path to it via the variable
    55 +DBUS_LAUNCHD_SESSION_BUS_SOCKET in launchd's environment. Every process
    56 +spawned by launchd (or dbus-daemon, if stared by launchd) can access it through
    57 +its own environment. Other processes can query launchd for it by executing:
    58 +$ launchctl getenv DBUS_LAUNCHD_SESSION_BUS_SOCKET
    59 +However, this is normally done by the dbus client lib for you.
    60 +
    61 +If launchd start dbus-daemon with a config file containing a "launchd:env=FOO"
    62 +address, as the default session config does with env=DBUS_LAUNCHD_SESSION_BUS_SOCKET,
    63 +the daemon will get the file descriptor from launchd and start listening on it.
    64 +The environment variable is used to get the actual socket path which is passed
    65 +to every service spawned by dbus-daemon as a result from autolaunch messages.
    66 +Please note that it's not possible to start dbus-daemon manually when using a
    67 +"launchd:" address. Only child processes of launchd can access the above
    68 +mentioned file descriptor!
    69 +
    70 +To create custom buses just set up an other launch agent. As a quick start copy
    71 +/Library/LaunchAgents/org.freedesktop.dbus-session.plist, change the label
    72 +to i.e. "org.freedesktop.dbus-foo" and change the SecureSocketWithKey value,
    73 +i.e. to "DBUS_LAUNCHD_FOO_BUS_SOCKET". This environment variable has to be set
    74 +in the config file for your new bus in the <listen> element (see session.config).
    75 +Then edit your /Library/LaunchAgents/org.freedesktop.dbus-foo.plist to start
    76 +dbus-daemon with "--config-file=/opt/local/etc/dbus-1/foo.conf" instead of
    77 +"--session". Now load the new plist onto launchd as described in the setup
    78 +section of this document.
    79 +Executing "launchctl export" should now give you two sockets, one in
    80 +DBUS_LAUNCHD_SESSION_BUS_SOCKET and the new DBUS_LAUNCHD_FOO_BUS_SOCKET.
    81 +To connect to this new bus use "launchd:env=DBUS_LAUNCHD_FOO_BUS_SOCKET".
    82 +
    83 +Since Mac OS X 10.5 "Leopard" you can also configure launchd to start
    84 +dbus-daemon on demand as soon as some process connects to the socket. Since
    85 +it's broken on 10.4 this feature is disabled per default. Look at
    86 +/Library/LaunchAgents/org.freedesktop.dbus-session.plist to change it.
    87 +
    88 +On the client side, the envvar DBUS_SESSION_BUS_ADDRESS can be normally used
    89 +but if it's not set, launchd is queried for the session bus socket.
    90 diff --git a/bus/Makefile.am b/bus/Makefile.am
    91 index 3b4f69d..420742b 100644
    92 --- a/bus/Makefile.am
    93 +++ b/bus/Makefile.am
    94 @@ -9,12 +9,18 @@ EFENCE=
    95  
    96  CONFIG_IN_FILES=                               \
    97         session.conf.in                         \
    98 -       system.conf.in
    99 +       system.conf.in                          \
    100 +       org.freedesktop.dbus-session.plist.in
    101  
    102  config_DATA=                                   \
    103         session.conf                            \
    104         system.conf
    105  
    106 +if DBUS_ENABLE_LAUNCHD
    107 +agentdir=$(LAUNCHD_AGENT_DIR)
    108 +agent_DATA=org.freedesktop.dbus-session.plist
    109 +endif
    110 +
    111  if DBUS_USE_LIBXML
    112  XML_SOURCES=config-loader-libxml.c
    113  endif
    114 diff --git a/bus/org.freedesktop.dbus-session.plist.in b/bus/org.freedesktop.dbus-session.plist.in
    115 new file mode 100644
    116 index 0000000..ac5a9d4
    117 --- /dev/null
    118 +++ b/bus/org.freedesktop.dbus-session.plist.in
    119 @@ -0,0 +1,31 @@
    120 +<?xml version="1.0" encoding="UTF-8"?>
    121 +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    122 +<plist version="1.0">
    123 +<dict>
    124 +       <key>Label</key>
    125 +       <string>org.freedesktop.dbus-session</string>
    126 +
    127 +       <key>ServiceIPC</key>
    128 +       <true/>
    129 +
    130 +       <!-- bug in 10.4's launchd - on-demand loading does not work -->
    131 +       <key>OnDemand</key>
    132 +       <false />
    133 +
    134 +       <key>ProgramArguments</key>
    135 +       <array>
    136 +               <string>@DBUS_DAEMONDIR@/dbus-daemon</string>
    137 +               <string>--nofork</string>
    138 +               <string>--session</string>
    139 +       </array>
    140 +
    141 +       <key>Sockets</key>
    142 +       <dict>
    143 +               <key>unix_domain_listener</key>
    144 +               <dict>
    145 +                       <key>SecureSocketWithKey</key>
    146 +                       <string>DBUS_LAUNCHD_SESSION_BUS_SOCKET</string>
    147 +               </dict>
    148 +       </dict>
    149 +</dict>
    150 +</plist>
    151 diff --git a/configure.in b/configure.in
    152 index 5b88385..85c3915 100644
    153 --- a/configure.in
    154 +++ b/configure.in
    155 @@ -79,6 +79,7 @@ AC_ARG_ENABLE(inotify, AS_HELP_STRING([--enable-inotify],[build with inotify sup
    156  AC_ARG_ENABLE(kqueue, AS_HELP_STRING([--enable-kqueue],[build with kqueue support]),enable_kqueue=$enableval,enable_kqueue=auto)
    157  AC_ARG_ENABLE(console-owner-file, AS_HELP_STRING([--enable-console-owner-file],[enable console owner file]),enable_console_owner_file=$enableval,enable_console_owner_file=auto)
    158  AC_ARG_ENABLE(userdb-cache, AS_HELP_STRING([--enable-userdb-cache],[build with userdb-cache support]),enable_userdb_cache=$enableval,enable_userdb_cache=yes)
    159 +AC_ARG_ENABLE(launchd, AS_HELP_STRING([--enable-launchd],[build with launchd auto-launch support]),enable_launchd=$enableval,enable_launchd=auto)
    160  
    161  AC_ARG_WITH(xml, AS_HELP_STRING([--with-xml=[libxml/expat]],[XML library to use]))
    162  AC_ARG_WITH(init-scripts, AS_HELP_STRING([--with-init-scripts=[redhat]],[Style of init scripts to install]))
    163 @@ -88,6 +89,7 @@ AC_ARG_WITH(system-pid-file, AS_HELP_STRING([--with-system-pid-file=[pidfile]],[
    164  AC_ARG_WITH(system-socket, AS_HELP_STRING([--with-system-socket=[filename]],[UNIX domain socket for systemwide daemon]))
    165  AC_ARG_WITH(console-auth-dir, AS_HELP_STRING([--with-console-auth-dir=[dirname]],[directory to check for console ownerhip]))
    166  AC_ARG_WITH(console-owner-file, AS_HELP_STRING([--with-console-owner-file=[filename]],[file whose owner determines current console owner]))
    167 +AC_ARG_WITH(launchd-agent-dir, AS_HELP_STRING([--with-launchd-agent-dir=[dirname]],[directory to put the launchd agent (default: /Library/LaunchAgents)]))
    168  AC_ARG_WITH(dbus_user, AS_HELP_STRING([--with-dbus-user=<user>],[User for running the DBUS daemon (messagebus)]))
    169  AC_ARG_WITH(dbus_daemondir, AS_HELP_STRING([--with-dbus-daemondir=[dirname]],[Directory for installing the DBUS daemon]))
    170  
    171 @@ -817,6 +819,38 @@ fi
    172  
    173  AM_CONDITIONAL(DBUS_BUS_ENABLE_KQUEUE, test x$have_kqueue = xyes)
    174  
    175 +# launchd checks
    176 +if test x$enable_launchd = xno ; then
    177 +    have_launchd=no
    178 +else
    179 +    have_launchd=yes
    180 +    AC_CHECK_HEADER([launch.h], , have_launchd=no)
    181 +    AC_PATH_PROG([LAUNCHCTL], [launchctl])
    182 +    if test "x$LAUNCHCTL" = "x"; then
    183 +        have_launchd=no
    184 +    fi
    185 +
    186 +    if test x$enable_launchd = xyes && test x$have_launchd = xno ; then
    187 +        AC_MSG_ERROR([launchd support explicitly enabled but not available])
    188 +    fi
    189 +fi
    190 +
    191 +dnl check if launchd is enabled
    192 +if test x$have_launchd = xyes; then
    193 +    AC_DEFINE(DBUS_ENABLE_LAUNCHD,1,[Use launchd autolaunch])
    194 +fi
    195 +
    196 +AM_CONDITIONAL(DBUS_ENABLE_LAUNCHD, test x$have_launchd = xyes)
    197 +
    198 +#### Directory to place launchd agent file
    199 +if test "x$with_launchd_agent_dir" = "x"; then
    200 +   LAUNCHD_AGENT_DIR="/Library/LaunchAgents"
    201 +else
    202 +   LAUNCHD_AGENT_DIR="$with_launchd_agent_dir"
    203 +fi
    204 +
    205 +AC_SUBST(LAUNCHD_AGENT_DIR)
    206 +
    207  dnl console owner file
    208  if test x$enable_console_owner_file = xno ; then
    209      have_console_owner_file=no;
    210 @@ -1287,7 +1321,11 @@ AC_SUBST(DBUS_SYSTEM_BUS_DEFAULT_ADDRESS)
    211  AC_DEFINE_UNQUOTED(DBUS_SYSTEM_BUS_DEFAULT_ADDRESS, "$DBUS_SYSTEM_BUS_DEFAULT_ADDRESS",[The default D-Bus address of the system bus])
    212  
    213  # set up the session bus address
    214 -DBUS_SESSION_BUS_DEFAULT_ADDRESS="unix:tmpdir=$DBUS_SESSION_SOCKET_DIR"
    215 +if test x$have_launchd = xyes; then
    216 +   DBUS_SESSION_BUS_DEFAULT_ADDRESS="launchd:env=DBUS_LAUNCHD_SESSION_BUS_SOCKET"
    217 +else
    218 +   DBUS_SESSION_BUS_DEFAULT_ADDRESS="unix:tmpdir=$DBUS_SESSION_SOCKET_DIR"
    219 +fi
    220  AC_SUBST(DBUS_SESSION_BUS_DEFAULT_ADDRESS)
    221  
    222  #### Set up the pid file
    223 @@ -1414,7 +1452,6 @@ else
    224     DBUS_SESSION_SOCKET_DIR=$DEFAULT_SOCKET_DIR
    225  fi
    226  AC_DEFINE_UNQUOTED(DBUS_SESSION_SOCKET_DIR, "$DBUS_SESSION_SOCKET_DIR", [Where per-session bus puts its sockets])
    227 -AC_SUBST(DBUS_SESSION_SOCKET_DIR)
    228  
    229  AC_DEFINE_UNQUOTED(DBUS_UNIX, "1", [Defined on UNIX and Linux systems and not on Windows])
    230  
    231 @@ -1436,6 +1473,7 @@ dbus/dbus-arch-deps.h
    232  bus/system.conf
    233  bus/session.conf
    234  bus/messagebus
    235 +bus/org.freedesktop.dbus-session.plist
    236  bus/rc.messagebus
    237  bus/dbus-daemon.1
    238  Makefile
    239 @@ -1503,6 +1541,7 @@ echo "
    240          Building Doxygen docs:    ${enable_doxygen_docs}
    241          Building XML docs:        ${enable_xml_docs}
    242          Building cache support:   ${enable_userdb_cache}
    243 +        Building launchd support: ${have_launchd}
    244          Gettext libs (empty OK):  ${INTLLIBS}
    245          Using XML parser:         ${with_xml}
    246          Init scripts style:       ${with_init_scripts}
    247 @@ -1516,8 +1555,11 @@ echo "
    248          Console owner file path:  ${DBUS_CONSOLE_OWNER_FILE}
    249         System bus user:          ${DBUS_USER}
    250         Session bus services dir: ${EXPANDED_DATADIR}/dbus-1/services
    251 -        'make check' socket dir:  ${TEST_SOCKET_DIR}
    252 -"
    253 +        'make check' socket dir:  ${TEST_SOCKET_DIR}"
    254 +if test x$have_launchd = xyes; then
    255 +        echo "        launchd agent dir:        ${LAUNCHD_AGENT_DIR}"
    256 +fi
    257 +echo
    258  
    259  if test x$enable_tests = xyes; then
    260          echo "NOTE: building with unit tests increases the size of the installed library and renders it insecure."
    261 diff --git a/dbus/Makefile.am b/dbus/Makefile.am
    262 index e966a43..ed0a4ae 100644
    263 --- a/dbus/Makefile.am
    264 +++ b/dbus/Makefile.am
    265 @@ -70,6 +70,8 @@ DBUS_LIB_SOURCES=                             \
    266         dbus-server.c                           \
    267         dbus-server-debug-pipe.c                \
    268         dbus-server-debug-pipe.h                \
    269 +       dbus-server-launchd.c                   \
    270 +       dbus-server-launchd.h                   \
    271         dbus-server-protected.h                 \
    272         dbus-server-socket.c                    \
    273         dbus-server-socket.h                    \
    274 diff --git a/dbus/dbus-server-unix.c b/dbus/dbus-server-unix.c
    275 index 07800c8..55ed9ab 100644
    276 --- a/dbus/dbus-server-unix.c
    277 +++ b/dbus/dbus-server-unix.c
    278 @@ -21,9 +21,11 @@
    279   *
    280   */
    281  
    282 +#include <config.h>
    283  #include "dbus-internals.h"
    284  #include "dbus-server-unix.h"
    285  #include "dbus-server-socket.h"
    286 +#include "dbus-server-launchd.h"
    287  #include "dbus-transport-unix.h"
    288  #include "dbus-connection-internal.h"
    289  #include "dbus-sysdeps-unix.h"
    290 @@ -145,6 +147,27 @@ _dbus_server_listen_platform_specific (DBusAddressEntry *entry,
    291            return DBUS_SERVER_LISTEN_DID_NOT_CONNECT;
    292          }
    293      }
    294 +  else if (strcmp (method, "launchd") == 0)
    295 +    {
    296 +      const char *launchd_env_var = dbus_address_entry_get_value (entry, "env");
    297 +      if (launchd_env_var == NULL)
    298 +        {
    299 +          _dbus_set_bad_address (error, "launchd", "env", NULL);
    300 +          return DBUS_SERVER_LISTEN_DID_NOT_CONNECT;
    301 +        }
    302 +      *server_p = _dbus_server_new_for_launchd (launchd_env_var, error);
    303 +
    304 +      if (*server_p != NULL)
    305 +        {
    306 +          _DBUS_ASSERT_ERROR_IS_CLEAR(error);
    307 +          return DBUS_SERVER_LISTEN_OK;
    308 +        }
    309 +      else
    310 +        {
    311 +          _DBUS_ASSERT_ERROR_IS_SET(error);
    312 +          return DBUS_SERVER_LISTEN_DID_NOT_CONNECT;
    313 +        }
    314 +    }
    315    else
    316      {
    317        /* If we don't handle the method, we return NULL with the
    318 diff --git a/dbus/dbus-sysdeps-unix.h b/dbus/dbus-sysdeps-unix.h
    319 index 96b44e2..8eec96b 100644
    320 --- a/dbus/dbus-sysdeps-unix.h
    321 +++ b/dbus/dbus-sysdeps-unix.h
    322 @@ -79,6 +79,10 @@ dbus_bool_t _dbus_read_credentials (int               client_fd,
    323  dbus_bool_t _dbus_send_credentials (int              server_fd,
    324                                      DBusError       *error);
    325  
    326 +dbus_bool_t _dbus_lookup_launchd_socket (DBusString *socket_path,
    327 +                                         const char *launchd_env_var,
    328 +                                         DBusError  *error);
    329 +
    330  /** Information about a UNIX user */
    331  typedef struct DBusUserInfo  DBusUserInfo;
    332  /** Information about a UNIX group */
    333 diff --git a/dbus/dbus-transport-unix.c b/dbus/dbus-transport-unix.c
    334 index 2f2a3da..ce77c57 100644
    335 --- a/dbus/dbus-transport-unix.c
    336 +++ b/dbus/dbus-transport-unix.c
    337 @@ -169,6 +169,57 @@ _dbus_transport_open_platform_specific (DBusAddressEntry  *entry,
    338            return DBUS_TRANSPORT_OPEN_OK;
    339          }     
    340      }
    341 +  else if (strcmp (method, "launchd") == 0)
    342 +    {
    343 +      DBusError tmp_error = DBUS_ERROR_INIT;
    344 +      const char *launchd_env_var = dbus_address_entry_get_value (entry, "env");
    345 +      const char *launchd_socket;
    346 +      DBusString socket_path;
    347 +      dbus_bool_t valid_socket;
    348 +
    349 +      if (!_dbus_string_init (&socket_path))
    350 +        {
    351 +          _DBUS_SET_OOM (error);
    352 +          return FALSE;
    353 +        }
    354 +
    355 +      if (launchd_env_var == NULL)
    356 +        {
    357 +          _dbus_set_bad_address (error, "launchd", "env", NULL);
    358 +          return DBUS_TRANSPORT_OPEN_BAD_ADDRESS;
    359 +        }
    360 +
    361 +      valid_socket = _dbus_lookup_launchd_socket (&socket_path, launchd_env_var, error);
    362 +
    363 +      if (dbus_error_is_set(error))
    364 +        {
    365 +          _dbus_string_free(&socket_path);
    366 +          return DBUS_TRANSPORT_OPEN_DID_NOT_CONNECT;
    367 +        }
    368 +
    369 +      if (!valid_socket)
    370 +        {
    371 +          dbus_set_error(&tmp_error, DBUS_ERROR_BAD_ADDRESS,
    372 +                         "launchd's env var %s does not exist", launchd_env_var);
    373 +          dbus_error_free(error);
    374 +          dbus_move_error(&tmp_error, error);
    375 +          return DBUS_TRANSPORT_OPEN_DID_NOT_CONNECT;
    376 +        }
    377 +
    378 +      launchd_socket = _dbus_string_get_const_data(&socket_path);
    379 +      *transport_p = _dbus_transport_new_for_domain_socket (launchd_socket, FALSE, error);
    380 +
    381 +      if (*transport_p == NULL)
    382 +        {
    383 +          _DBUS_ASSERT_ERROR_IS_SET (error);
    384 +          return DBUS_TRANSPORT_OPEN_DID_NOT_CONNECT;
    385 +        }
    386 +      else
    387 +        {
    388 +          _DBUS_ASSERT_ERROR_IS_CLEAR (error);
    389 +          return DBUS_TRANSPORT_OPEN_OK;
    390 +        }
    391 +    }
    392    else
    393      {
    394        _DBUS_ASSERT_ERROR_IS_CLEAR (error);
    395 --
    396 1.6.3.2
    397 
  • files/0001-make-session-bus-listen-tag-configurable.patch

     
    1 From e0809d6c48641ab11e0dc1b3f537e56692208912 Mon Sep 17 00:00:00 2001
    2 From: Benjamin Reed <rangerrick@befunk.com>
    3 Date: Sun, 19 Jul 2009 11:30:39 -0400
    4 Subject: [PATCH 1/7] make session bus <listen> tag configurable
    5 
    6 ---
    7  bus/session.conf.in |    2 +-
    8  configure.in        |    4 ++++
    9  2 files changed, 5 insertions(+), 1 deletions(-)
    10 
    11 diff --git a/bus/session.conf.in b/bus/session.conf.in
    12 index 85395c5..e121ff9 100644
    13 --- a/bus/session.conf.in
    14 +++ b/bus/session.conf.in
    15 @@ -12,7 +12,7 @@
    16         the behavior of child processes. -->
    17    <keep_umask/>
    18  
    19 -  <listen>unix:tmpdir=@DBUS_SESSION_SOCKET_DIR@</listen>
    20 +  <listen>@DBUS_SESSION_BUS_DEFAULT_ADDRESS@</listen>
    21  
    22    <standard_session_servicedirs />
    23  
    24 diff --git a/configure.in b/configure.in
    25 index d79d655..5b88385 100644
    26 --- a/configure.in
    27 +++ b/configure.in
    28 @@ -1286,6 +1286,10 @@ DBUS_SYSTEM_BUS_DEFAULT_ADDRESS="unix:path=$DBUS_SYSTEM_SOCKET"
    29  AC_SUBST(DBUS_SYSTEM_BUS_DEFAULT_ADDRESS)
    30  AC_DEFINE_UNQUOTED(DBUS_SYSTEM_BUS_DEFAULT_ADDRESS, "$DBUS_SYSTEM_BUS_DEFAULT_ADDRESS",[The default D-Bus address of the system bus])
    31  
    32 +# set up the session bus address
    33 +DBUS_SESSION_BUS_DEFAULT_ADDRESS="unix:tmpdir=$DBUS_SESSION_SOCKET_DIR"
    34 +AC_SUBST(DBUS_SESSION_BUS_DEFAULT_ADDRESS)
    35 +
    36  #### Set up the pid file
    37  if ! test -z "$with_system_pid_file"; then
    38     DBUS_SYSTEM_PID_FILE=$with_system_pid_file
    39 --
    40 1.6.3.2
    41 
  • files/0002-add-launchd-implementation.patch

     
    1 From fe2b03d47790a62bd179e2d443eda194a4f8e4d6 Mon Sep 17 00:00:00 2001
    2 From: Benjamin Reed <rangerrick@befunk.com>
    3 Date: Sun, 19 Jul 2009 11:44:50 -0400
    4 Subject: [PATCH 2/7] add launchd implementation
    5 
    6 ---
    7  dbus/dbus-server-launchd.c |  186 ++++++++++++++++++++++++++++++++++++++++++++
    8  dbus/dbus-server-launchd.h |   35 ++++++++
    9  dbus/dbus-sysdeps-unix.c   |  101 ++++++++++++++++++++++++
    10  3 files changed, 322 insertions(+), 0 deletions(-)
    11  create mode 100644 dbus/dbus-server-launchd.c
    12  create mode 100644 dbus/dbus-server-launchd.h
    13 
    14 Index: dbus-1.2.16/dbus/dbus-server-launchd.c
    15 ===================================================================
    16 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
    17 +++ dbus-1.2.16/dbus/dbus-server-launchd.c      2009-10-13 11:43:14.000000000 +0200
    18 @@ -0,0 +1,186 @@
    19 +/* dbus-server-launchd.c Server methods for interacting with launchd.
    20 + * Copyright (C) 2007, Tanner Lovelace <lovelace@wayfarer.org>
    21 + * Copyright (C) 2008, Colin Walters <walters@verbum.org>
    22 + * Copyright (C) 2008-2009, Benjamin Reed <rangerrick@befunk.com>
    23 + * Copyright (C) 2009, Jonas Bähr<jonas.baehr@web.de>
    24 + *
    25 + * Permission is hereby granted, free of charge, to any person
    26 + * obtaining a copy of this software and associated documentation
    27 + * files (the "Software"), to deal in the Software without
    28 + * restriction, including without limitation the rights to use, copy,
    29 + * modify, merge, publish, distribute, sublicense, and/or sell copies
    30 + * of the Software, and to permit persons to whom the Software is
    31 + * furnished to do so, subject to the following conditions:
    32 + *
    33 + * The above copyright notice and this permission notice shall be
    34 + * included in all copies or substantial portions of the Software.
    35 + *
    36 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
    37 + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
    38 + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
    39 + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
    40 + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
    41 + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    42 + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
    43 + * DEALINGS IN THE SOFTWARE.
    44 + */
    45 +
    46 +#include <config.h>
    47 +#include "dbus-server-launchd.h"
    48 +
    49 +/**
    50 + * @defgroup DBusServerLaunchd DBusServer implementations for Launchd
    51 + * @ingroup  DBusInternals
    52 + * @brief Implementation details of DBusServer with Launchd support
    53 + *
    54 + * @{
    55 + */
    56 +
    57 +#ifdef DBUS_ENABLE_LAUNCHD
    58 +#include <launch.h>
    59 +#include <errno.h>
    60 +
    61 +#include "dbus-server-socket.h"
    62 +
    63 +/* put other private launchd functions here */
    64 +
    65 +#endif /* DBUS_ENABLE_LAUNCHD */
    66 +
    67 +/**
    68 + * @brief Creates a new server from launchd.
    69 + *
    70 + * launchd has allocaed a socket for us. We now query launchd for the
    71 + * file descriptor of this socket and create a server on it.
    72 + * In addition we inherit launchd's environment which holds a variable
    73 + * containing the path to the socket. This is used to init the server's
    74 + * address which is passed to autolaunched services.
    75 + *
    76 + * @param launchd_env_var the environment variable which holds the unix path to the socket
    77 + * @param error location to store reason for failure.
    78 + * @returns the new server, or #NULL on failure.
    79 + */
    80 +
    81 +DBusServer *
    82 +_dbus_server_new_for_launchd (const char *launchd_env_var, DBusError * error)
    83 +  {
    84 +#ifdef DBUS_ENABLE_LAUNCHD
    85 +    DBusServer *server;
    86 +    DBusString address;
    87 +    int launchd_fd;
    88 +    launch_data_t sockets_dict, checkin_response;
    89 +    launch_data_t checkin_request;
    90 +    launch_data_t listening_fd_array, listening_fd;
    91 +    launch_data_t environment_dict, environment_param;
    92 +    const char *launchd_socket_path;
    93 
    94 +    launchd_socket_path = _dbus_getenv (launchd_env_var);
    95 
    96 +    _DBUS_ASSERT_ERROR_IS_CLEAR (error);
    97 
    98 +    if (launchd_socket_path == NULL || *launchd_socket_path == '\0')
    99 +      {
    100 +        dbus_set_error (error, DBUS_ERROR_BAD_ADDRESS,
    101 +                        "launchd's environment variable %s is empty, but should contain a socket path.\n", launchd_env_var);
    102 +        return NULL;
    103 +      }
    104 
    105 +    if (!_dbus_string_init (&address))
    106 +      {
    107 +        dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
    108 +        return NULL;
    109 +      }
    110 +    if (!_dbus_string_append (&address, "unix:path="))
    111 +      {
    112 +        dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
    113 +        goto l_failed_0;
    114 +      }
    115 +    if (!_dbus_string_append (&address, launchd_socket_path))
    116 +      {
    117 +        dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
    118 +        goto l_failed_0;
    119 +      }
    120 
    121 +    if ((checkin_request = launch_data_new_string (LAUNCH_KEY_CHECKIN)) == NULL)
    122 +      {
    123 +        dbus_set_error (error, DBUS_ERROR_NO_MEMORY,
    124 +                        "launch_data_new_string(\"%s\") Unable to create string.\n",
    125 +                        LAUNCH_KEY_CHECKIN);
    126 +        goto l_failed_0;
    127 +      }
    128 
    129 +    if ((checkin_response = launch_msg (checkin_request)) == NULL)
    130 +      {
    131 +        dbus_set_error (error, DBUS_ERROR_IO_ERROR,
    132 +                        "launch_msg(\"%s\") IPC failure: %s\n",
    133 +                        LAUNCH_KEY_CHECKIN, strerror (errno));
    134 +        goto l_failed_0;
    135 +      }
    136 
    137 +    if (LAUNCH_DATA_ERRNO == launch_data_get_type (checkin_response))
    138 +      {
    139 +        dbus_set_error (error, DBUS_ERROR_FAILED, "Check-in failed: %s\n",
    140 +                        strerror (launch_data_get_errno (checkin_response)));
    141 +        goto l_failed_0;
    142 +      }
    143 
    144 +    sockets_dict =
    145 +      launch_data_dict_lookup (checkin_response, LAUNCH_JOBKEY_SOCKETS);
    146 +    if (NULL == sockets_dict)
    147 +      {
    148 +        dbus_set_error (error, DBUS_ERROR_IO_ERROR,
    149 +                        "No sockets found to answer requests on!\n");
    150 +        goto l_failed_0;
    151 +      }
    152 
    153 +    listening_fd_array =
    154 +      launch_data_dict_lookup (sockets_dict, "unix_domain_listener");
    155 +    if (NULL == listening_fd_array)
    156 +      {
    157 +        dbus_set_error (error, DBUS_ERROR_IO_ERROR,
    158 +                        "No known sockets found to answer requests on!\n");
    159 +        goto l_failed_0;
    160 +      }
    161 
    162 +    if (launch_data_array_get_count (listening_fd_array) != 1)
    163 +      {
    164 +        dbus_set_error (error, DBUS_ERROR_LIMITS_EXCEEDED,
    165 +                        "Expected 1 socket from launchd, got %d.\n",
    166 +                        launch_data_array_get_count (listening_fd_array));
    167 +        goto l_failed_0;
    168 +      }
    169 
    170 +    listening_fd = launch_data_array_get_index (listening_fd_array, 0);
    171 +    launchd_fd = launch_data_get_fd (listening_fd);
    172 
    173 +    _dbus_fd_set_close_on_exec (launchd_fd);
    174 
    175 +    if (launchd_fd < 0)
    176 +      {
    177 +        _DBUS_ASSERT_ERROR_IS_SET (error);
    178 +        goto l_failed_0;
    179 +      }
    180 
    181 +    server = _dbus_server_new_for_socket (&launchd_fd, 1, &address);
    182 +    if (server == NULL)
    183 +      {
    184 +        dbus_set_error (error, DBUS_ERROR_NO_SERVER,
    185 +                        "Unable to listen on launchd fd %d.", launchd_fd);
    186 +        goto l_failed_0;
    187 +      }
    188 
    189 +    _dbus_string_free (&address);
    190 
    191 +    return server;
    192 
    193 +  l_failed_0:
    194 +    _dbus_string_free (&address);
    195 
    196 +    return NULL;
    197 +#else /* DBUS_ENABLE_LAUNCHD */
    198 +    dbus_set_error (error, DBUS_ERROR_BAD_ADDRESS,
    199 +                    "address type 'launchd' requested, but launchd support not compiled in");
    200 +    return NULL;
    201 +#endif
    202 +  }
    203 +
    204 +/** @} */
    205 Index: dbus-1.2.16/dbus/dbus-server-launchd.h
    206 ===================================================================
    207 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
    208 +++ dbus-1.2.16/dbus/dbus-server-launchd.h      2009-10-13 11:43:14.000000000 +0200
    209 @@ -0,0 +1,35 @@
    210 +/* dbus-server-launchd.h Server methods for interacting with launchd.
    211 +* Copyright (C) 2008, Benjamin Reed <rangerrick@befunk.com>
    212 +*
    213 +* Permission is hereby granted, free of charge, to any person
    214 +* obtaining a copy of this software and associated documentation
    215 +* files (the "Software"), to deal in the Software without
    216 +* restriction, including without limitation the rights to use, copy,
    217 +* modify, merge, publish, distribute, sublicense, and/or sell copies
    218 +* of the Software, and to permit persons to whom the Software is
    219 +* furnished to do so, subject to the following conditions:
    220 +*
    221 +* The above copyright notice and this permission notice shall be
    222 +* included in all copies or substantial portions of the Software.
    223 +*
    224 +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
    225 +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
    226 +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
    227 +* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
    228 +* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
    229 +* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    230 +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
    231 +* DEALINGS IN THE SOFTWARE.
    232 +*/
    233 +
    234 +#ifndef DBUS_SERVER_LAUNCHD_H
    235 +#define DBUS_SERVER_LAUNCHD_H
    236 +
    237 +#include <dbus/dbus-internals.h>
    238 +#include <dbus/dbus-server-protected.h>
    239 +
    240 +DBUS_BEGIN_DECLS
    241 +  DBusServer * _dbus_server_new_for_launchd (const char *launchd_env_var, DBusError * error);
    242 +
    243 +DBUS_END_DECLS
    244 +#endif /* DBUS_SERVER_LAUNCHD_H */
    245 Index: dbus-1.2.16/dbus/dbus-sysdeps-unix.c
    246 ===================================================================
    247 --- dbus-1.2.16.orig/dbus/dbus-sysdeps-unix.c   2009-10-13 11:43:07.000000000 +0200
    248 +++ dbus-1.2.16/dbus/dbus-sysdeps-unix.c        2009-10-13 11:44:10.000000000 +0200
    249 @@ -3168,6 +3168,102 @@
    250  #define DBUS_UNIX_STANDARD_SYSTEM_SERVICEDIR "/dbus-1/system-services"
    251  
    252  /**
    253 + * quries launchd for a specific env var which holds the socket path.
    254 + * @param launchd_env_var the env var to look up
    255 + * @param error a DBusError to store the error in case of failure
    256 + * @return the value of the env var
    257 + */
    258 +dbus_bool_t
    259 +_dbus_lookup_launchd_socket (DBusString *socket_path,
    260 +                             const char *launchd_env_var,
    261 +                             DBusError  *error)
    262 +{
    263 +#ifdef DBUS_ENABLE_LAUNCHD
    264 +  char *argv[4];
    265 +  int i;
    266 
    267 +  _DBUS_ASSERT_ERROR_IS_CLEAR (error);
    268 +
    269 +  i = 0;
    270 +  argv[i] = "launchctl";
    271 +  ++i;
    272 +  argv[i] = "getenv";
    273 +  ++i;
    274 +  argv[i] = (char*)launchd_env_var;
    275 +  ++i;
    276 +  argv[i] = NULL;
    277 +  ++i;
    278 +
    279 +  _dbus_assert (i == _DBUS_N_ELEMENTS (argv));
    280 +
    281 +  if (!_read_subprocess_line_argv(argv[0], TRUE, argv, socket_path, error))
    282 +    {
    283 +      return FALSE;
    284 +    }
    285 +
    286 +  /* no error, but no result either */
    287 +  if (_dbus_string_get_length(socket_path) == 0)
    288 +    {
    289 +      return FALSE;
    290 +    }
    291 +
    292 +  /* strip the carriage-return */
    293 +  _dbus_string_shorten(socket_path, 1);
    294 +  return TRUE;
    295 +#else /* DBUS_ENABLE_LAUNCHD */
    296 +  dbus_set_error(error, DBUS_ERROR_NOT_SUPPORTED,
    297 +                "can't lookup socket from launchd; launchd support not compiled in");
    298 +  return FALSE;
    299 +#endif
    300 +}
    301 +
    302 +static dbus_bool_t
    303 +_dbus_lookup_session_address_launchd (DBusString *address, DBusError  *error)
    304 +{
    305 +  dbus_bool_t valid_socket;
    306 +  DBusString socket_path;
    307 +
    308 +  if (!_dbus_string_init (&socket_path))
    309 +    {
    310 +      _DBUS_SET_OOM (error);
    311 +      return FALSE;
    312 +    }
    313 +
    314 +  valid_socket = _dbus_lookup_launchd_socket (&socket_path, "DBUS_LAUNCHD_SESSION_BUS_SOCKET", error);
    315 +
    316 +  if (dbus_error_is_set(error))
    317 +    {
    318 +      _dbus_string_free(&socket_path);
    319 +      return FALSE;
    320 +    }
    321 +
    322 +  if (!valid_socket)
    323 +    {
    324 +      dbus_set_error(error, "no socket path",
    325 +                "launchd did not provide a socket path, "
    326 +                "verify that org.freedesktop.dbus-session.plist is loaded!");
    327 +      _dbus_string_free(&socket_path);
    328 +      return FALSE;
    329 +    }
    330 +  if (!_dbus_string_append (address, "unix:path="))
    331 +    {
    332 +      _DBUS_SET_OOM (error);
    333 +      _dbus_string_free(&socket_path);
    334 +      return FALSE;
    335 +    }
    336 +  if (!_dbus_string_copy (&socket_path, 0, address,
    337 +                          _dbus_string_get_length (address)))
    338 +    {
    339 +      _DBUS_SET_OOM (error);
    340 +      _dbus_string_free(&socket_path);
    341 +      return FALSE;
    342 +    }
    343 +
    344 +  _dbus_string_free(&socket_path);
    345 +  return TRUE;
    346 +}
    347 +
    348 +/**
    349   * Determines the address of the session bus by querying a
    350   * platform-specific method. 
    351   *
    352 @@ -3191,12 +3287,17 @@
    353                                DBusString  *address,
    354                                DBusError   *error)
    355  {
    356 +#ifdef DBUS_ENABLE_LAUNCHD
    357 +  *supported = TRUE;
    358 +  return _dbus_lookup_session_address_launchd (address, error);
    359 +#else
    360    /* On non-Mac Unix platforms, if the session address isn't already
    361     * set in DBUS_SESSION_BUS_ADDRESS environment variable, we punt and
    362     * fall back to the autolaunch: global default; see
    363     * init_session_address in dbus/dbus-bus.c. */
    364    *supported = FALSE;
    365    return TRUE;
    366 +#endif
    367  }
    368  
    369  /**
  • files/10.5-launchd.diff

     
    1 --- dbus-1.2.24/bus/org.freedesktop.dbus-session.plist.in.orig  2011-03-22 00:27:21.000000000 +1100
    2 +++ dbus-1.2.24/bus/org.freedesktop.dbus-session.plist.in       2011-03-22 00:31:01.000000000 +1100
    3 @@ -5,13 +5,6 @@
    4         <key>Label</key>
    5         <string>org.freedesktop.dbus-session</string>
    6  
    7 -       <key>ServiceIPC</key>
    8 -       <true/>
    9 -
    10 -       <!-- bug in 10.4's launchd - on-demand loading does not work -->
    11 -       <key>OnDemand</key>
    12 -       <false />
    13 -
    14         <key>ProgramArguments</key>
    15         <array>
    16                 <string>@DBUS_DAEMONDIR@/dbus-daemon</string>
  • Portfile

     
    55PortGroup       muniversal 1.0
    66
    77name            dbus
    8 version         1.2.24
    9 revision        1
     8version         1.4.10
    109maintainers     mcalhoun openmaintainer
    1110categories      devel
    1211platforms       darwin
     
    1817homepage        http://www.freedesktop.org/Software/dbus
    1918master_sites    http://dbus.freedesktop.org/releases/dbus
    2019
    21 checksums       md5     565346cecd9cfecf1463540c6086cc2c \
    22                 sha1    9593717348ea36ba228b46f165bb67c127c12be8 \
    23                 rmd160  2f51def784056bc16fbec2ddc3be22c022a94fb5
     20checksums       md5     402a2f8102bedbe236e2891b2b0f31c2 \
     21                sha1    8a35d253d444d1450a206f717445b371e1d936a1 \
     22                rmd160  7eb3fd372eca42331541eb7465b62c18cd4a2546
    2423
    2524# There is a proposal to use launchd with dbus (see https://bugs.freedesktop.org/show_bug.cgi?id=14259).
    26 patchfiles      0001-make-session-bus-listen-tag-configurable.patch \
    27                 0002-add-launchd-implementation.patch \
    28                 0003-look-up-DISPLAY-from-launchd-if-not-initialized.patch \
    29                 0004-enable-launchd.patch \
    30                 0005-dont-dup-closed-stdin.patch \
     25patchfiles      0005-dont-dup-closed-stdin.patch \
    3126                0006-bus_system-conf-in.patch
    3227patch.pre_args  -p1
    3328
    34 if { $macosx_deployment_target != "10.4" } {
    35     # Allow on-demand loading for Leopard.
    36     patchfiles-append 10.5-launchd.diff
    37 }
    38 
    3929depends_build       \
    4030    port:pkgconfig
    4131
     
    4535
    4636depends_lib     port:expat
    4737
    48 use_autoreconf  yes
    49 
    5038configure.args  --disable-doxygen-docs \
    5139                --disable-xml-docs \
    5240                --without-x \
    5341                --enable-launchd \
    54                 --with-launchd-agent-dir=${prefix}/Library/LaunchAgents
     42                --with-launchd-agent-dir=${prefix}/Library/LaunchAgents \
     43                --with-session-socket-dir=/tmp \
     44                --with-test-socket-dir=/tmp
    5545
     46activate.asroot yes
     47
    5648pre-configure {
    5749    # Value must be set in pre-configure because dbus_user may change in variant.
    5850    configure.args-append  --with-dbus-user=${dbus_user}
     
    163155    file attributes ${prefix}/var/run/dbus -group ${dbus_group} -owner ${dbus_user}
    164156    file attributes ${prefix}/libexec/dbus-daemon-launch-helper -group ${dbus_group}
    165157   
     158    # Change the share directory so other ports can install to it without running as root.
     159    if {[geteuid] == 0 && [getuid] != 0 && ${install.user} != 0} {
     160        file attributes ${prefix}/share/dbus-1 -owner ${install.user} -group ${install.group}
     161    }
     162   
    166163    if { ![variant_isset no_startupitem] && ![variant_isset no_root] } {
    167164        file attributes /Library/LaunchAgents/org.freedesktop.dbus-session.plist -owner root -group wheel
    168165        file attributes /Library/LaunchDaemons/[file tail ${plistFl}] -owner root -group wheel