windbus-svn Mailing List for winDBus
Brought to you by:
syntheticpp
You can subscribe to this list here.
2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(16) |
Aug
(159) |
Sep
(139) |
Oct
(22) |
Nov
(128) |
Dec
(35) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2007 |
Jan
(12) |
Feb
(22) |
Mar
(38) |
Apr
(1) |
May
(10) |
Jun
(53) |
Jul
(71) |
Aug
(19) |
Sep
|
Oct
|
Nov
|
Dec
(2) |
2008 |
Jan
|
Feb
(1) |
Mar
(10) |
Apr
(7) |
May
(9) |
Jun
|
Jul
(5) |
Aug
(5) |
Sep
|
Oct
(8) |
Nov
|
Dec
|
2009 |
Jan
(6) |
Feb
(6) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(3) |
Dec
|
2010 |
Jan
(5) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <hab...@us...> - 2010-01-14 08:52:26
|
Revision: 820 http://windbus.svn.sourceforge.net/windbus/?rev=820&view=rev Author: habacker Date: 2010-01-14 08:52:15 +0000 (Thu, 14 Jan 2010) Log Message: ----------- fixes bug where sometimes objects were not unregistered from dbus although their app had exited. As it turns out it was a missing implementation of the method _dbus_fd_set_close_on_exec()for windows. It's been tested with msvc2005, msvc2008, and mingw, and solves all the unregistering issues on many kde apps. patch from Romain Pokrzywka romain at kdab dot com Modified Paths: -------------- tags/1.2.4/dbus/dbus-sysdeps-win.c Modified: tags/1.2.4/dbus/dbus-sysdeps-win.c =================================================================== --- tags/1.2.4/dbus/dbus-sysdeps-win.c 2010-01-14 08:50:12 UTC (rev 819) +++ tags/1.2.4/dbus/dbus-sysdeps-win.c 2010-01-14 08:52:15 UTC (rev 820) @@ -434,31 +434,12 @@ void _dbus_fd_set_close_on_exec (int handle) { -#ifdef ENABLE_DBUSSOCKET - DBusSocket *s; - if (handle < 0) - return; - - _dbus_lock_sockets(); - - _dbus_handle_to_socket_unlocked (handle, &s); - s->close_on_exec = TRUE; - - _dbus_unlock_sockets(); -#else - /* TODO unic code. - int val; - - val = fcntl (fd, F_GETFD, 0); - - if (val < 0) - return; - - val |= FD_CLOEXEC; - - fcntl (fd, F_SETFD, val); - */ -#endif + if ( !SetHandleInformation( (HANDLE) handle, + HANDLE_FLAG_INHERIT | HANDLE_FLAG_PROTECT_FROM_CLOSE, + 0 /*disable both flags*/ ) ) + { + _dbus_win_warn_win_error ("Disabling socket handle inheritance failed:", GetLastError()); + } } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hab...@us...> - 2010-01-14 08:50:18
|
Revision: 819 http://windbus.svn.sourceforge.net/windbus/?rev=819&view=rev Author: habacker Date: 2010-01-14 08:50:12 +0000 (Thu, 14 Jan 2010) Log Message: ----------- applied r815 from tags/1.2.4: prefixed keyring directory path with drive letter to support current dirs other then system drive Modified Paths: -------------- trunk/dbus/dbus-sysdeps-win.c Modified: trunk/dbus/dbus-sysdeps-win.c =================================================================== --- trunk/dbus/dbus-sysdeps-win.c 2010-01-14 08:47:41 UTC (rev 818) +++ trunk/dbus/dbus-sysdeps-win.c 2010-01-14 08:50:12 UTC (rev 819) @@ -3434,6 +3434,7 @@ DBusString dotdir; dbus_uid_t uid; const char *homepath; + const char *homedrive; _dbus_assert (credentials != NULL); _dbus_assert (!_dbus_credentials_are_anonymous (credentials)); @@ -3441,6 +3442,12 @@ if (!_dbus_string_init (&homedir)) return FALSE; + homedrive = _dbus_getenv("HOMEDRIVE"); + if (homedrive != NULL && *homedrive != '\0') + { + _dbus_string_append(&homedir,homedrive); + } + homepath = _dbus_getenv("HOMEPATH"); if (homepath != NULL && *homepath != '\0') { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hab...@us...> - 2010-01-14 08:47:47
|
Revision: 818 http://windbus.svn.sourceforge.net/windbus/?rev=818&view=rev Author: habacker Date: 2010-01-14 08:47:41 +0000 (Thu, 14 Jan 2010) Log Message: ----------- applied r814 from tags/1.2.4: added initial authentification support for system bus using DBUS_COOKIE_SHA1 - allow all users to connect. Because dbus-daemon is running on localhost by default, in fact only local clients are allowed. Implementing full policy support needs to refactor the unix only user/group related config-parser api Modified Paths: -------------- trunk/bus/connection.c trunk/bus/policy.c Modified: trunk/bus/connection.c =================================================================== --- trunk/bus/connection.c 2010-01-14 08:39:26 UTC (rev 817) +++ trunk/bus/connection.c 2010-01-14 08:47:41 UTC (rev 818) @@ -373,6 +373,19 @@ } } +static dbus_bool_t allow_windows_user_function(DBusConnection *connection, + const char *sid, + void *data) +{ + BusConnectionData *d; + + d = BUS_CONNECTION_DATA (connection); + + _dbus_assert (d != NULL); + + return bus_context_allow_windows_user (d->connections->context, sid); +} + static dbus_bool_t allow_unix_user_function (DBusConnection *connection, unsigned long uid, @@ -674,6 +687,10 @@ allow_unix_user_function, NULL, NULL); + dbus_connection_set_windows_user_function (connection, + allow_windows_user_function, + NULL, NULL); + dbus_connection_set_dispatch_status_function (connection, dispatch_status_function, bus_context_get_loop (connections->context), Modified: trunk/bus/policy.c =================================================================== --- trunk/bus/policy.c 2010-01-14 08:39:26 UTC (rev 817) +++ trunk/bus/policy.c 2010-01-14 08:47:41 UTC (rev 818) @@ -478,11 +478,16 @@ bus_policy_allow_windows_user (BusPolicy *policy, const char *windows_sid) { + /* for initial system bus support e.g running dbus-daemon as service + * under the SYSTEM user, we will allow all users for now + * until the policy user/group api is able to handle sid's and names' + */ + return TRUE; /* Windows has no policies here since only the session bus * is really used for now, so just checking that the * connecting person is the same as the bus owner is fine. */ - return _dbus_windows_user_is_process_owner (windows_sid); + //return _dbus_windows_user_is_process_owner (windows_sid); } dbus_bool_t This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hab...@us...> - 2010-01-14 08:39:44
|
Revision: 817 http://windbus.svn.sourceforge.net/windbus/?rev=817&view=rev Author: habacker Date: 2010-01-14 08:39:26 +0000 (Thu, 14 Jan 2010) Log Message: ----------- applied r813 from tags/1.2.4: fixed bug not displaying client id in log file Modified Paths: -------------- trunk/dbus/dbus-transport.c Modified: trunk/dbus/dbus-transport.c =================================================================== --- trunk/dbus/dbus-transport.c 2010-01-14 07:46:19 UTC (rev 816) +++ trunk/dbus/dbus-transport.c 2010-01-14 08:39:26 UTC (rev 817) @@ -651,12 +651,12 @@ if (_dbus_credentials_include(our_identity,DBUS_CREDENTIAL_WINDOWS_SID)) _dbus_verbose ("Client authorized as SID '%s'" " but our SID is '%s', disconnecting\n", - _dbus_credentials_get_windows_sid(our_identity), + _dbus_credentials_get_windows_sid(auth_identity), _dbus_credentials_get_windows_sid(our_identity)); else _dbus_verbose ("Client authorized as UID "DBUS_UID_FORMAT " but our UID is "DBUS_UID_FORMAT", disconnecting\n", - _dbus_credentials_get_unix_uid(our_identity), + _dbus_credentials_get_unix_uid(auth_identity), _dbus_credentials_get_unix_uid(our_identity)); _dbus_transport_disconnect (transport); allow = FALSE; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hab...@us...> - 2010-01-14 07:46:25
|
Revision: 816 http://windbus.svn.sourceforge.net/windbus/?rev=816&view=rev Author: habacker Date: 2010-01-14 07:46:19 +0000 (Thu, 14 Jan 2010) Log Message: ----------- fixes bug where sometimes objects were not unregistered from dbus although their app had exited. As it turns out it was a missing implementation of the method _dbus_fd_set_close_on_exec()for windows. It's been tested with msvc2005, msvc2008, and mingw, and solves all the unregistering issues on many kde apps. patch from Romain Pokrzywka romain at kdab dot com Modified Paths: -------------- trunk/dbus/dbus-sysdeps-win.c Modified: trunk/dbus/dbus-sysdeps-win.c =================================================================== --- trunk/dbus/dbus-sysdeps-win.c 2009-11-22 22:33:08 UTC (rev 815) +++ trunk/dbus/dbus-sysdeps-win.c 2010-01-14 07:46:19 UTC (rev 816) @@ -434,31 +434,12 @@ void _dbus_fd_set_close_on_exec (int handle) { -#ifdef ENABLE_DBUSSOCKET - DBusSocket *s; - if (handle < 0) - return; - - _dbus_lock_sockets(); - - _dbus_handle_to_socket_unlocked (handle, &s); - s->close_on_exec = TRUE; - - _dbus_unlock_sockets(); -#else - /* TODO unic code. - int val; - - val = fcntl (fd, F_GETFD, 0); - - if (val < 0) - return; - - val |= FD_CLOEXEC; - - fcntl (fd, F_SETFD, val); - */ -#endif + if ( !SetHandleInformation( (HANDLE) handle, + HANDLE_FLAG_INHERIT | HANDLE_FLAG_PROTECT_FROM_CLOSE, + 0 /*disable both flags*/ ) ) + { + _dbus_win_warn_win_error ("Disabling socket handle inheritance failed:", GetLastError()); + } } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hab...@us...> - 2009-11-22 22:33:17
|
Revision: 815 http://windbus.svn.sourceforge.net/windbus/?rev=815&view=rev Author: habacker Date: 2009-11-22 22:33:08 +0000 (Sun, 22 Nov 2009) Log Message: ----------- prefixed keyring directory path with drive letter to support current dirs other then system drive Modified Paths: -------------- tags/1.2.4/dbus/dbus-sysdeps-win.c Modified: tags/1.2.4/dbus/dbus-sysdeps-win.c =================================================================== --- tags/1.2.4/dbus/dbus-sysdeps-win.c 2009-11-22 21:58:25 UTC (rev 814) +++ tags/1.2.4/dbus/dbus-sysdeps-win.c 2009-11-22 22:33:08 UTC (rev 815) @@ -3448,6 +3448,7 @@ DBusString dotdir; dbus_uid_t uid; const char *homepath; + const char *homedrive; _dbus_assert (credentials != NULL); _dbus_assert (!_dbus_credentials_are_anonymous (credentials)); @@ -3455,6 +3456,12 @@ if (!_dbus_string_init (&homedir)) return FALSE; + homedrive = _dbus_getenv("HOMEDRIVE"); + if (homedrive != NULL && *homedrive != '\0') + { + _dbus_string_append(&homedir,homedrive); + } + homepath = _dbus_getenv("HOMEPATH"); if (homepath != NULL && *homepath != '\0') { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hab...@us...> - 2009-11-22 21:58:31
|
Revision: 814 http://windbus.svn.sourceforge.net/windbus/?rev=814&view=rev Author: habacker Date: 2009-11-22 21:58:25 +0000 (Sun, 22 Nov 2009) Log Message: ----------- added initial authentification support for system bus using DBUS_COOKIE_SHA1 - allow all users to connect. Because dbus-daemon is running on localhost by default, in fact only local clients are allowed. Implementing full policy support needs to refactor the unix only user/group related config-parser api Modified Paths: -------------- tags/1.2.4/bus/connection.c tags/1.2.4/bus/policy.c Modified: tags/1.2.4/bus/connection.c =================================================================== --- tags/1.2.4/bus/connection.c 2009-11-20 21:50:24 UTC (rev 813) +++ tags/1.2.4/bus/connection.c 2009-11-22 21:58:25 UTC (rev 814) @@ -369,6 +369,19 @@ } } +static dbus_bool_t allow_windows_user_function(DBusConnection *connection, + const char *sid, + void *data) +{ + BusConnectionData *d; + + d = BUS_CONNECTION_DATA (connection); + + _dbus_assert (d != NULL); + + return bus_context_allow_windows_user (d->connections->context, sid); +} + static dbus_bool_t allow_unix_user_function (DBusConnection *connection, unsigned long uid, @@ -608,6 +621,10 @@ allow_unix_user_function, NULL, NULL); + dbus_connection_set_windows_user_function (connection, + allow_windows_user_function, + NULL, NULL); + dbus_connection_set_dispatch_status_function (connection, dispatch_status_function, bus_context_get_loop (connections->context), Modified: tags/1.2.4/bus/policy.c =================================================================== --- tags/1.2.4/bus/policy.c 2009-11-20 21:50:24 UTC (rev 813) +++ tags/1.2.4/bus/policy.c 2009-11-22 21:58:25 UTC (rev 814) @@ -478,11 +478,16 @@ bus_policy_allow_windows_user (BusPolicy *policy, const char *windows_sid) { + /* for initial system bus support e.g running dbus-daemon as service + * under the SYSTEM user, we will allow all users for now + * until the policy user/group api is able to handle sid's and names' + */ + return TRUE; /* Windows has no policies here since only the session bus * is really used for now, so just checking that the * connecting person is the same as the bus owner is fine. */ - return _dbus_windows_user_is_process_owner (windows_sid); + //return _dbus_windows_user_is_process_owner (windows_sid); } dbus_bool_t This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hab...@us...> - 2009-11-20 21:50:31
|
Revision: 813 http://windbus.svn.sourceforge.net/windbus/?rev=813&view=rev Author: habacker Date: 2009-11-20 21:50:24 +0000 (Fri, 20 Nov 2009) Log Message: ----------- fixed bug not displaying client id in log file Modified Paths: -------------- tags/1.2.4/dbus/dbus-transport.c Modified: tags/1.2.4/dbus/dbus-transport.c =================================================================== --- tags/1.2.4/dbus/dbus-transport.c 2009-02-23 21:18:57 UTC (rev 812) +++ tags/1.2.4/dbus/dbus-transport.c 2009-11-20 21:50:24 UTC (rev 813) @@ -651,12 +651,12 @@ if (_dbus_credentials_include(our_identity,DBUS_CREDENTIAL_WINDOWS_SID)) _dbus_verbose ("Client authorized as SID '%s'" " but our SID is '%s', disconnecting\n", - _dbus_credentials_get_windows_sid(our_identity), + _dbus_credentials_get_windows_sid(auth_identity), _dbus_credentials_get_windows_sid(our_identity)); else _dbus_verbose ("Client authorized as UID "DBUS_UID_FORMAT " but our UID is "DBUS_UID_FORMAT", disconnecting\n", - _dbus_credentials_get_unix_uid(our_identity), + _dbus_credentials_get_unix_uid(auth_identity), _dbus_credentials_get_unix_uid(our_identity)); _dbus_transport_disconnect (transport); allow = FALSE; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <che...@us...> - 2009-02-23 21:19:05
|
Revision: 812 http://windbus.svn.sourceforge.net/windbus/?rev=812&view=rev Author: chehrlic Date: 2009-02-23 21:18:57 +0000 (Mon, 23 Feb 2009) Log Message: ----------- remove WaitForInputIdle as it doesn't work in non-console mode Modified Paths: -------------- trunk/dbus/dbus-sysdeps-win.c Modified: trunk/dbus/dbus-sysdeps-win.c =================================================================== --- trunk/dbus/dbus-sysdeps-win.c 2009-02-23 17:23:15 UTC (rev 811) +++ trunk/dbus/dbus-sysdeps-win.c 2009-02-23 21:18:57 UTC (rev 812) @@ -3150,9 +3150,7 @@ if(CreateProcessA(dbus_exe_path, dbus_args, NULL, NULL, FALSE, CREATE_NO_WINDOW, NULL, NULL, &si, &pi)) { - // Wait until started (see _dbus_get_autolaunch_shm()) - if (WaitForInputIdle(pi.hProcess, INFINITE) == 0) - retval = _dbus_get_autolaunch_shm( address ); + retval = _dbus_get_autolaunch_shm( address ); } if (retval == FALSE) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <che...@us...> - 2009-02-23 17:23:23
|
Revision: 811 http://windbus.svn.sourceforge.net/windbus/?rev=811&view=rev Author: chehrlic Date: 2009-02-23 17:23:15 +0000 (Mon, 23 Feb 2009) Log Message: ----------- fix deadlock when dbus-daemon could not start up mingw compile++ Modified Paths: -------------- trunk/dbus/dbus-sysdeps-util-win.c trunk/dbus/dbus-sysdeps-win.c Modified: trunk/dbus/dbus-sysdeps-util-win.c =================================================================== --- trunk/dbus/dbus-sysdeps-util-win.c 2009-02-12 19:55:22 UTC (rev 810) +++ trunk/dbus/dbus-sysdeps-util-win.c 2009-02-23 17:23:15 UTC (rev 811) @@ -78,7 +78,8 @@ dbus_bool_t _dbus_become_daemon (const DBusString *pidfile, DBusPipe *print_pid_pipe, - DBusError *error) + DBusError *error, + dbus_bool_t keep_umask) { return TRUE; } Modified: trunk/dbus/dbus-sysdeps-win.c =================================================================== --- trunk/dbus/dbus-sysdeps-win.c 2009-02-12 19:55:22 UTC (rev 810) +++ trunk/dbus/dbus-sysdeps-win.c 2009-02-23 17:23:15 UTC (rev 811) @@ -3025,6 +3025,7 @@ char szUserName[64]; DWORD dwUserNameSize = sizeof(szUserName); char szDBusDaemonAddressInfo[128]; + int i; if( !GetUserName(szUserName, &dwUserNameSize) ) return FALSE; @@ -3032,12 +3033,14 @@ cDBusDaemonAddressInfo, szUserName); // read shm - do { + for(i=0;i<20;++i) { // we know that dbus-daemon is available, so we wait until shm is available sharedMem = OpenFileMapping( FILE_MAP_READ, FALSE, szDBusDaemonAddressInfo ); if( sharedMem == 0 ) Sleep( 100 ); - } while( sharedMem == 0 ); + if ( sharedMem != 0) + break; + } if( sharedMem == 0 ) return FALSE; @@ -3100,7 +3103,7 @@ } dbus_bool_t -_dbus_get_autolaunch_address (DBusString *address, +_dbus_get_autolaunch_address (DBusString *address, DBusError *error) { HANDLE mutex; @@ -3143,25 +3146,24 @@ _snprintf(dbus_args, sizeof(dbus_args) - 1, "\"%s\" %s", dbus_exe_path, " --session"); // argv[i] = "--config-file=bus\\session.conf"; - printf("create process \"%s\" %s\n", dbus_exe_path, dbus_args); +// printf("create process \"%s\" %s\n", dbus_exe_path, dbus_args); if(CreateProcessA(dbus_exe_path, dbus_args, NULL, NULL, FALSE, CREATE_NO_WINDOW, NULL, NULL, &si, &pi)) { - retval = TRUE; // Wait until started (see _dbus_get_autolaunch_shm()) - WaitForInputIdle(pi.hProcess, INFINITE); + if (WaitForInputIdle(pi.hProcess, INFINITE) == 0) + retval = _dbus_get_autolaunch_shm( address ); + } - retval = _dbus_get_autolaunch_shm( address ); - } else { - retval = FALSE; - } - + if (retval == FALSE) + dbus_set_error_const (error, DBUS_ERROR_FAILED, "Failed to launch dbus-daemon"); + out: if (retval) _DBUS_ASSERT_ERROR_IS_CLEAR (error); else _DBUS_ASSERT_ERROR_IS_SET (error); - + _dbus_global_unlock (mutex); return retval; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <che...@us...> - 2009-02-12 19:55:26
|
Revision: 810 http://windbus.svn.sourceforge.net/windbus/?rev=810&view=rev Author: chehrlic Date: 2009-02-12 19:55:22 +0000 (Thu, 12 Feb 2009) Log Message: ----------- use "DBusDaemonAddressInfoDebug" in debug mode to be able to have one dbus-daemon in debug and on in release mode Modified Paths: -------------- trunk/dbus/dbus-sysdeps-win.c Modified: trunk/dbus/dbus-sysdeps-win.c =================================================================== --- trunk/dbus/dbus-sysdeps-win.c 2009-02-12 17:43:31 UTC (rev 809) +++ trunk/dbus/dbus-sysdeps-win.c 2009-02-12 19:55:22 UTC (rev 810) @@ -2943,7 +2943,11 @@ // mutex to determine if dbus-daemon is already started (per user) static const char *cDBusDaemonMutex = "DBusDaemonMutex"; // named shm for dbus adress info (per user) +#ifdef _DEBUG +static const char *cDBusDaemonAddressInfo = "DBusDaemonAddressInfoDebug"; +#else static const char *cDBusDaemonAddressInfo = "DBusDaemonAddressInfo"; +#endif void _dbus_daemon_init(const char *host, dbus_uint32_t port) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <che...@us...> - 2009-02-12 17:43:40
|
Revision: 809 http://windbus.svn.sourceforge.net/windbus/?rev=809&view=rev Author: chehrlic Date: 2009-02-12 17:43:31 +0000 (Thu, 12 Feb 2009) Log Message: ----------- remove an assert for windows only - don't know why this was added... Modified Paths: -------------- trunk/dbus/dbus-connection.c Modified: trunk/dbus/dbus-connection.c =================================================================== --- trunk/dbus/dbus-connection.c 2009-02-12 17:18:34 UTC (rev 808) +++ trunk/dbus/dbus-connection.c 2009-02-12 17:43:31 UTC (rev 809) @@ -4975,10 +4975,7 @@ else result = _dbus_transport_get_unix_process_id (connection->transport, pid); -#ifdef DBUS_WIN - _dbus_assert (!result); -#endif - + CONNECTION_UNLOCK (connection); return result; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <che...@us...> - 2009-02-12 17:18:49
|
Revision: 808 http://windbus.svn.sourceforge.net/windbus/?rev=808&view=rev Author: chehrlic Date: 2009-02-12 17:18:34 +0000 (Thu, 12 Feb 2009) Log Message: ----------- compile++, add debug_postfix for executables to see if it works s intended Modified Paths: -------------- trunk/cmake/bus/CMakeLists.txt trunk/cmake/dbus/dbus-1.def.cmake trunk/cmake/tools/CMakeLists.txt trunk/dbus/dbus-sysdeps-util-unix.c trunk/dbus/dbus-sysdeps-util-win.c trunk/dbus/dbus-sysdeps-win.c trunk/dbus/dbus-sysdeps.c trunk/tools/dbus-launch-win.c Modified: trunk/cmake/bus/CMakeLists.txt =================================================================== --- trunk/cmake/bus/CMakeLists.txt 2009-02-11 20:36:14 UTC (rev 807) +++ trunk/cmake/bus/CMakeLists.txt 2009-02-12 17:18:34 UTC (rev 808) @@ -80,14 +80,15 @@ if(splitlib AND MSVC) add_library(bus-lib STATIC ${BUS_SOURCES}) - add_executable(dbus-daemon${CMAKE_EXE_POSTFIX} ${BUS_DIR}/main.c) - target_link_libraries(dbus-daemon${CMAKE_EXE_POSTFIX} ${DBUS_1} ${LIBS} bus-lib) + add_executable(dbus-daemon ${BUS_DIR}/main.c) + target_link_libraries(dbus-daemon ${DBUS_1} ${LIBS} bus-lib) else(splitlib AND MSVC) - add_executable(dbus-daemon${CMAKE_EXE_POSTFIX} ${BUS_SOURCES} ${BUS_DIR}/main.c) - target_link_libraries(dbus-daemon${CMAKE_EXE_POSTFIX} ${DBUS_1} ${LIBS}) + add_executable(dbus-daemon ${BUS_SOURCES} ${BUS_DIR}/main.c) + target_link_libraries(dbus-daemon ${DBUS_1} ${LIBS}) endif(splitlib AND MSVC) +set_target_properties(dbus-daemon PROPERTIES DEBUG_POSTFIX d) -install_targets(/bin dbus-daemon${CMAKE_EXE_POSTFIX}) +install_targets(/bin dbus-daemon) install_files(/etc FILES ${config_DATA}) if (DBUS_SERVICE) @@ -98,9 +99,10 @@ # ${BUS_SOURCES} ) - add_executable(dbus-service${CMAKE_EXE_POSTFIX} ${dbus_service_SOURCES} ) - target_link_libraries(dbus-service${CMAKE_EXE_POSTFIX} ${DBUS_1} ${LIBS}) - install_targets(/bin dbus-service${CMAKE_EXE_POSTFIX} ) + add_executable(dbus-service ${dbus_service_SOURCES} ) + target_link_libraries(dbus-service ${DBUS_1} ${LIBS}) + install_targets(/bin dbus-service ) + set_target_properties(dbus-service PROPERTIES DEBUG_POSTFIX d) endif (DBUS_SERVICE) Modified: trunk/cmake/dbus/dbus-1.def.cmake =================================================================== --- trunk/cmake/dbus/dbus-1.def.cmake 2009-02-11 20:36:14 UTC (rev 807) +++ trunk/cmake/dbus/dbus-1.def.cmake 2009-02-12 17:18:34 UTC (rev 808) @@ -51,6 +51,7 @@ _dbus_check_is_valid_path _dbus_check_is_valid_signature _dbus_close_socket +_dbus_command_for_pid _dbus_concat_dir_and_file _dbus_condvar_free _dbus_condvar_free_at_location @@ -232,6 +233,7 @@ _dbus_header_set_serial _dbus_header_toggle_flag _dbus_header_update_lengths +_dbus_init_system_log _dbus_is_valid_file _dbus_is_verbose_real _dbus_keyring_get_best_key @@ -288,6 +290,8 @@ _dbus_lock_sid_atom_cache DATA _dbus_lock_system_users DATA _dbus_lock_win_fds DATA +_dbus_log_info +_dbus_log_security _dbus_loop_add_timeout _dbus_loop_add_watch _dbus_loop_dispatch Modified: trunk/cmake/tools/CMakeLists.txt =================================================================== --- trunk/cmake/tools/CMakeLists.txt 2009-02-11 20:36:14 UTC (rev 807) +++ trunk/cmake/tools/CMakeLists.txt 2009-02-12 17:18:34 UTC (rev 808) @@ -1,30 +1,5 @@ project(tools) -#nodist_libdbus_glib_HEADERS = dbus-glib-bindings.h -#libdbus_glibdir = $(includedir)/dbus-1.0/dbus - -#dbus-glib-bindings.h: dbus-bus-introspect.xml $(top_builddir)/glib/dbus-binding-tool$(EXEEXT) -# $(top_builddir)/glib/dbus-binding-tool --mode=glib-client --output=dbus-glib-bindings.h dbus-bus-introspect.xml - -#BUILT_SOURCES = dbus-glib-bindings.h dbus-bus-introspect.xml - -#else -#GLIB_TOOLS= -#endif - -#if HAVE_GTK -#GTK_TOOLS=dbus-viewer -#else -#GTK_TOOLS= -#endif - -#if HAVE_GLIB -#dbus-bus-introspect.xml: $(top_builddir)/bus/dbus-daemon$(EXEEXT) dbus-launch$(EXEEXT) dbus-send$(EXEEXT) $(top_builddir)/bus/dbus-daemon$(EXEEXT) Makefile -# DBUS_TOP_BUILDDIR=$(top_builddir) $(srcdir)/run-with-tmp-session-bus.sh ./dbus-send --print-reply=literal --dest=org.freedesktop.DBus /org/freedesktop/DBus org.freedesktop.DBus.Introspectable.Introspect > dbus-bus-introspect.xml.tmp && mv dbus-bus-introspect.xml.tmp dbus-bus-introspect.xml -#endif - -#bin_PROGRAMS=dbus-send $(GLIB_TOOLS) dbus-launch dbus-cleanup-sockets $(GTK_TOOLS) - set (dbus_send_SOURCES ../../tools/dbus-print-message.c ../../tools/dbus-print-message.h @@ -59,29 +34,16 @@ ../../tools/dbus-viewer.c ) -add_executable(dbus-send${CMAKE_EXE_POSTFIX} ${dbus_send_SOURCES}) -target_link_libraries(dbus-send${CMAKE_EXE_POSTFIX} ${DBUS_1}) -install_targets(/bin dbus-send${CMAKE_EXE_POSTFIX} ) +add_executable(dbus-send ${dbus_send_SOURCES}) +target_link_libraries(dbus-send ${DBUS_1}) +install_targets(/bin dbus-send ) -# glib required -#add_executable(dbus_launch${CMAKE_EXE_POSTFIX} ${dbus_launch_SOURCES}) +add_executable(dbus-launch ${dbus_launch_SOURCES}) +target_link_libraries(dbus-launch ) +install_targets(/bin dbus-launch ) -add_executable(dbus-launch${CMAKE_EXE_POSTFIX} ${dbus_launch_SOURCES}) -target_link_libraries(dbus-launch${CMAKE_EXE_POSTFIX} ) -install_targets(/bin dbus-launch${CMAKE_EXE_POSTFIX} ) +add_executable(dbus-monitor ${dbus_monitor_SOURCES}) +target_link_libraries(dbus-monitor ${DBUS_1}) +install_targets(/bin dbus-monitor ) -add_executable(dbus-monitor${CMAKE_EXE_POSTFIX} ${dbus_monitor_SOURCES}) -target_link_libraries(dbus-monitor${CMAKE_EXE_POSTFIX} ${DBUS_1}) -install_targets(/bin dbus-monitor${CMAKE_EXE_POSTFIX} ) - -#dbus_send_LDADD= $(top_builddir)/dbus/libdbus-1.la -#dbus_monitor_LDADD= $(top_builddir)/glib/libdbus-glib-1.la -#dbus_launch_LDADD= $(DBUS_X_LIBS) -#dbus_viewer_LDADD= $(top_builddir)/glib/libdbus-gtool.la $(DBUS_GTK_THREADS_LIBS) $(DBUS_GLIB_TOOL_LIBS) - -#man_MANS = dbus-send.1 dbus-monitor.1 dbus-launch.1 dbus-cleanup-sockets.1 -#EXTRA_DIST = $(man_MANS) run-with-tmp-session-bus.sh -#CLEANFILES = -# run-with-tmp-session-bus.conf -# dbus-bus-introspect.xml -# dbus-glib-bindings.h +set_target_properties(dbus-send dbus-launch dbus-monitor PROPERTIES DEBUG_POSTFIX d) Modified: trunk/dbus/dbus-sysdeps-util-unix.c =================================================================== --- trunk/dbus/dbus-sysdeps-util-unix.c 2009-02-11 20:36:14 UTC (rev 807) +++ trunk/dbus/dbus-sysdeps-util-unix.c 2009-02-12 17:18:34 UTC (rev 808) @@ -1233,4 +1233,4 @@ _dbus_string_free (&cmdline); _dbus_string_free (&path); return FALSE; -} \ No newline at end of file +} Modified: trunk/dbus/dbus-sysdeps-util-win.c =================================================================== --- trunk/dbus/dbus-sysdeps-util-win.c 2009-02-11 20:36:14 UTC (rev 807) +++ trunk/dbus/dbus-sysdeps-util-win.c 2009-02-12 17:18:34 UTC (rev 808) @@ -373,6 +373,38 @@ return TRUE; } +void +_dbus_init_system_log (void) +{ + // FIXME! +} + +/** + * Log an informative message. Intended for use primarily by + * the system bus. + * + * @param msg a printf-style format string + * @param args arguments for the format string + */ +void +_dbus_log_info (const char *msg, va_list args) +{ + // FIXME! +} + +/** + * Log a security-related message. Intended for use primarily by + * the system bus. + * + * @param msg a printf-style format string + * @param args arguments for the format string + */ +void +_dbus_log_security (const char *msg, va_list args) +{ + // FIXME! +} + /** Installs a signal handler * * @param sig the signal to handle @@ -1791,3 +1823,27 @@ return msg; #endif //DBUS_WINCE } + +/** + * Get a printable string describing the command used to execute + * the process with pid. This string should only be used for + * informative purposes such as logging; it may not be trusted. + * + * The command is guaranteed to be printable ASCII and no longer + * than max_len. + * + * @param pid Process id + * @param str Append command to this string + * @param max_len Maximum length of returned command + * @param error return location for errors + * @returns #FALSE on error + */ +dbus_bool_t +_dbus_command_for_pid (unsigned long pid, + DBusString *str, + int max_len, + DBusError *error) +{ + // FIXME + return FALSE; +} Modified: trunk/dbus/dbus-sysdeps-win.c =================================================================== --- trunk/dbus/dbus-sysdeps-win.c 2009-02-11 20:36:14 UTC (rev 807) +++ trunk/dbus/dbus-sysdeps-win.c 2009-02-12 17:18:34 UTC (rev 808) @@ -3106,6 +3106,11 @@ LPSTR lpFile; char dbus_exe_path[MAX_PATH]; char dbus_args[MAX_PATH * 2]; +#ifdef _DEBUG + const char * daemon_name = "dbus-daemond.exe"; +#else + const char * daemon_name = "dbus-daemon.exe"; +#endif mutex = _dbus_global_lock ( cDBusAutolaunchMutex ); @@ -3118,9 +3123,9 @@ goto out; } - if (!SearchPathA(NULL, "dbus-daemon.exe", NULL, sizeof(dbus_exe_path), dbus_exe_path, &lpFile)) + if (!SearchPathA(NULL, daemon_name, NULL, sizeof(dbus_exe_path), dbus_exe_path, &lpFile)) { - printf ("please add the path to dbus-daemon.exe to your PATH environment variable\n"); + printf ("please add the path to %s to your PATH environment variable\n", daemon_name); printf ("or start the daemon manually\n\n"); printf (""); goto out; Modified: trunk/dbus/dbus-sysdeps.c =================================================================== --- trunk/dbus/dbus-sysdeps.c 2009-02-11 20:36:14 UTC (rev 807) +++ trunk/dbus/dbus-sysdeps.c 2009-02-12 17:18:34 UTC (rev 808) @@ -51,7 +51,11 @@ _DBUS_DEFINE_GLOBAL_LOCK (sid_atom_cache); _DBUS_DEFINE_GLOBAL_LOCK (system_users); -extern char **environ; +#ifdef WIN32 + #include <stdlib.h> +#else + extern char **environ; +#endif /** * @defgroup DBusSysdeps Internal system-dependent API Modified: trunk/tools/dbus-launch-win.c =================================================================== --- trunk/tools/dbus-launch-win.c 2009-02-11 20:36:14 UTC (rev 807) +++ trunk/tools/dbus-launch-win.c 2009-02-12 17:18:34 UTC (rev 808) @@ -68,11 +68,12 @@ showConsole = 1; #endif GetModuleFileName(NULL,dbusDaemonPath,sizeof(dbusDaemonPath)); - /* check for debug version */ - if (strstr(dbusDaemonPath,"dbus-launchd.exe")) - daemon_name = "dbus-daemond.exe"; - else - daemon_name = "dbus-daemon.exe"; + +#ifdef _DEBUG + daemon_name = "dbus-daemond.exe"; +#else + daemon_name = "dbus-daemon.exe"; +#endif if ((p = strrchr(dbusDaemonPath,'\\'))) { *(p+1)= '\0'; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <che...@us...> - 2009-02-11 20:36:17
|
Revision: 807 http://windbus.svn.sourceforge.net/windbus/?rev=807&view=rev Author: chehrlic Date: 2009-02-11 20:36:14 +0000 (Wed, 11 Feb 2009) Log Message: ----------- use 0 as default port to be able to run more than one instance Modified Paths: -------------- trunk/cmake/CMakeLists.txt trunk/dbus/dbus-sysdeps-win.c Modified: trunk/cmake/CMakeLists.txt =================================================================== --- trunk/cmake/CMakeLists.txt 2009-01-17 23:18:46 UTC (rev 806) +++ trunk/cmake/CMakeLists.txt 2009-02-11 20:36:14 UTC (rev 807) @@ -24,7 +24,7 @@ if(COMMAND cmake_policy) cmake_policy(SET CMP0003 NEW) endif(COMMAND cmake_policy) - + # where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/modules") @@ -34,7 +34,7 @@ if (CYGWIN) set (WIN32) endif (CYGWIN) - + # search for required packages if (WIN32) # include local header first to avoid using old installed header @@ -52,7 +52,7 @@ # do config checks INCLUDE(ConfigureChecks.cmake) -# @TODO: how to remove last dir from ${CMAKE_SOURCE_DIR} ? +# @TODO: how to remove last dir from ${CMAKE_SOURCE_DIR} ? SET(DBUS_SOURCE_DIR ${CMAKE_SOURCE_DIR}/..) # make some more macros available @@ -71,19 +71,19 @@ set(GROUP_CODE flat) endif(NOT GROUP_CODE) ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE) - - + + # Use the highest warning level if (WALL) set(WALL 1 CACHE TYPE STRING FORCE) set(CMAKE_CXX_WARNING_LEVEL 4 CACHE TYPE STRING FORCE) - + if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]") STRING(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") else(CMAKE_CXX_FLAGS MATCHES "/W[0-4]") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4") endif(CMAKE_CXX_FLAGS MATCHES "/W[0-4]") - + if(CMAKE_C_FLAGS MATCHES "/W[0-4]") STRING(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") else(CMAKE_C_FLAGS MATCHES "/W[0-4]") @@ -92,7 +92,7 @@ else (WALL) set(CMAKE_CXX_WARNING_LEVEL 3 CACHE TYPE STRING FORCE) endif (WALL) - + SET(MSVC_W_ERROR " /we4028 /we4013 /we4133 /we4047 /we4031 /we4002 /we4003 /we4114") SET(MSVC_W_DISABLE " /wd4127 /wd4090 /wd4101 /wd4244") @@ -120,9 +120,9 @@ # don't forget parameters set(wince 1 CACHE TYPE STRING FORCE) set(wcelibcex ${wcelibcex} CACHE TYPE STRING FORCE) - + include_directories(${wcelibcex}/include/wcelibcex ${wcelibcex}/src) - + add_definitions( # see config.h.cmake # -DDBUS_WINCE @@ -133,22 +133,22 @@ -DUNICODE -DPOCKETPC2003_UI_MODEL ) - + # Windows CE Version add_definitions( -D_WIN32_WCE=0x420 -DWIN32_PLATFORM_PSPC=0x420 -DUNDER_CE=0x420 ) - + # Architecture add_definitions( -DARM -D_ARM_ ) - + set(CMAKE_CXX_STANDARD_LIBRARIES "coredll.lib corelibc.lib ole32.lib oleaut32.lib uuid.lib commctrl.lib ws2.lib") - + set(CMAKE_SHARED_LINKER_FLAGS "/subsystem:windowsce,4.20 /machine:THUMB") endif(wince) @@ -199,7 +199,7 @@ if (NOT DBUS_INSTALL_DIR) set(DBUS_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}" CACHE TYPE STRING) endif (NOT DBUS_INSTALL_DIR) - + # TODO: setting EXPANDED_... has nothing to do with DBUS_INSTALL_SYSTEM_LIBS if (DBUS_INSTALL_SYSTEM_LIBS) set(prefix ${DBUS_INSTALL_DIR}) @@ -217,7 +217,7 @@ if (MSVC_IDE) set(EXPANDED_BINDIR ${CMAKE_BINARY_DIR}/bin/debug) else (MSVC_IDE) - set(EXPANDED_BINDIR ${CMAKE_BINARY_DIR}/bin) + set(EXPANDED_BINDIR ${CMAKE_BINARY_DIR}/bin) endif (MSVC_IDE) set(DBUS_BINDIR ${EXPANDED_BINDIR}) set(DBUS_MACHINE_UUID_FILE ${CMAKE_BINARY_DIR}/lib/dbus/machine-id) @@ -226,15 +226,15 @@ set (DBUS_DAEMONDIR ${EXPANDED_BINDIR}) ########### command line options ############### -# TODO: take check from configure.in +# TODO: take check from configure.in #AC_ARG_ENABLE(tests, AS_HELP_STRING([--enable-tests],[enable unit test code]),enable_tests=$enableval,enable_tests=$USE_MAINTAINER_MODE) OPTION(DBUS_BUILD_TESTS "enable unit test code" ON) -if (DBUS_BUILD_TESTS) +if (DBUS_BUILD_TESTS) if(NOT MSVC AND NOT CMAKE_BUILD_TYPE MATCHES Release) add_definitions(-g) endif(NOT MSVC AND NOT CMAKE_BUILD_TYPE MATCHES Release) -endif (DBUS_BUILD_TESTS) +endif (DBUS_BUILD_TESTS) # win32 dbus service support - this support is not complete OPTION(DBUS_SERVICE "enable dbus service installer" OFF) @@ -246,7 +246,7 @@ add_definitions(-ansi -D_POSIX_C_SOURCE=199309L -D_BSD_SOURCE -pedantic) else(NOT MSVC) add_definitions(-Za -D_POSIX_C_SOURCE=199309L -D_BSD_SOURCE -W4) - endif(NOT MSVC) + endif(NOT MSVC) endif(DBUS_ENABLE_ANSI) #AC_ARG_ENABLE(verbose-mode, AS_HELP_STRING([--enable-verbose-mode],[support verbose debug mode]),enable_verbose_mode=$enableval,enable_verbose_mode=$USE_MAINTAINER_MODE) @@ -266,7 +266,7 @@ # FIXME!!!! ## remove optimization # CFLAGS=`echo "$CFLAGS" | sed -e 's/-O[0-9]*//g'` - endif(NOT MSVC) + endif(NOT MSVC) endif(DBUS_GCOV_ENABLED) #AC_ARG_ENABLE(abstract-sockets, AS_HELP_STRING([--enable-abstract-sockets],[use abstract socket namespace (linux only)]),enable_abstract_sockets=$enableval,enable_abstract_sockets=auto) @@ -417,7 +417,7 @@ #else # DBUS_SYSTEM_PID_FILE=${EXPANDED_LOCALSTATEDIR}/run/dbus/pid #fi -# TODO: fix redhet +# TODO: fix redhet if (WIN32) # bus-test expects a non empty string set (DBUS_SYSTEM_PID_FILE "/dbus-pid") @@ -441,12 +441,12 @@ if (WIN32) - set (DBUS_SESSION_BUS_DEFAULT_ADDRESS "tcp:host=localhost,port=12434") - set (DBUS_SYSTEM_BUS_DEFAULT_ADDRESS "tcp:host=localhost,port=12434") + set (DBUS_SESSION_BUS_DEFAULT_ADDRESS "tcp:host=localhost,port=0") + set (DBUS_SYSTEM_BUS_DEFAULT_ADDRESS "tcp:host=localhost,port=0") set (DBUS_SYSTEM_CONFIG_FILE "etc/system.conf") set (DBUS_SESSION_CONFIG_FILE "etc/session.conf") # bus-test expects a non empty string - set (DBUS_USER "Administrator") + set (DBUS_USER "Administrator") set (DBUS_DATADIR "data") else (WIN32) set (DBUS_SYSTEM_BUS_DEFAULT_ADDRESS unix:tmpdir=) @@ -455,26 +455,26 @@ set (configdir ${sysconfdir}/dbus-1 ) set (DBUS_SYSTEM_CONFIG_FILE ${configdir}/system.conf) set (DBUS_SESSION_CONFIG_FILE ${configdir}/session.conf) - set (DBUS_USER "root") + set (DBUS_USER "root") set (DBUS_DATADIR ${EXPANDED_DATADIR}) endif (WIN32) -set (DAEMON_NAME dbus-daemon) +set (DAEMON_NAME dbus-daemon) ########### create config.h ############### #include(ConfigureChecks.cmake) -# better use flags for gcc +# better use flags for gcc if (MINGW) set (HAVE_GNUC_VARARGS 1) endif(MINGW) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h ) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/dbus-env.bat.cmake ${CMAKE_BINARY_DIR}/bin/dbus-env.bat ) -install_files(/bin FILES ${CMAKE_BINARY_DIR}/bin/dbus-env.bat) +install_files(/bin FILES ${CMAKE_BINARY_DIR}/bin/dbus-env.bat) -# compiler definitions +# compiler definitions add_definitions(-DHAVE_CONFIG_H=1) add_definitions(${DBUS_BUS_CFLAGS} -DDBUS_API_SUBJECT_TO_CHANGE) Modified: trunk/dbus/dbus-sysdeps-win.c =================================================================== --- trunk/dbus/dbus-sysdeps-win.c 2009-01-17 23:18:46 UTC (rev 806) +++ trunk/dbus/dbus-sysdeps-win.c 2009-02-11 20:36:14 UTC (rev 807) @@ -1653,7 +1653,7 @@ } _DBUS_ASSERT_ERROR_IS_CLEAR(error); - if (bind (fd, (struct sockaddr*) tmp->ai_addr, tmp->ai_addrlen) < 0) + if (bind (fd, (struct sockaddr*) tmp->ai_addr, tmp->ai_addrlen) == SOCKET_ERROR) { closesocket (fd); dbus_set_error (error, _dbus_error_from_errno (errno), @@ -1662,7 +1662,7 @@ goto failed; } - if (listen (fd, 30 /* backlog */) < 0) + if (listen (fd, 30 /* backlog */) == SOCKET_ERROR) { closesocket (fd); dbus_set_error (error, _dbus_error_from_errno (errno), @@ -1692,22 +1692,18 @@ to use the same port */ if (!port || !strcmp(port, "0")) { - struct sockaddr_storage addr; - socklen_t addrlen; - char portbuf[50]; + sockaddr_gen addr; + socklen_t addrlen = sizeof(addr); + char portbuf[10]; - addrlen = sizeof(addr); - getsockname(fd, (struct sockaddr*) &addr, &addrlen); - - if ((res = getnameinfo((struct sockaddr*)&addr, addrlen, NULL, 0, - portbuf, sizeof(portbuf), - NI_NUMERICHOST)) != 0) + if ((res = getsockname(fd, &addr.Address, &addrlen)) != 0) { dbus_set_error (error, _dbus_error_from_errno (errno), - "Failed to resolve port \"%s:%s\": %s (%s)", + "Failed to resolve port \"%s:%s\": %s (%d)", host ? host : "*", port, gai_strerror(res), res); goto failed; } + snprintf( portbuf, sizeof( portbuf ) - 1, "%d", addr.AddressIn.sin_port ); if (!_dbus_string_append(retport, portbuf)) { dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <che...@us...> - 2009-01-17 23:18:55
|
Revision: 806 http://windbus.svn.sourceforge.net/windbus/?rev=806&view=rev Author: chehrlic Date: 2009-01-17 23:18:46 +0000 (Sat, 17 Jan 2009) Log Message: ----------- update to 1.2.12 - not tested yet! Modified Paths: -------------- trunk/HACKING trunk/Makefile.in trunk/aclocal.m4 trunk/bus/Makefile.in trunk/bus/activation.c trunk/bus/bus.c trunk/bus/bus.h trunk/bus/config-parser-common.c trunk/bus/config-parser-common.h trunk/bus/config-parser.c trunk/bus/config-parser.h trunk/bus/connection.c trunk/bus/connection.h trunk/bus/dbus-daemon.1 trunk/bus/dbus-daemon.1.in trunk/bus/driver.c trunk/bus/main.c trunk/bus/policy.c trunk/bus/policy.h trunk/bus/session.conf.in trunk/bus/system.conf.in trunk/cmake/CMakeLists.txt trunk/config.guess trunk/config.h.in trunk/config.sub trunk/configure trunk/configure.in trunk/dbus/Makefile.in trunk/dbus/dbus-marshal-basic.c trunk/dbus/dbus-marshal-validate.c trunk/dbus/dbus-spawn.c trunk/dbus/dbus-sysdeps-unix.c trunk/dbus/dbus-sysdeps-util-unix.c trunk/dbus/dbus-sysdeps.c trunk/dbus/dbus-sysdeps.h trunk/doc/Makefile.in trunk/doc/busconfig.dtd trunk/ltmain.sh trunk/test/Makefile.in trunk/test/data/valid-config-files/session.conf trunk/test/data/valid-config-files/system.conf trunk/test/name-test/Makefile.am trunk/test/name-test/Makefile.in trunk/test/name-test/run-with-tmp-session-bus.conf trunk/tools/Makefile.in trunk/tools/dbus-launch.c trunk/tools/dbus-print-message.c trunk/tools/dbus-send.c trunk/tools/run-with-tmp-session-bus.sh Added Paths: ----------- trunk/test/name-test/run-test-systemserver.sh trunk/test/name-test/test-wait-for-echo.py trunk/test/name-test/tmp-session-like-system.conf Property Changed: ---------------- trunk/ trunk/bus/dbus-daemon.1 trunk/config.guess Property changes on: trunk ___________________________________________________________________ Modified: svn:mergeinfo - /branches/import:775-793 + /branches/import:775-793,803-805 Modified: trunk/HACKING =================================================================== --- trunk/HACKING 2009-01-17 23:05:43 UTC (rev 805) +++ trunk/HACKING 2009-01-17 23:18:46 UTC (rev 806) @@ -237,6 +237,5 @@ The reviewer group that can approve patches: Havoc Pennington, Michael Meeks, Alex Larsson, Zack Rusin, Joe Shaw, Mikael Hallendal, Richard Hult, Owen Fraser-Green, Olivier Andrieu, Colin Walters, Thiago -Macieira, John Palmieri. +Macieira, John Palmieri, Scott James Remnant. - Modified: trunk/Makefile.in =================================================================== --- trunk/Makefile.in 2009-01-17 23:05:43 UTC (rev 805) +++ trunk/Makefile.in 2009-01-17 23:18:46 UTC (rev 806) @@ -32,7 +32,6 @@ POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ -target_triplet = @target@ subdir = . DIST_COMMON = README $(am__configure_deps) $(srcdir)/Doxyfile.in \ $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ @@ -167,6 +166,7 @@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DOXYGEN = @DOXYGEN@ +DSYMUTIL = @DSYMUTIL@ ECHO = @ECHO@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ @@ -202,6 +202,7 @@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ +NMEDIT = @NMEDIT@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ @@ -291,11 +292,8 @@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ -target = @target@ target_alias = @target_alias@ -target_cpu = @target_cpu@ -target_os = @target_os@ -target_vendor = @target_vendor@ +top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ SUBDIRS = dbus bus doc tools test Modified: trunk/aclocal.m4 =================================================================== --- trunk/aclocal.m4 2009-01-17 23:05:43 UTC (rev 805) +++ trunk/aclocal.m4 2009-01-17 23:18:46 UTC (rev 806) @@ -13,15 +13,15 @@ m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl -m4_if(AC_AUTOCONF_VERSION, [2.61],, -[m4_warning([this file was generated for autoconf 2.61. +m4_if(AC_AUTOCONF_VERSION, [2.63],, +[m4_warning([this file was generated for autoconf 2.63. You have another version of autoconf. It may work, but is not guaranteed to. If you have problems, you may need to regenerate the build system entirely. To do so, use the procedure documented by the package, typically `autoreconf'.])]) # libtool.m4 - Configure libtool for the host system. -*-Autoconf-*- -# serial 51 AC_PROG_LIBTOOL +# serial 52 AC_PROG_LIBTOOL # AC_PROVIDE_IFELSE(MACRO-NAME, IF-PROVIDED, IF-NOT-PROVIDED) @@ -109,7 +109,6 @@ AC_REQUIRE([AC_OBJEXT])dnl AC_REQUIRE([AC_EXEEXT])dnl dnl - AC_LIBTOOL_SYS_MAX_CMD_LEN AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE AC_LIBTOOL_OBJDIR @@ -211,6 +210,8 @@ ;; esac +_LT_REQUIRED_DARWIN_CHECKS + AC_PROVIDE_IFELSE([AC_LIBTOOL_DLOPEN], enable_dlopen=yes, enable_dlopen=no) AC_PROVIDE_IFELSE([AC_LIBTOOL_WIN32_DLL], enable_win32_dll=yes, enable_win32_dll=no) @@ -290,10 +291,81 @@ echo "$lt_simple_link_test_code" >conftest.$ac_ext eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_linker_boilerplate=`cat conftest.err` -$rm conftest* +$rm -r conftest* ])# _LT_LINKER_BOILERPLATE +# _LT_REQUIRED_DARWIN_CHECKS +# -------------------------- +# Check for some things on darwin +AC_DEFUN([_LT_REQUIRED_DARWIN_CHECKS],[ + case $host_os in + rhapsody* | darwin*) + AC_CHECK_TOOL([DSYMUTIL], [dsymutil], [:]) + AC_CHECK_TOOL([NMEDIT], [nmedit], [:]) + AC_CACHE_CHECK([for -single_module linker flag],[lt_cv_apple_cc_single_mod], + [lt_cv_apple_cc_single_mod=no + if test -z "${LT_MULTI_MODULE}"; then + # By default we will add the -single_module flag. You can override + # by either setting the environment variable LT_MULTI_MODULE + # non-empty at configure time, or by adding -multi_module to the + # link flags. + echo "int foo(void){return 1;}" > conftest.c + $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ + -dynamiclib ${wl}-single_module conftest.c + if test -f libconftest.dylib; then + lt_cv_apple_cc_single_mod=yes + rm -rf libconftest.dylib* + fi + rm conftest.c + fi]) + AC_CACHE_CHECK([for -exported_symbols_list linker flag], + [lt_cv_ld_exported_symbols_list], + [lt_cv_ld_exported_symbols_list=no + save_LDFLAGS=$LDFLAGS + echo "_main" > conftest.sym + LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym" + AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])], + [lt_cv_ld_exported_symbols_list=yes], + [lt_cv_ld_exported_symbols_list=no]) + LDFLAGS="$save_LDFLAGS" + ]) + case $host_os in + rhapsody* | darwin1.[[0123]]) + _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;; + darwin1.*) + _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; + darwin*) + # if running on 10.5 or later, the deployment target defaults + # to the OS version, if on x86, and 10.4, the deployment + # target defaults to 10.4. Don't you love it? + case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in + 10.0,*86*-darwin8*|10.0,*-darwin[[91]]*) + _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; + 10.[[012]]*) + _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; + 10.*) + _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; + esac + ;; + esac + if test "$lt_cv_apple_cc_single_mod" = "yes"; then + _lt_dar_single_mod='$single_module' + fi + if test "$lt_cv_ld_exported_symbols_list" = "yes"; then + _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym' + else + _lt_dar_export_syms="~$NMEDIT -s \$output_objdir/\${libname}-symbols.expsym \${lib}" + fi + if test "$DSYMUTIL" != ":"; then + _lt_dsymutil="~$DSYMUTIL \$lib || :" + else + _lt_dsymutil= + fi + ;; + esac +]) + # _LT_AC_SYS_LIBPATH_AIX # ---------------------- # Links a minimal program and checks the executable @@ -618,7 +690,11 @@ *64-bit*) case $lt_cv_prog_gnu_ld in yes*) LD="${LD-ld} -m elf64_sparc" ;; - *) LD="${LD-ld} -64" ;; + *) + if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then + LD="${LD-ld} -64" + fi + ;; esac ;; esac @@ -711,7 +787,7 @@ $2=yes fi fi - $rm conftest* + $rm -r conftest* LDFLAGS="$save_LDFLAGS" ]) @@ -982,7 +1058,7 @@ AC_CHECK_FUNC([shl_load], [lt_cv_dlopen="shl_load"], [AC_CHECK_LIB([dld], [shl_load], - [lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-dld"], + [lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld"], [AC_CHECK_FUNC([dlopen], [lt_cv_dlopen="dlopen"], [AC_CHECK_LIB([dl], [dlopen], @@ -990,7 +1066,7 @@ [AC_CHECK_LIB([svld], [dlopen], [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"], [AC_CHECK_LIB([dld], [dld_link], - [lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-dld"]) + [lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld"]) ]) ]) ]) @@ -1307,7 +1383,7 @@ soname_spec='${libname}${release}${shared_ext}$major' ;; -aix4* | aix5*) +aix[[4-9]]*) version_type=linux need_lib_prefix=no need_version=no @@ -1830,6 +1906,13 @@ AC_MSG_RESULT([$dynamic_linker]) test "$dynamic_linker" = no && can_build_shared=no +AC_CACHE_VAL([lt_cv_sys_lib_search_path_spec], +[lt_cv_sys_lib_search_path_spec="$sys_lib_search_path_spec"]) +sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec" +AC_CACHE_VAL([lt_cv_sys_lib_dlsearch_path_spec], +[lt_cv_sys_lib_dlsearch_path_spec="$sys_lib_dlsearch_path_spec"]) +sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec" + variables_saved_for_relink="PATH $shlibpath_var $runpath_var" if test "$GCC" = yes; then variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" @@ -2329,7 +2412,7 @@ # whether `pass_all' will *always* work, you probably want this one. case $host_os in -aix4* | aix5*) +aix[[4-9]]*) lt_cv_deplibs_check_method=pass_all ;; @@ -2765,7 +2848,7 @@ fi ;; -aix4* | aix5*) +aix[[4-9]]*) if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then test "$enable_shared" = yes && enable_static=no fi @@ -2822,6 +2905,7 @@ _LT_AC_TAGVAR(predeps, $1)= _LT_AC_TAGVAR(postdeps, $1)= _LT_AC_TAGVAR(compiler_lib_search_path, $1)= +_LT_AC_TAGVAR(compiler_lib_search_dirs, $1)= # Source file extension for C++ test sources. ac_ext=cpp @@ -2931,7 +3015,7 @@ # FIXME: insert proper C++ library support _LT_AC_TAGVAR(ld_shlibs, $1)=no ;; - aix4* | aix5*) + aix[[4-9]]*) if test "$host_cpu" = ia64; then # On IA64, the linker does run time linking by default, so we don't # have to do anything special. @@ -2944,7 +3028,7 @@ # Test if we are trying to use run time linking or normal # AIX style linking. If -brtl is somewhere in LDFLAGS, we # need to do runtime linking. - case $host_os in aix4.[[23]]|aix4.[[23]].*|aix5*) + case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*) for ld_flag in $LDFLAGS; do case $ld_flag in *-brtl*) @@ -3090,52 +3174,24 @@ fi ;; darwin* | rhapsody*) - case $host_os in - rhapsody* | darwin1.[[012]]) - _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-undefined ${wl}suppress' - ;; - *) # Darwin 1.3 on - if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then - _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' - else - case ${MACOSX_DEPLOYMENT_TARGET} in - 10.[[012]]) - _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' - ;; - 10.*) - _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-undefined ${wl}dynamic_lookup' - ;; - esac - fi - ;; - esac _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no _LT_AC_TAGVAR(hardcode_direct, $1)=no _LT_AC_TAGVAR(hardcode_automatic, $1)=yes _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='' _LT_AC_TAGVAR(link_all_deplibs, $1)=yes - - if test "$GXX" = yes ; then - lt_int_apple_cc_single_mod=no + _LT_AC_TAGVAR(allow_undefined_flag, $1)="$_lt_dar_allow_undefined" + if test "$GXX" = yes ; then output_verbose_link_cmd='echo' - if $CC -dumpspecs 2>&1 | $EGREP 'single_module' >/dev/null ; then - lt_int_apple_cc_single_mod=yes + _LT_AC_TAGVAR(archive_cmds, $1)="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}" + _LT_AC_TAGVAR(module_cmds, $1)="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}" + _LT_AC_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}" + _LT_AC_TAGVAR(module_expsym_cmds, $1)="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}" + if test "$lt_cv_apple_cc_single_mod" != "yes"; then + _LT_AC_TAGVAR(archive_cmds, $1)="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}" + _LT_AC_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}" fi - if test "X$lt_int_apple_cc_single_mod" = Xyes ; then - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring' else - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -r -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring' - fi - _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags' - # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds - if test "X$lt_int_apple_cc_single_mod" = Xyes ; then - _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' - else - _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -r -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' - fi - _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' - else case $cc_basename in xlc*) output_verbose_link_cmd='echo' @@ -3385,7 +3441,7 @@ _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive' ;; - pgCC*) + pgCC* | pgcpp*) # Portland Group C++ compiler _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib' _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib' @@ -3820,7 +3876,8 @@ # compiler output when linking a shared library. # Parse the compiler output and extract the necessary # objects, libraries and library flags. -AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP],[ +AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP], +[AC_REQUIRE([LT_AC_PROG_SED])dnl dnl we can't use the lt_simple_compile_test_code here, dnl because it contains code intended for an executable, dnl not a library. It's possible we should let each @@ -3945,6 +4002,11 @@ $rm -f confest.$objext +_LT_AC_TAGVAR(compiler_lib_search_dirs, $1)= +if test -n "$_LT_AC_TAGVAR(compiler_lib_search_path, $1)"; then + _LT_AC_TAGVAR(compiler_lib_search_dirs, $1)=`echo " ${_LT_AC_TAGVAR(compiler_lib_search_path, $1)}" | ${SED} -e 's! -L! !g' -e 's!^ !!'` +fi + # PORTME: override above test on systems where it is broken ifelse([$1],[CXX], [case $host_os in @@ -4001,7 +4063,6 @@ ;; esac ]) - case " $_LT_AC_TAGVAR(postdeps, $1) " in *" -lc "*) _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no ;; esac @@ -4086,7 +4147,7 @@ postinstall_cmds='$RANLIB $lib' fi ;; -aix4* | aix5*) +aix[[4-9]]*) if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then test "$enable_shared" = yes && enable_static=no fi @@ -4263,6 +4324,7 @@ _LT_AC_TAGVAR(predeps, $1) \ _LT_AC_TAGVAR(postdeps, $1) \ _LT_AC_TAGVAR(compiler_lib_search_path, $1) \ + _LT_AC_TAGVAR(compiler_lib_search_dirs, $1) \ _LT_AC_TAGVAR(archive_cmds, $1) \ _LT_AC_TAGVAR(archive_expsym_cmds, $1) \ _LT_AC_TAGVAR(postinstall_cmds, $1) \ @@ -4325,7 +4387,7 @@ # Generated automatically by $PROGRAM (GNU $PACKAGE $VERSION$TIMESTAMP) # NOTE: Changes made to this file will be lost: look at ltmain.sh. # -# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 # Free Software Foundation, Inc. # # This file is part of GNU Libtool: @@ -4562,6 +4624,10 @@ # shared library. postdeps=$lt_[]_LT_AC_TAGVAR(postdeps, $1) +# The directories searched by this compiler when creating a shared +# library +compiler_lib_search_dirs=$lt_[]_LT_AC_TAGVAR(compiler_lib_search_dirs, $1) + # The library search path used internally by the compiler when linking # a shared library. compiler_lib_search_path=$lt_[]_LT_AC_TAGVAR(compiler_lib_search_path, $1) @@ -4911,7 +4977,7 @@ echo "$progname: failed program was:" >&AS_MESSAGE_LOG_FD cat conftest.$ac_ext >&5 fi - rm -f conftest* conftst* + rm -rf conftest* conftst* # Do not use the global_symbol_pipe unless it works. if test "$pipe_works" = yes; then @@ -4968,7 +5034,8 @@ # built for inclusion in a dll (and should export symbols for example). # Although the cygwin gcc ignores -fPIC, still need this for old-style # (--disable-auto-import) libraries - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT' + m4_if([$1], [GCJ], [], + [_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) ;; darwin* | rhapsody*) # PIC is the default on this platform @@ -5005,7 +5072,7 @@ esac else case $host_os in - aix4* | aix5*) + aix[[4-9]]*) # All AIX code is PIC. if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor @@ -5101,7 +5168,7 @@ _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static' ;; - pgCC*) + pgCC* | pgcpp*) # Portland Group C++ compiler. _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' @@ -5252,7 +5319,8 @@ # built for inclusion in a dll (and should export symbols for example). # Although the cygwin gcc ignores -fPIC, still need this for old-style # (--disable-auto-import) libraries - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT' + m4_if([$1], [GCJ], [], + [_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) ;; darwin* | rhapsody*) @@ -5322,7 +5390,8 @@ mingw* | cygwin* | pw32* | os2*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT' + m4_if([$1], [GCJ], [], + [_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) ;; hpux9* | hpux10* | hpux11*) @@ -5459,7 +5528,7 @@ # if test -n "$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)"; then AC_LIBTOOL_COMPILER_OPTION([if $compiler PIC flag $_LT_AC_TAGVAR(lt_prog_compiler_pic, $1) works], - _LT_AC_TAGVAR(lt_prog_compiler_pic_works, $1), + _LT_AC_TAGVAR(lt_cv_prog_compiler_pic_works, $1), [$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)ifelse([$1],[],[ -DPIC],[ifelse([$1],[CXX],[ -DPIC],[])])], [], [case $_LT_AC_TAGVAR(lt_prog_compiler_pic, $1) in "" | " "*) ;; @@ -5483,7 +5552,7 @@ # wl=$_LT_AC_TAGVAR(lt_prog_compiler_wl, $1) eval lt_tmp_static_flag=\"$_LT_AC_TAGVAR(lt_prog_compiler_static, $1)\" AC_LIBTOOL_LINKER_OPTION([if $compiler static flag $lt_tmp_static_flag works], - _LT_AC_TAGVAR(lt_prog_compiler_static_works, $1), + _LT_AC_TAGVAR(lt_cv_prog_compiler_static_works, $1), $lt_tmp_static_flag, [], [_LT_AC_TAGVAR(lt_prog_compiler_static, $1)=]) @@ -5499,7 +5568,7 @@ ifelse([$1],[CXX],[ _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' case $host_os in - aix4* | aix5*) + aix[[4-9]]*) # If we're using GNU nm, then we don't want the "-C" option. # -C means demangle to AIX nm, but means don't demangle with GNU nm if $NM -V 2>&1 | grep 'GNU' > /dev/null; then @@ -5518,6 +5587,7 @@ _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' ;; esac + _LT_AC_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'] ],[ runpath_var= _LT_AC_TAGVAR(allow_undefined_flag, $1)= @@ -5548,12 +5618,14 @@ # it will be wrapped by ` (' and `)$', so one must not match beginning or # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc', # as well as any symbol that contains `d'. - _LT_AC_TAGVAR(exclude_expsyms, $1)="_GLOBAL_OFFSET_TABLE_" + _LT_AC_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'] # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out # platforms (ab)use it in PIC code, but their linkers get confused if # the symbol is explicitly referenced. Since portable code cannot # rely on this symbol name, it's probably fine to never include it in # preloaded symbol tables. + # Exclude shared library initialization/finalization symbols. +dnl Note also adjust exclude_expsyms for C++ above. extract_expsyms_cmds= # Just being paranoid about ensuring that cc_basename is set. _LT_CC_BASENAME([$compiler]) @@ -5603,7 +5675,7 @@ # See if GNU ld supports shared libraries. case $host_os in - aix3* | aix4* | aix5*) + aix[[3-9]]*) # On AIX/PPC, the GNU linker is very broken if test "$host_cpu" != ia64; then _LT_AC_TAGVAR(ld_shlibs, $1)=no @@ -5822,7 +5894,7 @@ fi ;; - aix4* | aix5*) + aix[[4-9]]*) if test "$host_cpu" = ia64; then # On IA64, the linker does run time linking by default, so we don't # have to do anything special. @@ -5842,7 +5914,7 @@ # Test if we are trying to use run time linking or normal # AIX style linking. If -brtl is somewhere in LDFLAGS, we # need to do runtime linking. - case $host_os in aix4.[[23]]|aix4.[[23]].*|aix5*) + case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*) for ld_flag in $LDFLAGS; do if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then aix_use_runtimelinking=yes @@ -6002,11 +6074,10 @@ _LT_AC_TAGVAR(link_all_deplibs, $1)=yes if test "$GCC" = yes ; then output_verbose_link_cmd='echo' - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring' - _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags' - # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds - _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' - _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + _LT_AC_TAGVAR(archive_cmds, $1)="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}" + _LT_AC_TAGVAR(module_cmds, $1)="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}" + _LT_AC_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}" + _LT_AC_TAGVAR(module_expsym_cmds, $1)="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}" else case $cc_basename in xlc*) Modified: trunk/bus/Makefile.in =================================================================== --- trunk/bus/Makefile.in 2009-01-17 23:05:43 UTC (rev 805) +++ trunk/bus/Makefile.in 2009-01-17 23:18:46 UTC (rev 806) @@ -34,7 +34,6 @@ POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ -target_triplet = @target@ @DBUS_BUILD_TESTS_TRUE@TESTS = bus-test$(EXEEXT) \ @DBUS_BUILD_TESTS_TRUE@ bus-test-system$(EXEEXT) \ @DBUS_BUILD_TESTS_TRUE@ bus-test-launch-helper$(EXEEXT) @@ -281,6 +280,7 @@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DOXYGEN = @DOXYGEN@ +DSYMUTIL = @DSYMUTIL@ ECHO = @ECHO@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ @@ -316,6 +316,7 @@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ +NMEDIT = @NMEDIT@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ @@ -405,11 +406,8 @@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ -target = @target@ target_alias = @target_alias@ -target_cpu = @target_cpu@ -target_os = @target_os@ -target_vendor = @target_vendor@ +top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ configdir = $(sysconfdir)/dbus-1 Modified: trunk/bus/activation.c =================================================================== --- trunk/bus/activation.c 2009-01-17 23:05:43 UTC (rev 805) +++ trunk/bus/activation.c 2009-01-17 23:18:46 UTC (rev 806) @@ -679,7 +679,7 @@ DBusString value; int i; char **environment; - dbus_bool_t retval; + dbus_bool_t retval = FALSE; environment = _dbus_get_environment (); Modified: trunk/bus/bus.c =================================================================== --- trunk/bus/bus.c 2009-01-17 23:05:43 UTC (rev 805) +++ trunk/bus/bus.c 2009-01-17 23:18:46 UTC (rev 806) @@ -54,6 +54,8 @@ BusMatchmaker *matchmaker; BusLimits limits; unsigned int fork : 1; + unsigned int syslog : 1; + unsigned int keep_umask : 1; }; static dbus_int32_t server_data_slot = -1; @@ -384,6 +386,8 @@ } context->fork = bus_config_parser_get_fork (parser); + context->syslog = bus_config_parser_get_syslog (parser); + context->keep_umask = bus_config_parser_get_keep_umask (parser); _DBUS_ASSERT_ERROR_IS_CLEAR (error); retval = TRUE; @@ -708,7 +712,8 @@ if (!_dbus_become_daemon (context->pidfile ? &u : NULL, print_pid_pipe, - error)) + error, + context->keep_umask)) { _DBUS_ASSERT_ERROR_IS_SET (error); goto failed; @@ -736,6 +741,11 @@ if (print_pid_pipe && _dbus_pipe_is_valid (print_pid_pipe) && !_dbus_pipe_is_stdout_or_stderr (print_pid_pipe)) _dbus_pipe_close (print_pid_pipe, NULL); + + if (!bus_selinux_full_init ()) + { + _dbus_warn ("SELinux initialization failed\n"); + } if (!process_config_postinit (context, parser, error)) { @@ -766,11 +776,6 @@ #endif } - if (!bus_selinux_full_init ()) - { - _dbus_warn ("SELinux initialization failed\n"); - } - dbus_server_free_data_slot (&server_data_slot); return context; @@ -826,7 +831,10 @@ } ret = TRUE; + bus_context_log_info (context, "Reloaded configuration"); failed: + if (!ret) + bus_context_log_info (context, "Unable to reload configuration: %s", error->message); if (parser != NULL) bus_config_parser_unref (parser); return ret; @@ -1107,6 +1115,32 @@ return context->limits.reply_timeout; } +void +bus_context_log_info (BusContext *context, const char *msg, ...) +{ + va_list args; + + va_start (args, msg); + + if (context->syslog) + _dbus_log_info (msg, args); + + va_end (args); +} + +void +bus_context_log_security (BusContext *context, const char *msg, ...) +{ + va_list args; + + va_start (args, msg); + + if (context->syslog) + _dbus_log_security (msg, args); + + va_end (args); +} + /* * addressed_recipient is the recipient specified in the message. * @@ -1129,21 +1163,45 @@ DBusMessage *message, DBusError *error) { + const char *dest; BusClientPolicy *sender_policy; BusClientPolicy *recipient_policy; + dbus_int32_t toggles; + dbus_bool_t log; int type; dbus_bool_t requested_reply; + const char *sender_name; + const char *sender_loginfo; + const char *proposed_recipient_loginfo; type = dbus_message_get_type (message); + dest = dbus_message_get_destination (message); /* dispatch.c was supposed to ensure these invariants */ - _dbus_assert (dbus_message_get_destination (message) != NULL || + _dbus_assert (dest != NULL || type == DBUS_MESSAGE_TYPE_SIGNAL || (sender == NULL && !bus_connection_is_active (proposed_recipient))); _dbus_assert (type == DBUS_MESSAGE_TYPE_SIGNAL || addressed_recipient != NULL || - strcmp (dbus_message_get_destination (message), DBUS_SERVICE_DBUS) == 0); + strcmp (dest, DBUS_SERVICE_DBUS) == 0); + + /* Used in logging below */ + if (sender != NULL) + { + sender_name = bus_connection_get_name (sender); + sender_loginfo = bus_connection_get_loginfo (sender); + } + else + { + sender_name = NULL; + sender_loginfo = "(bus)"; + } + if (proposed_recipient != NULL) + proposed_recipient_loginfo = bus_connection_get_loginfo (proposed_recipient); + else + proposed_recipient_loginfo = "bus"; + switch (type) { case DBUS_MESSAGE_TYPE_METHOD_CALL: @@ -1166,10 +1224,6 @@ if (sender != NULL) { - const char *dest; - - dest = dbus_message_get_destination (message); - /* First verify the SELinux access controls. If allowed then * go on with the standard checks. */ @@ -1185,8 +1239,9 @@ dbus_set_error (error, DBUS_ERROR_ACCESS_DENIED, "An SELinux policy prevents this sender " "from sending this message to this recipient " - "(rejected message had interface \"%s\" " + "(rejected message had sender \"%s\" interface \"%s\" " "member \"%s\" error name \"%s\" destination \"%s\")", + sender_name ? sender_name : "(unset)", dbus_message_get_interface (message) ? dbus_message_get_interface (message) : "(unset)", dbus_message_get_member (message) ? @@ -1299,57 +1354,112 @@ (proposed_recipient != NULL && sender == NULL && recipient_policy == NULL) || (proposed_recipient == NULL && recipient_policy == NULL)); + log = FALSE; if (sender_policy && !bus_client_policy_check_can_send (sender_policy, context->registry, requested_reply, proposed_recipient, - message)) + message, &toggles, &log)) { - const char *dest; + const char *msg = "Rejected send message, %d matched rules; " + "type=\"%s\", sender=\"%s\" (%s) interface=\"%s\" member=\"%s\" error name=\"%s\" requested_reply=%d destination=\"%s\" (%s))"; - dest = dbus_message_get_destination (message); - dbus_set_error (error, DBUS_ERROR_ACCESS_DENIED, - "A security policy in place prevents this sender " - "from sending this message to this recipient, " - "see message bus configuration file (rejected message " - "had interface \"%s\" member \"%s\" error name \"%s\" destination \"%s\")", + dbus_set_error (error, DBUS_ERROR_ACCESS_DENIED, msg, + toggles, + dbus_message_type_to_string (dbus_message_get_type (message)), + sender_name ? sender_name : "(unset)", + sender_loginfo, dbus_message_get_interface (message) ? dbus_message_get_interface (message) : "(unset)", dbus_message_get_member (message) ? dbus_message_get_member (message) : "(unset)", dbus_message_get_error_name (message) ? dbus_message_get_error_name (message) : "(unset)", - dest ? dest : DBUS_SERVICE_DBUS); + requested_reply, + dest ? dest : DBUS_SERVICE_DBUS, + proposed_recipient_loginfo); + /* Needs to be duplicated to avoid calling malloc and having to handle OOM */ + if (addressed_recipient == proposed_recipient) + bus_context_log_security (context, msg, + toggles, + dbus_message_type_to_string (dbus_message_get_type (message)), + sender_name ? sender_name : "(unset)", + sender_loginfo, + dbus_message_get_interface (message) ? + dbus_message_get_interface (message) : "(unset)", + dbus_message_get_member (message) ? + dbus_message_get_member (message) : "(unset)", + dbus_message_get_error_name (message) ? + dbus_message_get_error_name (message) : "(unset)", + requested_reply, + dest ? dest : DBUS_SERVICE_DBUS, + proposed_recipient_loginfo); _dbus_verbose ("security policy disallowing message due to sender policy\n"); return FALSE; } + if (log) + bus_context_log_security (context, + "Would reject message, %d matched rules; " + "type=\"%s\", sender=\"%s\" (%s) interface=\"%s\" member=\"%s\" error name=\"%s\" requested_reply=%d destination=\"%s\" (%s))", + toggles, + dbus_message_type_to_string (dbus_message_get_type (message)), + sender_name ? sender_name : "(unset)", + sender_loginfo, + dbus_message_get_interface (message) ? + dbus_message_get_interface (message) : "(unset)", + dbus_message_get_member (message) ? + dbus_message_get_member (message) : "(unset)", + dbus_message_get_error_name (message) ? + dbus_message_get_error_name (message) : "(unset)", + requested_reply, + dest ? dest : DBUS_SERVICE_DBUS, + proposed_recipient_loginfo); + if (recipient_policy && !bus_client_policy_check_can_receive (recipient_policy, context->registry, requested_reply, sender, addressed_recipient, proposed_recipient, - message)) + message, &toggles)) { - const char *dest; + const char *msg = "Rejected receive message, %d matched rules; " + "type=\"%s\" sender=\"%s\" (%s) interface=\"%s\" member=\"%s\" error name=\"%s\" reply serial=%u requested_reply=%d destination=\"%s\" (%s))"; - dest = dbus_message_get_destination (message); - dbus_set_error (error, DBUS_ERROR_ACCESS_DENIED, - "A security policy in place prevents this recipient " - "from receiving this message from this sender, " - "see message bus configuration file (rejected message " - "had interface \"%s\" member \"%s\" error name \"%s\" destination \"%s\" reply serial %u requested_reply=%d)", + dbus_set_error (error, DBUS_ERROR_ACCESS_DENIED, msg, + toggles, + dbus_message_type_to_string (dbus_message_get_type (message)), + sender_name ? sender_name : "(unset)", + sender_loginfo, dbus_message_get_interface (message) ? dbus_message_get_interface (message) : "(unset)", dbus_message_get_member (message) ? dbus_message_get_member (message) : "(unset)", dbus_message_get_error_name (message) ? dbus_message_get_error_name (message) : "(unset)", + dbus_message_get_reply_serial (message), + requested_reply, dest ? dest : DBUS_SERVICE_DBUS, - dbus_message_get_reply_serial (message), - requested_reply); + proposed_recipient_loginfo); + /* Needs to be duplicated to avoid calling malloc and having to handle OOM */ + if (addressed_recipient == proposed_recipient) + bus_context_log_security (context, msg, + toggles, + dbus_message_type_to_string (dbus_message_get_type (message)), + sender_name ? sender_name : "(unset)", + sender_loginfo, + dbus_message_get_interface (message) ? + dbus_message_get_interface (message) : "(unset)", + dbus_message_get_member (message) ? + dbus_message_get_member (message) : "(unset)", + dbus_message_get_error_name (message) ? + dbus_message_get_error_name (message) : "(unset)", + dbus_message_get_reply_serial (message), + requested_reply, + dest ? dest : DBUS_SERVICE_DBUS, + proposed_recipient_loginfo); _dbus_verbose ("security policy disallowing message due to recipient policy\n"); return FALSE; } @@ -1359,9 +1469,6 @@ dbus_connection_get_outgoing_size (proposed_recipient) > context->limits.max_outgoing_bytes) { - const char *dest; - - dest = dbus_message_get_destination (message); dbus_set_error (error, DBUS_ERROR_LIMITS_EXCEEDED, "The destination service \"%s\" has a full message queue", dest ? dest : (proposed_recipient ? Modified: trunk/bus/bus.h =================================================================== --- trunk/bus/bus.h 2009-01-17 23:05:43 UTC (rev 805) +++ trunk/bus/bus.h 2009-01-17 23:18:46 UTC (rev 806) @@ -107,6 +107,12 @@ int bus_context_get_max_match_rules_per_connection (BusContext *context); int bus_context_get_max_replies_per_connection (BusContext *context); int bus_context_get_reply_timeout (BusContext *context); +void bus_context_log_info (BusContext *context, + const char *msg, + ...); +void bus_context_log_security (BusContext *context, + const char *msg, + ...); dbus_bool_t bus_context_check_security_policy (BusContext *context, BusTransaction *transaction, DBusConnection *sender, Modified: trunk/bus/config-parser-common.c =================================================================== --- trunk/bus/config-parser-common.c 2009-01-17 23:05:43 UTC (rev 805) +++ trunk/bus/config-parser-common.c 2009-01-17 23:18:46 UTC (rev 806) @@ -114,6 +114,14 @@ { return ELEMENT_ASSOCIATE; } + else if (strcmp (name, "syslog") == 0) + { + return ELEMENT_SYSLOG; + } + else if (strcmp (name, "keep_umask") == 0) + { + return ELEMENT_KEEP_UMASK; + } return ELEMENT_NONE; } @@ -162,6 +170,10 @@ return "selinux"; case ELEMENT_ASSOCIATE: return "associate"; + case ELEMENT_SYSLOG: + return "syslog"; + case ELEMENT_KEEP_UMASK: + return "keep_umask"; } _dbus_assert_not_reached ("bad element type"); Modified: trunk/bus/config-parser-common.h =================================================================== --- trunk/bus/config-parser-common.h 2009-01-17 23:05:43 UTC (rev 805) +++ trunk/bus/config-parser-common.h 2009-01-17 23:18:46 UTC (rev 806) @@ -47,7 +47,9 @@ ELEMENT_SELINUX, ELEMENT_ASSOCIATE, ELEMENT_STANDARD_SESSION_SERVICEDIRS, - ELEMENT_STANDARD_SYSTEM_SERVICEDIRS + ELEMENT_STANDARD_SYSTEM_SERVICEDIRS, + ELEMENT_SYSLOG, + ELEMENT_KEEP_UMASK } ElementType; ElementType bus_config_parser_element_name_to_type (const char *element_name); Modified: trunk/bus/config-parser.c =================================================================== --- trunk/bus/config-parser.c 2009-01-17 23:05:43 UTC (rev 805) +++ trunk/bus/config-parser.c 2009-01-17 23:18:46 UTC (rev 806) @@ -111,6 +111,9 @@ unsigned int fork : 1; /**< TRUE to fork into daemon mode */ + unsigned int syslog : 1; /**< TRUE to enable syslog */ + unsigned int keep_umask : 1; /**< TRUE to keep original umask when forking */ + unsigned int is_toplevel : 1; /**< FALSE if we are a sub-config-file inside another one */ }; @@ -306,6 +309,9 @@ if (included->fork) parser->fork = TRUE; + if (included->keep_umask) + parser->keep_umask = TRUE; + if (included->pidfile != NULL) { dbus_free (parser->pidfile); @@ -698,6 +704,36 @@ return TRUE; } + else if (element_type == ELEMENT_SYSLOG) + { + if (!check_no_attributes (parser, "syslog", attribute_names, attribute_values, error)) + return FALSE; + + if (push_element (parser, ELEMENT_SYSLOG) == NULL) + { + BUS_SET_OOM (error); + return FALSE; + } + + parser->syslog = TRUE; + + return TRUE; + } + else if (element_type == ELEMENT_KEEP_UMASK) + { + if (!check_no_attributes (parser, "keep_umask", attribute_names, attribute_values, error)) + return FALSE; + + if (push_element (parser, ELEMENT_KEEP_UMASK) == NULL) + { + BUS_SET_OOM (error); + return FALSE; + } + + parser->keep_umask = TRUE; + + return TRUE; + } else if (element_type == ELEMENT_PIDFILE) { if (!check_no_attributes (parser, "pidfile", attribute_names, attribute_values, error)) @@ -1073,6 +1109,7 @@ dbus_bool_t allow, DBusError *error) { + const char *log; const char *send_interface; const char *send_member; const char *send_error; @@ -1116,6 +1153,7 @@ "own", &own, "user", &user, "group", &group, + "log", &log, NULL)) return FALSE; @@ -1320,6 +1358,9 @@ if (eavesdrop) rule->d.send.eavesdrop = (strcmp (eavesdrop, "true") == 0); + if (log) + rule->d.send.log = (strcmp (log, "true") == 0); + if (send_requested_reply) rule->d.send.requested_reply = (strcmp (send_requested_reply, "true") == 0); @@ -1947,6 +1988,8 @@ case ELEMENT_ALLOW: case ELEMENT_DENY: case ELEMENT_FORK: + case ELEMENT_SYSLOG: + case ELEMENT_KEEP_UMASK: case ELEMENT_SELINUX: case ELEMENT_ASSOCIATE: case ELEMENT_STANDARD_SESSION_SERVICEDIRS: @@ -2232,6 +2275,8 @@ case ELEMENT_ALLOW: case ELEMENT_DENY: case ELEMENT_FORK: + case ELEMENT_SYSLOG: + case ELEMENT_KEEP_UMASK: case ELEMENT_STANDARD_SESSION_SERVICEDIRS: case ELEMENT_STANDARD_SYSTEM_SERVICEDIRS: case ELEMENT_SELINUX: @@ -2554,6 +2599,18 @@ return parser->fork; } +dbus_bool_t +bus_config_parser_get_syslog (BusConfigParser *parser) +{ + return parser->syslog; +} + +dbus_bool_t +bus_config_parser_get_keep_umask (BusConfigParser *parser) +{ + return parser->keep_umask; +} + const char * bus_config_parser_get_pidfile (BusConfigParser *parser) { @@ -2947,6 +3004,9 @@ if (! bools_equal (a->fork, b->fork)) return FALSE; + if (! bools_equal (a->keep_umask, b->keep_umask)) + return FALSE; + if (! bools_equal (a->is_toplevel, b->is_toplevel)) return FALSE; Modified: trunk/bus/config-parser.h =================================================================== --- trunk/bus/config-parser.h 2009-01-17 23:05:43 UTC (rev 805) +++ trunk/bus/config-parser.h 2009-01-17 23:18:46 UTC (rev 806) @@ -65,6 +65,9 @@ DBusList** bus_config_parser_get_addresses (BusConfigParser *parser); DBusList** bus_config_parser_get_mechanisms (BusConfigParser *parser); dbus_bool_t bus_config_parser_get_fork (BusConfigParser *parser); +dbus_bool_t bus_config_parser_get_allow_anonymous (BusConfigParser *parser); +dbus_bool_t bus_config_parser_get_syslog (BusConfigParser *parser); +dbus_bool_t bus_config_parser_get_keep_umask (BusConfigParser *parser); const char* bus_config_parser_get_pidfile (BusConfigParser *parser); const char* bus_config_parser_get_servicehelper (BusConfigParser *parser); DBusList** bus_config_parser_get_service_dirs (BusConfigParser *parser); Modified: trunk/bus/connection.c =================================================================== --- trunk/bus/connection.c 2009-01-17 23:05:43 UTC (rev 805) +++ trunk/bus/connection.c 2009-01-17 23:18:46 UTC (rev 806) @@ -32,6 +32,9 @@ #include <dbus/dbus-hash.h> #include <dbus/dbus-timeout.h> +/* Trim executed commands to this length; we want to keep logs readable */ +#define MAX_LOG_COMMAND_LEN 50 + static void bus_connection_remove_transactions (DBusConnection *connection); typedef struct @@ -76,6 +79,7 @@ DBusPreallocatedSend *oom_preallocated; BusClientPolicy *policy; + char *cached_loginfo_string; BusSELinuxID *selinux_id; long connection_tv_sec; /**< Time when we connected (seconds component) */ @@ -406,6 +410,8 @@ if (d->selinux_id) bus_selinux_id_unref (d->selinux_id); + dbus_free (d->cached_loginfo_string); + dbus_free (d->name); dbus_free (d); @@ -537,13 +543,73 @@ } } +/* Used for logging */ +static dbus_bool_t +cache_peer_loginfo_string (BusConnectionData *d, + DBusConnection *connection) +{ + DBusString loginfo_buf; + unsigned long uid; + unsigned long pid; + char *windows_sid; + dbus_bool_t prev_added; + + if (!_dbus_string_init (&loginfo_buf)) + return FALSE; + + prev_added = FALSE; + if (dbus_connection_get_unix_user (connection, &uid)) + { + if (!_dbus_string_append_printf (&loginfo_buf, "uid=%ld", uid)) + goto oom; + else + prev_added = TRUE; + } + + if (dbus_connection_get_unix_process_id (connection, &pid)) + { + if (prev_added) + { + if (!_dbus_string_append_byte (&loginfo_buf, ' ')) + goto oom; + } + if (!_dbus_string_append_printf (&loginfo_buf, "pid=%ld comm=\"", pid)) + goto oom; + /* Ignore errors here */ + if (_dbus_command_for_pid (pid, &loginfo_buf, MAX_LOG_COMMAND_LEN, NULL)) + { + if (!_dbus_string_append_byte (&loginfo_buf, '"')) + goto oom; + } + } + + if (dbus_connection_get_windows_user (connection, &windows_sid)) + { + if (!_dbus_string_append_printf (&loginfo_buf, "sid=\"%s\" ", windows_sid)) + goto oom; + dbus_free (windows_sid); + } + + if (!_dbus_string_steal_data (&loginfo_buf, &(d->cached_loginfo_string))) + goto oom; + + _dbus_string_free (&loginfo_buf); + + return TRUE; +oom: + _dbus_string_free (&loginfo_buf); + return FALSE; +} + dbus_bool_t bus_connections_setup_connection (BusConnections *connections, DBusConnection *connection) { + BusConnectionData *d; dbus_bool_t retval; DBusError error; + d = dbus_new0 (BusConnectionData, 1); @@ -583,7 +649,7 @@ dbus_error_free (&error); goto out; } - + if (!dbus_connection_set_watch_functions (connection, add_connection_watch, remove_connection_watch, @@ -842,6 +908,18 @@ return FALSE; } +const char * +bus_connection_get_loginfo (DBusConnection *connection) +{ + BusConnectionData *d; + + d = BUS_CONNECTION_DATA (connection); + + if (!bus_connection_is_active (connection)) + return "inactive"; + return d->cached_loginfo_string; +} + BusClientPolicy* bus_connection_get_policy (DBusConnection *connection) { @@ -1302,16 +1380,15 @@ { if (!adjust_connections_for_uid (d->connections, uid, 1)) - { - BUS_SET_OOM (error); - dbus_free (d->name); - d->name = NULL; - bus_client_policy_unref (d->policy); - d->policy = NULL; - return FALSE; - } + goto fail; } - + + /* Create and cache a string which holds information about the + * peer process; used for logging purposes. + */ + if (!cache_peer_loginfo_string (d, connection)) + goto fail; + /* Now the connection is active, move it between lists */ _dbus_list_unlink (&d->connections->incomplete, d->link_in_connection_list); @@ -1329,6 +1406,14 @@ _dbus_assert (bus_connection_is_active (connection)); return TRUE; +fail: + BUS_SET_OOM (error); + dbus_free (d->name); + d->name = NULL; + if (d->policy) + bus_client_policy_unref (d->policy); + d->policy = NULL; + return FALSE; } const char * Modified: trunk/bus/connection.h =================================================================== --- trunk/bus/connection.h 2009-01-17 23:05:43 UTC (rev 805) +++ trunk/bus/connection.h 2009-01-17 23:18:46 UTC (rev 806) @@ -50,6 +50,7 @@ BusRegistry* bus_connection_get_registry (DBusConnection *connection); BusActivation* bus_connection_get_activation (DBusConnection *connection); BusMatchmaker* bus_connection_get_matchmaker (DBusConnection *connection); +const char * bus_connection_get_loginfo (DBusConnection *connection); BusSELinuxID* bus_connection_get_selinux_id (DBusConnection *connection); dbus_bool_t bus_connections_check_limits (BusConnections *connections, DBusConnection *requesting_completion, Modified: trunk/bus/dbus-daemon.1 =================================================================== --- trunk/bus/dbus-daemon.1 2009-01-17 23:05:43 UTC (rev 805) +++ trunk/bus/dbus-daemon.1 2009-01-17 23:18:46 UTC (rev 806) @@ -1,6 +1,6 @@ .\" .\" dbus-daemon manual page. -.\" Copyright (C) 2003 Red Hat, Inc. +.\" Copyright (C) 2003,2008 Red Hat, Inc. .\" .TH dbus-daemon 1 .SH NAME @@ -214,6 +214,13 @@ rather than the \-\-fork command line option. .TP +.I "<keep_umask>" + +.PP +If present, the bus daemon keeps its original umask when forking. +This may be useful to avoid affecting the behavior of child processes. + +.TP .I "<listen>" .PP @@ -410,15 +417,28 @@ and prevent unexpected traffic. .PP -The <policy> element has one of three attributes: +Currently, the system bus has a default-deny policy for sending method calls +and owning bus names. Everything else, in particular reply messages, receive +checks, and signals has a default allow policy. + +.PP +In general, it is best to keep system services as small, targeted programs which +run in their own process and provide a single bus name. Then, all that is needed +is an <allow> rule for the "own" permission to let the process claim the bus +name, and a "send_destination" rule to allow traffic from some or all uids to +your service. + +.PP +The <policy> element has one of four attributes: +daemon.1.in .nf context="(default|mandatory)" + at_console="(true|false)" user="username or userid" group="group name or gid" .fi .PP - Policies are applied to a connection as follows: .nf - all context="default" policies are applied @@ -426,6 +446,8 @@ in undefined order - all user="connection's auth user" policies are applied in undefined order + - all at_console="true" policies are applied + - all at_console="false" policies are applied - all context="mandatory" policies are applied .fi @@ -566,7 +588,11 @@ .PP Be careful with send_interface/receive_interface, because the -interface field in messages is optional. +interface field in messages is optional. In particular, do NOT +specify <deny send_interface="org.foo.Bar"/>! This will cause +no-interface messages to be blocked for all services, which is +almost certainly not what you intended. Always use rules of +the form: <deny send_interface="org.foo.Bar" send_destination="org.foo.Service"/> .TP .I "<selinux>" Property changes on: trunk/bus/dbus-daemon.1 ___________________________________________________________________ Added: svn:eol-style + native Modified: trunk/bus/dbus-daemon.1.in =================================================================== --- trunk/bus/dbus-daemon.1.in 2009-01-17 23:05:43 UTC (rev 805) +++ trunk/bus/dbus-daemon.1.in 2009-01-17 23:18:46 UTC (rev 806) @@ -1,6 +1,6 @@ .\" .\" dbus-daemon manual page. -.\" Copyright (C) 2003 Red Hat, Inc. +.\" Copyright (C) 2003,2008 Red Hat, Inc. .\" .TH dbus-daemon 1 .SH NAME @@ -214,6 +214,13 @@ rather than the \-\-fork command line option. .TP +.I "<keep_umask>" + +.PP +If present, the bus daemon keeps its original umask when forking. +This may be useful to avoid affecting the behavior of child processes. + +.TP .I "<listen>" .PP @@ -410,15 +417,28 @@ and prevent unexpected traffic. .PP -The <policy> element has one of three attributes: +Currently, the system bus has a default-deny policy for sending method calls +and owning bus names. Everything else, in particular reply messages, receive +checks, and signals has a default allow policy. + +.PP +In general, it is best to keep system services as small, targeted programs which +run in their own process and provide a single bus name. Then, all that is needed +is an <allow> rule for the "own" permission to let the process claim the bus +name, and a "send_destination" rule to allow traffic from some or all uids to +your service. + +.PP +The <policy> element has one of four attributes: +daemon.1.in .nf context="(default|mandatory)" + at_console="(true|false)" user="username or userid" group="group name or gid" .fi .PP - Policies are applied to a connection as follows: .nf - all context="default" policies are applied @@ -426,6 +446,8 @@ in undefined order - all user="connection's auth user" policies are applied in undefined order + - all at_console="true" policies are applied + - all at_console="false" policies are applied - all context="mandatory" policies are applied .fi @@ -566,7 +588,11 @@ .PP Be careful with send_interface/receive_interface, because the -interface field in messages is optional. +interface field in messages is optional. In particular, do NOT +specify <deny send_interface="org.foo.Bar"/>! This will cause +no-interface messages to be blocked for all services, which is +almost certainly not what you intended. Always use rules of +the form: <deny send_interface="org.foo.Bar" send_destination="org.foo.Service"/> .TP .I "<selinux>" Modified: trunk/bus/driver.c =================================================================== --- trunk/bus/driver.c 2009-01-17 23:05:43 UTC (rev 805) +++ trunk/bus/driver.c 2009-01-17 23:18:46 UTC (rev 806) @@ -1429,7 +1429,7 @@ BusService *serv; DBusConnection *conn; DBusMessage *reply; - char *data = NULL; + void *data = NULL; dbus_uint32_t data_size; _DBUS_ASSERT_ERROR_IS_CLEAR (error); Modified: trunk/bus/main.c =================================================================== --- trunk/bus/main.c 2009-01-1... [truncated message content] |
From: <che...@us...> - 2009-01-17 23:05:51
|
Revision: 805 http://windbus.svn.sourceforge.net/windbus/?rev=805&view=rev Author: chehrlic Date: 2009-01-17 23:05:43 +0000 (Sat, 17 Jan 2009) Log Message: ----------- update to 1.2.12 Modified Paths: -------------- branches/import/HACKING branches/import/Makefile.in branches/import/aclocal.m4 branches/import/bus/Makefile.in branches/import/bus/activation.c branches/import/bus/bus.c branches/import/bus/bus.h branches/import/bus/config-parser-common.c branches/import/bus/config-parser-common.h branches/import/bus/config-parser.c branches/import/bus/config-parser.h branches/import/bus/connection.c branches/import/bus/connection.h branches/import/bus/dbus-daemon.1 branches/import/bus/dbus-daemon.1.in branches/import/bus/driver.c branches/import/bus/main.c branches/import/bus/policy.c branches/import/bus/policy.h branches/import/bus/session.conf.in branches/import/bus/system.conf.in branches/import/config.guess branches/import/config.h.in branches/import/config.sub branches/import/configure branches/import/configure.in branches/import/dbus/Makefile.in branches/import/dbus/dbus-arch-deps.h branches/import/dbus/dbus-marshal-basic.c branches/import/dbus/dbus-marshal-validate.c branches/import/dbus/dbus-spawn.c branches/import/dbus/dbus-sysdeps-unix.c branches/import/dbus/dbus-sysdeps-util-unix.c branches/import/dbus/dbus-sysdeps.c branches/import/dbus/dbus-sysdeps.h branches/import/doc/Makefile.in branches/import/doc/busconfig.dtd branches/import/ltmain.sh branches/import/test/Makefile.in branches/import/test/data/valid-config-files/session.conf branches/import/test/data/valid-config-files/system.conf branches/import/test/name-test/Makefile.am branches/import/test/name-test/Makefile.in branches/import/test/name-test/run-with-tmp-session-bus.conf branches/import/tools/Makefile.in branches/import/tools/dbus-launch.c branches/import/tools/dbus-print-message.c branches/import/tools/dbus-send.c branches/import/tools/run-with-tmp-session-bus.sh Added Paths: ----------- branches/import/test/name-test/run-test-systemserver.sh branches/import/test/name-test/test-wait-for-echo.py branches/import/test/name-test/tmp-session-like-system.conf Property Changed: ---------------- branches/import/bus/dbus-daemon.1 branches/import/config.guess branches/import/test/data/valid-config-files/session.conf branches/import/test/data/valid-config-files/system.conf branches/import/test/name-test/run-with-tmp-session-bus.conf Modified: branches/import/HACKING =================================================================== --- branches/import/HACKING 2009-01-06 13:13:30 UTC (rev 804) +++ branches/import/HACKING 2009-01-17 23:05:43 UTC (rev 805) @@ -237,6 +237,5 @@ The reviewer group that can approve patches: Havoc Pennington, Michael Meeks, Alex Larsson, Zack Rusin, Joe Shaw, Mikael Hallendal, Richard Hult, Owen Fraser-Green, Olivier Andrieu, Colin Walters, Thiago -Macieira, John Palmieri. +Macieira, John Palmieri, Scott James Remnant. - Modified: branches/import/Makefile.in =================================================================== --- branches/import/Makefile.in 2009-01-06 13:13:30 UTC (rev 804) +++ branches/import/Makefile.in 2009-01-17 23:05:43 UTC (rev 805) @@ -32,7 +32,6 @@ POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ -target_triplet = @target@ subdir = . DIST_COMMON = README $(am__configure_deps) $(srcdir)/Doxyfile.in \ $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ @@ -167,6 +166,7 @@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DOXYGEN = @DOXYGEN@ +DSYMUTIL = @DSYMUTIL@ ECHO = @ECHO@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ @@ -202,6 +202,7 @@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ +NMEDIT = @NMEDIT@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ @@ -291,11 +292,8 @@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ -target = @target@ target_alias = @target_alias@ -target_cpu = @target_cpu@ -target_os = @target_os@ -target_vendor = @target_vendor@ +top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ SUBDIRS = dbus bus doc tools test Modified: branches/import/aclocal.m4 =================================================================== --- branches/import/aclocal.m4 2009-01-06 13:13:30 UTC (rev 804) +++ branches/import/aclocal.m4 2009-01-17 23:05:43 UTC (rev 805) @@ -13,15 +13,15 @@ m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl -m4_if(AC_AUTOCONF_VERSION, [2.61],, -[m4_warning([this file was generated for autoconf 2.61. +m4_if(AC_AUTOCONF_VERSION, [2.63],, +[m4_warning([this file was generated for autoconf 2.63. You have another version of autoconf. It may work, but is not guaranteed to. If you have problems, you may need to regenerate the build system entirely. To do so, use the procedure documented by the package, typically `autoreconf'.])]) # libtool.m4 - Configure libtool for the host system. -*-Autoconf-*- -# serial 51 AC_PROG_LIBTOOL +# serial 52 AC_PROG_LIBTOOL # AC_PROVIDE_IFELSE(MACRO-NAME, IF-PROVIDED, IF-NOT-PROVIDED) @@ -109,7 +109,6 @@ AC_REQUIRE([AC_OBJEXT])dnl AC_REQUIRE([AC_EXEEXT])dnl dnl - AC_LIBTOOL_SYS_MAX_CMD_LEN AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE AC_LIBTOOL_OBJDIR @@ -211,6 +210,8 @@ ;; esac +_LT_REQUIRED_DARWIN_CHECKS + AC_PROVIDE_IFELSE([AC_LIBTOOL_DLOPEN], enable_dlopen=yes, enable_dlopen=no) AC_PROVIDE_IFELSE([AC_LIBTOOL_WIN32_DLL], enable_win32_dll=yes, enable_win32_dll=no) @@ -290,10 +291,81 @@ echo "$lt_simple_link_test_code" >conftest.$ac_ext eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_linker_boilerplate=`cat conftest.err` -$rm conftest* +$rm -r conftest* ])# _LT_LINKER_BOILERPLATE +# _LT_REQUIRED_DARWIN_CHECKS +# -------------------------- +# Check for some things on darwin +AC_DEFUN([_LT_REQUIRED_DARWIN_CHECKS],[ + case $host_os in + rhapsody* | darwin*) + AC_CHECK_TOOL([DSYMUTIL], [dsymutil], [:]) + AC_CHECK_TOOL([NMEDIT], [nmedit], [:]) + AC_CACHE_CHECK([for -single_module linker flag],[lt_cv_apple_cc_single_mod], + [lt_cv_apple_cc_single_mod=no + if test -z "${LT_MULTI_MODULE}"; then + # By default we will add the -single_module flag. You can override + # by either setting the environment variable LT_MULTI_MODULE + # non-empty at configure time, or by adding -multi_module to the + # link flags. + echo "int foo(void){return 1;}" > conftest.c + $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ + -dynamiclib ${wl}-single_module conftest.c + if test -f libconftest.dylib; then + lt_cv_apple_cc_single_mod=yes + rm -rf libconftest.dylib* + fi + rm conftest.c + fi]) + AC_CACHE_CHECK([for -exported_symbols_list linker flag], + [lt_cv_ld_exported_symbols_list], + [lt_cv_ld_exported_symbols_list=no + save_LDFLAGS=$LDFLAGS + echo "_main" > conftest.sym + LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym" + AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])], + [lt_cv_ld_exported_symbols_list=yes], + [lt_cv_ld_exported_symbols_list=no]) + LDFLAGS="$save_LDFLAGS" + ]) + case $host_os in + rhapsody* | darwin1.[[0123]]) + _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;; + darwin1.*) + _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; + darwin*) + # if running on 10.5 or later, the deployment target defaults + # to the OS version, if on x86, and 10.4, the deployment + # target defaults to 10.4. Don't you love it? + case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in + 10.0,*86*-darwin8*|10.0,*-darwin[[91]]*) + _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; + 10.[[012]]*) + _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; + 10.*) + _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; + esac + ;; + esac + if test "$lt_cv_apple_cc_single_mod" = "yes"; then + _lt_dar_single_mod='$single_module' + fi + if test "$lt_cv_ld_exported_symbols_list" = "yes"; then + _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym' + else + _lt_dar_export_syms="~$NMEDIT -s \$output_objdir/\${libname}-symbols.expsym \${lib}" + fi + if test "$DSYMUTIL" != ":"; then + _lt_dsymutil="~$DSYMUTIL \$lib || :" + else + _lt_dsymutil= + fi + ;; + esac +]) + # _LT_AC_SYS_LIBPATH_AIX # ---------------------- # Links a minimal program and checks the executable @@ -618,7 +690,11 @@ *64-bit*) case $lt_cv_prog_gnu_ld in yes*) LD="${LD-ld} -m elf64_sparc" ;; - *) LD="${LD-ld} -64" ;; + *) + if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then + LD="${LD-ld} -64" + fi + ;; esac ;; esac @@ -711,7 +787,7 @@ $2=yes fi fi - $rm conftest* + $rm -r conftest* LDFLAGS="$save_LDFLAGS" ]) @@ -982,7 +1058,7 @@ AC_CHECK_FUNC([shl_load], [lt_cv_dlopen="shl_load"], [AC_CHECK_LIB([dld], [shl_load], - [lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-dld"], + [lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld"], [AC_CHECK_FUNC([dlopen], [lt_cv_dlopen="dlopen"], [AC_CHECK_LIB([dl], [dlopen], @@ -990,7 +1066,7 @@ [AC_CHECK_LIB([svld], [dlopen], [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"], [AC_CHECK_LIB([dld], [dld_link], - [lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-dld"]) + [lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld"]) ]) ]) ]) @@ -1307,7 +1383,7 @@ soname_spec='${libname}${release}${shared_ext}$major' ;; -aix4* | aix5*) +aix[[4-9]]*) version_type=linux need_lib_prefix=no need_version=no @@ -1830,6 +1906,13 @@ AC_MSG_RESULT([$dynamic_linker]) test "$dynamic_linker" = no && can_build_shared=no +AC_CACHE_VAL([lt_cv_sys_lib_search_path_spec], +[lt_cv_sys_lib_search_path_spec="$sys_lib_search_path_spec"]) +sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec" +AC_CACHE_VAL([lt_cv_sys_lib_dlsearch_path_spec], +[lt_cv_sys_lib_dlsearch_path_spec="$sys_lib_dlsearch_path_spec"]) +sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec" + variables_saved_for_relink="PATH $shlibpath_var $runpath_var" if test "$GCC" = yes; then variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" @@ -2329,7 +2412,7 @@ # whether `pass_all' will *always* work, you probably want this one. case $host_os in -aix4* | aix5*) +aix[[4-9]]*) lt_cv_deplibs_check_method=pass_all ;; @@ -2765,7 +2848,7 @@ fi ;; -aix4* | aix5*) +aix[[4-9]]*) if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then test "$enable_shared" = yes && enable_static=no fi @@ -2822,6 +2905,7 @@ _LT_AC_TAGVAR(predeps, $1)= _LT_AC_TAGVAR(postdeps, $1)= _LT_AC_TAGVAR(compiler_lib_search_path, $1)= +_LT_AC_TAGVAR(compiler_lib_search_dirs, $1)= # Source file extension for C++ test sources. ac_ext=cpp @@ -2931,7 +3015,7 @@ # FIXME: insert proper C++ library support _LT_AC_TAGVAR(ld_shlibs, $1)=no ;; - aix4* | aix5*) + aix[[4-9]]*) if test "$host_cpu" = ia64; then # On IA64, the linker does run time linking by default, so we don't # have to do anything special. @@ -2944,7 +3028,7 @@ # Test if we are trying to use run time linking or normal # AIX style linking. If -brtl is somewhere in LDFLAGS, we # need to do runtime linking. - case $host_os in aix4.[[23]]|aix4.[[23]].*|aix5*) + case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*) for ld_flag in $LDFLAGS; do case $ld_flag in *-brtl*) @@ -3090,52 +3174,24 @@ fi ;; darwin* | rhapsody*) - case $host_os in - rhapsody* | darwin1.[[012]]) - _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-undefined ${wl}suppress' - ;; - *) # Darwin 1.3 on - if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then - _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' - else - case ${MACOSX_DEPLOYMENT_TARGET} in - 10.[[012]]) - _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' - ;; - 10.*) - _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-undefined ${wl}dynamic_lookup' - ;; - esac - fi - ;; - esac _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no _LT_AC_TAGVAR(hardcode_direct, $1)=no _LT_AC_TAGVAR(hardcode_automatic, $1)=yes _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='' _LT_AC_TAGVAR(link_all_deplibs, $1)=yes - - if test "$GXX" = yes ; then - lt_int_apple_cc_single_mod=no + _LT_AC_TAGVAR(allow_undefined_flag, $1)="$_lt_dar_allow_undefined" + if test "$GXX" = yes ; then output_verbose_link_cmd='echo' - if $CC -dumpspecs 2>&1 | $EGREP 'single_module' >/dev/null ; then - lt_int_apple_cc_single_mod=yes + _LT_AC_TAGVAR(archive_cmds, $1)="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}" + _LT_AC_TAGVAR(module_cmds, $1)="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}" + _LT_AC_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}" + _LT_AC_TAGVAR(module_expsym_cmds, $1)="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}" + if test "$lt_cv_apple_cc_single_mod" != "yes"; then + _LT_AC_TAGVAR(archive_cmds, $1)="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}" + _LT_AC_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}" fi - if test "X$lt_int_apple_cc_single_mod" = Xyes ; then - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring' else - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -r -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring' - fi - _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags' - # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds - if test "X$lt_int_apple_cc_single_mod" = Xyes ; then - _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' - else - _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -r -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' - fi - _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' - else case $cc_basename in xlc*) output_verbose_link_cmd='echo' @@ -3385,7 +3441,7 @@ _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive' ;; - pgCC*) + pgCC* | pgcpp*) # Portland Group C++ compiler _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib' _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib' @@ -3820,7 +3876,8 @@ # compiler output when linking a shared library. # Parse the compiler output and extract the necessary # objects, libraries and library flags. -AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP],[ +AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP], +[AC_REQUIRE([LT_AC_PROG_SED])dnl dnl we can't use the lt_simple_compile_test_code here, dnl because it contains code intended for an executable, dnl not a library. It's possible we should let each @@ -3945,6 +4002,11 @@ $rm -f confest.$objext +_LT_AC_TAGVAR(compiler_lib_search_dirs, $1)= +if test -n "$_LT_AC_TAGVAR(compiler_lib_search_path, $1)"; then + _LT_AC_TAGVAR(compiler_lib_search_dirs, $1)=`echo " ${_LT_AC_TAGVAR(compiler_lib_search_path, $1)}" | ${SED} -e 's! -L! !g' -e 's!^ !!'` +fi + # PORTME: override above test on systems where it is broken ifelse([$1],[CXX], [case $host_os in @@ -4001,7 +4063,6 @@ ;; esac ]) - case " $_LT_AC_TAGVAR(postdeps, $1) " in *" -lc "*) _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no ;; esac @@ -4086,7 +4147,7 @@ postinstall_cmds='$RANLIB $lib' fi ;; -aix4* | aix5*) +aix[[4-9]]*) if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then test "$enable_shared" = yes && enable_static=no fi @@ -4263,6 +4324,7 @@ _LT_AC_TAGVAR(predeps, $1) \ _LT_AC_TAGVAR(postdeps, $1) \ _LT_AC_TAGVAR(compiler_lib_search_path, $1) \ + _LT_AC_TAGVAR(compiler_lib_search_dirs, $1) \ _LT_AC_TAGVAR(archive_cmds, $1) \ _LT_AC_TAGVAR(archive_expsym_cmds, $1) \ _LT_AC_TAGVAR(postinstall_cmds, $1) \ @@ -4325,7 +4387,7 @@ # Generated automatically by $PROGRAM (GNU $PACKAGE $VERSION$TIMESTAMP) # NOTE: Changes made to this file will be lost: look at ltmain.sh. # -# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 # Free Software Foundation, Inc. # # This file is part of GNU Libtool: @@ -4562,6 +4624,10 @@ # shared library. postdeps=$lt_[]_LT_AC_TAGVAR(postdeps, $1) +# The directories searched by this compiler when creating a shared +# library +compiler_lib_search_dirs=$lt_[]_LT_AC_TAGVAR(compiler_lib_search_dirs, $1) + # The library search path used internally by the compiler when linking # a shared library. compiler_lib_search_path=$lt_[]_LT_AC_TAGVAR(compiler_lib_search_path, $1) @@ -4911,7 +4977,7 @@ echo "$progname: failed program was:" >&AS_MESSAGE_LOG_FD cat conftest.$ac_ext >&5 fi - rm -f conftest* conftst* + rm -rf conftest* conftst* # Do not use the global_symbol_pipe unless it works. if test "$pipe_works" = yes; then @@ -4968,7 +5034,8 @@ # built for inclusion in a dll (and should export symbols for example). # Although the cygwin gcc ignores -fPIC, still need this for old-style # (--disable-auto-import) libraries - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT' + m4_if([$1], [GCJ], [], + [_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) ;; darwin* | rhapsody*) # PIC is the default on this platform @@ -5005,7 +5072,7 @@ esac else case $host_os in - aix4* | aix5*) + aix[[4-9]]*) # All AIX code is PIC. if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor @@ -5101,7 +5168,7 @@ _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static' ;; - pgCC*) + pgCC* | pgcpp*) # Portland Group C++ compiler. _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' @@ -5252,7 +5319,8 @@ # built for inclusion in a dll (and should export symbols for example). # Although the cygwin gcc ignores -fPIC, still need this for old-style # (--disable-auto-import) libraries - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT' + m4_if([$1], [GCJ], [], + [_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) ;; darwin* | rhapsody*) @@ -5322,7 +5390,8 @@ mingw* | cygwin* | pw32* | os2*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT' + m4_if([$1], [GCJ], [], + [_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) ;; hpux9* | hpux10* | hpux11*) @@ -5459,7 +5528,7 @@ # if test -n "$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)"; then AC_LIBTOOL_COMPILER_OPTION([if $compiler PIC flag $_LT_AC_TAGVAR(lt_prog_compiler_pic, $1) works], - _LT_AC_TAGVAR(lt_prog_compiler_pic_works, $1), + _LT_AC_TAGVAR(lt_cv_prog_compiler_pic_works, $1), [$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)ifelse([$1],[],[ -DPIC],[ifelse([$1],[CXX],[ -DPIC],[])])], [], [case $_LT_AC_TAGVAR(lt_prog_compiler_pic, $1) in "" | " "*) ;; @@ -5483,7 +5552,7 @@ # wl=$_LT_AC_TAGVAR(lt_prog_compiler_wl, $1) eval lt_tmp_static_flag=\"$_LT_AC_TAGVAR(lt_prog_compiler_static, $1)\" AC_LIBTOOL_LINKER_OPTION([if $compiler static flag $lt_tmp_static_flag works], - _LT_AC_TAGVAR(lt_prog_compiler_static_works, $1), + _LT_AC_TAGVAR(lt_cv_prog_compiler_static_works, $1), $lt_tmp_static_flag, [], [_LT_AC_TAGVAR(lt_prog_compiler_static, $1)=]) @@ -5499,7 +5568,7 @@ ifelse([$1],[CXX],[ _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' case $host_os in - aix4* | aix5*) + aix[[4-9]]*) # If we're using GNU nm, then we don't want the "-C" option. # -C means demangle to AIX nm, but means don't demangle with GNU nm if $NM -V 2>&1 | grep 'GNU' > /dev/null; then @@ -5518,6 +5587,7 @@ _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' ;; esac + _LT_AC_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'] ],[ runpath_var= _LT_AC_TAGVAR(allow_undefined_flag, $1)= @@ -5548,12 +5618,14 @@ # it will be wrapped by ` (' and `)$', so one must not match beginning or # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc', # as well as any symbol that contains `d'. - _LT_AC_TAGVAR(exclude_expsyms, $1)="_GLOBAL_OFFSET_TABLE_" + _LT_AC_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'] # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out # platforms (ab)use it in PIC code, but their linkers get confused if # the symbol is explicitly referenced. Since portable code cannot # rely on this symbol name, it's probably fine to never include it in # preloaded symbol tables. + # Exclude shared library initialization/finalization symbols. +dnl Note also adjust exclude_expsyms for C++ above. extract_expsyms_cmds= # Just being paranoid about ensuring that cc_basename is set. _LT_CC_BASENAME([$compiler]) @@ -5603,7 +5675,7 @@ # See if GNU ld supports shared libraries. case $host_os in - aix3* | aix4* | aix5*) + aix[[3-9]]*) # On AIX/PPC, the GNU linker is very broken if test "$host_cpu" != ia64; then _LT_AC_TAGVAR(ld_shlibs, $1)=no @@ -5822,7 +5894,7 @@ fi ;; - aix4* | aix5*) + aix[[4-9]]*) if test "$host_cpu" = ia64; then # On IA64, the linker does run time linking by default, so we don't # have to do anything special. @@ -5842,7 +5914,7 @@ # Test if we are trying to use run time linking or normal # AIX style linking. If -brtl is somewhere in LDFLAGS, we # need to do runtime linking. - case $host_os in aix4.[[23]]|aix4.[[23]].*|aix5*) + case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*) for ld_flag in $LDFLAGS; do if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then aix_use_runtimelinking=yes @@ -6002,11 +6074,10 @@ _LT_AC_TAGVAR(link_all_deplibs, $1)=yes if test "$GCC" = yes ; then output_verbose_link_cmd='echo' - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring' - _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags' - # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds - _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' - _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + _LT_AC_TAGVAR(archive_cmds, $1)="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}" + _LT_AC_TAGVAR(module_cmds, $1)="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}" + _LT_AC_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}" + _LT_AC_TAGVAR(module_expsym_cmds, $1)="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}" else case $cc_basename in xlc*) Modified: branches/import/bus/Makefile.in =================================================================== --- branches/import/bus/Makefile.in 2009-01-06 13:13:30 UTC (rev 804) +++ branches/import/bus/Makefile.in 2009-01-17 23:05:43 UTC (rev 805) @@ -34,7 +34,6 @@ POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ -target_triplet = @target@ @DBUS_BUILD_TESTS_TRUE@TESTS = bus-test$(EXEEXT) \ @DBUS_BUILD_TESTS_TRUE@ bus-test-system$(EXEEXT) \ @DBUS_BUILD_TESTS_TRUE@ bus-test-launch-helper$(EXEEXT) @@ -281,6 +280,7 @@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DOXYGEN = @DOXYGEN@ +DSYMUTIL = @DSYMUTIL@ ECHO = @ECHO@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ @@ -316,6 +316,7 @@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ +NMEDIT = @NMEDIT@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ @@ -405,11 +406,8 @@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ -target = @target@ target_alias = @target_alias@ -target_cpu = @target_cpu@ -target_os = @target_os@ -target_vendor = @target_vendor@ +top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ configdir = $(sysconfdir)/dbus-1 Modified: branches/import/bus/activation.c =================================================================== --- branches/import/bus/activation.c 2009-01-06 13:13:30 UTC (rev 804) +++ branches/import/bus/activation.c 2009-01-17 23:05:43 UTC (rev 805) @@ -679,7 +679,7 @@ DBusString value; int i; char **environment; - dbus_bool_t retval; + dbus_bool_t retval = FALSE; environment = _dbus_get_environment (); Modified: branches/import/bus/bus.c =================================================================== --- branches/import/bus/bus.c 2009-01-06 13:13:30 UTC (rev 804) +++ branches/import/bus/bus.c 2009-01-17 23:05:43 UTC (rev 805) @@ -54,6 +54,8 @@ BusMatchmaker *matchmaker; BusLimits limits; unsigned int fork : 1; + unsigned int syslog : 1; + unsigned int keep_umask : 1; }; static dbus_int32_t server_data_slot = -1; @@ -384,6 +386,8 @@ } context->fork = bus_config_parser_get_fork (parser); + context->syslog = bus_config_parser_get_syslog (parser); + context->keep_umask = bus_config_parser_get_keep_umask (parser); _DBUS_ASSERT_ERROR_IS_CLEAR (error); retval = TRUE; @@ -708,7 +712,8 @@ if (!_dbus_become_daemon (context->pidfile ? &u : NULL, print_pid_pipe, - error)) + error, + context->keep_umask)) { _DBUS_ASSERT_ERROR_IS_SET (error); goto failed; @@ -736,6 +741,11 @@ if (print_pid_pipe && _dbus_pipe_is_valid (print_pid_pipe) && !_dbus_pipe_is_stdout_or_stderr (print_pid_pipe)) _dbus_pipe_close (print_pid_pipe, NULL); + + if (!bus_selinux_full_init ()) + { + _dbus_warn ("SELinux initialization failed\n"); + } if (!process_config_postinit (context, parser, error)) { @@ -766,11 +776,6 @@ #endif } - if (!bus_selinux_full_init ()) - { - _dbus_warn ("SELinux initialization failed\n"); - } - dbus_server_free_data_slot (&server_data_slot); return context; @@ -826,7 +831,10 @@ } ret = TRUE; + bus_context_log_info (context, "Reloaded configuration"); failed: + if (!ret) + bus_context_log_info (context, "Unable to reload configuration: %s", error->message); if (parser != NULL) bus_config_parser_unref (parser); return ret; @@ -1107,6 +1115,32 @@ return context->limits.reply_timeout; } +void +bus_context_log_info (BusContext *context, const char *msg, ...) +{ + va_list args; + + va_start (args, msg); + + if (context->syslog) + _dbus_log_info (msg, args); + + va_end (args); +} + +void +bus_context_log_security (BusContext *context, const char *msg, ...) +{ + va_list args; + + va_start (args, msg); + + if (context->syslog) + _dbus_log_security (msg, args); + + va_end (args); +} + /* * addressed_recipient is the recipient specified in the message. * @@ -1129,21 +1163,45 @@ DBusMessage *message, DBusError *error) { + const char *dest; BusClientPolicy *sender_policy; BusClientPolicy *recipient_policy; + dbus_int32_t toggles; + dbus_bool_t log; int type; dbus_bool_t requested_reply; + const char *sender_name; + const char *sender_loginfo; + const char *proposed_recipient_loginfo; type = dbus_message_get_type (message); + dest = dbus_message_get_destination (message); /* dispatch.c was supposed to ensure these invariants */ - _dbus_assert (dbus_message_get_destination (message) != NULL || + _dbus_assert (dest != NULL || type == DBUS_MESSAGE_TYPE_SIGNAL || (sender == NULL && !bus_connection_is_active (proposed_recipient))); _dbus_assert (type == DBUS_MESSAGE_TYPE_SIGNAL || addressed_recipient != NULL || - strcmp (dbus_message_get_destination (message), DBUS_SERVICE_DBUS) == 0); + strcmp (dest, DBUS_SERVICE_DBUS) == 0); + + /* Used in logging below */ + if (sender != NULL) + { + sender_name = bus_connection_get_name (sender); + sender_loginfo = bus_connection_get_loginfo (sender); + } + else + { + sender_name = NULL; + sender_loginfo = "(bus)"; + } + if (proposed_recipient != NULL) + proposed_recipient_loginfo = bus_connection_get_loginfo (proposed_recipient); + else + proposed_recipient_loginfo = "bus"; + switch (type) { case DBUS_MESSAGE_TYPE_METHOD_CALL: @@ -1166,10 +1224,6 @@ if (sender != NULL) { - const char *dest; - - dest = dbus_message_get_destination (message); - /* First verify the SELinux access controls. If allowed then * go on with the standard checks. */ @@ -1185,8 +1239,9 @@ dbus_set_error (error, DBUS_ERROR_ACCESS_DENIED, "An SELinux policy prevents this sender " "from sending this message to this recipient " - "(rejected message had interface \"%s\" " + "(rejected message had sender \"%s\" interface \"%s\" " "member \"%s\" error name \"%s\" destination \"%s\")", + sender_name ? sender_name : "(unset)", dbus_message_get_interface (message) ? dbus_message_get_interface (message) : "(unset)", dbus_message_get_member (message) ? @@ -1299,57 +1354,112 @@ (proposed_recipient != NULL && sender == NULL && recipient_policy == NULL) || (proposed_recipient == NULL && recipient_policy == NULL)); + log = FALSE; if (sender_policy && !bus_client_policy_check_can_send (sender_policy, context->registry, requested_reply, proposed_recipient, - message)) + message, &toggles, &log)) { - const char *dest; + const char *msg = "Rejected send message, %d matched rules; " + "type=\"%s\", sender=\"%s\" (%s) interface=\"%s\" member=\"%s\" error name=\"%s\" requested_reply=%d destination=\"%s\" (%s))"; - dest = dbus_message_get_destination (message); - dbus_set_error (error, DBUS_ERROR_ACCESS_DENIED, - "A security policy in place prevents this sender " - "from sending this message to this recipient, " - "see message bus configuration file (rejected message " - "had interface \"%s\" member \"%s\" error name \"%s\" destination \"%s\")", + dbus_set_error (error, DBUS_ERROR_ACCESS_DENIED, msg, + toggles, + dbus_message_type_to_string (dbus_message_get_type (message)), + sender_name ? sender_name : "(unset)", + sender_loginfo, dbus_message_get_interface (message) ? dbus_message_get_interface (message) : "(unset)", dbus_message_get_member (message) ? dbus_message_get_member (message) : "(unset)", dbus_message_get_error_name (message) ? dbus_message_get_error_name (message) : "(unset)", - dest ? dest : DBUS_SERVICE_DBUS); + requested_reply, + dest ? dest : DBUS_SERVICE_DBUS, + proposed_recipient_loginfo); + /* Needs to be duplicated to avoid calling malloc and having to handle OOM */ + if (addressed_recipient == proposed_recipient) + bus_context_log_security (context, msg, + toggles, + dbus_message_type_to_string (dbus_message_get_type (message)), + sender_name ? sender_name : "(unset)", + sender_loginfo, + dbus_message_get_interface (message) ? + dbus_message_get_interface (message) : "(unset)", + dbus_message_get_member (message) ? + dbus_message_get_member (message) : "(unset)", + dbus_message_get_error_name (message) ? + dbus_message_get_error_name (message) : "(unset)", + requested_reply, + dest ? dest : DBUS_SERVICE_DBUS, + proposed_recipient_loginfo); _dbus_verbose ("security policy disallowing message due to sender policy\n"); return FALSE; } + if (log) + bus_context_log_security (context, + "Would reject message, %d matched rules; " + "type=\"%s\", sender=\"%s\" (%s) interface=\"%s\" member=\"%s\" error name=\"%s\" requested_reply=%d destination=\"%s\" (%s))", + toggles, + dbus_message_type_to_string (dbus_message_get_type (message)), + sender_name ? sender_name : "(unset)", + sender_loginfo, + dbus_message_get_interface (message) ? + dbus_message_get_interface (message) : "(unset)", + dbus_message_get_member (message) ? + dbus_message_get_member (message) : "(unset)", + dbus_message_get_error_name (message) ? + dbus_message_get_error_name (message) : "(unset)", + requested_reply, + dest ? dest : DBUS_SERVICE_DBUS, + proposed_recipient_loginfo); + if (recipient_policy && !bus_client_policy_check_can_receive (recipient_policy, context->registry, requested_reply, sender, addressed_recipient, proposed_recipient, - message)) + message, &toggles)) { - const char *dest; + const char *msg = "Rejected receive message, %d matched rules; " + "type=\"%s\" sender=\"%s\" (%s) interface=\"%s\" member=\"%s\" error name=\"%s\" reply serial=%u requested_reply=%d destination=\"%s\" (%s))"; - dest = dbus_message_get_destination (message); - dbus_set_error (error, DBUS_ERROR_ACCESS_DENIED, - "A security policy in place prevents this recipient " - "from receiving this message from this sender, " - "see message bus configuration file (rejected message " - "had interface \"%s\" member \"%s\" error name \"%s\" destination \"%s\" reply serial %u requested_reply=%d)", + dbus_set_error (error, DBUS_ERROR_ACCESS_DENIED, msg, + toggles, + dbus_message_type_to_string (dbus_message_get_type (message)), + sender_name ? sender_name : "(unset)", + sender_loginfo, dbus_message_get_interface (message) ? dbus_message_get_interface (message) : "(unset)", dbus_message_get_member (message) ? dbus_message_get_member (message) : "(unset)", dbus_message_get_error_name (message) ? dbus_message_get_error_name (message) : "(unset)", + dbus_message_get_reply_serial (message), + requested_reply, dest ? dest : DBUS_SERVICE_DBUS, - dbus_message_get_reply_serial (message), - requested_reply); + proposed_recipient_loginfo); + /* Needs to be duplicated to avoid calling malloc and having to handle OOM */ + if (addressed_recipient == proposed_recipient) + bus_context_log_security (context, msg, + toggles, + dbus_message_type_to_string (dbus_message_get_type (message)), + sender_name ? sender_name : "(unset)", + sender_loginfo, + dbus_message_get_interface (message) ? + dbus_message_get_interface (message) : "(unset)", + dbus_message_get_member (message) ? + dbus_message_get_member (message) : "(unset)", + dbus_message_get_error_name (message) ? + dbus_message_get_error_name (message) : "(unset)", + dbus_message_get_reply_serial (message), + requested_reply, + dest ? dest : DBUS_SERVICE_DBUS, + proposed_recipient_loginfo); _dbus_verbose ("security policy disallowing message due to recipient policy\n"); return FALSE; } @@ -1359,9 +1469,6 @@ dbus_connection_get_outgoing_size (proposed_recipient) > context->limits.max_outgoing_bytes) { - const char *dest; - - dest = dbus_message_get_destination (message); dbus_set_error (error, DBUS_ERROR_LIMITS_EXCEEDED, "The destination service \"%s\" has a full message queue", dest ? dest : (proposed_recipient ? Modified: branches/import/bus/bus.h =================================================================== --- branches/import/bus/bus.h 2009-01-06 13:13:30 UTC (rev 804) +++ branches/import/bus/bus.h 2009-01-17 23:05:43 UTC (rev 805) @@ -107,6 +107,12 @@ int bus_context_get_max_match_rules_per_connection (BusContext *context); int bus_context_get_max_replies_per_connection (BusContext *context); int bus_context_get_reply_timeout (BusContext *context); +void bus_context_log_info (BusContext *context, + const char *msg, + ...); +void bus_context_log_security (BusContext *context, + const char *msg, + ...); dbus_bool_t bus_context_check_security_policy (BusContext *context, BusTransaction *transaction, DBusConnection *sender, Modified: branches/import/bus/config-parser-common.c =================================================================== --- branches/import/bus/config-parser-common.c 2009-01-06 13:13:30 UTC (rev 804) +++ branches/import/bus/config-parser-common.c 2009-01-17 23:05:43 UTC (rev 805) @@ -114,6 +114,14 @@ { return ELEMENT_ASSOCIATE; } + else if (strcmp (name, "syslog") == 0) + { + return ELEMENT_SYSLOG; + } + else if (strcmp (name, "keep_umask") == 0) + { + return ELEMENT_KEEP_UMASK; + } return ELEMENT_NONE; } @@ -162,6 +170,10 @@ return "selinux"; case ELEMENT_ASSOCIATE: return "associate"; + case ELEMENT_SYSLOG: + return "syslog"; + case ELEMENT_KEEP_UMASK: + return "keep_umask"; } _dbus_assert_not_reached ("bad element type"); Modified: branches/import/bus/config-parser-common.h =================================================================== --- branches/import/bus/config-parser-common.h 2009-01-06 13:13:30 UTC (rev 804) +++ branches/import/bus/config-parser-common.h 2009-01-17 23:05:43 UTC (rev 805) @@ -47,7 +47,9 @@ ELEMENT_SELINUX, ELEMENT_ASSOCIATE, ELEMENT_STANDARD_SESSION_SERVICEDIRS, - ELEMENT_STANDARD_SYSTEM_SERVICEDIRS + ELEMENT_STANDARD_SYSTEM_SERVICEDIRS, + ELEMENT_SYSLOG, + ELEMENT_KEEP_UMASK } ElementType; ElementType bus_config_parser_element_name_to_type (const char *element_name); Modified: branches/import/bus/config-parser.c =================================================================== --- branches/import/bus/config-parser.c 2009-01-06 13:13:30 UTC (rev 804) +++ branches/import/bus/config-parser.c 2009-01-17 23:05:43 UTC (rev 805) @@ -111,6 +111,9 @@ unsigned int fork : 1; /**< TRUE to fork into daemon mode */ + unsigned int syslog : 1; /**< TRUE to enable syslog */ + unsigned int keep_umask : 1; /**< TRUE to keep original umask when forking */ + unsigned int is_toplevel : 1; /**< FALSE if we are a sub-config-file inside another one */ }; @@ -306,6 +309,9 @@ if (included->fork) parser->fork = TRUE; + if (included->keep_umask) + parser->keep_umask = TRUE; + if (included->pidfile != NULL) { dbus_free (parser->pidfile); @@ -698,6 +704,36 @@ return TRUE; } + else if (element_type == ELEMENT_SYSLOG) + { + if (!check_no_attributes (parser, "syslog", attribute_names, attribute_values, error)) + return FALSE; + + if (push_element (parser, ELEMENT_SYSLOG) == NULL) + { + BUS_SET_OOM (error); + return FALSE; + } + + parser->syslog = TRUE; + + return TRUE; + } + else if (element_type == ELEMENT_KEEP_UMASK) + { + if (!check_no_attributes (parser, "keep_umask", attribute_names, attribute_values, error)) + return FALSE; + + if (push_element (parser, ELEMENT_KEEP_UMASK) == NULL) + { + BUS_SET_OOM (error); + return FALSE; + } + + parser->keep_umask = TRUE; + + return TRUE; + } else if (element_type == ELEMENT_PIDFILE) { if (!check_no_attributes (parser, "pidfile", attribute_names, attribute_values, error)) @@ -1073,6 +1109,7 @@ dbus_bool_t allow, DBusError *error) { + const char *log; const char *send_interface; const char *send_member; const char *send_error; @@ -1116,6 +1153,7 @@ "own", &own, "user", &user, "group", &group, + "log", &log, NULL)) return FALSE; @@ -1320,6 +1358,9 @@ if (eavesdrop) rule->d.send.eavesdrop = (strcmp (eavesdrop, "true") == 0); + if (log) + rule->d.send.log = (strcmp (log, "true") == 0); + if (send_requested_reply) rule->d.send.requested_reply = (strcmp (send_requested_reply, "true") == 0); @@ -1947,6 +1988,8 @@ case ELEMENT_ALLOW: case ELEMENT_DENY: case ELEMENT_FORK: + case ELEMENT_SYSLOG: + case ELEMENT_KEEP_UMASK: case ELEMENT_SELINUX: case ELEMENT_ASSOCIATE: case ELEMENT_STANDARD_SESSION_SERVICEDIRS: @@ -2232,6 +2275,8 @@ case ELEMENT_ALLOW: case ELEMENT_DENY: case ELEMENT_FORK: + case ELEMENT_SYSLOG: + case ELEMENT_KEEP_UMASK: case ELEMENT_STANDARD_SESSION_SERVICEDIRS: case ELEMENT_STANDARD_SYSTEM_SERVICEDIRS: case ELEMENT_SELINUX: @@ -2554,6 +2599,18 @@ return parser->fork; } +dbus_bool_t +bus_config_parser_get_syslog (BusConfigParser *parser) +{ + return parser->syslog; +} + +dbus_bool_t +bus_config_parser_get_keep_umask (BusConfigParser *parser) +{ + return parser->keep_umask; +} + const char * bus_config_parser_get_pidfile (BusConfigParser *parser) { @@ -2947,6 +3004,9 @@ if (! bools_equal (a->fork, b->fork)) return FALSE; + if (! bools_equal (a->keep_umask, b->keep_umask)) + return FALSE; + if (! bools_equal (a->is_toplevel, b->is_toplevel)) return FALSE; Modified: branches/import/bus/config-parser.h =================================================================== --- branches/import/bus/config-parser.h 2009-01-06 13:13:30 UTC (rev 804) +++ branches/import/bus/config-parser.h 2009-01-17 23:05:43 UTC (rev 805) @@ -65,6 +65,9 @@ DBusList** bus_config_parser_get_addresses (BusConfigParser *parser); DBusList** bus_config_parser_get_mechanisms (BusConfigParser *parser); dbus_bool_t bus_config_parser_get_fork (BusConfigParser *parser); +dbus_bool_t bus_config_parser_get_allow_anonymous (BusConfigParser *parser); +dbus_bool_t bus_config_parser_get_syslog (BusConfigParser *parser); +dbus_bool_t bus_config_parser_get_keep_umask (BusConfigParser *parser); const char* bus_config_parser_get_pidfile (BusConfigParser *parser); const char* bus_config_parser_get_servicehelper (BusConfigParser *parser); DBusList** bus_config_parser_get_service_dirs (BusConfigParser *parser); Modified: branches/import/bus/connection.c =================================================================== --- branches/import/bus/connection.c 2009-01-06 13:13:30 UTC (rev 804) +++ branches/import/bus/connection.c 2009-01-17 23:05:43 UTC (rev 805) @@ -32,6 +32,9 @@ #include <dbus/dbus-hash.h> #include <dbus/dbus-timeout.h> +/* Trim executed commands to this length; we want to keep logs readable */ +#define MAX_LOG_COMMAND_LEN 50 + static void bus_connection_remove_transactions (DBusConnection *connection); typedef struct @@ -76,6 +79,7 @@ DBusPreallocatedSend *oom_preallocated; BusClientPolicy *policy; + char *cached_loginfo_string; BusSELinuxID *selinux_id; long connection_tv_sec; /**< Time when we connected (seconds component) */ @@ -406,6 +410,8 @@ if (d->selinux_id) bus_selinux_id_unref (d->selinux_id); + dbus_free (d->cached_loginfo_string); + dbus_free (d->name); dbus_free (d); @@ -537,13 +543,73 @@ } } +/* Used for logging */ +static dbus_bool_t +cache_peer_loginfo_string (BusConnectionData *d, + DBusConnection *connection) +{ + DBusString loginfo_buf; + unsigned long uid; + unsigned long pid; + char *windows_sid; + dbus_bool_t prev_added; + + if (!_dbus_string_init (&loginfo_buf)) + return FALSE; + + prev_added = FALSE; + if (dbus_connection_get_unix_user (connection, &uid)) + { + if (!_dbus_string_append_printf (&loginfo_buf, "uid=%ld", uid)) + goto oom; + else + prev_added = TRUE; + } + + if (dbus_connection_get_unix_process_id (connection, &pid)) + { + if (prev_added) + { + if (!_dbus_string_append_byte (&loginfo_buf, ' ')) + goto oom; + } + if (!_dbus_string_append_printf (&loginfo_buf, "pid=%ld comm=\"", pid)) + goto oom; + /* Ignore errors here */ + if (_dbus_command_for_pid (pid, &loginfo_buf, MAX_LOG_COMMAND_LEN, NULL)) + { + if (!_dbus_string_append_byte (&loginfo_buf, '"')) + goto oom; + } + } + + if (dbus_connection_get_windows_user (connection, &windows_sid)) + { + if (!_dbus_string_append_printf (&loginfo_buf, "sid=\"%s\" ", windows_sid)) + goto oom; + dbus_free (windows_sid); + } + + if (!_dbus_string_steal_data (&loginfo_buf, &(d->cached_loginfo_string))) + goto oom; + + _dbus_string_free (&loginfo_buf); + + return TRUE; +oom: + _dbus_string_free (&loginfo_buf); + return FALSE; +} + dbus_bool_t bus_connections_setup_connection (BusConnections *connections, DBusConnection *connection) { + BusConnectionData *d; dbus_bool_t retval; DBusError error; + d = dbus_new0 (BusConnectionData, 1); @@ -583,7 +649,7 @@ dbus_error_free (&error); goto out; } - + if (!dbus_connection_set_watch_functions (connection, add_connection_watch, remove_connection_watch, @@ -842,6 +908,18 @@ return FALSE; } +const char * +bus_connection_get_loginfo (DBusConnection *connection) +{ + BusConnectionData *d; + + d = BUS_CONNECTION_DATA (connection); + + if (!bus_connection_is_active (connection)) + return "inactive"; + return d->cached_loginfo_string; +} + BusClientPolicy* bus_connection_get_policy (DBusConnection *connection) { @@ -1302,16 +1380,15 @@ { if (!adjust_connections_for_uid (d->connections, uid, 1)) - { - BUS_SET_OOM (error); - dbus_free (d->name); - d->name = NULL; - bus_client_policy_unref (d->policy); - d->policy = NULL; - return FALSE; - } + goto fail; } - + + /* Create and cache a string which holds information about the + * peer process; used for logging purposes. + */ + if (!cache_peer_loginfo_string (d, connection)) + goto fail; + /* Now the connection is active, move it between lists */ _dbus_list_unlink (&d->connections->incomplete, d->link_in_connection_list); @@ -1329,6 +1406,14 @@ _dbus_assert (bus_connection_is_active (connection)); return TRUE; +fail: + BUS_SET_OOM (error); + dbus_free (d->name); + d->name = NULL; + if (d->policy) + bus_client_policy_unref (d->policy); + d->policy = NULL; + return FALSE; } const char * Modified: branches/import/bus/connection.h =================================================================== --- branches/import/bus/connection.h 2009-01-06 13:13:30 UTC (rev 804) +++ branches/import/bus/connection.h 2009-01-17 23:05:43 UTC (rev 805) @@ -50,6 +50,7 @@ BusRegistry* bus_connection_get_registry (DBusConnection *connection); BusActivation* bus_connection_get_activation (DBusConnection *connection); BusMatchmaker* bus_connection_get_matchmaker (DBusConnection *connection); +const char * bus_connection_get_loginfo (DBusConnection *connection); BusSELinuxID* bus_connection_get_selinux_id (DBusConnection *connection); dbus_bool_t bus_connections_check_limits (BusConnections *connections, DBusConnection *requesting_completion, Modified: branches/import/bus/dbus-daemon.1 =================================================================== --- branches/import/bus/dbus-daemon.1 2009-01-06 13:13:30 UTC (rev 804) +++ branches/import/bus/dbus-daemon.1 2009-01-17 23:05:43 UTC (rev 805) @@ -1,6 +1,6 @@ .\" .\" dbus-daemon manual page. -.\" Copyright (C) 2003 Red Hat, Inc. +.\" Copyright (C) 2003,2008 Red Hat, Inc. .\" .TH dbus-daemon 1 .SH NAME @@ -214,6 +214,13 @@ rather than the \-\-fork command line option. .TP +.I "<keep_umask>" + +.PP +If present, the bus daemon keeps its original umask when forking. +This may be useful to avoid affecting the behavior of child processes. + +.TP .I "<listen>" .PP @@ -410,15 +417,28 @@ and prevent unexpected traffic. .PP -The <policy> element has one of three attributes: +Currently, the system bus has a default-deny policy for sending method calls +and owning bus names. Everything else, in particular reply messages, receive +checks, and signals has a default allow policy. + +.PP +In general, it is best to keep system services as small, targeted programs which +run in their own process and provide a single bus name. Then, all that is needed +is an <allow> rule for the "own" permission to let the process claim the bus +name, and a "send_destination" rule to allow traffic from some or all uids to +your service. + +.PP +The <policy> element has one of four attributes: +daemon.1.in .nf context="(default|mandatory)" + at_console="(true|false)" user="username or userid" group="group name or gid" .fi .PP - Policies are applied to a connection as follows: .nf - all context="default" policies are applied @@ -426,6 +446,8 @@ in undefined order - all user="connection's auth user" policies are applied in undefined order + - all at_console="true" policies are applied + - all at_console="false" policies are applied - all context="mandatory" policies are applied .fi @@ -566,7 +588,11 @@ .PP Be careful with send_interface/receive_interface, because the -interface field in messages is optional. +interface field in messages is optional. In particular, do NOT +specify <deny send_interface="org.foo.Bar"/>! This will cause +no-interface messages to be blocked for all services, which is +almost certainly not what you intended. Always use rules of +the form: <deny send_interface="org.foo.Bar" send_destination="org.foo.Service"/> .TP .I "<selinux>" Property changes on: branches/import/bus/dbus-daemon.1 ___________________________________________________________________ Added: svn:eol-style + native Modified: branches/import/bus/dbus-daemon.1.in =================================================================== --- branches/import/bus/dbus-daemon.1.in 2009-01-06 13:13:30 UTC (rev 804) +++ branches/import/bus/dbus-daemon.1.in 2009-01-17 23:05:43 UTC (rev 805) @@ -1,6 +1,6 @@ .\" .\" dbus-daemon manual page. -.\" Copyright (C) 2003 Red Hat, Inc. +.\" Copyright (C) 2003,2008 Red Hat, Inc. .\" .TH dbus-daemon 1 .SH NAME @@ -214,6 +214,13 @@ rather than the \-\-fork command line option. .TP +.I "<keep_umask>" + +.PP +If present, the bus daemon keeps its original umask when forking. +This may be useful to avoid affecting the behavior of child processes. + +.TP .I "<listen>" .PP @@ -410,15 +417,28 @@ and prevent unexpected traffic. .PP -The <policy> element has one of three attributes: +Currently, the system bus has a default-deny policy for sending method calls +and owning bus names. Everything else, in particular reply messages, receive +checks, and signals has a default allow policy. + +.PP +In general, it is best to keep system services as small, targeted programs which +run in their own process and provide a single bus name. Then, all that is needed +is an <allow> rule for the "own" permission to let the process claim the bus +name, and a "send_destination" rule to allow traffic from some or all uids to +your service. + +.PP +The <policy> element has one of four attributes: +daemon.1.in .nf context="(default|mandatory)" + at_console="(true|false)" user="username or userid" group="group name or gid" .fi .PP - Policies are applied to a connection as follows: .nf - all context="default" policies are applied @@ -426,6 +446,8 @@ in undefined order - all user="connection's auth user" policies are applied in undefined order + - all at_console="true" policies are applied + - all at_console="false" policies are applied - all context="mandatory" policies are applied .fi @@ -566,7 +588,11 @@ .PP Be careful with send_interface/receive... [truncated message content] |
From: <hab...@us...> - 2009-01-06 13:13:33
|
Revision: 804 http://windbus.svn.sourceforge.net/windbus/?rev=804&view=rev Author: habacker Date: 2009-01-06 13:13:30 +0000 (Tue, 06 Jan 2009) Log Message: ----------- removed obsolate debug message Modified Paths: -------------- trunk/dbus/dbus-sysdeps-win.c Modified: trunk/dbus/dbus-sysdeps-win.c =================================================================== --- trunk/dbus/dbus-sysdeps-win.c 2009-01-06 13:11:03 UTC (rev 803) +++ trunk/dbus/dbus-sysdeps-win.c 2009-01-06 13:13:30 UTC (rev 804) @@ -1504,7 +1504,6 @@ "Unknown address family %s", family); return -1; } - fprintf(stderr, "Family %s\n", family ? family : "none"); hints.ai_protocol = IPPROTO_TCP; hints.ai_socktype = SOCK_STREAM; #ifdef AI_ADDRCONFIG This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hab...@us...> - 2009-01-06 13:11:04
|
Revision: 803 http://windbus.svn.sourceforge.net/windbus/?rev=803&view=rev Author: habacker Date: 2009-01-06 13:11:03 +0000 (Tue, 06 Jan 2009) Log Message: ----------- removed obsolate debug message Modified Paths: -------------- branches/import/dbus/dbus-sysdeps-win.c Modified: branches/import/dbus/dbus-sysdeps-win.c =================================================================== --- branches/import/dbus/dbus-sysdeps-win.c 2009-01-06 13:05:20 UTC (rev 802) +++ branches/import/dbus/dbus-sysdeps-win.c 2009-01-06 13:11:03 UTC (rev 803) @@ -1496,7 +1496,6 @@ "Unknown address family %s", family); return -1; } - fprintf(stderr, "Family %s\n", family ? family : "none"); hints.ai_protocol = IPPROTO_TCP; hints.ai_socktype = SOCK_STREAM; #ifdef AI_ADDRCONFIG This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hab...@us...> - 2009-01-06 13:05:23
|
Revision: 802 http://windbus.svn.sourceforge.net/windbus/?rev=802&view=rev Author: habacker Date: 2009-01-06 13:05:20 +0000 (Tue, 06 Jan 2009) Log Message: ----------- removed obsolate debug message Modified Paths: -------------- tags/1.2.4/dbus/dbus-sysdeps-win.c Modified: tags/1.2.4/dbus/dbus-sysdeps-win.c =================================================================== --- tags/1.2.4/dbus/dbus-sysdeps-win.c 2009-01-06 13:01:20 UTC (rev 801) +++ tags/1.2.4/dbus/dbus-sysdeps-win.c 2009-01-06 13:05:20 UTC (rev 802) @@ -1504,7 +1504,6 @@ "Unknown address family %s", family); return -1; } - fprintf(stderr, "Family %s\n", family ? family : "none"); hints.ai_protocol = IPPROTO_TCP; hints.ai_socktype = SOCK_STREAM; #ifdef AI_ADDRCONFIG This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hab...@us...> - 2009-01-06 13:01:21
|
Revision: 801 http://windbus.svn.sourceforge.net/windbus/?rev=801&view=rev Author: habacker Date: 2009-01-06 13:01:20 +0000 (Tue, 06 Jan 2009) Log Message: ----------- removed obsolate debug message Modified Paths: -------------- trunk/dbus/dbus-internals.c Modified: trunk/dbus/dbus-internals.c =================================================================== --- trunk/dbus/dbus-internals.c 2008-10-26 20:04:22 UTC (rev 800) +++ trunk/dbus/dbus-internals.c 2009-01-06 13:01:20 UTC (rev 801) @@ -28,6 +28,9 @@ #include <stdarg.h> #include <string.h> #include <stdlib.h> +#ifdef USE_OUTPUTDEBUGSTRING +#include <windows.h> +#endif /** * @defgroup DBusInternals D-Bus secret internal implementation details @@ -298,15 +301,28 @@ #ifdef DBUS_WIN #define inline #endif +#ifdef USE_OUTPUTDEBUGSTRING +static char module_name[1024]; +#endif static inline void _dbus_verbose_init (void) { if (!verbose_initted) { - const char *p = _dbus_getenv ("DBUS_VERBOSE"); + char *p = _dbus_getenv ("DBUS_VERBOSE"); verbose = p != NULL && *p == '1'; verbose_initted = TRUE; +#ifdef USE_OUTPUTDEBUGSTRING + GetModuleFileName(0,module_name,sizeof(module_name)-1); + p = strrchr(module_name,'.'); + if (p) + *p ='\0'; + p = strrchr(module_name,'\\'); + if (p) + strcpy(module_name,p+1); + strcat(module_name,": "); +#endif } } @@ -345,6 +361,7 @@ if (!_dbus_is_verbose_real()) return; +#ifndef USE_OUTPUTDEBUGSTRING /* Print out pid before the line */ if (need_pid) { @@ -354,7 +371,7 @@ fprintf (stderr, "%lu: ", _dbus_pid_for_log ()); #endif } - +#endif /* Only print pid again if the next line is a new line */ len = strlen (format); @@ -364,10 +381,20 @@ need_pid = FALSE; va_start (args, format); +#ifdef USE_OUTPUTDEBUGSTRING + { + char buf[1024]; + strcpy(buf,module_name); + vsprintf (buf+strlen(buf),format, args); + va_end (args); + OutputDebugString(buf); + } +#else vfprintf (stderr, format, args); va_end (args); fflush (stderr); +#endif } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <che...@us...> - 2008-10-26 20:04:27
|
Revision: 800 http://windbus.svn.sourceforge.net/windbus/?rev=800&view=rev Author: chehrlic Date: 2008-10-26 20:04:22 +0000 (Sun, 26 Oct 2008) Log Message: ----------- fix dbus_watch_get_unix_fd() Added Paths: ----------- tags/1.2.4/dbus/dbus-watch.c Copied: tags/1.2.4/dbus/dbus-watch.c (from rev 799, trunk/dbus/dbus-watch.c) =================================================================== --- tags/1.2.4/dbus/dbus-watch.c (rev 0) +++ tags/1.2.4/dbus/dbus-watch.c 2008-10-26 20:04:22 UTC (rev 800) @@ -0,0 +1,668 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ +/* dbus-watch.c DBusWatch implementation + * + * Copyright (C) 2002, 2003 Red Hat Inc. + * + * Licensed under the Academic Free License version 2.1 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include "dbus-internals.h" +#include "dbus-watch.h" +#include "dbus-list.h" + +/** + * @defgroup DBusWatchInternals DBusWatch implementation details + * @ingroup DBusInternals + * @brief implementation details for DBusWatch + * + * @{ + */ + +/** + * Implementation of DBusWatch + */ +struct DBusWatch +{ + int refcount; /**< Reference count */ + int fd; /**< File descriptor. */ + unsigned int flags; /**< Conditions to watch. */ + + DBusWatchHandler handler; /**< Watch handler. */ + void *handler_data; /**< Watch handler data. */ + DBusFreeFunction free_handler_data_function; /**< Free the watch handler data. */ + + void *data; /**< Application data. */ + DBusFreeFunction free_data_function; /**< Free the application data. */ + unsigned int enabled : 1; /**< Whether it's enabled. */ +}; + +/** + * Creates a new DBusWatch. Used to add a file descriptor to be polled + * by a main loop. + * + * @param fd the file descriptor to be watched. + * @param flags the conditions to watch for on the descriptor. + * @param enabled the initial enabled state + * @param handler the handler function + * @param data data for handler function + * @param free_data_function function to free the data + * @returns the new DBusWatch object. + */ +DBusWatch* +_dbus_watch_new (int fd, + unsigned int flags, + dbus_bool_t enabled, + DBusWatchHandler handler, + void *data, + DBusFreeFunction free_data_function) +{ + DBusWatch *watch; + +#define VALID_WATCH_FLAGS (DBUS_WATCH_WRITABLE | DBUS_WATCH_READABLE) + + _dbus_assert ((flags & VALID_WATCH_FLAGS) == flags); + + watch = dbus_new0 (DBusWatch, 1); + if (watch == NULL) + return NULL; + + watch->refcount = 1; + watch->fd = fd; + watch->flags = flags; + watch->enabled = enabled; + + watch->handler = handler; + watch->handler_data = data; + watch->free_handler_data_function = free_data_function; + + return watch; +} + +/** + * Increments the reference count of a DBusWatch object. + * + * @param watch the watch object. + * @returns the watch object. + */ +DBusWatch * +_dbus_watch_ref (DBusWatch *watch) +{ + watch->refcount += 1; + + return watch; +} + +/** + * Decrements the reference count of a DBusWatch object + * and finalizes the object if the count reaches zero. + * + * @param watch the watch object. + */ +void +_dbus_watch_unref (DBusWatch *watch) +{ + _dbus_assert (watch != NULL); + _dbus_assert (watch->refcount > 0); + + watch->refcount -= 1; + if (watch->refcount == 0) + { + dbus_watch_set_data (watch, NULL, NULL); /* call free_data_function */ + + if (watch->free_handler_data_function) + (* watch->free_handler_data_function) (watch->handler_data); + + dbus_free (watch); + } +} + +/** + * Clears the file descriptor from a now-invalid watch object so that + * no one tries to use it. This is because a watch may stay alive due + * to reference counts after the file descriptor is closed. + * Invalidation makes it easier to catch bugs. It also + * keeps people from doing dorky things like assuming file descriptors + * are unique (never recycled). + * + * @param watch the watch object. + */ +void +_dbus_watch_invalidate (DBusWatch *watch) +{ + watch->fd = -1; + watch->flags = 0; +} + +/** + * Sanitizes the given condition so that it only contains + * flags that the DBusWatch requested. e.g. if the + * watch is a DBUS_WATCH_READABLE watch then + * DBUS_WATCH_WRITABLE will be stripped from the condition. + * + * @param watch the watch object. + * @param condition address of the condition to sanitize. + */ +void +_dbus_watch_sanitize_condition (DBusWatch *watch, + unsigned int *condition) +{ + if (!(watch->flags & DBUS_WATCH_READABLE)) + *condition &= ~DBUS_WATCH_READABLE; + if (!(watch->flags & DBUS_WATCH_WRITABLE)) + *condition &= ~DBUS_WATCH_WRITABLE; +} + + +/** + * @typedef DBusWatchList + * + * Opaque data type representing a list of watches + * and a set of DBusAddWatchFunction/DBusRemoveWatchFunction. + * Automatically handles removing/re-adding watches + * when the DBusAddWatchFunction is updated or changed. + * Holds a reference count to each watch. + * + * Used in the implementation of both DBusServer and + * DBusClient. + * + */ + +/** + * DBusWatchList implementation details. All fields + * are private. + * + */ +struct DBusWatchList +{ + DBusList *watches; /**< Watch objects. */ + + DBusAddWatchFunction add_watch_function; /**< Callback for adding a watch. */ + DBusRemoveWatchFunction remove_watch_function; /**< Callback for removing a watch. */ + DBusWatchToggledFunction watch_toggled_function; /**< Callback on toggling enablement */ + void *watch_data; /**< Data for watch callbacks */ + DBusFreeFunction watch_free_data_function; /**< Free function for watch callback data */ +}; + +/** + * Creates a new watch list. Returns #NULL if insufficient + * memory exists. + * + * @returns the new watch list, or #NULL on failure. + */ +DBusWatchList* +_dbus_watch_list_new (void) +{ + DBusWatchList *watch_list; + + watch_list = dbus_new0 (DBusWatchList, 1); + if (watch_list == NULL) + return NULL; + + return watch_list; +} + +/** + * Frees a DBusWatchList. + * + * @param watch_list the watch list. + */ +void +_dbus_watch_list_free (DBusWatchList *watch_list) +{ + /* free watch_data and removes watches as a side effect */ + _dbus_watch_list_set_functions (watch_list, + NULL, NULL, NULL, NULL, NULL); + _dbus_list_foreach (&watch_list->watches, + (DBusForeachFunction) _dbus_watch_unref, + NULL); + _dbus_list_clear (&watch_list->watches); + + dbus_free (watch_list); +} + +/** + * Sets the watch functions. This function is the "backend" + * for dbus_connection_set_watch_functions() and + * dbus_server_set_watch_functions(). + * + * @param watch_list the watch list. + * @param add_function the add watch function. + * @param remove_function the remove watch function. + * @param toggled_function function on toggling enabled flag, or #NULL + * @param data the data for those functions. + * @param free_data_function the function to free the data. + * @returns #FALSE if not enough memory + * + */ +dbus_bool_t +_dbus_watch_list_set_functions (DBusWatchList *watch_list, + DBusAddWatchFunction add_function, + DBusRemoveWatchFunction remove_function, + DBusWatchToggledFunction toggled_function, + void *data, + DBusFreeFunction free_data_function) +{ + /* Add watches with the new watch function, failing on OOM */ + if (add_function != NULL) + { + DBusList *link; + + link = _dbus_list_get_first_link (&watch_list->watches); + while (link != NULL) + { + DBusList *next = _dbus_list_get_next_link (&watch_list->watches, + link); + +#ifdef DBUS_ENABLE_VERBOSE_MODE + { + const char *watch_type; + int flags; + + flags = dbus_watch_get_flags (link->data); + if ((flags & DBUS_WATCH_READABLE) && + (flags & DBUS_WATCH_WRITABLE)) + watch_type = "readwrite"; + else if (flags & DBUS_WATCH_READABLE) + watch_type = "read"; + else if (flags & DBUS_WATCH_WRITABLE) + watch_type = "write"; + else + watch_type = "not read or write"; + + _dbus_verbose ("Adding a %s watch on fd %d using newly-set add watch function\n", + watch_type, + dbus_watch_get_socket (link->data)); + } +#endif /* DBUS_ENABLE_VERBOSE_MODE */ + + if (!(* add_function) (link->data, data)) + { + /* remove it all again and return FALSE */ + DBusList *link2; + + link2 = _dbus_list_get_first_link (&watch_list->watches); + while (link2 != link) + { + DBusList *next = _dbus_list_get_next_link (&watch_list->watches, + link2); + + _dbus_verbose ("Removing watch on fd %d using newly-set remove function because initial add failed\n", + dbus_watch_get_socket (link2->data)); + + (* remove_function) (link2->data, data); + + link2 = next; + } + + return FALSE; + } + + link = next; + } + } + + /* Remove all current watches from previous watch handlers */ + + if (watch_list->remove_watch_function != NULL) + { + _dbus_verbose ("Removing all pre-existing watches\n"); + + _dbus_list_foreach (&watch_list->watches, + (DBusForeachFunction) watch_list->remove_watch_function, + watch_list->watch_data); + } + + if (watch_list->watch_free_data_function != NULL) + (* watch_list->watch_free_data_function) (watch_list->watch_data); + + watch_list->add_watch_function = add_function; + watch_list->remove_watch_function = remove_function; + watch_list->watch_toggled_function = toggled_function; + watch_list->watch_data = data; + watch_list->watch_free_data_function = free_data_function; + + return TRUE; +} + +/** + * Adds a new watch to the watch list, invoking the + * application DBusAddWatchFunction if appropriate. + * + * @param watch_list the watch list. + * @param watch the watch to add. + * @returns #TRUE on success, #FALSE if no memory. + */ +dbus_bool_t +_dbus_watch_list_add_watch (DBusWatchList *watch_list, + DBusWatch *watch) +{ + if (!_dbus_list_append (&watch_list->watches, watch)) + return FALSE; + + _dbus_watch_ref (watch); + + if (watch_list->add_watch_function != NULL) + { + _dbus_verbose ("Adding watch on fd %d\n", + dbus_watch_get_socket (watch)); + + if (!(* watch_list->add_watch_function) (watch, + watch_list->watch_data)) + { + _dbus_list_remove_last (&watch_list->watches, watch); + _dbus_watch_unref (watch); + return FALSE; + } + } + + return TRUE; +} + +/** + * Removes a watch from the watch list, invoking the + * application's DBusRemoveWatchFunction if appropriate. + * + * @param watch_list the watch list. + * @param watch the watch to remove. + */ +void +_dbus_watch_list_remove_watch (DBusWatchList *watch_list, + DBusWatch *watch) +{ + if (!_dbus_list_remove (&watch_list->watches, watch)) + _dbus_assert_not_reached ("Nonexistent watch was removed"); + + if (watch_list->remove_watch_function != NULL) + { + _dbus_verbose ("Removing watch on fd %d\n", + dbus_watch_get_socket (watch)); + + (* watch_list->remove_watch_function) (watch, + watch_list->watch_data); + } + + _dbus_watch_unref (watch); +} + +/** + * Sets a watch to the given enabled state, invoking the + * application's DBusWatchToggledFunction if appropriate. + * + * @param watch_list the watch list. + * @param watch the watch to toggle. + * @param enabled #TRUE to enable + */ +void +_dbus_watch_list_toggle_watch (DBusWatchList *watch_list, + DBusWatch *watch, + dbus_bool_t enabled) +{ + enabled = !!enabled; + + if (enabled == watch->enabled) + return; + + watch->enabled = enabled; + + if (watch_list->watch_toggled_function != NULL) + { + _dbus_verbose ("Toggling watch %p on fd %d to %d\n", + watch, dbus_watch_get_socket (watch), watch->enabled); + + (* watch_list->watch_toggled_function) (watch, + watch_list->watch_data); + } +} + +/** + * Sets the handler for the watch. + * + * @todo this function only exists because of the weird + * way connection watches are done, see the note + * in docs for _dbus_connection_handle_watch(). + * + * @param watch the watch + * @param handler the new handler + * @param data the data + * @param free_data_function free data with this + */ +void +_dbus_watch_set_handler (DBusWatch *watch, + DBusWatchHandler handler, + void *data, + DBusFreeFunction free_data_function) +{ + if (watch->free_handler_data_function) + (* watch->free_handler_data_function) (watch->handler_data); + + watch->handler = handler; + watch->handler_data = data; + watch->free_handler_data_function = free_data_function; +} + +/** @} */ + +/** + * @defgroup DBusWatch DBusWatch + * @ingroup DBus + * @brief Object representing a file descriptor to be watched. + * + * Types and functions related to DBusWatch. A watch represents + * a file descriptor that the main loop needs to monitor, + * as in Qt's QSocketNotifier or GLib's g_io_add_watch(). + * + * Use dbus_connection_set_watch_functions() or dbus_server_set_watch_functions() + * to be notified when libdbus needs to add or remove watches. + * + * @{ + */ + +/** + * @typedef DBusWatch + * + * Opaque object representing a file descriptor + * to be watched for changes in readability, + * writability, or hangup. + */ + +/** + * Deprecated former name of dbus_watch_get_unix_fd(). + * + * @param watch the DBusWatch object. + * @returns the file descriptor to watch. + */ +int +dbus_watch_get_fd (DBusWatch *watch) +{ + return dbus_watch_get_unix_fd(watch); +} + +/** + * Returns a UNIX file descriptor to be watched, + * which may be a pipe, socket, or other type of + * descriptor. On UNIX this is preferred to + * dbus_watch_get_socket() since it works with + * more kinds of #DBusWatch. + * + * Always returns -1 on Windows. On Windows you use + * dbus_watch_get_socket() to get a Winsock socket to watch. + * + * @param watch the DBusWatch object. + * @returns the file descriptor to watch. + */ +int +dbus_watch_get_unix_fd (DBusWatch *watch) +{ + /* FIXME remove #ifdef and do this on a lower level + * (watch should have set_socket and set_unix_fd and track + * which it has, and the transport should provide the + * appropriate watch type) + */ +#ifdef DBUS_UNIX + return watch->fd; +#else + return dbus_watch_get_socket( watch ); +#endif +} + +/** + * Returns a socket to be watched, on UNIX this will return -1 if our + * transport is not socket-based so dbus_watch_get_unix_fd() is + * preferred. + * + * On Windows, dbus_watch_get_unix_fd() returns -1 but this function + * returns a Winsock socket (assuming the transport is socket-based, + * as it always is for now). + * + * @param watch the DBusWatch object. + * @returns the socket to watch. + */ +int +dbus_watch_get_socket (DBusWatch *watch) +{ + return watch->fd; +} + +/** + * Gets flags from DBusWatchFlags indicating + * what conditions should be monitored on the + * file descriptor. + * + * The flags returned will only contain DBUS_WATCH_READABLE + * and DBUS_WATCH_WRITABLE, never DBUS_WATCH_HANGUP or + * DBUS_WATCH_ERROR; all watches implicitly include a watch + * for hangups, errors, and other exceptional conditions. + * + * @param watch the DBusWatch object. + * @returns the conditions to watch. + */ +unsigned int +dbus_watch_get_flags (DBusWatch *watch) +{ + _dbus_assert ((watch->flags & VALID_WATCH_FLAGS) == watch->flags); + + return watch->flags; +} + +/** + * Gets data previously set with dbus_watch_set_data() + * or #NULL if none. + * + * @param watch the DBusWatch object. + * @returns previously-set data. + */ +void* +dbus_watch_get_data (DBusWatch *watch) +{ + return watch->data; +} + +/** + * Sets data which can be retrieved with dbus_watch_get_data(). + * Intended for use by the DBusAddWatchFunction and + * DBusRemoveWatchFunction to store their own data. For example with + * Qt you might store the QSocketNotifier for this watch and with GLib + * you might store a GSource. + * + * @param watch the DBusWatch object. + * @param data the data. + * @param free_data_function function to be called to free the data. + */ +void +dbus_watch_set_data (DBusWatch *watch, + void *data, + DBusFreeFunction free_data_function) +{ + _dbus_verbose ("Setting watch fd %d data to data = %p function = %p from data = %p function = %p\n", + dbus_watch_get_socket (watch), + data, free_data_function, watch->data, watch->free_data_function); + + if (watch->free_data_function != NULL) + (* watch->free_data_function) (watch->data); + + watch->data = data; + watch->free_data_function = free_data_function; +} + +/** + * Returns whether a watch is enabled or not. If not + * enabled, it should not be polled by the main loop. + * + * @param watch the DBusWatch object + * @returns #TRUE if the watch is enabled + */ +dbus_bool_t +dbus_watch_get_enabled (DBusWatch *watch) +{ + _dbus_assert (watch != NULL); + return watch->enabled; +} + + +/** + * Called to notify the D-Bus library when a previously-added watch is + * ready for reading or writing, or has an exception such as a hangup. + * + * If this function returns #FALSE, then the file descriptor may still + * be ready for reading or writing, but more memory is needed in order + * to do the reading or writing. If you ignore the #FALSE return, your + * application may spin in a busy loop on the file descriptor until + * memory becomes available, but nothing more catastrophic should + * happen. + * + * dbus_watch_handle() cannot be called during the + * DBusAddWatchFunction, as the connection will not be ready to handle + * that watch yet. + * + * It is not allowed to reference a DBusWatch after it has been passed + * to remove_function. + * + * @param watch the DBusWatch object. + * @param flags the poll condition using #DBusWatchFlags values + * @returns #FALSE if there wasn't enough memory + */ +dbus_bool_t +dbus_watch_handle (DBusWatch *watch, + unsigned int flags) +{ +#ifndef DBUS_DISABLE_CHECKS + if (watch->fd < 0 || watch->flags == 0) + { + _dbus_warn_check_failed ("%s: Watch is invalid, it should have been removed\n", + _DBUS_FUNCTION_NAME); + return TRUE; + } +#endif + + _dbus_return_val_if_fail (watch->fd >= 0 /* fails if watch was removed */, TRUE); + + _dbus_watch_sanitize_condition (watch, &flags); + + if (flags == 0) + { + _dbus_verbose ("After sanitization, watch flags on fd %d were 0\n", + watch->fd); + return TRUE; + } + else + return (* watch->handler) (watch, flags, + watch->handler_data); +} + + +/** @} */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <che...@us...> - 2008-10-26 20:03:07
|
Revision: 799 http://windbus.svn.sourceforge.net/windbus/?rev=799&view=rev Author: chehrlic Date: 2008-10-26 20:03:02 +0000 (Sun, 26 Oct 2008) Log Message: ----------- fix dbus_watch_get_unix_fd() Added Paths: ----------- tags/1.2.3/dbus/dbus-watch.c Copied: tags/1.2.3/dbus/dbus-watch.c (from rev 798, trunk/dbus/dbus-watch.c) =================================================================== --- tags/1.2.3/dbus/dbus-watch.c (rev 0) +++ tags/1.2.3/dbus/dbus-watch.c 2008-10-26 20:03:02 UTC (rev 799) @@ -0,0 +1,668 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ +/* dbus-watch.c DBusWatch implementation + * + * Copyright (C) 2002, 2003 Red Hat Inc. + * + * Licensed under the Academic Free License version 2.1 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include "dbus-internals.h" +#include "dbus-watch.h" +#include "dbus-list.h" + +/** + * @defgroup DBusWatchInternals DBusWatch implementation details + * @ingroup DBusInternals + * @brief implementation details for DBusWatch + * + * @{ + */ + +/** + * Implementation of DBusWatch + */ +struct DBusWatch +{ + int refcount; /**< Reference count */ + int fd; /**< File descriptor. */ + unsigned int flags; /**< Conditions to watch. */ + + DBusWatchHandler handler; /**< Watch handler. */ + void *handler_data; /**< Watch handler data. */ + DBusFreeFunction free_handler_data_function; /**< Free the watch handler data. */ + + void *data; /**< Application data. */ + DBusFreeFunction free_data_function; /**< Free the application data. */ + unsigned int enabled : 1; /**< Whether it's enabled. */ +}; + +/** + * Creates a new DBusWatch. Used to add a file descriptor to be polled + * by a main loop. + * + * @param fd the file descriptor to be watched. + * @param flags the conditions to watch for on the descriptor. + * @param enabled the initial enabled state + * @param handler the handler function + * @param data data for handler function + * @param free_data_function function to free the data + * @returns the new DBusWatch object. + */ +DBusWatch* +_dbus_watch_new (int fd, + unsigned int flags, + dbus_bool_t enabled, + DBusWatchHandler handler, + void *data, + DBusFreeFunction free_data_function) +{ + DBusWatch *watch; + +#define VALID_WATCH_FLAGS (DBUS_WATCH_WRITABLE | DBUS_WATCH_READABLE) + + _dbus_assert ((flags & VALID_WATCH_FLAGS) == flags); + + watch = dbus_new0 (DBusWatch, 1); + if (watch == NULL) + return NULL; + + watch->refcount = 1; + watch->fd = fd; + watch->flags = flags; + watch->enabled = enabled; + + watch->handler = handler; + watch->handler_data = data; + watch->free_handler_data_function = free_data_function; + + return watch; +} + +/** + * Increments the reference count of a DBusWatch object. + * + * @param watch the watch object. + * @returns the watch object. + */ +DBusWatch * +_dbus_watch_ref (DBusWatch *watch) +{ + watch->refcount += 1; + + return watch; +} + +/** + * Decrements the reference count of a DBusWatch object + * and finalizes the object if the count reaches zero. + * + * @param watch the watch object. + */ +void +_dbus_watch_unref (DBusWatch *watch) +{ + _dbus_assert (watch != NULL); + _dbus_assert (watch->refcount > 0); + + watch->refcount -= 1; + if (watch->refcount == 0) + { + dbus_watch_set_data (watch, NULL, NULL); /* call free_data_function */ + + if (watch->free_handler_data_function) + (* watch->free_handler_data_function) (watch->handler_data); + + dbus_free (watch); + } +} + +/** + * Clears the file descriptor from a now-invalid watch object so that + * no one tries to use it. This is because a watch may stay alive due + * to reference counts after the file descriptor is closed. + * Invalidation makes it easier to catch bugs. It also + * keeps people from doing dorky things like assuming file descriptors + * are unique (never recycled). + * + * @param watch the watch object. + */ +void +_dbus_watch_invalidate (DBusWatch *watch) +{ + watch->fd = -1; + watch->flags = 0; +} + +/** + * Sanitizes the given condition so that it only contains + * flags that the DBusWatch requested. e.g. if the + * watch is a DBUS_WATCH_READABLE watch then + * DBUS_WATCH_WRITABLE will be stripped from the condition. + * + * @param watch the watch object. + * @param condition address of the condition to sanitize. + */ +void +_dbus_watch_sanitize_condition (DBusWatch *watch, + unsigned int *condition) +{ + if (!(watch->flags & DBUS_WATCH_READABLE)) + *condition &= ~DBUS_WATCH_READABLE; + if (!(watch->flags & DBUS_WATCH_WRITABLE)) + *condition &= ~DBUS_WATCH_WRITABLE; +} + + +/** + * @typedef DBusWatchList + * + * Opaque data type representing a list of watches + * and a set of DBusAddWatchFunction/DBusRemoveWatchFunction. + * Automatically handles removing/re-adding watches + * when the DBusAddWatchFunction is updated or changed. + * Holds a reference count to each watch. + * + * Used in the implementation of both DBusServer and + * DBusClient. + * + */ + +/** + * DBusWatchList implementation details. All fields + * are private. + * + */ +struct DBusWatchList +{ + DBusList *watches; /**< Watch objects. */ + + DBusAddWatchFunction add_watch_function; /**< Callback for adding a watch. */ + DBusRemoveWatchFunction remove_watch_function; /**< Callback for removing a watch. */ + DBusWatchToggledFunction watch_toggled_function; /**< Callback on toggling enablement */ + void *watch_data; /**< Data for watch callbacks */ + DBusFreeFunction watch_free_data_function; /**< Free function for watch callback data */ +}; + +/** + * Creates a new watch list. Returns #NULL if insufficient + * memory exists. + * + * @returns the new watch list, or #NULL on failure. + */ +DBusWatchList* +_dbus_watch_list_new (void) +{ + DBusWatchList *watch_list; + + watch_list = dbus_new0 (DBusWatchList, 1); + if (watch_list == NULL) + return NULL; + + return watch_list; +} + +/** + * Frees a DBusWatchList. + * + * @param watch_list the watch list. + */ +void +_dbus_watch_list_free (DBusWatchList *watch_list) +{ + /* free watch_data and removes watches as a side effect */ + _dbus_watch_list_set_functions (watch_list, + NULL, NULL, NULL, NULL, NULL); + _dbus_list_foreach (&watch_list->watches, + (DBusForeachFunction) _dbus_watch_unref, + NULL); + _dbus_list_clear (&watch_list->watches); + + dbus_free (watch_list); +} + +/** + * Sets the watch functions. This function is the "backend" + * for dbus_connection_set_watch_functions() and + * dbus_server_set_watch_functions(). + * + * @param watch_list the watch list. + * @param add_function the add watch function. + * @param remove_function the remove watch function. + * @param toggled_function function on toggling enabled flag, or #NULL + * @param data the data for those functions. + * @param free_data_function the function to free the data. + * @returns #FALSE if not enough memory + * + */ +dbus_bool_t +_dbus_watch_list_set_functions (DBusWatchList *watch_list, + DBusAddWatchFunction add_function, + DBusRemoveWatchFunction remove_function, + DBusWatchToggledFunction toggled_function, + void *data, + DBusFreeFunction free_data_function) +{ + /* Add watches with the new watch function, failing on OOM */ + if (add_function != NULL) + { + DBusList *link; + + link = _dbus_list_get_first_link (&watch_list->watches); + while (link != NULL) + { + DBusList *next = _dbus_list_get_next_link (&watch_list->watches, + link); + +#ifdef DBUS_ENABLE_VERBOSE_MODE + { + const char *watch_type; + int flags; + + flags = dbus_watch_get_flags (link->data); + if ((flags & DBUS_WATCH_READABLE) && + (flags & DBUS_WATCH_WRITABLE)) + watch_type = "readwrite"; + else if (flags & DBUS_WATCH_READABLE) + watch_type = "read"; + else if (flags & DBUS_WATCH_WRITABLE) + watch_type = "write"; + else + watch_type = "not read or write"; + + _dbus_verbose ("Adding a %s watch on fd %d using newly-set add watch function\n", + watch_type, + dbus_watch_get_socket (link->data)); + } +#endif /* DBUS_ENABLE_VERBOSE_MODE */ + + if (!(* add_function) (link->data, data)) + { + /* remove it all again and return FALSE */ + DBusList *link2; + + link2 = _dbus_list_get_first_link (&watch_list->watches); + while (link2 != link) + { + DBusList *next = _dbus_list_get_next_link (&watch_list->watches, + link2); + + _dbus_verbose ("Removing watch on fd %d using newly-set remove function because initial add failed\n", + dbus_watch_get_socket (link2->data)); + + (* remove_function) (link2->data, data); + + link2 = next; + } + + return FALSE; + } + + link = next; + } + } + + /* Remove all current watches from previous watch handlers */ + + if (watch_list->remove_watch_function != NULL) + { + _dbus_verbose ("Removing all pre-existing watches\n"); + + _dbus_list_foreach (&watch_list->watches, + (DBusForeachFunction) watch_list->remove_watch_function, + watch_list->watch_data); + } + + if (watch_list->watch_free_data_function != NULL) + (* watch_list->watch_free_data_function) (watch_list->watch_data); + + watch_list->add_watch_function = add_function; + watch_list->remove_watch_function = remove_function; + watch_list->watch_toggled_function = toggled_function; + watch_list->watch_data = data; + watch_list->watch_free_data_function = free_data_function; + + return TRUE; +} + +/** + * Adds a new watch to the watch list, invoking the + * application DBusAddWatchFunction if appropriate. + * + * @param watch_list the watch list. + * @param watch the watch to add. + * @returns #TRUE on success, #FALSE if no memory. + */ +dbus_bool_t +_dbus_watch_list_add_watch (DBusWatchList *watch_list, + DBusWatch *watch) +{ + if (!_dbus_list_append (&watch_list->watches, watch)) + return FALSE; + + _dbus_watch_ref (watch); + + if (watch_list->add_watch_function != NULL) + { + _dbus_verbose ("Adding watch on fd %d\n", + dbus_watch_get_socket (watch)); + + if (!(* watch_list->add_watch_function) (watch, + watch_list->watch_data)) + { + _dbus_list_remove_last (&watch_list->watches, watch); + _dbus_watch_unref (watch); + return FALSE; + } + } + + return TRUE; +} + +/** + * Removes a watch from the watch list, invoking the + * application's DBusRemoveWatchFunction if appropriate. + * + * @param watch_list the watch list. + * @param watch the watch to remove. + */ +void +_dbus_watch_list_remove_watch (DBusWatchList *watch_list, + DBusWatch *watch) +{ + if (!_dbus_list_remove (&watch_list->watches, watch)) + _dbus_assert_not_reached ("Nonexistent watch was removed"); + + if (watch_list->remove_watch_function != NULL) + { + _dbus_verbose ("Removing watch on fd %d\n", + dbus_watch_get_socket (watch)); + + (* watch_list->remove_watch_function) (watch, + watch_list->watch_data); + } + + _dbus_watch_unref (watch); +} + +/** + * Sets a watch to the given enabled state, invoking the + * application's DBusWatchToggledFunction if appropriate. + * + * @param watch_list the watch list. + * @param watch the watch to toggle. + * @param enabled #TRUE to enable + */ +void +_dbus_watch_list_toggle_watch (DBusWatchList *watch_list, + DBusWatch *watch, + dbus_bool_t enabled) +{ + enabled = !!enabled; + + if (enabled == watch->enabled) + return; + + watch->enabled = enabled; + + if (watch_list->watch_toggled_function != NULL) + { + _dbus_verbose ("Toggling watch %p on fd %d to %d\n", + watch, dbus_watch_get_socket (watch), watch->enabled); + + (* watch_list->watch_toggled_function) (watch, + watch_list->watch_data); + } +} + +/** + * Sets the handler for the watch. + * + * @todo this function only exists because of the weird + * way connection watches are done, see the note + * in docs for _dbus_connection_handle_watch(). + * + * @param watch the watch + * @param handler the new handler + * @param data the data + * @param free_data_function free data with this + */ +void +_dbus_watch_set_handler (DBusWatch *watch, + DBusWatchHandler handler, + void *data, + DBusFreeFunction free_data_function) +{ + if (watch->free_handler_data_function) + (* watch->free_handler_data_function) (watch->handler_data); + + watch->handler = handler; + watch->handler_data = data; + watch->free_handler_data_function = free_data_function; +} + +/** @} */ + +/** + * @defgroup DBusWatch DBusWatch + * @ingroup DBus + * @brief Object representing a file descriptor to be watched. + * + * Types and functions related to DBusWatch. A watch represents + * a file descriptor that the main loop needs to monitor, + * as in Qt's QSocketNotifier or GLib's g_io_add_watch(). + * + * Use dbus_connection_set_watch_functions() or dbus_server_set_watch_functions() + * to be notified when libdbus needs to add or remove watches. + * + * @{ + */ + +/** + * @typedef DBusWatch + * + * Opaque object representing a file descriptor + * to be watched for changes in readability, + * writability, or hangup. + */ + +/** + * Deprecated former name of dbus_watch_get_unix_fd(). + * + * @param watch the DBusWatch object. + * @returns the file descriptor to watch. + */ +int +dbus_watch_get_fd (DBusWatch *watch) +{ + return dbus_watch_get_unix_fd(watch); +} + +/** + * Returns a UNIX file descriptor to be watched, + * which may be a pipe, socket, or other type of + * descriptor. On UNIX this is preferred to + * dbus_watch_get_socket() since it works with + * more kinds of #DBusWatch. + * + * Always returns -1 on Windows. On Windows you use + * dbus_watch_get_socket() to get a Winsock socket to watch. + * + * @param watch the DBusWatch object. + * @returns the file descriptor to watch. + */ +int +dbus_watch_get_unix_fd (DBusWatch *watch) +{ + /* FIXME remove #ifdef and do this on a lower level + * (watch should have set_socket and set_unix_fd and track + * which it has, and the transport should provide the + * appropriate watch type) + */ +#ifdef DBUS_UNIX + return watch->fd; +#else + return dbus_watch_get_socket( watch ); +#endif +} + +/** + * Returns a socket to be watched, on UNIX this will return -1 if our + * transport is not socket-based so dbus_watch_get_unix_fd() is + * preferred. + * + * On Windows, dbus_watch_get_unix_fd() returns -1 but this function + * returns a Winsock socket (assuming the transport is socket-based, + * as it always is for now). + * + * @param watch the DBusWatch object. + * @returns the socket to watch. + */ +int +dbus_watch_get_socket (DBusWatch *watch) +{ + return watch->fd; +} + +/** + * Gets flags from DBusWatchFlags indicating + * what conditions should be monitored on the + * file descriptor. + * + * The flags returned will only contain DBUS_WATCH_READABLE + * and DBUS_WATCH_WRITABLE, never DBUS_WATCH_HANGUP or + * DBUS_WATCH_ERROR; all watches implicitly include a watch + * for hangups, errors, and other exceptional conditions. + * + * @param watch the DBusWatch object. + * @returns the conditions to watch. + */ +unsigned int +dbus_watch_get_flags (DBusWatch *watch) +{ + _dbus_assert ((watch->flags & VALID_WATCH_FLAGS) == watch->flags); + + return watch->flags; +} + +/** + * Gets data previously set with dbus_watch_set_data() + * or #NULL if none. + * + * @param watch the DBusWatch object. + * @returns previously-set data. + */ +void* +dbus_watch_get_data (DBusWatch *watch) +{ + return watch->data; +} + +/** + * Sets data which can be retrieved with dbus_watch_get_data(). + * Intended for use by the DBusAddWatchFunction and + * DBusRemoveWatchFunction to store their own data. For example with + * Qt you might store the QSocketNotifier for this watch and with GLib + * you might store a GSource. + * + * @param watch the DBusWatch object. + * @param data the data. + * @param free_data_function function to be called to free the data. + */ +void +dbus_watch_set_data (DBusWatch *watch, + void *data, + DBusFreeFunction free_data_function) +{ + _dbus_verbose ("Setting watch fd %d data to data = %p function = %p from data = %p function = %p\n", + dbus_watch_get_socket (watch), + data, free_data_function, watch->data, watch->free_data_function); + + if (watch->free_data_function != NULL) + (* watch->free_data_function) (watch->data); + + watch->data = data; + watch->free_data_function = free_data_function; +} + +/** + * Returns whether a watch is enabled or not. If not + * enabled, it should not be polled by the main loop. + * + * @param watch the DBusWatch object + * @returns #TRUE if the watch is enabled + */ +dbus_bool_t +dbus_watch_get_enabled (DBusWatch *watch) +{ + _dbus_assert (watch != NULL); + return watch->enabled; +} + + +/** + * Called to notify the D-Bus library when a previously-added watch is + * ready for reading or writing, or has an exception such as a hangup. + * + * If this function returns #FALSE, then the file descriptor may still + * be ready for reading or writing, but more memory is needed in order + * to do the reading or writing. If you ignore the #FALSE return, your + * application may spin in a busy loop on the file descriptor until + * memory becomes available, but nothing more catastrophic should + * happen. + * + * dbus_watch_handle() cannot be called during the + * DBusAddWatchFunction, as the connection will not be ready to handle + * that watch yet. + * + * It is not allowed to reference a DBusWatch after it has been passed + * to remove_function. + * + * @param watch the DBusWatch object. + * @param flags the poll condition using #DBusWatchFlags values + * @returns #FALSE if there wasn't enough memory + */ +dbus_bool_t +dbus_watch_handle (DBusWatch *watch, + unsigned int flags) +{ +#ifndef DBUS_DISABLE_CHECKS + if (watch->fd < 0 || watch->flags == 0) + { + _dbus_warn_check_failed ("%s: Watch is invalid, it should have been removed\n", + _DBUS_FUNCTION_NAME); + return TRUE; + } +#endif + + _dbus_return_val_if_fail (watch->fd >= 0 /* fails if watch was removed */, TRUE); + + _dbus_watch_sanitize_condition (watch, &flags); + + if (flags == 0) + { + _dbus_verbose ("After sanitization, watch flags on fd %d were 0\n", + watch->fd); + return TRUE; + } + else + return (* watch->handler) (watch, flags, + watch->handler_data); +} + + +/** @} */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <che...@us...> - 2008-10-26 20:02:22
|
Revision: 798 http://windbus.svn.sourceforge.net/windbus/?rev=798&view=rev Author: chehrlic Date: 2008-10-26 20:02:16 +0000 (Sun, 26 Oct 2008) Log Message: ----------- this one is wrong Removed Paths: ------------- tags/1.2.4/dbus/dbus-watch.c Deleted: tags/1.2.4/dbus/dbus-watch.c =================================================================== --- tags/1.2.4/dbus/dbus-watch.c 2008-10-26 20:02:05 UTC (rev 797) +++ tags/1.2.4/dbus/dbus-watch.c 2008-10-26 20:02:16 UTC (rev 798) @@ -1,668 +0,0 @@ -/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ -/* dbus-watch.c DBusWatch implementation - * - * Copyright (C) 2002, 2003 Red Hat Inc. - * - * Licensed under the Academic Free License version 2.1 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#include "dbus-internals.h" -#include "dbus-watch.h" -#include "dbus-list.h" - -/** - * @defgroup DBusWatchInternals DBusWatch implementation details - * @ingroup DBusInternals - * @brief implementation details for DBusWatch - * - * @{ - */ - -/** - * Implementation of DBusWatch - */ -struct DBusWatch -{ - int refcount; /**< Reference count */ - int fd; /**< File descriptor. */ - unsigned int flags; /**< Conditions to watch. */ - - DBusWatchHandler handler; /**< Watch handler. */ - void *handler_data; /**< Watch handler data. */ - DBusFreeFunction free_handler_data_function; /**< Free the watch handler data. */ - - void *data; /**< Application data. */ - DBusFreeFunction free_data_function; /**< Free the application data. */ - unsigned int enabled : 1; /**< Whether it's enabled. */ -}; - -/** - * Creates a new DBusWatch. Used to add a file descriptor to be polled - * by a main loop. - * - * @param fd the file descriptor to be watched. - * @param flags the conditions to watch for on the descriptor. - * @param enabled the initial enabled state - * @param handler the handler function - * @param data data for handler function - * @param free_data_function function to free the data - * @returns the new DBusWatch object. - */ -DBusWatch* -_dbus_watch_new (int fd, - unsigned int flags, - dbus_bool_t enabled, - DBusWatchHandler handler, - void *data, - DBusFreeFunction free_data_function) -{ - DBusWatch *watch; - -#define VALID_WATCH_FLAGS (DBUS_WATCH_WRITABLE | DBUS_WATCH_READABLE) - - _dbus_assert ((flags & VALID_WATCH_FLAGS) == flags); - - watch = dbus_new0 (DBusWatch, 1); - if (watch == NULL) - return NULL; - - watch->refcount = 1; - watch->fd = fd; - watch->flags = flags; - watch->enabled = enabled; - - watch->handler = handler; - watch->handler_data = data; - watch->free_handler_data_function = free_data_function; - - return watch; -} - -/** - * Increments the reference count of a DBusWatch object. - * - * @param watch the watch object. - * @returns the watch object. - */ -DBusWatch * -_dbus_watch_ref (DBusWatch *watch) -{ - watch->refcount += 1; - - return watch; -} - -/** - * Decrements the reference count of a DBusWatch object - * and finalizes the object if the count reaches zero. - * - * @param watch the watch object. - */ -void -_dbus_watch_unref (DBusWatch *watch) -{ - _dbus_assert (watch != NULL); - _dbus_assert (watch->refcount > 0); - - watch->refcount -= 1; - if (watch->refcount == 0) - { - dbus_watch_set_data (watch, NULL, NULL); /* call free_data_function */ - - if (watch->free_handler_data_function) - (* watch->free_handler_data_function) (watch->handler_data); - - dbus_free (watch); - } -} - -/** - * Clears the file descriptor from a now-invalid watch object so that - * no one tries to use it. This is because a watch may stay alive due - * to reference counts after the file descriptor is closed. - * Invalidation makes it easier to catch bugs. It also - * keeps people from doing dorky things like assuming file descriptors - * are unique (never recycled). - * - * @param watch the watch object. - */ -void -_dbus_watch_invalidate (DBusWatch *watch) -{ - watch->fd = -1; - watch->flags = 0; -} - -/** - * Sanitizes the given condition so that it only contains - * flags that the DBusWatch requested. e.g. if the - * watch is a DBUS_WATCH_READABLE watch then - * DBUS_WATCH_WRITABLE will be stripped from the condition. - * - * @param watch the watch object. - * @param condition address of the condition to sanitize. - */ -void -_dbus_watch_sanitize_condition (DBusWatch *watch, - unsigned int *condition) -{ - if (!(watch->flags & DBUS_WATCH_READABLE)) - *condition &= ~DBUS_WATCH_READABLE; - if (!(watch->flags & DBUS_WATCH_WRITABLE)) - *condition &= ~DBUS_WATCH_WRITABLE; -} - - -/** - * @typedef DBusWatchList - * - * Opaque data type representing a list of watches - * and a set of DBusAddWatchFunction/DBusRemoveWatchFunction. - * Automatically handles removing/re-adding watches - * when the DBusAddWatchFunction is updated or changed. - * Holds a reference count to each watch. - * - * Used in the implementation of both DBusServer and - * DBusClient. - * - */ - -/** - * DBusWatchList implementation details. All fields - * are private. - * - */ -struct DBusWatchList -{ - DBusList *watches; /**< Watch objects. */ - - DBusAddWatchFunction add_watch_function; /**< Callback for adding a watch. */ - DBusRemoveWatchFunction remove_watch_function; /**< Callback for removing a watch. */ - DBusWatchToggledFunction watch_toggled_function; /**< Callback on toggling enablement */ - void *watch_data; /**< Data for watch callbacks */ - DBusFreeFunction watch_free_data_function; /**< Free function for watch callback data */ -}; - -/** - * Creates a new watch list. Returns #NULL if insufficient - * memory exists. - * - * @returns the new watch list, or #NULL on failure. - */ -DBusWatchList* -_dbus_watch_list_new (void) -{ - DBusWatchList *watch_list; - - watch_list = dbus_new0 (DBusWatchList, 1); - if (watch_list == NULL) - return NULL; - - return watch_list; -} - -/** - * Frees a DBusWatchList. - * - * @param watch_list the watch list. - */ -void -_dbus_watch_list_free (DBusWatchList *watch_list) -{ - /* free watch_data and removes watches as a side effect */ - _dbus_watch_list_set_functions (watch_list, - NULL, NULL, NULL, NULL, NULL); - _dbus_list_foreach (&watch_list->watches, - (DBusForeachFunction) _dbus_watch_unref, - NULL); - _dbus_list_clear (&watch_list->watches); - - dbus_free (watch_list); -} - -/** - * Sets the watch functions. This function is the "backend" - * for dbus_connection_set_watch_functions() and - * dbus_server_set_watch_functions(). - * - * @param watch_list the watch list. - * @param add_function the add watch function. - * @param remove_function the remove watch function. - * @param toggled_function function on toggling enabled flag, or #NULL - * @param data the data for those functions. - * @param free_data_function the function to free the data. - * @returns #FALSE if not enough memory - * - */ -dbus_bool_t -_dbus_watch_list_set_functions (DBusWatchList *watch_list, - DBusAddWatchFunction add_function, - DBusRemoveWatchFunction remove_function, - DBusWatchToggledFunction toggled_function, - void *data, - DBusFreeFunction free_data_function) -{ - /* Add watches with the new watch function, failing on OOM */ - if (add_function != NULL) - { - DBusList *link; - - link = _dbus_list_get_first_link (&watch_list->watches); - while (link != NULL) - { - DBusList *next = _dbus_list_get_next_link (&watch_list->watches, - link); - -#ifdef DBUS_ENABLE_VERBOSE_MODE - { - const char *watch_type; - int flags; - - flags = dbus_watch_get_flags (link->data); - if ((flags & DBUS_WATCH_READABLE) && - (flags & DBUS_WATCH_WRITABLE)) - watch_type = "readwrite"; - else if (flags & DBUS_WATCH_READABLE) - watch_type = "read"; - else if (flags & DBUS_WATCH_WRITABLE) - watch_type = "write"; - else - watch_type = "not read or write"; - - _dbus_verbose ("Adding a %s watch on fd %d using newly-set add watch function\n", - watch_type, - dbus_watch_get_socket (link->data)); - } -#endif /* DBUS_ENABLE_VERBOSE_MODE */ - - if (!(* add_function) (link->data, data)) - { - /* remove it all again and return FALSE */ - DBusList *link2; - - link2 = _dbus_list_get_first_link (&watch_list->watches); - while (link2 != link) - { - DBusList *next = _dbus_list_get_next_link (&watch_list->watches, - link2); - - _dbus_verbose ("Removing watch on fd %d using newly-set remove function because initial add failed\n", - dbus_watch_get_socket (link2->data)); - - (* remove_function) (link2->data, data); - - link2 = next; - } - - return FALSE; - } - - link = next; - } - } - - /* Remove all current watches from previous watch handlers */ - - if (watch_list->remove_watch_function != NULL) - { - _dbus_verbose ("Removing all pre-existing watches\n"); - - _dbus_list_foreach (&watch_list->watches, - (DBusForeachFunction) watch_list->remove_watch_function, - watch_list->watch_data); - } - - if (watch_list->watch_free_data_function != NULL) - (* watch_list->watch_free_data_function) (watch_list->watch_data); - - watch_list->add_watch_function = add_function; - watch_list->remove_watch_function = remove_function; - watch_list->watch_toggled_function = toggled_function; - watch_list->watch_data = data; - watch_list->watch_free_data_function = free_data_function; - - return TRUE; -} - -/** - * Adds a new watch to the watch list, invoking the - * application DBusAddWatchFunction if appropriate. - * - * @param watch_list the watch list. - * @param watch the watch to add. - * @returns #TRUE on success, #FALSE if no memory. - */ -dbus_bool_t -_dbus_watch_list_add_watch (DBusWatchList *watch_list, - DBusWatch *watch) -{ - if (!_dbus_list_append (&watch_list->watches, watch)) - return FALSE; - - _dbus_watch_ref (watch); - - if (watch_list->add_watch_function != NULL) - { - _dbus_verbose ("Adding watch on fd %d\n", - dbus_watch_get_socket (watch)); - - if (!(* watch_list->add_watch_function) (watch, - watch_list->watch_data)) - { - _dbus_list_remove_last (&watch_list->watches, watch); - _dbus_watch_unref (watch); - return FALSE; - } - } - - return TRUE; -} - -/** - * Removes a watch from the watch list, invoking the - * application's DBusRemoveWatchFunction if appropriate. - * - * @param watch_list the watch list. - * @param watch the watch to remove. - */ -void -_dbus_watch_list_remove_watch (DBusWatchList *watch_list, - DBusWatch *watch) -{ - if (!_dbus_list_remove (&watch_list->watches, watch)) - _dbus_assert_not_reached ("Nonexistent watch was removed"); - - if (watch_list->remove_watch_function != NULL) - { - _dbus_verbose ("Removing watch on fd %d\n", - dbus_watch_get_socket (watch)); - - (* watch_list->remove_watch_function) (watch, - watch_list->watch_data); - } - - _dbus_watch_unref (watch); -} - -/** - * Sets a watch to the given enabled state, invoking the - * application's DBusWatchToggledFunction if appropriate. - * - * @param watch_list the watch list. - * @param watch the watch to toggle. - * @param enabled #TRUE to enable - */ -void -_dbus_watch_list_toggle_watch (DBusWatchList *watch_list, - DBusWatch *watch, - dbus_bool_t enabled) -{ - enabled = !!enabled; - - if (enabled == watch->enabled) - return; - - watch->enabled = enabled; - - if (watch_list->watch_toggled_function != NULL) - { - _dbus_verbose ("Toggling watch %p on fd %d to %d\n", - watch, dbus_watch_get_socket (watch), watch->enabled); - - (* watch_list->watch_toggled_function) (watch, - watch_list->watch_data); - } -} - -/** - * Sets the handler for the watch. - * - * @todo this function only exists because of the weird - * way connection watches are done, see the note - * in docs for _dbus_connection_handle_watch(). - * - * @param watch the watch - * @param handler the new handler - * @param data the data - * @param free_data_function free data with this - */ -void -_dbus_watch_set_handler (DBusWatch *watch, - DBusWatchHandler handler, - void *data, - DBusFreeFunction free_data_function) -{ - if (watch->free_handler_data_function) - (* watch->free_handler_data_function) (watch->handler_data); - - watch->handler = handler; - watch->handler_data = data; - watch->free_handler_data_function = free_data_function; -} - -/** @} */ - -/** - * @defgroup DBusWatch DBusWatch - * @ingroup DBus - * @brief Object representing a file descriptor to be watched. - * - * Types and functions related to DBusWatch. A watch represents - * a file descriptor that the main loop needs to monitor, - * as in Qt's QSocketNotifier or GLib's g_io_add_watch(). - * - * Use dbus_connection_set_watch_functions() or dbus_server_set_watch_functions() - * to be notified when libdbus needs to add or remove watches. - * - * @{ - */ - -/** - * @typedef DBusWatch - * - * Opaque object representing a file descriptor - * to be watched for changes in readability, - * writability, or hangup. - */ - -/** - * Deprecated former name of dbus_watch_get_unix_fd(). - * - * @param watch the DBusWatch object. - * @returns the file descriptor to watch. - */ -int -dbus_watch_get_fd (DBusWatch *watch) -{ - return dbus_watch_get_unix_fd(watch); -} - -/** - * Returns a UNIX file descriptor to be watched, - * which may be a pipe, socket, or other type of - * descriptor. On UNIX this is preferred to - * dbus_watch_get_socket() since it works with - * more kinds of #DBusWatch. - * - * Always returns -1 on Windows. On Windows you use - * dbus_watch_get_socket() to get a Winsock socket to watch. - * - * @param watch the DBusWatch object. - * @returns the file descriptor to watch. - */ -int -dbus_watch_get_unix_fd (DBusWatch *watch) -{ - /* FIXME remove #ifdef and do this on a lower level - * (watch should have set_socket and set_unix_fd and track - * which it has, and the transport should provide the - * appropriate watch type) - */ -#ifdef DBUS_UNIX - return watch->fd; -#else - return -1; -#endif -} - -/** - * Returns a socket to be watched, on UNIX this will return -1 if our - * transport is not socket-based so dbus_watch_get_unix_fd() is - * preferred. - * - * On Windows, dbus_watch_get_unix_fd() returns -1 but this function - * returns a Winsock socket (assuming the transport is socket-based, - * as it always is for now). - * - * @param watch the DBusWatch object. - * @returns the socket to watch. - */ -int -dbus_watch_get_socket (DBusWatch *watch) -{ - return watch->fd; -} - -/** - * Gets flags from DBusWatchFlags indicating - * what conditions should be monitored on the - * file descriptor. - * - * The flags returned will only contain DBUS_WATCH_READABLE - * and DBUS_WATCH_WRITABLE, never DBUS_WATCH_HANGUP or - * DBUS_WATCH_ERROR; all watches implicitly include a watch - * for hangups, errors, and other exceptional conditions. - * - * @param watch the DBusWatch object. - * @returns the conditions to watch. - */ -unsigned int -dbus_watch_get_flags (DBusWatch *watch) -{ - _dbus_assert ((watch->flags & VALID_WATCH_FLAGS) == watch->flags); - - return watch->flags; -} - -/** - * Gets data previously set with dbus_watch_set_data() - * or #NULL if none. - * - * @param watch the DBusWatch object. - * @returns previously-set data. - */ -void* -dbus_watch_get_data (DBusWatch *watch) -{ - return watch->data; -} - -/** - * Sets data which can be retrieved with dbus_watch_get_data(). - * Intended for use by the DBusAddWatchFunction and - * DBusRemoveWatchFunction to store their own data. For example with - * Qt you might store the QSocketNotifier for this watch and with GLib - * you might store a GSource. - * - * @param watch the DBusWatch object. - * @param data the data. - * @param free_data_function function to be called to free the data. - */ -void -dbus_watch_set_data (DBusWatch *watch, - void *data, - DBusFreeFunction free_data_function) -{ - _dbus_verbose ("Setting watch fd %d data to data = %p function = %p from data = %p function = %p\n", - dbus_watch_get_socket (watch), - data, free_data_function, watch->data, watch->free_data_function); - - if (watch->free_data_function != NULL) - (* watch->free_data_function) (watch->data); - - watch->data = data; - watch->free_data_function = free_data_function; -} - -/** - * Returns whether a watch is enabled or not. If not - * enabled, it should not be polled by the main loop. - * - * @param watch the DBusWatch object - * @returns #TRUE if the watch is enabled - */ -dbus_bool_t -dbus_watch_get_enabled (DBusWatch *watch) -{ - _dbus_assert (watch != NULL); - return watch->enabled; -} - - -/** - * Called to notify the D-Bus library when a previously-added watch is - * ready for reading or writing, or has an exception such as a hangup. - * - * If this function returns #FALSE, then the file descriptor may still - * be ready for reading or writing, but more memory is needed in order - * to do the reading or writing. If you ignore the #FALSE return, your - * application may spin in a busy loop on the file descriptor until - * memory becomes available, but nothing more catastrophic should - * happen. - * - * dbus_watch_handle() cannot be called during the - * DBusAddWatchFunction, as the connection will not be ready to handle - * that watch yet. - * - * It is not allowed to reference a DBusWatch after it has been passed - * to remove_function. - * - * @param watch the DBusWatch object. - * @param flags the poll condition using #DBusWatchFlags values - * @returns #FALSE if there wasn't enough memory - */ -dbus_bool_t -dbus_watch_handle (DBusWatch *watch, - unsigned int flags) -{ -#ifndef DBUS_DISABLE_CHECKS - if (watch->fd < 0 || watch->flags == 0) - { - _dbus_warn_check_failed ("%s: Watch is invalid, it should have been removed\n", - _DBUS_FUNCTION_NAME); - return TRUE; - } -#endif - - _dbus_return_val_if_fail (watch->fd >= 0 /* fails if watch was removed */, TRUE); - - _dbus_watch_sanitize_condition (watch, &flags); - - if (flags == 0) - { - _dbus_verbose ("After sanitization, watch flags on fd %d were 0\n", - watch->fd); - return TRUE; - } - else - return (* watch->handler) (watch, flags, - watch->handler_data); -} - - -/** @} */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <che...@us...> - 2008-10-26 20:02:10
|
Revision: 797 http://windbus.svn.sourceforge.net/windbus/?rev=797&view=rev Author: chehrlic Date: 2008-10-26 20:02:05 +0000 (Sun, 26 Oct 2008) Log Message: ----------- this one is wrong Removed Paths: ------------- tags/1.2.3/dbus/dbus-watch.c Deleted: tags/1.2.3/dbus/dbus-watch.c =================================================================== --- tags/1.2.3/dbus/dbus-watch.c 2008-10-26 19:58:25 UTC (rev 796) +++ tags/1.2.3/dbus/dbus-watch.c 2008-10-26 20:02:05 UTC (rev 797) @@ -1,668 +0,0 @@ -/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ -/* dbus-watch.c DBusWatch implementation - * - * Copyright (C) 2002, 2003 Red Hat Inc. - * - * Licensed under the Academic Free License version 2.1 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#include "dbus-internals.h" -#include "dbus-watch.h" -#include "dbus-list.h" - -/** - * @defgroup DBusWatchInternals DBusWatch implementation details - * @ingroup DBusInternals - * @brief implementation details for DBusWatch - * - * @{ - */ - -/** - * Implementation of DBusWatch - */ -struct DBusWatch -{ - int refcount; /**< Reference count */ - int fd; /**< File descriptor. */ - unsigned int flags; /**< Conditions to watch. */ - - DBusWatchHandler handler; /**< Watch handler. */ - void *handler_data; /**< Watch handler data. */ - DBusFreeFunction free_handler_data_function; /**< Free the watch handler data. */ - - void *data; /**< Application data. */ - DBusFreeFunction free_data_function; /**< Free the application data. */ - unsigned int enabled : 1; /**< Whether it's enabled. */ -}; - -/** - * Creates a new DBusWatch. Used to add a file descriptor to be polled - * by a main loop. - * - * @param fd the file descriptor to be watched. - * @param flags the conditions to watch for on the descriptor. - * @param enabled the initial enabled state - * @param handler the handler function - * @param data data for handler function - * @param free_data_function function to free the data - * @returns the new DBusWatch object. - */ -DBusWatch* -_dbus_watch_new (int fd, - unsigned int flags, - dbus_bool_t enabled, - DBusWatchHandler handler, - void *data, - DBusFreeFunction free_data_function) -{ - DBusWatch *watch; - -#define VALID_WATCH_FLAGS (DBUS_WATCH_WRITABLE | DBUS_WATCH_READABLE) - - _dbus_assert ((flags & VALID_WATCH_FLAGS) == flags); - - watch = dbus_new0 (DBusWatch, 1); - if (watch == NULL) - return NULL; - - watch->refcount = 1; - watch->fd = fd; - watch->flags = flags; - watch->enabled = enabled; - - watch->handler = handler; - watch->handler_data = data; - watch->free_handler_data_function = free_data_function; - - return watch; -} - -/** - * Increments the reference count of a DBusWatch object. - * - * @param watch the watch object. - * @returns the watch object. - */ -DBusWatch * -_dbus_watch_ref (DBusWatch *watch) -{ - watch->refcount += 1; - - return watch; -} - -/** - * Decrements the reference count of a DBusWatch object - * and finalizes the object if the count reaches zero. - * - * @param watch the watch object. - */ -void -_dbus_watch_unref (DBusWatch *watch) -{ - _dbus_assert (watch != NULL); - _dbus_assert (watch->refcount > 0); - - watch->refcount -= 1; - if (watch->refcount == 0) - { - dbus_watch_set_data (watch, NULL, NULL); /* call free_data_function */ - - if (watch->free_handler_data_function) - (* watch->free_handler_data_function) (watch->handler_data); - - dbus_free (watch); - } -} - -/** - * Clears the file descriptor from a now-invalid watch object so that - * no one tries to use it. This is because a watch may stay alive due - * to reference counts after the file descriptor is closed. - * Invalidation makes it easier to catch bugs. It also - * keeps people from doing dorky things like assuming file descriptors - * are unique (never recycled). - * - * @param watch the watch object. - */ -void -_dbus_watch_invalidate (DBusWatch *watch) -{ - watch->fd = -1; - watch->flags = 0; -} - -/** - * Sanitizes the given condition so that it only contains - * flags that the DBusWatch requested. e.g. if the - * watch is a DBUS_WATCH_READABLE watch then - * DBUS_WATCH_WRITABLE will be stripped from the condition. - * - * @param watch the watch object. - * @param condition address of the condition to sanitize. - */ -void -_dbus_watch_sanitize_condition (DBusWatch *watch, - unsigned int *condition) -{ - if (!(watch->flags & DBUS_WATCH_READABLE)) - *condition &= ~DBUS_WATCH_READABLE; - if (!(watch->flags & DBUS_WATCH_WRITABLE)) - *condition &= ~DBUS_WATCH_WRITABLE; -} - - -/** - * @typedef DBusWatchList - * - * Opaque data type representing a list of watches - * and a set of DBusAddWatchFunction/DBusRemoveWatchFunction. - * Automatically handles removing/re-adding watches - * when the DBusAddWatchFunction is updated or changed. - * Holds a reference count to each watch. - * - * Used in the implementation of both DBusServer and - * DBusClient. - * - */ - -/** - * DBusWatchList implementation details. All fields - * are private. - * - */ -struct DBusWatchList -{ - DBusList *watches; /**< Watch objects. */ - - DBusAddWatchFunction add_watch_function; /**< Callback for adding a watch. */ - DBusRemoveWatchFunction remove_watch_function; /**< Callback for removing a watch. */ - DBusWatchToggledFunction watch_toggled_function; /**< Callback on toggling enablement */ - void *watch_data; /**< Data for watch callbacks */ - DBusFreeFunction watch_free_data_function; /**< Free function for watch callback data */ -}; - -/** - * Creates a new watch list. Returns #NULL if insufficient - * memory exists. - * - * @returns the new watch list, or #NULL on failure. - */ -DBusWatchList* -_dbus_watch_list_new (void) -{ - DBusWatchList *watch_list; - - watch_list = dbus_new0 (DBusWatchList, 1); - if (watch_list == NULL) - return NULL; - - return watch_list; -} - -/** - * Frees a DBusWatchList. - * - * @param watch_list the watch list. - */ -void -_dbus_watch_list_free (DBusWatchList *watch_list) -{ - /* free watch_data and removes watches as a side effect */ - _dbus_watch_list_set_functions (watch_list, - NULL, NULL, NULL, NULL, NULL); - _dbus_list_foreach (&watch_list->watches, - (DBusForeachFunction) _dbus_watch_unref, - NULL); - _dbus_list_clear (&watch_list->watches); - - dbus_free (watch_list); -} - -/** - * Sets the watch functions. This function is the "backend" - * for dbus_connection_set_watch_functions() and - * dbus_server_set_watch_functions(). - * - * @param watch_list the watch list. - * @param add_function the add watch function. - * @param remove_function the remove watch function. - * @param toggled_function function on toggling enabled flag, or #NULL - * @param data the data for those functions. - * @param free_data_function the function to free the data. - * @returns #FALSE if not enough memory - * - */ -dbus_bool_t -_dbus_watch_list_set_functions (DBusWatchList *watch_list, - DBusAddWatchFunction add_function, - DBusRemoveWatchFunction remove_function, - DBusWatchToggledFunction toggled_function, - void *data, - DBusFreeFunction free_data_function) -{ - /* Add watches with the new watch function, failing on OOM */ - if (add_function != NULL) - { - DBusList *link; - - link = _dbus_list_get_first_link (&watch_list->watches); - while (link != NULL) - { - DBusList *next = _dbus_list_get_next_link (&watch_list->watches, - link); - -#ifdef DBUS_ENABLE_VERBOSE_MODE - { - const char *watch_type; - int flags; - - flags = dbus_watch_get_flags (link->data); - if ((flags & DBUS_WATCH_READABLE) && - (flags & DBUS_WATCH_WRITABLE)) - watch_type = "readwrite"; - else if (flags & DBUS_WATCH_READABLE) - watch_type = "read"; - else if (flags & DBUS_WATCH_WRITABLE) - watch_type = "write"; - else - watch_type = "not read or write"; - - _dbus_verbose ("Adding a %s watch on fd %d using newly-set add watch function\n", - watch_type, - dbus_watch_get_socket (link->data)); - } -#endif /* DBUS_ENABLE_VERBOSE_MODE */ - - if (!(* add_function) (link->data, data)) - { - /* remove it all again and return FALSE */ - DBusList *link2; - - link2 = _dbus_list_get_first_link (&watch_list->watches); - while (link2 != link) - { - DBusList *next = _dbus_list_get_next_link (&watch_list->watches, - link2); - - _dbus_verbose ("Removing watch on fd %d using newly-set remove function because initial add failed\n", - dbus_watch_get_socket (link2->data)); - - (* remove_function) (link2->data, data); - - link2 = next; - } - - return FALSE; - } - - link = next; - } - } - - /* Remove all current watches from previous watch handlers */ - - if (watch_list->remove_watch_function != NULL) - { - _dbus_verbose ("Removing all pre-existing watches\n"); - - _dbus_list_foreach (&watch_list->watches, - (DBusForeachFunction) watch_list->remove_watch_function, - watch_list->watch_data); - } - - if (watch_list->watch_free_data_function != NULL) - (* watch_list->watch_free_data_function) (watch_list->watch_data); - - watch_list->add_watch_function = add_function; - watch_list->remove_watch_function = remove_function; - watch_list->watch_toggled_function = toggled_function; - watch_list->watch_data = data; - watch_list->watch_free_data_function = free_data_function; - - return TRUE; -} - -/** - * Adds a new watch to the watch list, invoking the - * application DBusAddWatchFunction if appropriate. - * - * @param watch_list the watch list. - * @param watch the watch to add. - * @returns #TRUE on success, #FALSE if no memory. - */ -dbus_bool_t -_dbus_watch_list_add_watch (DBusWatchList *watch_list, - DBusWatch *watch) -{ - if (!_dbus_list_append (&watch_list->watches, watch)) - return FALSE; - - _dbus_watch_ref (watch); - - if (watch_list->add_watch_function != NULL) - { - _dbus_verbose ("Adding watch on fd %d\n", - dbus_watch_get_socket (watch)); - - if (!(* watch_list->add_watch_function) (watch, - watch_list->watch_data)) - { - _dbus_list_remove_last (&watch_list->watches, watch); - _dbus_watch_unref (watch); - return FALSE; - } - } - - return TRUE; -} - -/** - * Removes a watch from the watch list, invoking the - * application's DBusRemoveWatchFunction if appropriate. - * - * @param watch_list the watch list. - * @param watch the watch to remove. - */ -void -_dbus_watch_list_remove_watch (DBusWatchList *watch_list, - DBusWatch *watch) -{ - if (!_dbus_list_remove (&watch_list->watches, watch)) - _dbus_assert_not_reached ("Nonexistent watch was removed"); - - if (watch_list->remove_watch_function != NULL) - { - _dbus_verbose ("Removing watch on fd %d\n", - dbus_watch_get_socket (watch)); - - (* watch_list->remove_watch_function) (watch, - watch_list->watch_data); - } - - _dbus_watch_unref (watch); -} - -/** - * Sets a watch to the given enabled state, invoking the - * application's DBusWatchToggledFunction if appropriate. - * - * @param watch_list the watch list. - * @param watch the watch to toggle. - * @param enabled #TRUE to enable - */ -void -_dbus_watch_list_toggle_watch (DBusWatchList *watch_list, - DBusWatch *watch, - dbus_bool_t enabled) -{ - enabled = !!enabled; - - if (enabled == watch->enabled) - return; - - watch->enabled = enabled; - - if (watch_list->watch_toggled_function != NULL) - { - _dbus_verbose ("Toggling watch %p on fd %d to %d\n", - watch, dbus_watch_get_socket (watch), watch->enabled); - - (* watch_list->watch_toggled_function) (watch, - watch_list->watch_data); - } -} - -/** - * Sets the handler for the watch. - * - * @todo this function only exists because of the weird - * way connection watches are done, see the note - * in docs for _dbus_connection_handle_watch(). - * - * @param watch the watch - * @param handler the new handler - * @param data the data - * @param free_data_function free data with this - */ -void -_dbus_watch_set_handler (DBusWatch *watch, - DBusWatchHandler handler, - void *data, - DBusFreeFunction free_data_function) -{ - if (watch->free_handler_data_function) - (* watch->free_handler_data_function) (watch->handler_data); - - watch->handler = handler; - watch->handler_data = data; - watch->free_handler_data_function = free_data_function; -} - -/** @} */ - -/** - * @defgroup DBusWatch DBusWatch - * @ingroup DBus - * @brief Object representing a file descriptor to be watched. - * - * Types and functions related to DBusWatch. A watch represents - * a file descriptor that the main loop needs to monitor, - * as in Qt's QSocketNotifier or GLib's g_io_add_watch(). - * - * Use dbus_connection_set_watch_functions() or dbus_server_set_watch_functions() - * to be notified when libdbus needs to add or remove watches. - * - * @{ - */ - -/** - * @typedef DBusWatch - * - * Opaque object representing a file descriptor - * to be watched for changes in readability, - * writability, or hangup. - */ - -/** - * Deprecated former name of dbus_watch_get_unix_fd(). - * - * @param watch the DBusWatch object. - * @returns the file descriptor to watch. - */ -int -dbus_watch_get_fd (DBusWatch *watch) -{ - return dbus_watch_get_unix_fd(watch); -} - -/** - * Returns a UNIX file descriptor to be watched, - * which may be a pipe, socket, or other type of - * descriptor. On UNIX this is preferred to - * dbus_watch_get_socket() since it works with - * more kinds of #DBusWatch. - * - * Always returns -1 on Windows. On Windows you use - * dbus_watch_get_socket() to get a Winsock socket to watch. - * - * @param watch the DBusWatch object. - * @returns the file descriptor to watch. - */ -int -dbus_watch_get_unix_fd (DBusWatch *watch) -{ - /* FIXME remove #ifdef and do this on a lower level - * (watch should have set_socket and set_unix_fd and track - * which it has, and the transport should provide the - * appropriate watch type) - */ -#ifdef DBUS_UNIX - return watch->fd; -#else - return -1; -#endif -} - -/** - * Returns a socket to be watched, on UNIX this will return -1 if our - * transport is not socket-based so dbus_watch_get_unix_fd() is - * preferred. - * - * On Windows, dbus_watch_get_unix_fd() returns -1 but this function - * returns a Winsock socket (assuming the transport is socket-based, - * as it always is for now). - * - * @param watch the DBusWatch object. - * @returns the socket to watch. - */ -int -dbus_watch_get_socket (DBusWatch *watch) -{ - return watch->fd; -} - -/** - * Gets flags from DBusWatchFlags indicating - * what conditions should be monitored on the - * file descriptor. - * - * The flags returned will only contain DBUS_WATCH_READABLE - * and DBUS_WATCH_WRITABLE, never DBUS_WATCH_HANGUP or - * DBUS_WATCH_ERROR; all watches implicitly include a watch - * for hangups, errors, and other exceptional conditions. - * - * @param watch the DBusWatch object. - * @returns the conditions to watch. - */ -unsigned int -dbus_watch_get_flags (DBusWatch *watch) -{ - _dbus_assert ((watch->flags & VALID_WATCH_FLAGS) == watch->flags); - - return watch->flags; -} - -/** - * Gets data previously set with dbus_watch_set_data() - * or #NULL if none. - * - * @param watch the DBusWatch object. - * @returns previously-set data. - */ -void* -dbus_watch_get_data (DBusWatch *watch) -{ - return watch->data; -} - -/** - * Sets data which can be retrieved with dbus_watch_get_data(). - * Intended for use by the DBusAddWatchFunction and - * DBusRemoveWatchFunction to store their own data. For example with - * Qt you might store the QSocketNotifier for this watch and with GLib - * you might store a GSource. - * - * @param watch the DBusWatch object. - * @param data the data. - * @param free_data_function function to be called to free the data. - */ -void -dbus_watch_set_data (DBusWatch *watch, - void *data, - DBusFreeFunction free_data_function) -{ - _dbus_verbose ("Setting watch fd %d data to data = %p function = %p from data = %p function = %p\n", - dbus_watch_get_socket (watch), - data, free_data_function, watch->data, watch->free_data_function); - - if (watch->free_data_function != NULL) - (* watch->free_data_function) (watch->data); - - watch->data = data; - watch->free_data_function = free_data_function; -} - -/** - * Returns whether a watch is enabled or not. If not - * enabled, it should not be polled by the main loop. - * - * @param watch the DBusWatch object - * @returns #TRUE if the watch is enabled - */ -dbus_bool_t -dbus_watch_get_enabled (DBusWatch *watch) -{ - _dbus_assert (watch != NULL); - return watch->enabled; -} - - -/** - * Called to notify the D-Bus library when a previously-added watch is - * ready for reading or writing, or has an exception such as a hangup. - * - * If this function returns #FALSE, then the file descriptor may still - * be ready for reading or writing, but more memory is needed in order - * to do the reading or writing. If you ignore the #FALSE return, your - * application may spin in a busy loop on the file descriptor until - * memory becomes available, but nothing more catastrophic should - * happen. - * - * dbus_watch_handle() cannot be called during the - * DBusAddWatchFunction, as the connection will not be ready to handle - * that watch yet. - * - * It is not allowed to reference a DBusWatch after it has been passed - * to remove_function. - * - * @param watch the DBusWatch object. - * @param flags the poll condition using #DBusWatchFlags values - * @returns #FALSE if there wasn't enough memory - */ -dbus_bool_t -dbus_watch_handle (DBusWatch *watch, - unsigned int flags) -{ -#ifndef DBUS_DISABLE_CHECKS - if (watch->fd < 0 || watch->flags == 0) - { - _dbus_warn_check_failed ("%s: Watch is invalid, it should have been removed\n", - _DBUS_FUNCTION_NAME); - return TRUE; - } -#endif - - _dbus_return_val_if_fail (watch->fd >= 0 /* fails if watch was removed */, TRUE); - - _dbus_watch_sanitize_condition (watch, &flags); - - if (flags == 0) - { - _dbus_verbose ("After sanitization, watch flags on fd %d were 0\n", - watch->fd); - return TRUE; - } - else - return (* watch->handler) (watch, flags, - watch->handler_data); -} - - -/** @} */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <che...@us...> - 2008-10-26 19:58:29
|
Revision: 796 http://windbus.svn.sourceforge.net/windbus/?rev=796&view=rev Author: chehrlic Date: 2008-10-26 19:58:25 +0000 (Sun, 26 Oct 2008) Log Message: ----------- forgot that our friend added this trap for windows... :( Modified Paths: -------------- trunk/dbus/dbus-watch.c Modified: trunk/dbus/dbus-watch.c =================================================================== --- trunk/dbus/dbus-watch.c 2008-10-23 17:38:30 UTC (rev 795) +++ trunk/dbus/dbus-watch.c 2008-10-26 19:58:25 UTC (rev 796) @@ -516,7 +516,7 @@ #ifdef DBUS_UNIX return watch->fd; #else - return -1; + return dbus_watch_get_socket( watch ); #endif } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |