From 4f0b78ae7e2948621f6ba582957bb6908e19285f Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Fri, 9 May 2008 16:17:13 +0000 Subject: [PATCH 001/114] mingw compile++ , w2k-support++ dbus/dbus-sysdeps-win.c: Don't unconditionally #include * cmake/ConfigureChecks.cmake, cmake/config.h.cmake, configure.in: check for wspiapi.h presence which isn't available (and unneeded) in mingw32 * dbus/dbus-sysdeps-win.c: use HAVE_WSPIAPI_H --- cmake/ConfigureChecks.cmake | 1 + cmake/config.h.cmake | 3 +++ configure.in | 2 ++ dbus/dbus-sysdeps-win.c | 10 ++++++++++ 4 files changed, 16 insertions(+), 0 deletions(-) diff --git a/cmake/ConfigureChecks.cmake b/cmake/ConfigureChecks.cmake index 1212bf9..756d67f 100644 --- a/cmake/ConfigureChecks.cmake +++ b/cmake/ConfigureChecks.cmake @@ -10,6 +10,7 @@ check_include_file(sys/poll.h HAVE_POLL) # dbus-sysdeps.c, dbus-sysdeps-w check_include_file(sys/time.h HAVE_SYS_TIME_H)# dbus-sysdeps-win.c check_include_file(sys/wait.h HAVE_SYS_WAIT_H)# dbus-sysdeps-win.c check_include_file(time.h HAVE_TIME_H) # dbus-sysdeps-win.c +check_include_file(wspiapi.h HAVE_WSPIAPI_H) # dbus-sysdeps-win.c check_include_file(unistd.h HAVE_UNISTD_H) # dbus-sysdeps-util-win.c check_include_file(stdio.h HAVE_STDIO_H) # dbus-sysdeps.h check_include_file(sys/syslimits.h HAVE_SYS_SYSLIMITS_H) # dbus-sysdeps-unix.c diff --git a/cmake/config.h.cmake b/cmake/config.h.cmake index 018fdfd..4f52387 100644 --- a/cmake/config.h.cmake +++ b/cmake/config.h.cmake @@ -82,6 +82,9 @@ /* Define to 1 if you have time.h */ #cmakedefine HAVE_TIME_H 1 +/* Define to 1 if you have wspiapi.h */ +#cmakedefine HAVE_WSPIAPI_H 1 + /* Define to 1 if you have unistd.h */ #cmakedefine HAVE_UNISTD_H 1 diff --git a/configure.in b/configure.in index 34c79a5..24ad554 100644 --- a/configure.in +++ b/configure.in @@ -443,6 +443,8 @@ AC_CHECK_HEADERS(byteswap.h) AC_CHECK_HEADERS(unistd.h) +AC_CHECK_HEADERS(wspiapi.h) + # Add -D_POSIX_PTHREAD_SEMANTICS if on Solaris # case $host_os in diff --git a/dbus/dbus-sysdeps-win.c b/dbus/dbus-sysdeps-win.c index 4a42c76..98bf4c9 100644 --- a/dbus/dbus-sysdeps-win.c +++ b/dbus/dbus-sysdeps-win.c @@ -53,6 +53,16 @@ #include #include +#ifdef HAVE_WSPIAPI_H +// needed for w2k compatibility (getaddrinfo/freeaddrinfo/getnameinfo) +#ifdef __GNUC__ +#define _inline +#include "wspiapi.h" +#else +#include +#endif +#endif // HAVE_WSPIAPI_H + #ifndef O_BINARY #define O_BINARY 0 #endif -- 1.6.4.msysgit.0 From e7c42374c265006ada3ba68d03019a642e45f1c7 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Wed, 1 Aug 2007 11:17:46 +0000 Subject: [PATCH 002/114] msvc 8 compile++ remove some stupid casts (cherry picked from commit 8c635b4a3944bcabc479718946e2a033d4c01489) --- dbus/dbus-sysdeps-util-win.c | 2 ++ dbus/dbus-sysdeps-win.c | 10 +++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/dbus/dbus-sysdeps-util-win.c b/dbus/dbus-sysdeps-util-win.c index b0e4eab..2e522c5 100644 --- a/dbus/dbus-sysdeps-util-win.c +++ b/dbus/dbus-sysdeps-util-win.c @@ -32,6 +32,7 @@ #include "dbus-string.h" #include "dbus-sysdeps.h" #include "dbus-sysdeps-win.h" +#include "dbus-sockets-win.h" #include "dbus-memory.h" #include @@ -42,6 +43,7 @@ #include #include #include +#include // WSA error codes #if defined __MINGW32__ || (defined _MSC_VER && _MSC_VER <= 1310) /* save string functions version diff --git a/dbus/dbus-sysdeps-win.c b/dbus/dbus-sysdeps-win.c index 98bf4c9..4afa165 100644 --- a/dbus/dbus-sysdeps-win.c +++ b/dbus/dbus-sysdeps-win.c @@ -2849,7 +2849,7 @@ void _dbus_daemon_init(const char *host, dbus_uint32_t port) { HANDLE lock; - const char *adr = NULL; + char *adr = NULL; char szUserName[64]; DWORD dwUserNameSize = sizeof(szUserName); char szDBusDaemonMutex[128]; @@ -2884,10 +2884,10 @@ _dbus_daemon_init(const char *host, dbus_uint32_t port) _dbus_assert( adr ); - strcpy( (char*) adr, szAddress); + strcpy( adr, szAddress); // cleanup - UnmapViewOfFile( (char*) adr ); + UnmapViewOfFile( adr ); _dbus_global_unlock( lock ); } @@ -2917,7 +2917,7 @@ static dbus_bool_t _dbus_get_autolaunch_shm(DBusString *adress) { HANDLE sharedMem; - const char *adr; + char *adr; char szUserName[64]; DWORD dwUserNameSize = sizeof(szUserName); char szDBusDaemonAddressInfo[128]; @@ -2948,7 +2948,7 @@ _dbus_get_autolaunch_shm(DBusString *adress) _dbus_string_append( adress, adr ); // cleanup - UnmapViewOfFile( (char*) adr ); + UnmapViewOfFile( adr ); CloseHandle( sharedMem ); -- 1.6.4.msysgit.0 From 0442a522fbcb775cbda9def19592e71495d49daa Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Mon, 27 Apr 2009 14:34:45 +0200 Subject: [PATCH 003/114] Include for envion on Windows (cherry picked from commit 5874d104f52a0ef4d956ab56376776d3e385072f) --- dbus/dbus-sysdeps.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/dbus/dbus-sysdeps.c b/dbus/dbus-sysdeps.c index ccd80cc..0fdf33c 100644 --- a/dbus/dbus-sysdeps.c +++ b/dbus/dbus-sysdeps.c @@ -51,7 +51,11 @@ _DBUS_DEFINE_GLOBAL_LOCK (win_fds); _DBUS_DEFINE_GLOBAL_LOCK (sid_atom_cache); _DBUS_DEFINE_GLOBAL_LOCK (system_users); +#ifdef WIN32 + #include +#else extern char **environ; +#endif /** * @defgroup DBusSysdeps Internal system-dependent API -- 1.6.4.msysgit.0 From aae7289bb0901a81f1b88ecef5cf20de3af25213 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Mon, 20 Apr 2009 15:07:06 +0200 Subject: [PATCH 004/114] dbus/dbus-sysdeps-win.c: fix linking with mingw32 * freeaddrinfo/getaddrinfo need _WIN32_WINNT to be 0x050_1_ (cherry picked from commit fa1f38452fafb841b7e2b36c7ca8918f9bde408f) --- dbus/dbus-sysdeps-win.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/dbus/dbus-sysdeps-win.c b/dbus/dbus-sysdeps-win.c index 4afa165..358d151 100644 --- a/dbus/dbus-sysdeps-win.c +++ b/dbus/dbus-sysdeps-win.c @@ -31,7 +31,7 @@ #define STRSAFE_NO_DEPRECATE #ifndef DBUS_WINCE -#define _WIN32_WINNT 0x0500 +#define _WIN32_WINNT 0x0501 #endif #include "dbus-internals.h" -- 1.6.4.msysgit.0 From cd90173c01db2b9022141b5a0264de1eda438d7b Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Mon, 24 Dec 2007 08:42:31 +0000 Subject: [PATCH 005/114] hide console when autostarting dbus-daemon (cherry picked from commit 27fad960837b54b6e47f408e6d1eecea1bee563f) --- dbus/dbus-sysdeps-win.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/dbus/dbus-sysdeps-win.c b/dbus/dbus-sysdeps-win.c index 358d151..3634a71 100644 --- a/dbus/dbus-sysdeps-win.c +++ b/dbus/dbus-sysdeps-win.c @@ -3033,7 +3033,7 @@ _dbus_get_autolaunch_address (DBusString *address, // argv[i] = "--config-file=bus\\session.conf"; printf("create process \"%s\" %s\n", dbus_exe_path, dbus_args); - if(CreateProcessA(dbus_exe_path, dbus_args, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) + if(CreateProcessA(dbus_exe_path, dbus_args, NULL, NULL, FALSE, CREATE_NO_WINDOW, NULL, NULL, &si, &pi)) { retval = TRUE; -- 1.6.4.msysgit.0 From dacfa05886f2a160b8c07a426ee2801336ac738a Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Fri, 17 Apr 2009 14:37:41 +0200 Subject: [PATCH 006/114] remove an assert for windows only - don't know why this was added... (cherry picked from commit a248de6b733f4a3a78f6646174d899ba2058395e) --- dbus/dbus-connection.c | 5 +---- 1 files changed, 1 insertions(+), 4 deletions(-) diff --git a/dbus/dbus-connection.c b/dbus/dbus-connection.c index 31edd61..dffc16f 100644 --- a/dbus/dbus-connection.c +++ b/dbus/dbus-connection.c @@ -5125,10 +5125,7 @@ dbus_connection_get_unix_process_id (DBusConnection *connection, else result = _dbus_transport_get_unix_process_id (connection->transport, pid); -#ifdef DBUS_WIN - _dbus_assert (!result); -#endif - + CONNECTION_UNLOCK (connection); return result; -- 1.6.4.msysgit.0 From 1669a64b67895724c9c5ffc9f461041c796b1af1 Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Tue, 6 Jan 2009 13:01:20 +0000 Subject: [PATCH 007/114] _dbus_verbose_real: (optionally) use OutputDebugString() (cherry picked from commit fd6d354c47b4b8dc24ce32e31171568a8704e7d1) --- dbus/dbus-internals.c | 31 +++++++++++++++++++++++++++++-- 1 files changed, 29 insertions(+), 2 deletions(-) diff --git a/dbus/dbus-internals.c b/dbus/dbus-internals.c index c5885ea..061b637 100644 --- a/dbus/dbus-internals.c +++ b/dbus/dbus-internals.c @@ -28,6 +28,9 @@ #include #include #include +#ifdef USE_OUTPUTDEBUGSTRING +#include +#endif /** * @defgroup DBusInternals D-Bus secret internal implementation details @@ -298,15 +301,28 @@ static dbus_bool_t verbose = TRUE; #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 @@ _dbus_verbose_real (const char *format, if (!_dbus_is_verbose_real()) return; +#ifndef USE_OUTPUTDEBUGSTRING /* Print out pid before the line */ if (need_pid) { @@ -354,7 +371,7 @@ _dbus_verbose_real (const char *format, 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 @@ _dbus_verbose_real (const char *format, 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 } /** -- 1.6.4.msysgit.0 From 73bb04ec3d73e56cd1c9dd881c0175fcd7937954 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Tue, 28 Apr 2009 16:29:49 +0200 Subject: [PATCH 008/114] use dbus_watch_get_socket in dbus_watch_get_unix_fd on windows (cherry picked from commit c15206da8e56e32c7de98824d8d2c38a7d92c707) --- dbus/dbus-watch.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/dbus/dbus-watch.c b/dbus/dbus-watch.c index bca699f..484dbbe 100644 --- a/dbus/dbus-watch.c +++ b/dbus/dbus-watch.c @@ -522,7 +522,7 @@ dbus_watch_get_unix_fd (DBusWatch *watch) #ifdef DBUS_UNIX return watch->fd; #else - return -1; + return dbus_watch_get_socket( watch ); #endif } -- 1.6.4.msysgit.0 From 7ca4e932e6661349701b53c77d50f2e8531bed5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20K=C3=BCmmel?= Date: Tue, 21 Nov 2006 19:51:13 +0000 Subject: [PATCH 009/114] no fake lock under Windows (cherry picked from commit 62cb039e40811a5881ee8dcc37c97103a848f74d) --- dbus/dbus-threads.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/dbus/dbus-threads.c b/dbus/dbus-threads.c index 2e41ed9..b425ae7 100644 --- a/dbus/dbus-threads.c +++ b/dbus/dbus-threads.c @@ -812,7 +812,11 @@ dbus_fake_condvar_wake_all (DBusCondVar *cond) dbus_bool_t _dbus_threads_init_debug (void) { +#ifdef DBUS_WIN + return _dbus_threads_init_platform_specific(); +#else return dbus_threads_init (&fake_functions); +#endif } #endif /* DBUS_BUILD_TESTS */ -- 1.6.4.msysgit.0 From b97d2de87b2d28ab10fda9dd497c031a4d6ab74d Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Fri, 24 Apr 2009 16:15:36 +0200 Subject: [PATCH 010/114] r773: patch from Thorvald Natvig to fix a copy+paste error that could result in a dangling handle at windows. (cherry picked from commit 97d0f058527c62ce3a2203b1632e742b10d5b7a9) --- dbus/dbus-spawn-win.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/dbus/dbus-spawn-win.c b/dbus/dbus-spawn-win.c index 5c0c299..cd7e6bb 100644 --- a/dbus/dbus-spawn-win.c +++ b/dbus/dbus-spawn-win.c @@ -228,7 +228,7 @@ _dbus_babysitter_unref (DBusBabysitter *sitter) { PING(); CloseHandle (sitter->start_sync_event); - sitter->end_sync_event = NULL; + sitter->start_sync_event = NULL; } #ifdef DBUS_BUILD_TESTS -- 1.6.4.msysgit.0 From 2ac6738799232ebb1ae49f3fc807bea1254cd121 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Mon, 27 Apr 2009 13:37:23 +0200 Subject: [PATCH 011/114] merge in all changes done in windbus.sf.net/trunk related to adopting windbus to dbus-1.2 API-changes; r778 | chehrlic | 2008-04-23 20:11:35 +0200 (Wed, 23 Apr 2008) | 2 lines update trunk to 1.2.1 this also means that we don't have a cvs version in trunk anymore - we have to work on a release version instead. Shouldn't be that big problem. If you need it,plz open a branch. r789 | chehrlic | 2008-08-13 12:32:03 +0200 (Wed, 13 Aug 2008) | 1 line update to 1.2.3 r794 | chehrlic | 2008-10-23 19:35:39 +0200 (Thu, 23 Oct 2008) | 1 line update to 1.2.4 r806 | chehrlic | 2009-01-18 00:18:46 +0100 (Sun, 18 Jan 2009) | 1 line update to 1.2.12 - not tested yet! (cherry picked from commit 6734a3210a0705e3ab01ee123fac275799877353) --- dbus/dbus-spawn-win.c | 59 ++++++- dbus/dbus-sysdeps-util-win.c | 138 +++++++++++++++- dbus/dbus-sysdeps-win.c | 375 +++++++++++++++++++++++++++++------------- tools/dbus-launch-win.c | 7 +- 4 files changed, 451 insertions(+), 128 deletions(-) diff --git a/dbus/dbus-spawn-win.c b/dbus/dbus-spawn-win.c index cd7e6bb..de07789 100644 --- a/dbus/dbus-spawn-win.c +++ b/dbus/dbus-spawn-win.c @@ -269,6 +269,33 @@ _dbus_babysitter_get_child_exited (DBusBabysitter *sitter) } /** + * Gets the exit status of the child. We do this so implementation specific + * detail is not cluttering up dbus, for example the system launcher code. + * This can only be called if the child has exited, i.e. call + * _dbus_babysitter_get_child_exited(). It returns FALSE if the child + * did not return a status code, e.g. because the child was signaled + * or we failed to ever launch the child in the first place. + * + * @param sitter the babysitter + * @param status the returned status code + * @returns #FALSE on failure + */ +dbus_bool_t +_dbus_babysitter_get_child_exit_status (DBusBabysitter *sitter, + int *status) +{ + if (!_dbus_babysitter_get_child_exited (sitter)) + _dbus_assert_not_reached ("Child has not exited"); + + if (!sitter->have_child_status || + sitter->child_status == STILL_ACTIVE) + return FALSE; + + *status = sitter->child_status; + return TRUE; +} + +/** * Sets the #DBusError with an explanation of why the spawned * child process exited (on a signal, or whatever). If * the child process has not exited, does nothing (error @@ -621,8 +648,12 @@ static dbus_bool_t check_spawn_nonexistent (void *data) { char *argv[4] = { NULL, NULL, NULL, NULL }; - DBusBabysitter *sitter = NULL; - DBusError error = DBUS_ERROR_INIT; + DBusBabysitter *sitter; + DBusError error; + + sitter = NULL; + + dbus_error_init (&error); /*** Test launching nonexistent binary */ @@ -662,8 +693,12 @@ static dbus_bool_t check_spawn_segfault (void *data) { char *argv[4] = { NULL, NULL, NULL, NULL }; - DBusBabysitter *sitter = NULL; - DBusError error = DBUS_ERROR_INIT; + DBusBabysitter *sitter; + DBusError error; + + sitter = NULL; + + dbus_error_init (&error); /*** Test launching segfault binary */ @@ -703,8 +738,12 @@ static dbus_bool_t check_spawn_exit (void *data) { char *argv[4] = { NULL, NULL, NULL, NULL }; - DBusBabysitter *sitter = NULL; - DBusError error = DBUS_ERROR_INIT; + DBusBabysitter *sitter; + DBusError error; + + sitter = NULL; + + dbus_error_init (&error); /*** Test launching exit failure binary */ @@ -744,8 +783,12 @@ static dbus_bool_t check_spawn_and_kill (void *data) { char *argv[4] = { NULL, NULL, NULL, NULL }; - DBusBabysitter *sitter = NULL; - DBusError error = DBUS_ERROR_INIT; + DBusBabysitter *sitter; + DBusError error; + + sitter = NULL; + + dbus_error_init (&error); /*** Test launching sleeping binary then killing it */ diff --git a/dbus/dbus-sysdeps-util-win.c b/dbus/dbus-sysdeps-util-win.c index 2e522c5..d589a21 100644 --- a/dbus/dbus-sysdeps-util-win.c +++ b/dbus/dbus-sysdeps-util-win.c @@ -38,6 +38,7 @@ #include #include #include +#include #include #include @@ -141,6 +142,84 @@ _dbus_write_pid_file (const DBusString *filename, } /** + * Writes the given pid_to_write to a pidfile (if non-NULL) and/or to a + * pipe (if non-NULL). Does nothing if pidfile and print_pid_pipe are both + * NULL. + * + * @param pidfile the file to write to or #NULL + * @param print_pid_pipe the pipe to write to or #NULL + * @param pid_to_write the pid to write out + * @param error error on failure + * @returns FALSE if error is set + */ +dbus_bool_t +_dbus_write_pid_to_file_and_pipe (const DBusString *pidfile, + DBusPipe *print_pid_pipe, + dbus_pid_t pid_to_write, + DBusError *error) +{ + if (pidfile) + { + _dbus_verbose ("writing pid file %s\n", _dbus_string_get_const_data (pidfile)); + if (!_dbus_write_pid_file (pidfile, + pid_to_write, + error)) + { + _dbus_verbose ("pid file write failed\n"); + _DBUS_ASSERT_ERROR_IS_SET(error); + return FALSE; + } + } + else + { + _dbus_verbose ("No pid file requested\n"); + } + + if (print_pid_pipe != NULL && _dbus_pipe_is_valid (print_pid_pipe)) + { + DBusString pid; + int bytes; + + _dbus_verbose ("writing our pid to pipe %d\n", print_pid_pipe->fd_or_handle); + + if (!_dbus_string_init (&pid)) + { + _DBUS_SET_OOM (error); + return FALSE; + } + + if (!_dbus_string_append_int (&pid, pid_to_write) || + !_dbus_string_append (&pid, "\n")) + { + _dbus_string_free (&pid); + _DBUS_SET_OOM (error); + return FALSE; + } + + bytes = _dbus_string_get_length (&pid); + if (_dbus_pipe_write (print_pid_pipe, &pid, 0, bytes, error) != bytes) + { + /* _dbus_pipe_write sets error only on failure, not short write */ + if (error != NULL && !dbus_error_is_set(error)) + { + dbus_set_error (error, DBUS_ERROR_FAILED, + "Printing message bus PID: did not write enough bytes\n"); + } + _dbus_string_free (&pid); + return FALSE; + } + + _dbus_string_free (&pid); + } + else + { + _dbus_verbose ("No pid pipe to write to\n"); + } + + return TRUE; +} + +/** * Verify that after the fork we can successfully change to this user. * * @param user the username given in the daemon configuration @@ -296,6 +375,38 @@ _dbus_delete_directory (const DBusString *filename, 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 @@ -921,8 +1032,9 @@ void _dbus_win_warn_win_error (const char *message, int code) { - DBusError error = DBUS_ERROR_INIT; + DBusError error; + dbus_error_init (&error); _dbus_win_set_error_from_win_error (&error, code); _dbus_warn ("%s: %s\n", message, error.message); dbus_error_free (&error); @@ -1713,3 +1825,27 @@ _dbus_lm_strerror(int error_number) 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; +} diff --git a/dbus/dbus-sysdeps-win.c b/dbus/dbus-sysdeps-win.c index 3634a71..a4a3505 100644 --- a/dbus/dbus-sysdeps-win.c +++ b/dbus/dbus-sysdeps-win.c @@ -47,6 +47,7 @@ #include "dbus-credentials.h" #include +#include #include #include @@ -849,15 +850,6 @@ _dbus_getuid (void) return DBUS_UID_UNSET; } -/** Gets our effective UID - * @returns process effective UID - */ -dbus_uid_t -_dbus_geteuid (void) -{ - return DBUS_UID_UNSET; -} - /** * The only reason this is separate from _dbus_getpid() is to allow it * on Windows for logging but not for other purposes. @@ -1464,21 +1456,21 @@ _dbus_exit (int code) * and port. The connection fd is returned, and is set up as * nonblocking. * - * @param host the host name to connect to, NULL for loopback - * @param port the prot to connect to + * @param host the host name to connect to + * @param port the port to connect to + * @param family the address family to listen on, NULL for all * @param error return location for error code * @returns connection file descriptor or -1 on error */ int _dbus_connect_tcp_socket (const char *host, - dbus_uint32_t port, + const char *port, + const char *family, DBusError *error) { - int fd; - struct sockaddr_in addr; - struct hostent *he; - struct in_addr *haddr; - struct in_addr ina; + int fd = -1, res; + struct addrinfo hints; + struct addrinfo *ai, *tmp; _DBUS_ASSERT_ERROR_IS_CLEAR (error); @@ -1497,50 +1489,80 @@ _dbus_connect_tcp_socket (const char *host, return -1; } - if (host == NULL) + _DBUS_ASSERT_ERROR_IS_CLEAR(error); + + _DBUS_ZERO (hints); + + if (!family) + hints.ai_family = AF_UNSPEC; + else if (!strcmp(family, "ipv4")) + hints.ai_family = AF_INET; + else if (!strcmp(family, "ipv6")) + hints.ai_family = AF_INET6; + else { - host = "localhost"; - ina.s_addr = htonl (INADDR_LOOPBACK); - haddr = &ina; + dbus_set_error (error, + _dbus_error_from_errno (errno), + "Unknown address family %s", family); + return -1; } + hints.ai_protocol = IPPROTO_TCP; + hints.ai_socktype = SOCK_STREAM; +#ifdef AI_ADDRCONFIG + hints.ai_flags = AI_ADDRCONFIG; +#else + hints.ai_flags = 0; +#endif - he = gethostbyname (host); - if (he == NULL) + if ((res = getaddrinfo(host, port, &hints, &ai)) != 0) { - DBUS_SOCKET_SET_ERRNO (); dbus_set_error (error, _dbus_error_from_errno (errno), - "Failed to lookup hostname: %s", - host); - DBUS_CLOSE_SOCKET (fd); + "Failed to lookup host/port: \"%s:%s\": %s (%d)", + host, port, gai_strerror(res), res); + closesocket (fd); return -1; } - haddr = ((struct in_addr *) (he->h_addr_list)[0]); - - _DBUS_ZERO (addr); - memcpy (&addr.sin_addr, haddr, sizeof(struct in_addr)); - addr.sin_family = AF_INET; - addr.sin_port = htons (port); - - if (DBUS_SOCKET_API_RETURNS_ERROR - (connect (fd, (struct sockaddr*) &addr, sizeof (addr)) < 0)) + tmp = ai; + while (tmp) { - DBUS_SOCKET_SET_ERRNO (); + if ((fd = socket (tmp->ai_family, SOCK_STREAM, 0)) < 0) + { + freeaddrinfo(ai); dbus_set_error (error, _dbus_error_from_errno (errno), - "Failed to connect to socket %s:%d %s", - host, port, _dbus_strerror (errno)); + "Failed to open socket: %s", + _dbus_strerror (errno)); + return -1; + } + _DBUS_ASSERT_ERROR_IS_CLEAR(error); - DBUS_CLOSE_SOCKET (fd); + if (connect (fd, (struct sockaddr*) tmp->ai_addr, tmp->ai_addrlen) < 0) + { + closesocket(fd); fd = -1; + tmp = tmp->ai_next; + continue; + } + + break; + } + freeaddrinfo(ai); + if (fd == -1) + { + dbus_set_error (error, + _dbus_error_from_errno (errno), + "Failed to connect to socket \"%s:%s\" %s", + host, port, _dbus_strerror(errno)); return -1; } + if (!_dbus_set_fd_nonblocking (fd, error)) { - _dbus_close_socket (fd, NULL); + closesocket (fd); fd = -1; return -1; @@ -1549,114 +1571,198 @@ _dbus_connect_tcp_socket (const char *host, return fd; } + void _dbus_daemon_init(const char *host, dbus_uint32_t port); + /** - * Creates a socket and binds it to the given port, - * then listens on the socket. The socket is - * set to be nonblocking. - * In case of port=0 a random free port is used and - * returned in the port parameter. + * Creates a socket and binds it to the given path, then listens on + * the socket. The socket is set to be nonblocking. In case of port=0 + * a random free port is used and returned in the port parameter. + * If inaddr_any is specified, the hostname is ignored. * - * @param host the interface to listen on, NULL for loopback, empty for any + * @param host the host name to listen on * @param port the port to listen on, if zero a free port will be used + * @param family the address family to listen on, NULL for all + * @param retport string to return the actual port listened on + * @param fds_p location to store returned file descriptors * @param error return location for errors - * @returns the listening file descriptor or -1 on error + * @returns the number of listening file descriptors or -1 on error */ int _dbus_listen_tcp_socket (const char *host, - dbus_uint32_t *port, - dbus_bool_t inaddr_any, + const char *port, + const char *family, + DBusString *retport, + int **fds_p, DBusError *error) { - int fd; - struct sockaddr_in addr; - struct hostent *he; - struct in_addr *haddr; - socklen_t len = (socklen_t) sizeof (struct sockaddr); - struct in_addr ina; - + int nlisten_fd = 0, *listen_fd = NULL, res, i, port_num = -1; + struct addrinfo hints; + struct addrinfo *ai, *tmp; + *fds_p = NULL; _DBUS_ASSERT_ERROR_IS_CLEAR (error); _dbus_win_startup_winsock (); - fd = socket (AF_INET, SOCK_STREAM, 0); + _DBUS_ZERO (hints); - if (DBUS_SOCKET_IS_INVALID (fd)) + if (!family) + hints.ai_family = AF_UNSPEC; + else if (!strcmp(family, "ipv4")) + hints.ai_family = AF_INET; + else if (!strcmp(family, "ipv6")) + hints.ai_family = AF_INET6; + else { - DBUS_SOCKET_SET_ERRNO (); - dbus_set_error (error, _dbus_error_from_errno (errno), - "Failed to create socket \"%s:%d\": %s", - host, port, _dbus_strerror (errno)); + dbus_set_error (error, + _dbus_error_from_errno (errno), + "Unknown address family %s", family); return -1; } - if (host == NULL) - { - host = "localhost"; - ina.s_addr = htonl (INADDR_LOOPBACK); - haddr = &ina; - } - else if (!host[0]) + + hints.ai_protocol = IPPROTO_TCP; + hints.ai_socktype = SOCK_STREAM; +#ifdef AI_ADDRCONFIG + hints.ai_flags = AI_ADDRCONFIG | AI_PASSIVE; +#else + hints.ai_flags = AI_PASSIVE; +#endif + + redo_lookup_with_port: + if ((res = getaddrinfo(host, port, &hints, &ai)) != 0 || !ai) { - ina.s_addr = htonl (INADDR_ANY); - haddr = &ina; + dbus_set_error (error, + _dbus_error_from_errno (errno), + "Failed to lookup host/port: \"%s:%s\": %s (%d)", + host ? host : "*", port, gai_strerror(res), res); + return -1; } - else + + tmp = ai; + while (tmp) { - he = gethostbyname (host); - if (he == NULL) + int fd = -1, *newlisten_fd; + if ((fd = socket (tmp->ai_family, SOCK_STREAM, 0)) < 0) { - DBUS_SOCKET_SET_ERRNO (); dbus_set_error (error, _dbus_error_from_errno (errno), - "Failed to lookup hostname: %s", - host); - DBUS_CLOSE_SOCKET (fd); - return -1; + "Failed to open socket: %s", + _dbus_strerror (errno)); + goto failed; } + _DBUS_ASSERT_ERROR_IS_CLEAR(error); - haddr = ((struct in_addr *) (he->h_addr_list)[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), + "Failed to bind socket \"%s:%s\": %s", + host ? host : "*", port, _dbus_strerror (errno)); + goto failed; } - _DBUS_ZERO (addr); - memcpy (&addr.sin_addr, haddr, sizeof (struct in_addr)); - addr.sin_family = AF_INET; - addr.sin_port = htons (*port); + if (listen (fd, 30 /* backlog */) == SOCKET_ERROR) + { + closesocket (fd); + dbus_set_error (error, _dbus_error_from_errno (errno), + "Failed to listen on socket \"%s:%s\": %s", + host ? host : "*", port, _dbus_strerror (errno)); + goto failed; + } - if (bind (fd, (struct sockaddr*) &addr, sizeof (struct sockaddr))) + newlisten_fd = dbus_realloc(listen_fd, sizeof(int)*(nlisten_fd+1)); + if (!newlisten_fd) { - DBUS_SOCKET_SET_ERRNO (); + closesocket (fd); dbus_set_error (error, _dbus_error_from_errno (errno), - "Failed to bind socket \"%s:%d\": %s", - host, *port, _dbus_strerror (errno)); - DBUS_CLOSE_SOCKET (fd); - return -1; + "Failed to allocate file handle array: %s", + _dbus_strerror (errno)); + goto failed; } + listen_fd = newlisten_fd; + listen_fd[nlisten_fd] = fd; + nlisten_fd++; + + if (!_dbus_string_get_length(retport)) + { + /* If the user didn't specify a port, or used 0, then + the kernel chooses a port. After the first address + is bound to, we need to force all remaining addresses + to use the same port */ + if (!port || !strcmp(port, "0")) + { + sockaddr_gen addr; + socklen_t addrlen = sizeof(addr); + char portbuf[10]; - if (DBUS_SOCKET_API_RETURNS_ERROR (listen (fd, 30 /* backlog */))) + if ((res = getsockname(fd, &addr.Address, &addrlen)) != 0) { - DBUS_SOCKET_SET_ERRNO (); dbus_set_error (error, _dbus_error_from_errno (errno), - "Failed to listen on socket \"%s:%d\": %s", - host, *port, _dbus_strerror (errno)); - DBUS_CLOSE_SOCKET (fd); + "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); + goto failed; + } + + /* Release current address list & redo lookup */ + port = _dbus_string_get_const_data(retport); + freeaddrinfo(ai); + goto redo_lookup_with_port; + } + else + { + if (!_dbus_string_append(retport, port)) + { + dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL); + goto failed; + } + } + } + + tmp = tmp->ai_next; + } + freeaddrinfo(ai); + ai = NULL; + + if (!nlisten_fd) + { + errno = WSAEADDRINUSE; + dbus_set_error (error, _dbus_error_from_errno (errno), + "Failed to bind socket \"%s:%s\": %s", + host ? host : "*", port, _dbus_strerror (errno)); return -1; } - getsockname(fd, (struct sockaddr*) &addr, &len); - *port = (dbus_uint32_t) ntohs(addr.sin_port); - - _dbus_daemon_init(host, ntohs(addr.sin_port)); + sscanf(_dbus_string_get_const_data(retport), "%d", &port_num); + _dbus_daemon_init(host, port_num); - if (!_dbus_set_fd_nonblocking (fd, error)) + for (i = 0 ; i < nlisten_fd ; i++) { - _dbus_close_socket (fd, NULL); - return -1; + if (!_dbus_set_fd_nonblocking (listen_fd[i], error)) + { + goto failed; + } } - return fd; + *fds_p = listen_fd; + + return nlisten_fd; + + failed: + if (ai) + freeaddrinfo(ai); + for (i = 0 ; i < nlisten_fd ; i++) + closesocket (listen_fd[i]); + dbus_free(listen_fd); + return -1; } @@ -1671,13 +1777,9 @@ int _dbus_accept (int listen_fd) { int client_fd; - struct sockaddr addr; - socklen_t addrlen; - - addrlen = sizeof (addr); retry: - client_fd = accept (listen_fd, &addr, &addrlen); + client_fd = accept (listen_fd, NULL, NULL); if (DBUS_SOCKET_IS_INVALID (client_fd)) { @@ -2843,7 +2945,11 @@ static const char *cDBusAutolaunchMutex = "DBusAutolaunchMutex"; // 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) @@ -3006,6 +3112,11 @@ _dbus_get_autolaunch_address (DBusString *address, 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 ); @@ -3013,14 +3124,16 @@ _dbus_get_autolaunch_address (DBusString *address, if (_dbus_daemon_already_runs(address)) { - printf("dbus daemon already exists\n"); + _dbus_verbose("found already running dbus daemon\n"); retval = TRUE; 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 ("could not find dbus-daemon executable\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; } @@ -3127,6 +3240,31 @@ _dbus_get_standard_session_servicedirs (DBusList **dirs) return FALSE; } +/** + * Returns the standard directories for a system bus to look for service + * activation files + * + * On UNIX this should be the standard xdg freedesktop.org data directories: + * + * XDG_DATA_DIRS=${XDG_DATA_DIRS-/usr/local/share:/usr/share} + * + * and + * + * DBUS_DATADIR + * + * On Windows there is no system bus and this function can return nothing. + * + * @param dirs the directory list we are returning + * @returns #FALSE on OOM + */ + +dbus_bool_t +_dbus_get_standard_system_servicedirs (DBusList **dirs) +{ + *dirs = NULL; + return TRUE; +} + _DBUS_DEFINE_GLOBAL_LOCK (atomic); /** @@ -3237,12 +3375,15 @@ _dbus_get_config_file_name(DBusString *config_file, char *s) { char path[MAX_PATH*2]; int path_size = sizeof(path); + int len = 4 + strlen(s); if (!_dbus_get_install_root(path,path_size)) return FALSE; - strcat_s(path,path_size,"etc\\"); - strcat_s(path,path_size,s); + if(len > sizeof(path)-2) + return FALSE; + strcat(path,"etc\\"); + strcat(path,s); if (_dbus_file_exists(path)) { // find path from executable @@ -3253,8 +3394,10 @@ _dbus_get_config_file_name(DBusString *config_file, char *s) { if (!_dbus_get_install_root(path,path_size)) return FALSE; - strcat_s(path,path_size,"bus\\"); - strcat_s(path,path_size,s); + if(len + strlen(path) > sizeof(path)-2) + return FALSE; + strcat(path,"bus\\"); + strcat(path,s); if (_dbus_file_exists(path)) { diff --git a/tools/dbus-launch-win.c b/tools/dbus-launch-win.c index cc936a6..27fabbc 100644 --- a/tools/dbus-launch-win.c +++ b/tools/dbus-launch-win.c @@ -68,11 +68,12 @@ int main(int argc,char **argv) showConsole = 1; #endif GetModuleFileName(NULL,dbusDaemonPath,sizeof(dbusDaemonPath)); - /* check for debug version */ - if (strstr(dbusDaemonPath,"dbus-launchd.exe")) + +#ifdef _DEBUG daemon_name = "dbus-daemond.exe"; - else +#else daemon_name = "dbus-daemon.exe"; +#endif if ((p = strrchr(dbusDaemonPath,'\\'))) { *(p+1)= '\0'; -- 1.6.4.msysgit.0 From e6ea39942495323ec508bd15de3a078e3c7ee980 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Mon, 27 Apr 2009 13:41:48 +0200 Subject: [PATCH 012/114] fix deadlock when dbus-daemon could not start up r811: apply patch by Thorvald Natvig to fix endless loop when _dbus_get_autolaunch_shm got called and the dbus-daemon failed to start up. * if launching for some reason fails, set an error message * _dbus_get_autolaunch_shm will abort getting the shared memory after 20 attempts (2 seconds) * _dbus_get_autolaunch_address checks if the return state of WaitForInputIdle before calling _dbus_get_autolaunch_shm. r812: remove WaitForInputIdle as it doesn't work in non-console mode (cherry picked from commit 363fd736556219bad77c4b217e051b7983dc34e9) --- dbus/dbus-sysdeps-win.c | 18 +++++++++--------- 1 files changed, 9 insertions(+), 9 deletions(-) diff --git a/dbus/dbus-sysdeps-win.c b/dbus/dbus-sysdeps-win.c index a4a3505..fd4eebd 100644 --- a/dbus/dbus-sysdeps-win.c +++ b/dbus/dbus-sysdeps-win.c @@ -3027,6 +3027,7 @@ _dbus_get_autolaunch_shm(DBusString *adress) char szUserName[64]; DWORD dwUserNameSize = sizeof(szUserName); char szDBusDaemonAddressInfo[128]; + int i; if( !GetUserName(szUserName, &dwUserNameSize) ) return FALSE; @@ -3034,12 +3035,14 @@ _dbus_get_autolaunch_shm(DBusString *adress) 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; @@ -3145,19 +3148,16 @@ _dbus_get_autolaunch_address (DBusString *address, _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); 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); -- 1.6.4.msysgit.0 From e9e599bab6111ac517baacb523035e03b95a8370 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Fri, 24 Apr 2009 11:36:50 +0200 Subject: [PATCH 013/114] merge changes done to the cmake-buildsystem from the sf.net windbus-svn trunk. tested and works fine with at least msvc2008. (cherry picked from commit 45c168fd61e3f6447e014df4bb6417efbe725ccd) --- cmake/CMakeLists.txt | 137 ++++-- cmake/bus/CMakeLists.txt | 53 ++- cmake/config.h.cmake | 6 + cmake/dbus/CMakeLists.txt | 66 +++- cmake/dbus/dbus-1.def.cmake | 880 +++++++++++++++++++++++++++++++++++ cmake/test/CMakeLists.txt | 55 ++- cmake/test/name-test/CMakeLists.txt | 8 +- cmake/tools/CMakeLists.txt | 61 +-- 8 files changed, 1105 insertions(+), 161 deletions(-) create mode 100755 cmake/dbus/dbus-1.def.cmake diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 5482c5d..7156b22 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -2,19 +2,28 @@ set (PACKAGE dbus) # the version major, minor and release number should be synchron to the dbus cvs - windows releases should only update the patch level set (VERSION_MAJOR "1") -set (VERSION_MINOR "1") -set (VERSION_RELEASE "1") -set (VERSION_PATCH "2") +set (VERSION_MINOR "2") +set (VERSION_RELEASE "14") +set (VERSION_PATCH "0") if (VERSION_PATCH) set (VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_RELEASE}-${VERSION_PATCH}" ) else (VERSION_PATCH) set (VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_RELEASE}" ) endif (VERSION_PATCH) +set (DBUS_MAJOR_VERSION ${VERSION_MAJOR}) +set (DBUS_MINOR_VERSION ${VERSION_MAJOR}) +set (DBUS_MICRO_VERSION ${VERSION_MAJOR}) +set (DBUS_MAJOR_VERSION ${VERSION_MAJOR}) +set (DBUS_VERSION ${VERSION}) +set (DBUS_VERSION_STRING "${VERSION}") project(${PACKAGE}) # we need to be up to date CMAKE_MINIMUM_REQUIRED(VERSION 2.4.4 FATAL_ERROR) +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") @@ -25,7 +34,7 @@ SET(BUILD_SHARED_LIBS ON) if (CYGWIN) set (WIN32) endif (CYGWIN) - + # search for required packages if (WIN32) # include local header first to avoid using old installed header @@ -43,7 +52,7 @@ find_package(X11) # 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 @@ -62,19 +71,19 @@ if(MSVC) 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]") @@ -83,19 +92,20 @@ if(MSVC) 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") SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /FIconfig.h ${MSVC_W_ERROR} ${MSVC_W_DISABLE}") SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /FIconfig.h ${MSVC_W_ERROR} ${MSVC_W_DISABLE}") -endif(MSVC) -if(CMAKE_BUILD_TYPE STREQUAL "Debug") # used by executables, CMAKE_DEBUG_POSTFIX does not handle this case #set (CMAKE_EXE_POSTFIX "d") - #set (CMAKE_DEBUG_POSTFIX "d") -endif(CMAKE_BUILD_TYPE STREQUAL "Debug") + +endif(MSVC) +if(WIN32) + set (CMAKE_DEBUG_POSTFIX "d") +endif(WIN32) ######################################################################### # Windows CE @@ -110,9 +120,9 @@ if(wince) # 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 @@ -123,22 +133,22 @@ if(wince) -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) @@ -167,8 +177,7 @@ endif (WIN32 OR CYGWIN) set (EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin) # for including config.h and for includes like -include_directories( ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} ) -include_directories( ${CMAKE_INCLUDE_PATH} ) +include_directories( ${CMAKE_SOURCE_DIR}/.. ${CMAKE_BINARY_DIR} ${CMAKE_INCLUDE_PATH} ) # linker search directories link_directories(${DBUS_LIB_DIR} ${LIBRARY_OUTPUT_PATH} ) @@ -190,7 +199,7 @@ endif (DBUSDIR) 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}) @@ -208,7 +217,7 @@ else (DBUS_INSTALL_SYSTEM_LIBS) 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) @@ -217,15 +226,15 @@ endif (DBUS_INSTALL_SYSTEM_LIBS) 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) @@ -237,7 +246,7 @@ if(DBUS_ENABLE_ANSI) 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) @@ -257,7 +266,7 @@ if(DBUS_GCOV_ENABLED) # 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) @@ -351,12 +360,34 @@ if (WIN32) set (EXT ".exe") endif(WIN32) -set(TEST_SERVICE_DIR ${CMAKE_BINARY_DIR}/test/data/valid-service-files CACHE STRING "Full path to test file test/data/valid-service-files in builddir") -set(TEST_SERVICE_BINARY ${CMAKE_BINARY_DIR}/bin/test-service${EXT} CACHE STRING "Full path to test file test/test-service in builddir") -set(TEST_SHELL_SERVICE_BINARY ${CMAKE_BINARY_DIR}/bin/test-shell-service${EXT} CACHE STRING "Full path to test file test/test-shell-service in builddir") -set(TEST_EXIT_BINARY ${CMAKE_BINARY_DIR}/bin/test-exit${EXT} CACHE STRING "Full path to test file test/test-exit in builddir") -set(TEST_SEGFAULT_BINARY ${CMAKE_BINARY_DIR}/bin/test-segfault${EXT} CACHE STRING "Full path to test file test/test-segfault in builddir") -set(TEST_SLEEP_FOREVER_BINARY ${CMAKE_BINARY_DIR}/bin/test-sleep-forever${EXT} CACHE STRING "Full path to test file test/test-sleep-forever in builddir") +if (MSVC_IDE) + if (test_debug) + set(test_debug TRUE CACHE TYPE STRING FORCE) + set(IDE_BIN Debug/ ) + message(STATUS) + message(STATUS "Using Visual Studio: test programs will only work with the 'Debug' configuration!") + message(STATUS "To run the tests with the 'Release' configuration use -Dtest_debug=0") + message(STATUS "Add '..\\..\\test\\data' to the command line option of the test programs") + message(STATUS) + else (test_debug) + set(test_debug FALSE CACHE TYPE STRING FORCE) + set(IDE_BIN Release/) + message(STATUS) + message(STATUS "Using Visual Studio: test programs will only work with the 'Release' configuration!") + message(STATUS "To run the tests with the 'Debug' configuration use -Dtest_debug=1") + message(STATUS "Add '..\\..\\test\\data' to the command line option of the test programs") + message(STATUS) + endif (test_debug) + set (TEST_PATH_FORCE FORCE) + FILE(REMOVE ${CMAKE_BINARY_DIR}/data/dbus-1/services) +endif (MSVC_IDE) + +set(TEST_SERVICE_DIR ${CMAKE_BINARY_DIR}/test/data/valid-service-files CACHE STRING "Full path to test file test/data/valid-service-files in builddir" ) +set(TEST_SERVICE_BINARY ${CMAKE_BINARY_DIR}/bin/${IDE_BIN}test-service${EXT} CACHE STRING "Full path to test file test/test-service in builddir" ${TEST_PATH_FORCE}) +set(TEST_SHELL_SERVICE_BINARY ${CMAKE_BINARY_DIR}/bin/${IDE_BIN}test-shell-service${EXT} CACHE STRING "Full path to test file test/test-shell-service in builddir" ${TEST_PATH_FORCE}) +set(TEST_EXIT_BINARY ${CMAKE_BINARY_DIR}/bin/${IDE_BIN}test-exit${EXT} CACHE STRING "Full path to test file test/test-exit in builddir" ${TEST_PATH_FORCE}) +set(TEST_SEGFAULT_BINARY ${CMAKE_BINARY_DIR}/bin/${IDE_BIN}test-segfault${EXT} CACHE STRING "Full path to test file test/test-segfault in builddir" ${TEST_PATH_FORCE}) +set(TEST_SLEEP_FOREVER_BINARY ${CMAKE_BINARY_DIR}/bin/${IDE_BIN}test-sleep-forever${EXT} CACHE STRING "Full path to test file test/test-sleep-forever in builddir" ${TEST_PATH_FORCE}) #### Find socket directories if (NOT WIN32) @@ -386,7 +417,7 @@ endif (NOT WIN32) #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") @@ -410,12 +441,12 @@ set (DBUS_USER ) 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=) @@ -424,30 +455,48 @@ else (WIN32) 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) +option(splitlib "split library into dbus-lib-client, dbus-lib-generic, and dbus-lib-util, no installing possible" OFF) +if(splitlib AND MSVC) + # does not work with GCC/ld + set(DBUS_1 dbus-lib-client dbus-lib-generic dbus-lib-util) + message(STATUS "") + message(STATUS "dbus library is splitted into dbus-lib-client, dbus-lib-generic, and dbus-lib-util") + message(STATUS "installing is not possible") + message(STATUS "disable splitting: -Dsplitlib=0") + message(STATUS "") +else(splitlib AND MSVC) + message(STATUS "") + message(STATUS "for better code reading the dbus library could be splitted into three libraries:") + message(STATUS "dbus-lib-client, dbus-lib-generic, and dbus-lib-util (installing is then not possible)") + message(STATUS "enable splitting: -Dsplitlib=1") + message(STATUS "") + set(DBUS_1 dbus-1) +endif(splitlib AND MSVC) + ########### subdirs ############### add_subdirectory( dbus ) diff --git a/cmake/bus/CMakeLists.txt b/cmake/bus/CMakeLists.txt index 5ae4674..a19ab82 100644 --- a/cmake/bus/CMakeLists.txt +++ b/cmake/bus/CMakeLists.txt @@ -1,6 +1,4 @@ - -include_directories(${CMAKE_SOURCE_DIR}/..) -include_directories( ${CMAKE_INCLUDE_PATH} ) +project(bus) add_definitions(-DDBUS_COMPILATION) @@ -45,8 +43,11 @@ set (BUS_SOURCES ${BUS_DIR}/bus.c ${BUS_DIR}/bus.h ${BUS_DIR}/config-parser.c - ${BUS_DIR}/config-parser.h - ${BUS_DIR}/connection.c + ${BUS_DIR}/config-parser.h + ${BUS_DIR}/config-parser-common.c + ${BUS_DIR}/config-parser-common.h +# ${BUS_DIR}/config-parser-trivial.c + ${BUS_DIR}/connection.c ${BUS_DIR}/connection.h ${BUS_DIR}/desktop-file.c ${BUS_DIR}/desktop-file.h @@ -74,30 +75,34 @@ set (BUS_SOURCES ${DIR_WATCH_SOURCE} ) -set (dbus_daemon_SOURCES - ${BUS_SOURCES} - ${BUS_DIR}/main.c -) - include_directories(${XML_INCLUDE_DIR}) SET (LIBS ${XML_LIBRARY}) -add_executable(dbus-daemon${CMAKE_EXE_POSTFIX} ${dbus_daemon_SOURCES}) -target_link_libraries(dbus-daemon${CMAKE_EXE_POSTFIX} dbus-1 ${LIBS}) -install_targets(/bin dbus-daemon${CMAKE_EXE_POSTFIX} ) +if(splitlib AND MSVC) + add_library(bus-lib STATIC ${BUS_SOURCES}) + 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 ${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) install_files(/etc FILES ${config_DATA}) if (DBUS_SERVICE) set (dbus_service_SOURCES ${BUS_DIR}/bus-service-win.c - # TODO: add additional files + # TODO: add additional files # ${BUS_DIR}/service-main.c # ${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) @@ -115,14 +120,14 @@ endif (DBUS_SERVICE) ## even when not doing "make check" #noinst_PROGRAMS=$(TESTS) -set (bus_test_SOURCES - ${BUS_SOURCES} - ${BUS_DIR}/test-main.c -) - if (DBUS_BUILD_TESTS) - add_executable(bus-test ${bus_test_SOURCES}) - target_link_libraries(bus-test dbus-1 ${LIBS} ) + if(splitlib AND MSVC) + add_executable(bus-test ${BUS_DIR}/test-main.c) + target_link_libraries(bus-test ${DBUS_1} ${LIBS} bus-lib) + else(splitlib AND MSVC) + add_executable(bus-test ${BUS_SOURCES} ${BUS_DIR}/test-main.c) + target_link_libraries(bus-test ${DBUS_1} ${LIBS}) + endif(splitlib AND MSVC) #install_targets(/bin bus-test) add_test(bus-test ${EXECUTABLE_OUTPUT_PATH}/bus-test ${CMAKE_SOURCE_DIR}/../test/data) endif (DBUS_BUILD_TESTS) diff --git a/cmake/config.h.cmake b/cmake/config.h.cmake index 4f52387..63afe55 100644 --- a/cmake/config.h.cmake +++ b/cmake/config.h.cmake @@ -19,6 +19,12 @@ #cmakedefine PACKAGE "@PACKAGE@" /* Version number of package */ #cmakedefine VERSION "@VERSION@" +#cmakedefine DBUS_MAJOR_VERSION ${VERSION_MAJOR} +#cmakedefine DBUS_MINOR_VERSION ${VERSION_MINOR} +#cmakedefine DBUS_MICRO_VERSION ${VERSION_RELEASE} +#cmakedefine DBUS_VERSION ((@VERSION_MAJOR@ << 16) | (@VERSION_MINOR@ << 8) | (@VERSION_RELEASE@)) +#cmakedefine DBUS_VERSION_STRING "@VERSION@" + // test binaries /* Full path to test file test/test-exit in builddir */ #define TEST_BUS_BINARY "@TEST_BUS_BINARY@" diff --git a/cmake/dbus/CMakeLists.txt b/cmake/dbus/CMakeLists.txt index 306e9f3..b88d588 100644 --- a/cmake/dbus/CMakeLists.txt +++ b/cmake/dbus/CMakeLists.txt @@ -1,8 +1,7 @@ -project(dbus) +project(dbus-lib) #INCLUDES=-I$(top_srcdir) $(DBUS_CLIENT_CFLAGS) -DDBUS_COMPILATION -include_directories(${CMAKE_SOURCE_DIR}/..) SET(DBUS_DIR ${CMAKE_SOURCE_DIR}/../dbus) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/dbus-arch-deps.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/dbus-arch-deps.h ) @@ -24,6 +23,7 @@ set (dbusinclude_HEADERS ${DBUS_DIR}/dbus-server.h ${DBUS_DIR}/dbus-shared.h ${DBUS_DIR}/dbus-signature.h + ${DBUS_DIR}/dbus-spawn.h ${DBUS_DIR}/dbus-threads.h ${DBUS_DIR}/dbus-types.h dbus-arch-deps.h @@ -64,6 +64,8 @@ set (DBUS_LIB_SOURCES # find a clean Windows implementation # and move code to a *-win.c file ) + + if(UNIX) set (DBUS_LIB_SOURCES ${DBUS_LIB_SOURCES} ${DBUS_DIR}/dbus-transport-unix.c @@ -225,17 +227,57 @@ set(libdbus_HEADERS ${DBUS_UTIL_HEADERS} ) -if(MSVC) - add_library(dbus-1 STATIC ${libdbus_SOURCES} ${libdbus_HEADERS} ) - project_source_group(${GROUP_CODE} libdbus_SOURCES libdbus_HEADERS) -else(MSVC) - add_library(dbus-1 ${libdbus_SOURCES} ${libdbus_HEADERS} ) -endif(MSVC) +if(MSVC AND splitlib) + set(DBUS_LIB_TYPE STATIC) +elseif(MSVC AND splitlib) + set(DBUS_LIB_TYPE SHARED) +endif(MSVC AND splitlib) + + +if(splitlib AND MSVC) + # code for the client library and daemon/tests + add_library(dbus-lib-generic ${DBUS_LIB_TYPE} ${DBUS_SHARED_SOURCES} ${DBUS_SHARED_HEADERS}) + + # code only for daemon/tests + add_library(dbus-lib-util ${DBUS_LIB_TYPE} ${DBUS_UTIL_SOURCES} ${DBUS_UTIL_HEADERS}) + + # code for the client library + add_library(dbus-lib-client ${DBUS_LIB_TYPE} ${DBUS_LIB_SOURCES} ${DBUS_LIB_HEADERS}) + + target_link_libraries(dbus-lib-generic ${LIBS}) + target_link_libraries(dbus-lib-util ${LIBS}) + target_link_libraries(dbus-lib-client ${LIBS}) + + if(MSVC_IDE) + project_source_group(${GROUP_CODE} DBUS_LIB_SOURCES DBUS_LIB_HEADERS) + project_source_group(${GROUP_CODE} DBUS_SHARED_SOURCES DBUS_SHARED_HEADERS) + project_source_group(${GROUP_CODE} DBUS_UTIL_SOURCES DBUS_UTIL_SOURCES) + endif(MSVC_IDE) +else(splitlib AND MSVC) + # all code into one library + add_library(dbus-1 ${DBUS_LIB_TYPE} ${libdbus_SOURCES} ${libdbus_HEADERS} ) + target_link_libraries(dbus-1 ${LIBS}) + + if(MSVC) + set(DEF_LIBRARY_NAME dbus-1.dll) + configure_file("${CMAKE_CURRENT_SOURCE_DIR}/dbus-1.def.cmake" "${CMAKE_BINARY_DIR}/dbus-1.def") + set(DEF_LIBRARY_NAME dbus-1d.dll) + configure_file("${CMAKE_CURRENT_SOURCE_DIR}/dbus-1.def.cmake" "${CMAKE_BINARY_DIR}/dbus-1d.def") + set_target_properties(dbus-1 PROPERTIES LINK_FLAGS_RELWITHDEBINFO /def:"${CMAKE_BINARY_DIR}/dbus-1.def") + set_target_properties(dbus-1 PROPERTIES LINK_FLAGS_RELEASE /def:"${CMAKE_BINARY_DIR}/dbus-1.def") + set_target_properties(dbus-1 PROPERTIES LINK_FLAGS_MINSIZEREL /def:"${CMAKE_BINARY_DIR}/dbus-1.def") + set_target_properties(dbus-1 PROPERTIES LINK_FLAGS_DEBUG /def:"${CMAKE_BINARY_DIR}/dbus-1d.def") + endif(MSVC) + if(MSVC_IDE) + project_source_group(${GROUP_CODE} libdbus_SOURCES libdbus_HEADERS) + endif(MSVC_IDE) +endif(splitlib AND MSVC) -target_link_libraries(dbus-1 ${LIBS} ) -install_targets(/lib dbus-1 ) -install_files(/include/dbus FILES ${dbusinclude_HEADERS}) +if(NOT splitlib) + install_targets(/lib dbus-1 ) + install_files(/include/dbus FILES ${dbusinclude_HEADERS}) +endif(NOT splitlib) #ADD_EXECUTABLE(dbus-example dbus-example.c) #target_link_libraries(${CMAKE_SOURCE_DIR}/../dbus/dbus-example dbus-1) @@ -254,7 +296,7 @@ install_files(/include/dbus FILES ${dbusinclude_HEADERS}) if (DBUS_BUILD_TESTS) set (TESTS_ENVIRONMENT "DBUS_TEST_DATA=${CMAKE_SOURCE_DIR}/test/data DBUS_TEST_HOMEDIR=${CMAKE_BUILD_DIR}/dbus") ADD_EXECUTABLE(dbus-test ${CMAKE_SOURCE_DIR}/../dbus/dbus-test-main.c) - target_link_libraries(dbus-test dbus-1 ${LIBS}) + target_link_libraries(dbus-test ${DBUS_1} ${LIBS}) add_test(dbus-test ${EXECUTABLE_OUTPUT_PATH}/dbus-test ${CMAKE_SOURCE_DIR}/../test/data) #install_targets(/bin dbus-test) ENDIF (DBUS_BUILD_TESTS) diff --git a/cmake/dbus/dbus-1.def.cmake b/cmake/dbus/dbus-1.def.cmake new file mode 100755 index 0000000..bee3a67 --- /dev/null +++ b/cmake/dbus/dbus-1.def.cmake @@ -0,0 +1,880 @@ +/LIBRARY ${DEF_LIBRARY_NAME} +EXPORTS +_dbus_abort +_dbus_accept +_dbus_address_append_escaped +_dbus_address_test +_dbus_append_keyring_directory_for_credentials +_dbus_append_session_config_file +_dbus_append_system_config_file +_dbus_append_user_from_current_process +_dbus_atomic_dec +_dbus_atomic_inc +_dbus_auth_bytes_sent +_dbus_auth_client_new +_dbus_auth_decode_data +_dbus_auth_delete_unused_bytes +_dbus_auth_do_work +_dbus_auth_encode_data +_dbus_auth_get_buffer +_dbus_auth_get_bytes_to_send +_dbus_auth_get_guid_from_server +_dbus_auth_get_identity +_dbus_auth_get_unused_bytes +_dbus_auth_needs_decoding +_dbus_auth_needs_encoding +_dbus_auth_ref +_dbus_auth_return_buffer +_dbus_auth_script_run +_dbus_auth_server_new +_dbus_auth_set_context +_dbus_auth_set_credentials +_dbus_auth_set_mechanisms +_dbus_auth_test +_dbus_auth_unref +_dbus_babysitter_get_child_exited +_dbus_babysitter_get_child_exit_status +_dbus_babysitter_kill_child +_dbus_babysitter_ref +_dbus_babysitter_set_child_exit_error +_dbus_babysitter_set_watch_functions +_dbus_babysitter_unref +_dbus_become_daemon +_dbus_bus_notify_shared_connection_disconnected_unlocked +_dbus_change_identity +_dbus_change_to_daemon_user +_dbus_check_dir_is_private_to_user +_dbus_check_is_valid_bus_name +_dbus_check_is_valid_error_name +_dbus_check_is_valid_interface +_dbus_check_is_valid_member +_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 +_dbus_condvar_new +_dbus_condvar_new_at_location +_dbus_condvar_wait +_dbus_condvar_wait_timeout +_dbus_condvar_wake_all +_dbus_condvar_wake_one +_dbus_connect_tcp_socket +_dbus_connection_add_timeout_unlocked +_dbus_connection_add_watch_unlocked +_dbus_connection_block_pending_call +_dbus_connection_close_if_only_one_ref +_dbus_connection_close_possibly_shared +_dbus_connection_do_iteration_unlocked +_dbus_connection_get_message_to_send +_dbus_connection_handle_watch +_dbus_connection_has_messages_to_send_unlocked +_dbus_connection_lock +_dbus_connection_message_sent +_dbus_connection_new_for_transport +_dbus_connection_queue_received_message +_dbus_connection_queue_received_message_link +_dbus_connection_queue_synthesized_message_link +_dbus_connection_ref_unlocked +_dbus_connection_remove_pending_call +_dbus_connection_remove_timeout_unlocked +_dbus_connection_remove_watch_unlocked +_dbus_connection_send_and_unlock +_dbus_connection_test_get_locks +_dbus_connection_toggle_timeout_unlocked +_dbus_connection_toggle_watch_unlocked +_dbus_connection_unlock +_dbus_connection_unref_unlocked +_dbus_counter_adjust +_dbus_counter_get_value +_dbus_counter_new +_dbus_counter_ref +_dbus_counter_set_notify +_dbus_counter_unref +_dbus_create_directory +_dbus_create_file_exclusively +_dbus_credentials_add_credential +_dbus_credentials_add_credentials +_dbus_credentials_add_from_current_process +_dbus_credentials_add_from_user +_dbus_credentials_add_unix_pid +_dbus_credentials_add_unix_uid +_dbus_credentials_add_windows_sid +_dbus_credentials_are_anonymous +_dbus_credentials_are_empty +_dbus_credentials_are_superset +_dbus_credentials_clear +_dbus_credentials_copy +_dbus_credentials_get_unix_pid +_dbus_credentials_get_unix_uid +_dbus_credentials_get_windows_sid +_dbus_credentials_include +_dbus_credentials_new +_dbus_credentials_new_from_current_process +_dbus_credentials_ref +_dbus_credentials_same_user +_dbus_credentials_test +_dbus_credentials_unref +_dbus_current_generation DATA +_dbus_daemon_init +_dbus_daemon_release +_dbus_data_slot_allocator_alloc +_dbus_data_slot_allocator_free +_dbus_data_slot_allocator_init +_dbus_data_slot_list_clear +_dbus_data_slot_list_free +_dbus_data_slot_list_get +_dbus_data_slot_list_init +_dbus_data_slot_list_set +_dbus_data_slot_test +_dbus_decompose_path +_dbus_decrement_fail_alloc_counter +_dbus_delete_directory +_dbus_delete_file +_dbus_directory_close +_dbus_directory_get_next_file +_dbus_directory_open +_dbus_disable_mem_pools +_dbus_disable_sigpipe +_dbus_dup_string_array +_dbus_error_from_errno +_dbus_exit +_dbus_fd_set_close_on_exec +_dbus_file_close +_dbus_file_exists +_dbus_file_get_contents +_dbus_file_open +_dbus_file_read +_dbus_file_write +_dbus_first_type_in_signature +_dbus_first_type_in_signature_c_str +_dbus_flush_caches +_dbus_fstat +_dbus_full_duplex_pipe +_dbus_generate_pseudorandom_bytes_buffer +_dbus_generate_random_ascii +_dbus_generate_random_bytes +_dbus_generate_random_bytes_buffer +_dbus_generate_uuid +_dbus_get_autolaunch_address +_dbus_get_config_file_name +_dbus_get_current_time +_dbus_get_environment +_dbus_get_fail_alloc_counter +_dbus_get_fail_alloc_failures +_dbus_get_install_root +_dbus_get_is_errno_eagain_or_ewouldblock +_dbus_get_is_errno_eintr +_dbus_get_is_errno_enomem +_dbus_get_is_errno_nonzero +_dbus_get_local_machine_uuid_encoded +_dbus_get_malloc_blocks_outstanding +_dbus_get_oom_wait +_dbus_get_standard_session_servicedirs +_dbus_get_standard_system_servicedirs +_dbus_get_tmpdir +_dbus_getenv +_dbus_getgid +_dbus_getpid +_dbus_getsid +_dbus_getuid +_dbus_hash_iter_get_int_key +_dbus_hash_iter_get_string_key +_dbus_hash_iter_get_two_strings_key +_dbus_hash_iter_get_ulong_key +_dbus_hash_iter_get_value +_dbus_hash_iter_init +_dbus_hash_iter_lookup +_dbus_hash_iter_next +_dbus_hash_iter_remove_entry +_dbus_hash_iter_set_value +_dbus_hash_table_free_preallocated_entry +_dbus_hash_table_get_n_entries +_dbus_hash_table_insert_int +_dbus_hash_table_insert_pointer +_dbus_hash_table_insert_string +_dbus_hash_table_insert_string_preallocated +_dbus_hash_table_insert_two_strings +_dbus_hash_table_insert_ulong +_dbus_hash_table_lookup_int +_dbus_hash_table_lookup_pointer +_dbus_hash_table_lookup_string +_dbus_hash_table_lookup_two_strings +_dbus_hash_table_lookup_ulong +_dbus_hash_table_new +_dbus_hash_table_preallocate_entry +_dbus_hash_table_ref +_dbus_hash_table_remove_all +_dbus_hash_table_remove_int +_dbus_hash_table_remove_pointer +_dbus_hash_table_remove_string +_dbus_hash_table_remove_two_strings +_dbus_hash_table_remove_ulong +_dbus_hash_table_unref +_dbus_hash_test +_dbus_header_byteswap +_dbus_header_copy +_dbus_header_create +_dbus_header_delete_field +_dbus_header_field_to_string +_dbus_header_free +_dbus_header_get_field_basic +_dbus_header_get_field_raw +_dbus_header_get_flag +_dbus_header_get_message_type +_dbus_header_get_serial +_dbus_header_have_message_untrusted +_dbus_header_init +_dbus_header_load +_dbus_header_reinit +_dbus_header_set_field_basic +_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 +_dbus_keyring_get_hex_key +_dbus_keyring_is_for_credentials +_dbus_keyring_new_for_credentials +_dbus_keyring_ref +_dbus_keyring_test +_dbus_keyring_unref +_dbus_keyring_validate_context +_dbus_list_alloc_link +_dbus_list_append +_dbus_list_append_link +_dbus_list_clear +_dbus_list_copy +_dbus_list_find_last +_dbus_list_foreach +_dbus_list_free_link +_dbus_list_get_first +_dbus_list_get_first_link +_dbus_list_get_last +_dbus_list_get_last_link +_dbus_list_get_length +_dbus_list_insert_after +_dbus_list_insert_after_link +_dbus_list_insert_before +_dbus_list_insert_before_link +_dbus_list_length_is_one +_dbus_list_pop_first +_dbus_list_pop_first_link +_dbus_list_pop_last +_dbus_list_pop_last_link +_dbus_list_prepend +_dbus_list_prepend_link +_dbus_list_remove +_dbus_list_remove_last +_dbus_list_remove_link +_dbus_list_test +_dbus_list_unlink +_dbus_listen_tcp_socket +_dbus_lm_strerror +_dbus_lock_atomic DATA +_dbus_lock_bus DATA +_dbus_lock_bus_datas DATA +_dbus_lock_connection_slots DATA +_dbus_lock_list DATA +_dbus_lock_machine_uuid DATA +_dbus_lock_message_cache DATA +_dbus_lock_message_slots DATA +_dbus_lock_pending_call_slots DATA +_dbus_lock_server_slots DATA +_dbus_lock_shared_connections DATA +_dbus_lock_shutdown_funcs DATA +_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 +_dbus_loop_iterate +_dbus_loop_new +_dbus_loop_queue_dispatch +_dbus_loop_quit +_dbus_loop_ref +_dbus_loop_remove_timeout +_dbus_loop_remove_watch +_dbus_loop_run +_dbus_loop_unref +_dbus_make_file_world_readable +_dbus_marshal_byteswap +_dbus_marshal_byteswap_test +_dbus_marshal_header_test +_dbus_marshal_read_basic +_dbus_marshal_read_fixed_multi +_dbus_marshal_read_uint32 +_dbus_marshal_recursive_test +_dbus_marshal_set_basic +_dbus_marshal_set_uint32 +_dbus_marshal_skip_array +_dbus_marshal_skip_basic +_dbus_marshal_test +_dbus_marshal_validate_test +_dbus_marshal_write_basic +_dbus_marshal_write_fixed_multi +_dbus_mem_pool_alloc +_dbus_mem_pool_dealloc +_dbus_mem_pool_free +_dbus_mem_pool_new +_dbus_mem_pool_test +_dbus_memdup +_dbus_memory_test +_dbus_message_add_size_counter +_dbus_message_add_size_counter_link +_dbus_message_data_free +_dbus_message_data_iter_get_and_next +_dbus_message_data_iter_init +_dbus_message_get_network_data +_dbus_message_iter_get_args_valist +_dbus_message_loader_get_buffer +_dbus_message_loader_get_is_corrupted +_dbus_message_loader_get_max_message_size +_dbus_message_loader_new +_dbus_message_loader_peek_message +_dbus_message_loader_pop_message +_dbus_message_loader_pop_message_link +_dbus_message_loader_putback_message_link +_dbus_message_loader_queue_messages +_dbus_message_loader_ref +_dbus_message_loader_return_buffer +_dbus_message_loader_set_max_message_size +_dbus_message_loader_unref +_dbus_message_lock +_dbus_message_remove_size_counter +_dbus_message_set_serial +_dbus_message_test +_dbus_misc_test +_dbus_mkdir +_dbus_mutex_free +_dbus_mutex_free_at_location +_dbus_mutex_lock +_dbus_mutex_new +_dbus_mutex_new_at_location +_dbus_mutex_unlock +_dbus_no_memory_message +_dbus_object_tree_dispatch_and_unlock +_dbus_object_tree_free_all_unlocked +_dbus_object_tree_get_user_data_unlocked +_dbus_object_tree_list_registered_and_unlock +_dbus_object_tree_new +_dbus_object_tree_ref +_dbus_object_tree_register +_dbus_object_tree_test +_dbus_object_tree_unref +_dbus_object_tree_unregister_and_unlock +_dbus_pack_uint32 +_dbus_parse_unix_group_from_config +_dbus_parse_unix_user_from_config +_dbus_path_is_absolute +_dbus_pending_call_complete +_dbus_pending_call_get_completed_unlocked +_dbus_pending_call_get_connection_and_lock +_dbus_pending_call_get_connection_unlocked +_dbus_pending_call_get_reply_serial_unlocked +_dbus_pending_call_get_timeout_unlocked +_dbus_pending_call_is_timeout_added_unlocked +_dbus_pending_call_new_unlocked +_dbus_pending_call_queue_timeout_error_unlocked +_dbus_pending_call_ref_unlocked +_dbus_pending_call_set_data_unlocked +_dbus_pending_call_set_reply_serial_unlocked +_dbus_pending_call_set_reply_unlocked +_dbus_pending_call_set_timeout_added_unlocked +_dbus_pending_call_set_timeout_error_unlocked +_dbus_pending_call_test +_dbus_pending_call_unref_and_unlock +_dbus_pid_for_log +_dbus_pipe_close +_dbus_pipe_init +_dbus_pipe_init_stdout +_dbus_pipe_invalidate +_dbus_pipe_is_stdout_or_stderr +_dbus_pipe_is_valid +_dbus_pipe_write +_dbus_poll +_dbus_print_backtrace +_dbus_printf_string_upper_bound +_dbus_read_credentials_socket +_dbus_read_local_machine_uuid +_dbus_read_socket +_dbus_read_uuid_file +_dbus_real_assert +_dbus_real_assert_not_reached +_dbus_register_shutdown_func +_dbus_return_if_fail_warning_format DATA +_dbus_send_credentials_socket +_dbus_server_add_timeout +_dbus_server_add_watch +_dbus_server_debug_pipe_new +_dbus_server_finalize_base +_dbus_server_init_base +_dbus_server_listen_debug_pipe +_dbus_server_listen_platform_specific +_dbus_server_listen_socket +_dbus_server_new_for_socket +_dbus_server_new_for_tcp_socket +_dbus_server_ref_unlocked +_dbus_server_remove_timeout +_dbus_server_remove_watch +_dbus_server_socket_own_filename +_dbus_server_test +_dbus_server_toggle_timeout +_dbus_server_toggle_watch +_dbus_server_unref_unlocked +_dbus_set_bad_address +_dbus_set_errno_to_zero +_dbus_set_fail_alloc_counter +_dbus_set_fail_alloc_failures +_dbus_set_fd_nonblocking +_dbus_set_signal_handler +_dbus_setenv +_dbus_sha_compute +_dbus_sha_final +_dbus_sha_init +_dbus_sha_test +_dbus_sha_update +_dbus_shell_parse_argv +_dbus_shell_unquote +_dbus_signature_test +_dbus_sleep_milliseconds +_dbus_spawn_async_with_babysitter +_dbus_spawn_test +_dbus_split_paths_and_append +_dbus_stat +_dbus_strdup +_dbus_strerror +_dbus_strerror_from_errno +_dbus_string_align_length +_dbus_string_alloc_space +_dbus_string_append +_dbus_string_append_4_aligned +_dbus_string_append_8_aligned +_dbus_string_append_byte +_dbus_string_append_byte_as_hex +_dbus_string_append_double +_dbus_string_append_int +_dbus_string_append_len +_dbus_string_append_printf +_dbus_string_append_printf_valist +_dbus_string_append_uint +_dbus_string_append_unichar +_dbus_string_array_contains +_dbus_string_chop_white +_dbus_string_copy +_dbus_string_copy_data +_dbus_string_copy_data_len +_dbus_string_copy_len +_dbus_string_copy_to_buffer +_dbus_string_delete +_dbus_string_delete_first_word +_dbus_string_delete_leading_blanks +_dbus_string_ends_with_c_str +_dbus_string_equal +_dbus_string_equal_c_str +_dbus_string_equal_len +_dbus_string_equal_substring +_dbus_string_find +_dbus_string_find_blank +_dbus_string_find_byte_backward +_dbus_string_find_eol +_dbus_string_find_to +_dbus_string_free +_dbus_string_get_byte +_dbus_string_get_const_data +_dbus_string_get_const_data_len +_dbus_string_get_data +_dbus_string_get_data_len +_dbus_string_get_dirname +_dbus_string_get_length +_dbus_string_get_unichar +_dbus_string_hex_decode +_dbus_string_hex_encode +_dbus_string_init +_dbus_string_init_const +_dbus_string_init_const_len +_dbus_string_init_preallocated +_dbus_string_insert_2_aligned +_dbus_string_insert_4_aligned +_dbus_string_insert_8_aligned +_dbus_string_insert_alignment +_dbus_string_insert_byte +_dbus_string_insert_bytes +_dbus_string_lengthen +_dbus_string_lock +_dbus_string_move +_dbus_string_move_len +_dbus_string_parse_double +_dbus_string_parse_int +_dbus_string_parse_uint +_dbus_string_pop_line +_dbus_string_replace_len +_dbus_string_save_to_file +_dbus_string_set_byte +_dbus_string_set_length +_dbus_string_shorten +_dbus_string_skip_blank +_dbus_string_skip_white +_dbus_string_skip_white_reverse +_dbus_string_split_on_byte +_dbus_string_starts_with_c_str +_dbus_string_steal_data +_dbus_string_steal_data_len +_dbus_string_test +_dbus_string_validate_ascii +_dbus_string_validate_nul +_dbus_string_validate_utf8 +_dbus_string_zero +_dbus_swap_array +_dbus_sysdeps_test +_dbus_test_oom_handling +_dbus_threads_init_debug +_dbus_threads_init_platform_specific +_dbus_timeout_list_add_timeout +_dbus_timeout_list_free +_dbus_timeout_list_new +_dbus_timeout_list_remove_timeout +_dbus_timeout_list_set_functions +_dbus_timeout_list_toggle_timeout +_dbus_timeout_new +_dbus_timeout_ref +_dbus_timeout_set_enabled +_dbus_timeout_set_interval +_dbus_timeout_unref +_dbus_transport_debug_pipe_new +_dbus_transport_disconnect +_dbus_transport_do_iteration +_dbus_transport_finalize_base +_dbus_transport_get_address +_dbus_transport_get_adt_audit_session_data +_dbus_transport_get_dispatch_status +_dbus_transport_get_is_anonymous +_dbus_transport_get_is_authenticated +_dbus_transport_get_is_connected +_dbus_transport_get_max_message_size +_dbus_transport_get_max_received_size +_dbus_transport_get_server_id +_dbus_transport_get_socket_fd +_dbus_transport_get_unix_process_id +_dbus_transport_get_unix_user +_dbus_transport_get_windows_user +_dbus_transport_handle_watch +_dbus_transport_init_base +_dbus_transport_new_for_socket +_dbus_transport_new_for_tcp_socket +_dbus_transport_open +_dbus_transport_open_debug_pipe +_dbus_transport_open_platform_specific +_dbus_transport_open_socket +_dbus_transport_queue_messages +_dbus_transport_ref +_dbus_transport_set_allow_anonymous +_dbus_transport_set_auth_mechanisms +_dbus_transport_set_connection +_dbus_transport_set_max_message_size +_dbus_transport_set_max_received_size +_dbus_transport_set_unix_user_function +_dbus_transport_set_windows_user_function +_dbus_transport_unref +_dbus_type_get_alignment +_dbus_type_is_valid +_dbus_type_reader_delete +_dbus_type_reader_equal_values +_dbus_type_reader_get_array_length +_dbus_type_reader_get_current_type +_dbus_type_reader_get_element_type +_dbus_type_reader_get_signature +_dbus_type_reader_get_value_pos +_dbus_type_reader_greater_than +_dbus_type_reader_has_next +_dbus_type_reader_init +_dbus_type_reader_init_types_only +_dbus_type_reader_next +_dbus_type_reader_read_basic +_dbus_type_reader_read_fixed_multi +_dbus_type_reader_read_raw +_dbus_type_reader_recurse +_dbus_type_reader_set_basic +_dbus_type_signature_next +_dbus_type_to_string +_dbus_type_writer_add_types +_dbus_type_writer_append_array +_dbus_type_writer_init +_dbus_type_writer_init_types_delayed +_dbus_type_writer_init_values_only +_dbus_type_writer_recurse +_dbus_type_writer_remove_types +_dbus_type_writer_set_enabled +_dbus_type_writer_unrecurse +_dbus_type_writer_write_basic +_dbus_type_writer_write_fixed_multi +_dbus_type_writer_write_reader +_dbus_type_writer_write_reader_partial +_dbus_unix_groups_from_uid +_dbus_unix_user_is_at_console +_dbus_unix_user_is_process_owner +_dbus_unpack_uint16 +_dbus_unpack_uint32 +_dbus_user_at_console +_dbus_uuid_encode +_dbus_validate_body_with_reason +_dbus_validate_bus_name +_dbus_validate_error_name +_dbus_validate_interface +_dbus_validate_member +_dbus_validate_path +_dbus_validate_signature +_dbus_validate_signature_with_reason +_dbus_verbose_bytes +_dbus_verbose_bytes_of_string +_dbus_verbose_real +_dbus_verbose_reset_real +_dbus_verify_daemon_user +_dbus_wait_for_memory +_dbus_warn +_dbus_warn_check_failed +_dbus_watch_invalidate +_dbus_watch_list_add_watch +_dbus_watch_list_free +_dbus_watch_list_new +_dbus_watch_list_remove_watch +_dbus_watch_list_set_functions +_dbus_watch_list_toggle_watch +_dbus_watch_new +_dbus_watch_ref +_dbus_watch_sanitize_condition +_dbus_watch_set_handler +_dbus_watch_unref +_dbus_win_account_to_sid +_dbus_win_set_error_from_win_error +_dbus_win_startup_winsock +_dbus_win_utf16_to_utf8 +_dbus_win_utf8_to_utf16 +_dbus_win_warn_win_error +_dbus_windows_user_is_process_owner +_dbus_write_pid_to_file_and_pipe +_dbus_write_socket +_dbus_write_socket_two +dbus_address_entries_free +dbus_address_entry_get_method +dbus_address_entry_get_value +dbus_address_escape_value +dbus_address_unescape_value +dbus_bus_add_match +dbus_bus_get +dbus_bus_get_id +dbus_bus_get_private +dbus_bus_get_unique_name +dbus_bus_get_unix_user +dbus_bus_name_has_owner +dbus_bus_register +dbus_bus_release_name +dbus_bus_remove_match +dbus_bus_request_name +dbus_bus_set_unique_name +dbus_bus_start_service_by_name +dbus_connection_add_filter +dbus_connection_allocate_data_slot +dbus_connection_borrow_message +dbus_connection_close +dbus_connection_dispatch +dbus_connection_flush +dbus_connection_free_data_slot +dbus_connection_free_preallocated_send +dbus_connection_get_adt_audit_session_data +dbus_connection_get_data +dbus_connection_get_dispatch_status +dbus_connection_get_is_anonymous +dbus_connection_get_is_authenticated +dbus_connection_get_is_connected +dbus_connection_get_max_message_size +dbus_connection_get_max_received_size +dbus_connection_get_object_path_data +dbus_connection_get_outgoing_size +dbus_connection_get_server_id +dbus_connection_get_socket +dbus_connection_get_unix_fd +dbus_connection_get_unix_process_id +dbus_connection_get_unix_user +dbus_connection_get_windows_user +dbus_connection_has_messages_to_send +dbus_connection_list_registered +dbus_connection_open +dbus_connection_open_private +dbus_connection_pop_message +dbus_connection_preallocate_send +dbus_connection_read_write +dbus_connection_read_write_dispatch +dbus_connection_ref +dbus_connection_register_fallback +dbus_connection_register_object_path +dbus_connection_remove_filter +dbus_connection_return_message +dbus_connection_send +dbus_connection_send_preallocated +dbus_connection_send_with_reply +dbus_connection_send_with_reply_and_block +dbus_connection_set_allow_anonymous +dbus_connection_set_change_sigpipe +dbus_connection_set_data +dbus_connection_set_dispatch_status_function +dbus_connection_set_exit_on_disconnect +dbus_connection_set_max_message_size +dbus_connection_set_max_received_size +dbus_connection_set_route_peer_messages +dbus_connection_set_timeout_functions +dbus_connection_set_unix_user_function +dbus_connection_set_wakeup_main_function +dbus_connection_set_watch_functions +dbus_connection_set_windows_user_function +dbus_connection_steal_borrowed_message +dbus_connection_unref +dbus_connection_unregister_object_path +dbus_error_free +dbus_error_has_name +dbus_error_init +dbus_error_is_set +dbus_free +dbus_free_string_array +dbus_get_local_machine_id +dbus_internal_do_not_use_foreach_message_file +dbus_internal_do_not_use_generate_bodies +dbus_internal_do_not_use_load_message_file +dbus_internal_do_not_use_run_tests +dbus_internal_do_not_use_try_message_data +dbus_internal_do_not_use_try_message_file +dbus_malloc +dbus_malloc0 +dbus_message_allocate_data_slot +dbus_message_append_args +dbus_message_append_args_valist +dbus_message_copy +dbus_message_demarshal +dbus_message_free_data_slot +dbus_message_get_args +dbus_message_get_args_valist +dbus_message_get_auto_start +dbus_message_get_data +dbus_message_get_destination +dbus_message_get_error_name +dbus_message_get_interface +dbus_message_get_member +dbus_message_get_no_reply +dbus_message_get_path +dbus_message_get_path_decomposed +dbus_message_get_reply_serial +dbus_message_get_sender +dbus_message_get_serial +dbus_message_get_signature +dbus_message_get_type +dbus_message_has_destination +dbus_message_has_interface +dbus_message_has_member +dbus_message_has_path +dbus_message_has_sender +dbus_message_has_signature +dbus_message_is_error +dbus_message_is_method_call +dbus_message_is_signal +dbus_message_iter_append_basic +dbus_message_iter_append_fixed_array +dbus_message_iter_close_container +dbus_message_iter_get_arg_type +dbus_message_iter_get_array_len +dbus_message_iter_get_basic +dbus_message_iter_get_element_type +dbus_message_iter_get_fixed_array +dbus_message_iter_get_signature +dbus_message_iter_has_next +dbus_message_iter_init +dbus_message_iter_init_append +dbus_message_iter_next +dbus_message_iter_open_container +dbus_message_iter_recurse +dbus_message_marshal +dbus_message_new +dbus_message_new_error +dbus_message_new_error_printf +dbus_message_new_method_call +dbus_message_new_method_return +dbus_message_new_signal +dbus_message_ref +dbus_message_set_auto_start +dbus_message_set_data +dbus_message_set_destination +dbus_message_set_error_name +dbus_message_set_interface +dbus_message_set_member +dbus_message_set_no_reply +dbus_message_set_path +dbus_message_set_reply_serial +dbus_message_set_sender +dbus_message_type_from_string +dbus_message_type_to_string +dbus_message_unref +dbus_move_error +dbus_parse_address +dbus_pending_call_allocate_data_slot +dbus_pending_call_block +dbus_pending_call_cancel +dbus_pending_call_free_data_slot +dbus_pending_call_get_completed +dbus_pending_call_get_data +dbus_pending_call_ref +dbus_pending_call_set_data +dbus_pending_call_set_notify +dbus_pending_call_steal_reply +dbus_pending_call_unref +dbus_realloc +dbus_server_allocate_data_slot +dbus_server_disconnect +dbus_server_free_data_slot +dbus_server_get_address +dbus_server_get_data +dbus_server_get_id +dbus_server_get_is_connected +dbus_server_listen +dbus_server_ref +dbus_server_set_auth_mechanisms +dbus_server_set_data +dbus_server_set_new_connection_function +dbus_server_set_timeout_functions +dbus_server_set_watch_functions +dbus_server_unref +dbus_set_error +dbus_set_error_const +dbus_set_error_from_message +dbus_shutdown +dbus_signature_iter_get_current_type +dbus_signature_iter_get_element_type +dbus_signature_iter_get_signature +dbus_signature_iter_init +dbus_signature_iter_next +dbus_signature_iter_recurse +dbus_signature_validate +dbus_signature_validate_single +dbus_threads_init +dbus_threads_init_default +dbus_timeout_get_data +dbus_timeout_get_enabled +dbus_timeout_get_interval +dbus_timeout_handle +dbus_timeout_set_data +dbus_type_is_basic +dbus_type_is_container +dbus_type_is_fixed +dbus_watch_get_data +dbus_watch_get_enabled +dbus_watch_get_fd +dbus_watch_get_flags +dbus_watch_get_socket +dbus_watch_get_unix_fd +dbus_watch_handle +dbus_watch_set_data diff --git a/cmake/test/CMakeLists.txt b/cmake/test/CMakeLists.txt index ef79c26..2540f3d 100644 --- a/cmake/test/CMakeLists.txt +++ b/cmake/test/CMakeLists.txt @@ -1,3 +1,4 @@ +project(test) #if HAVE_GLIB # GLIB_SUBDIR=glib @@ -16,9 +17,6 @@ add_subdirectory( name-test ) #INCLUDES=-I$(top_srcdir) $(DBUS_test-CFLAGS) -include_directories( ${CMAKE_SOURCE_DIR}/.. ) -include_directories( ${CMAKE_INCLUDE_PATH} ) - if (WIN32) add_definitions(-Dsleep=_sleep) endif (WIN32) @@ -89,7 +87,7 @@ set (decode_gcov_SOURCES ) add_executable(test-service ${test-service_SOURCES}) -target_link_libraries(test-service dbus-1) +target_link_libraries(test-service ${DBUS_1}) #install_targets(/bin test-service) # (rh) does not work at now @@ -98,63 +96,68 @@ ADD_TEST(test-service ${EXECUTABLE_OUTPUT_PATH}/test-service${EXT}) add_executable(test-names ${test-names_SOURCES}) -target_link_libraries(test-names dbus-1) +target_link_libraries(test-names ${DBUS_1}) #install_targets(/bin test-names) ADD_TEST(test-names ${EXECUTABLE_OUTPUT_PATH}/test-names${EXT}) add_executable(test-shell ${test-shell_SOURCES}) -target_link_libraries(test-shell dbus-1) +target_link_libraries(test-shell ${DBUS_1}) #install_targets(/bin test-shell) ADD_TEST(test-shell ${EXECUTABLE_OUTPUT_PATH}/test-shell${EXT}) add_executable(test-shell-service ${test-shell_SOURCES}) -target_link_libraries(test-shell-service dbus-1) +target_link_libraries(test-shell-service ${DBUS_1}) #install_targets(/bin test-shell-service) ADD_TEST(test-shell-service ${EXECUTABLE_OUTPUT_PATH}/test-shell-service${EXT}) add_executable(test-spawn ${test-spawn_SOURCES}) -target_link_libraries(test-spawn dbus-1) +target_link_libraries(test-spawn ${DBUS_1}) # (rh) does not work now #ADD_TEST(test-spawn ${EXECUTABLE_OUTPUT_PATH}/test-spawn${EXT}) add_executable(test-exit ${test-exit_SOURCES}) -target_link_libraries(test-exit dbus-1) +target_link_libraries(test-exit ${DBUS_1}) #install_targets(/bin test-exit) ADD_TEST(test-exit ${EXECUTABLE_OUTPUT_PATH}/test-exit${EXT}) add_executable(test-segfault ${test-segfault_SOURCES}) -target_link_libraries(test-segfault dbus-1) +target_link_libraries(test-segfault ${DBUS_1}) #install_targets(/bin test-segfault) ADD_TEST(test-segfault ${EXECUTABLE_OUTPUT_PATH}/test-segfault${EXT}) add_executable(test-sleep-forever ${test-sleep-forever_SOURCES}) -target_link_libraries(test-sleep-forever dbus-1) +target_link_libraries(test-sleep-forever ${DBUS_1}) # (rh) don't know for what this test is good #ADD_TEST(test-sleep-forever ${EXECUTABLE_OUTPUT_PATH}/test-sleep-forever${EXT}) #add_executable(decode-gcov ${decode_gcov_SOURCES}) -#target_link_libraries(decode-gcov dbus-1) +#target_link_libraries(decode-gcov ${DBUS_1}) #EXTRA_DIST= # ### keep these in creation order, i.e. uppermost dirs first set (TESTDIRS test/data - test/data/valid-messages - test/data/invalid-messages - test/data/incomplete-messages - test/data/auth - test/data/sha-1 - test/data/valid-config-files - test/data/valid-config-files/basic.d - test/data/valid-config-files/system.d - test/data/valid-service-files - test/data/invalid-config-files - test/data/equiv-config-files - test/data/equiv-config-files/basic - test/data/equiv-config-files/basic/basic.d - test/data/equiv-config-files/entities + test/data/auth + test/data/equiv-config-files + test/data/equiv-config-files/basic + test/data/equiv-config-files/basic/basic.d + test/data/equiv-config-files/entities test/data/equiv-config-files/entities/basic.d + test/data/incomplete-messages + test/data/invalid-config-files + test/data/invalid-config-files-system + test/data/invalid-messages + test/data/invalid-service-files-system + test/data/sha-1 + test/data/valid-config-files + test/data/valid-config-files/basic.d + test/data/valid-config-files/system.d + test/data/valid-config-files-system + test/data/valid-introspection-files + test/data/valid-messages + test/data/valid-service-files + test/data/valid-service-files-system ) set (CONFIG_VERBOSE 0) diff --git a/cmake/test/name-test/CMakeLists.txt b/cmake/test/name-test/CMakeLists.txt index 2af0d89..3c392b6 100644 --- a/cmake/test/name-test/CMakeLists.txt +++ b/cmake/test/name-test/CMakeLists.txt @@ -2,23 +2,21 @@ if (DBUS_BUILD_TESTS) set (NAMEtest-DIR ../../../test/name-test) -include_directories( ${CMAKE_SOURCE_DIR}/.. ) -include_directories( ${CMAKE_INCLUDE_PATH} ) add_definitions(-DDBUS_COMPILATION) # there is also a test-names executable, don't know if this is the same add_executable(test-names1 ${NAMEtest-DIR}/test-names.c) -target_link_libraries(test-names1 dbus-1) +target_link_libraries(test-names1 ${DBUS_1}) #install_targets(/bin test-names1) ADD_TEST(test-names ${EXECUTABLE_OUTPUT_PATH}/test-names1) add_executable(test-pending-call-dispatch ${NAMEtest-DIR}/test-pending-call-dispatch.c) -target_link_libraries(test-pending-call-dispatch dbus-1) +target_link_libraries(test-pending-call-dispatch ${DBUS_1}) #install_targets(/bin test-pending-call-dispatch) ADD_TEST(test-pending-call-dispatch ${EXECUTABLE_OUTPUT_PATH}/test-pending_call-dispatch) add_executable(test-thread-init ${NAMEtest-DIR}/test-threads-init.c) -target_link_libraries(test-thread-init dbus-1) +target_link_libraries(test-thread-init ${DBUS_1}) #install_targets(/bin test-thread-init) ADD_TEST(test-names ${EXECUTABLE_OUTPUT_PATH}/test-thread-init) diff --git a/cmake/tools/CMakeLists.txt b/cmake/tools/CMakeLists.txt index adff930..684ec0e 100644 --- a/cmake/tools/CMakeLists.txt +++ b/cmake/tools/CMakeLists.txt @@ -1,30 +1,4 @@ - -include_directories(${CMAKE_SOURCE_DIR}/..) - -#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) +project(tools) set (dbus_send_SOURCES ../../tools/dbus-print-message.c @@ -60,29 +34,16 @@ set (dbus_viewer_SOURCES ../../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} ) - -# glib required -#add_executable(dbus_launch${CMAKE_EXE_POSTFIX} ${dbus_launch_SOURCES}) - -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-send ${dbus_send_SOURCES}) +target_link_libraries(dbus-send ${DBUS_1}) +install_targets(/bin dbus-send ) -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} ) +add_executable(dbus-launch ${dbus_launch_SOURCES}) +target_link_libraries(dbus-launch ) +install_targets(/bin dbus-launch ) -#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) +add_executable(dbus-monitor ${dbus_monitor_SOURCES}) +target_link_libraries(dbus-monitor ${DBUS_1}) +install_targets(/bin dbus-monitor ) -#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) -- 1.6.4.msysgit.0 From 2232bfcc39b6d75a78ca5241904f7d501cb952cb Mon Sep 17 00:00:00 2001 From: Frank Osterfeld Date: Thu, 23 Apr 2009 12:15:33 +0200 Subject: [PATCH 014/114] build fixes for tests on unix (cherry picked from commit 99f567e97f807a1270d01f97223941acd279dbf8) --- cmake/tools/CMakeLists.txt | 10 ++++++++++ 1 files changed, 10 insertions(+), 0 deletions(-) diff --git a/cmake/tools/CMakeLists.txt b/cmake/tools/CMakeLists.txt index 684ec0e..976262c 100644 --- a/cmake/tools/CMakeLists.txt +++ b/cmake/tools/CMakeLists.txt @@ -22,6 +22,13 @@ set (dbus_launch_SOURCES ) endif (WIN32) +if (DBUS_BUILD_X11) +set (dbus_launch_SOURCES + ${dbus_launch_SOURCES} + ../../tools/dbus-launch-x11.c +) +endif(DBUS_BUILD_X11) + set (dbus_cleanup_sockets_SOURCES ../../tools/dbus-cleanup-sockets.c ) @@ -40,6 +47,9 @@ install_targets(/bin dbus-send ) add_executable(dbus-launch ${dbus_launch_SOURCES}) target_link_libraries(dbus-launch ) +if (DBUS_BUILD_X11) + target_link_libraries(dbus-launch ${X11_LIBRARIES} ) +endif (DBUS_BUILD_X11) install_targets(/bin dbus-launch ) add_executable(dbus-monitor ${dbus_monitor_SOURCES}) -- 1.6.4.msysgit.0 From 2fbdc8830a8b9b8097c8eb0cddb06c531fea22f0 Mon Sep 17 00:00:00 2001 From: Frank Osterfeld Date: Thu, 23 Apr 2009 12:16:49 +0200 Subject: [PATCH 015/114] set -DDBUS_BUILD_TESTS remove -g, it's already set via CMAKE_BUILD_TYPE (cherry picked from commit 0dc4c572cf94edf81e0a2460d0aa82ca32eb24d7) --- cmake/CMakeLists.txt | 6 +----- 1 files changed, 1 insertions(+), 5 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 7156b22..ecc3607 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -230,11 +230,7 @@ set (DBUS_DAEMONDIR ${EXPANDED_BINDIR}) #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(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) + add_definitions(-DDBUS_BUILD_TESTS) # win32 dbus service support - this support is not complete OPTION(DBUS_SERVICE "enable dbus service installer" OFF) -- 1.6.4.msysgit.0 From 5f005355aa6a04ec4d02610af8ed6ca0525c0103 Mon Sep 17 00:00:00 2001 From: Frank Osterfeld Date: Tue, 28 Apr 2009 17:10:46 +0200 Subject: [PATCH 016/114] fix configure check and VA_COPY usage * fix configure check: set DBUS_VA_COPY_FUNC correctly, and DBUS_VA_COPY_AS_ARRAY if no usable one was found * add DBUS_VA_COPY_AS_ARRAY * define DBUS_VA_COPY indirectly, cmakedefine plus variable does not work for me on windows, and is the wrong thing to do according to Allen. The undef seems unnecessary now, the address parsing test passes on windows, using mingw (cherry picked from commit e6680d78d943be4ee2d85e9d82cd8aa1350db882) --- cmake/ConfigureChecks.cmake | 8 +++++--- cmake/config.h.cmake | 10 ++++++---- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/cmake/ConfigureChecks.cmake b/cmake/ConfigureChecks.cmake index 756d67f..c44ea7a 100644 --- a/cmake/ConfigureChecks.cmake +++ b/cmake/ConfigureChecks.cmake @@ -105,7 +105,7 @@ try_compile(DBUS_HAVE_VA_COPY ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/cmake_try_compile.c) if(DBUS_HAVE_VA_COPY) - SET(DBUS_VA_COPY va_copy CACHE STRING "va_copy function") + SET(DBUS_VA_COPY_FUNC va_copy CACHE STRING "va_copy function") else(DBUS_HAVE_VA_COPY) write_file("${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/cmake_try_compile.c" "#include void f (int i, ...) { @@ -121,10 +121,12 @@ else(DBUS_HAVE_VA_COPY) return 0; } ") - try_compile(DBUS_HAVE_VA_COPY + try_compile(DBUS_HAVE___VA_COPY ${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/cmake_try_compile.c) if(DBUS_HAVE___VA_COPY) - SET(DBUS_VA_COPY __va_copy CACHE STRING "va_copy function") + SET(DBUS_VA_COPY_FUNC __va_copy CACHE STRING "va_copy function") + else(DBUS_HAVE___VA_COPY) + SET(DBUS_VA_COPY_AS_ARRAY "1" CACHE STRING "'va_lists' cannot be copies as values") endif(DBUS_HAVE___VA_COPY) endif(DBUS_HAVE_VA_COPY) diff --git a/cmake/config.h.cmake b/cmake/config.h.cmake index 63afe55..047135b 100644 --- a/cmake/config.h.cmake +++ b/cmake/config.h.cmake @@ -64,7 +64,12 @@ #cmakedefine DBUS_BUILD_X11 1 -#cmakedefine DBUS_VA_COPY @DBUS_VA_COPY_FUNC@ +#cmakedefine DBUS_VA_COPY_FUNC +#if (defined DBUS_VA_COPY_FUNC) +# define DBUS_VA_COPY @DBUS_VA_COPY_FUNC@ +#endif + +#cmakedefine DBUS_VA_COPY_AS_ARRAY 1 // headers /* Define to 1 if you have dirent.h */ @@ -165,9 +170,6 @@ # define strtoull _strtoui64 typedef int mode_t; # endif -# ifdef DBUS_VA_COPY -# undef DBUS_VA_COPY // DBUS_VA_COPY kills mingw's bus-test -# endif #endif // defined(_WIN32) || defined(_WIN64) #ifdef interface -- 1.6.4.msysgit.0 From f16a14f1f5835e9339dac1676bac14a729350832 Mon Sep 17 00:00:00 2001 From: Frank Osterfeld Date: Tue, 21 Apr 2009 16:21:06 +0100 Subject: [PATCH 017/114] do not call functions with side-effects inside assert (cherry picked from commit 0d0f443564403fedffd0450bed377230511ba0d7) --- dbus/dbus-sysdeps-win.c | 9 +++++---- 1 files changed, 5 insertions(+), 4 deletions(-) diff --git a/dbus/dbus-sysdeps-win.c b/dbus/dbus-sysdeps-win.c index fd4eebd..2163da7 100644 --- a/dbus/dbus-sysdeps-win.c +++ b/dbus/dbus-sysdeps-win.c @@ -2961,13 +2961,14 @@ _dbus_daemon_init(const char *host, dbus_uint32_t port) char szDBusDaemonMutex[128]; char szDBusDaemonAddressInfo[128]; char szAddress[128]; + DWORD ret; _dbus_assert(host); _dbus_assert(port); _snprintf(szAddress, sizeof(szAddress) - 1, "tcp:host=%s,port=%d", host, port); - - _dbus_assert( GetUserName(szUserName, &dwUserNameSize) != 0); + ret = GetUserName(szUserName, &dwUserNameSize); + _dbus_assert(ret != 0); _snprintf(szDBusDaemonMutex, sizeof(szDBusDaemonMutex) - 1, "%s:%s", cDBusDaemonMutex, szUserName); _snprintf(szDBusDaemonAddressInfo, sizeof(szDBusDaemonAddressInfo) - 1, "%s:%s", @@ -2975,8 +2976,8 @@ _dbus_daemon_init(const char *host, dbus_uint32_t port) // before _dbus_global_lock to keep correct lock/release order hDBusDaemonMutex = CreateMutex( NULL, FALSE, szDBusDaemonMutex ); - - _dbus_assert(WaitForSingleObject( hDBusDaemonMutex, 1000 ) == WAIT_OBJECT_0); + ret = WaitForSingleObject( hDBusDaemonMutex, 1000 ); + _dbus_assert(ret == WAIT_OBJECT_0); // sync _dbus_daemon_init, _dbus_daemon_uninit and _dbus_daemon_already_runs lock = _dbus_global_lock( cUniqueDBusInitMutex ); -- 1.6.4.msysgit.0 From b63d39d793aa83da4b481e5f07bd4b2a2e585f37 Mon Sep 17 00:00:00 2001 From: Frank Osterfeld Date: Wed, 22 Apr 2009 12:49:45 +0100 Subject: [PATCH 018/114] be more verbose when locking the mutex fails (cherry picked from commit 4a14a050c4be026c7b9d67fd1f47c8479edebfc4) --- dbus/dbus-sysdeps-win.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-) diff --git a/dbus/dbus-sysdeps-win.c b/dbus/dbus-sysdeps-win.c index 2163da7..ab71981 100644 --- a/dbus/dbus-sysdeps-win.c +++ b/dbus/dbus-sysdeps-win.c @@ -2977,7 +2977,10 @@ _dbus_daemon_init(const char *host, dbus_uint32_t port) // before _dbus_global_lock to keep correct lock/release order hDBusDaemonMutex = CreateMutex( NULL, FALSE, szDBusDaemonMutex ); ret = WaitForSingleObject( hDBusDaemonMutex, 1000 ); - _dbus_assert(ret == WAIT_OBJECT_0); + if ( ret != WAIT_OBJECT_0 ) { + _dbus_warn("Could not lock mutex %s (return code %d). daemon already running?\n", szDBusDaemonMutex, ret ); + _dbus_assert( !"Could not lock mutex, daemon already running?" ); + } // sync _dbus_daemon_init, _dbus_daemon_uninit and _dbus_daemon_already_runs lock = _dbus_global_lock( cUniqueDBusInitMutex ); -- 1.6.4.msysgit.0 From 4d8bc1337ef9878d4a5d66dd04b280d0b635e5d4 Mon Sep 17 00:00:00 2001 From: Frank Osterfeld Date: Wed, 22 Apr 2009 11:49:58 +0200 Subject: [PATCH 019/114] add check for abstract sockets (cherry picked from commit 5b657984f4bc5544a8df560adcd224ed243972f1) --- cmake/CMakeLists.txt | 3 ++ cmake/ConfigureChecks.cmake | 17 ++++++++++++++++ cmake/config.h.cmake | 18 ++++++++++++++++ cmake/modules/CheckForAbstractSockets.c | 33 +++++++++++++++++++++++++++++++ 4 files changed, 71 insertions(+), 0 deletions(-) create mode 100644 cmake/modules/CheckForAbstractSockets.c diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index ecc3607..c794056 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -49,6 +49,9 @@ find_package(LibXml2) find_package(LibExpat) find_package(X11) + +OPTION(DBUS_ENABLE_ABSTRACT_SOCKETS "enable support for abstract sockets" ON) + # do config checks INCLUDE(ConfigureChecks.cmake) diff --git a/cmake/ConfigureChecks.cmake b/cmake/ConfigureChecks.cmake index c44ea7a..f42ce76 100644 --- a/cmake/ConfigureChecks.cmake +++ b/cmake/ConfigureChecks.cmake @@ -130,3 +130,20 @@ else(DBUS_HAVE_VA_COPY) SET(DBUS_VA_COPY_AS_ARRAY "1" CACHE STRING "'va_lists' cannot be copies as values") endif(DBUS_HAVE___VA_COPY) endif(DBUS_HAVE_VA_COPY) + +#### Abstract sockets + +if (DBUS_ENABLE_ABSTRACT_SOCKETS) + + try_compile(HAVE_ABSTRACT_SOCKETS + ${CMAKE_BINARY_DIR} + ${CMAKE_SOURCE_DIR}/modules/CheckForAbstractSockets.c) + +endif(DBUS_ENABLE_ABSTRACT_SOCKETS) + +if(HAVE_ABSTRACT_SOCKETS) + set(DBUS_PATH_OR_ABSTRACT_VALUE abstract) +else(HAVE_ABSTRACT_SOCKETS) + set(DBUS_PATH_OR_ABSTRACT_VALUE path) +endif(HAVE_ABSTRACT_SOCKETS) + diff --git a/cmake/config.h.cmake b/cmake/config.h.cmake index 047135b..3461338 100644 --- a/cmake/config.h.cmake +++ b/cmake/config.h.cmake @@ -48,7 +48,21 @@ /* xmldocs */ /* doxygen */ #cmakedefine DBUS_GCOV_ENABLED 1 + /* abstract-sockets */ + +#cmakedefine HAVE_ABSTRACT_SOCKETS 1 + +#cmakedefine DBUS_PATH_OR_ABSTRACT_VALUE 1 + +#if (defined DBUS_PATH_OR_ABSTRACT_VALUE) +#define DBUS_PATH_OR_ABSTRACT @DBUS_PATH_OR_ABSTRACT_VALUE@ +#endif + +#ifdef DBUS_PATH_OR_ABSTRACT_VALUE +#undef DBUS_PATH_OR_ABSTRACT_VALUE +#endif + /* selinux */ #cmakedefine DBUS_BUS_ENABLE_DNOTIFY_ON_LINUX 1 /* kqueue */ @@ -69,6 +83,10 @@ # define DBUS_VA_COPY @DBUS_VA_COPY_FUNC@ #endif +#ifdef DBUS_VA_COPY_FUNC +#undef DBUS_VA_COPY_FUNC +#endif + #cmakedefine DBUS_VA_COPY_AS_ARRAY 1 // headers diff --git a/cmake/modules/CheckForAbstractSockets.c b/cmake/modules/CheckForAbstractSockets.c new file mode 100644 index 0000000..062b846 --- /dev/null +++ b/cmake/modules/CheckForAbstractSockets.c @@ -0,0 +1,33 @@ +#include +#include +#include +#include +#include +#include + +int main() { + int listen_fd; + struct sockaddr_un addr; + + listen_fd = socket (PF_UNIX, SOCK_STREAM, 0); + + if (listen_fd < 0) + { + fprintf (stderr, "socket() failed: %s\n", strerror (errno)); + exit (1); + } + + memset (&addr, '\0', sizeof (addr)); + addr.sun_family = AF_UNIX; + strcpy (addr.sun_path, "X/tmp/dbus-fake-socket-path-used-in-configure-test"); + addr.sun_path[0] = '\0'; /* this is what makes it abstract */ + + if (bind (listen_fd, (struct sockaddr*) &addr, SUN_LEN (&addr)) < 0) + { + fprintf (stderr, "Abstract socket namespace bind() failed: %s\n", + strerror (errno)); + exit (1); + } + else + exit (0); +} \ No newline at end of file -- 1.6.4.msysgit.0 From cd8944b6d21c733b68b150c16825aab33df03e8c Mon Sep 17 00:00:00 2001 From: Frank Osterfeld Date: Wed, 22 Apr 2009 15:26:06 +0100 Subject: [PATCH 020/114] don't leak string list in error case (cherry picked from commit e4f39254976544781f1060c2051b10f32628408e) --- bus/dispatch.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/bus/dispatch.c b/bus/dispatch.c index a69a929..9ad494b 100644 --- a/bus/dispatch.c +++ b/bus/dispatch.c @@ -4197,6 +4197,7 @@ check_list_services (BusContext *context, if (!_dbus_string_array_contains ((const char **)services, existent)) { _dbus_warn ("Did not get the expected %s from ListActivatableNames\n", existent); + dbus_free_string_array (services); return FALSE; } -- 1.6.4.msysgit.0 From db95356711efd0e92dfe541f6d925bf69eeaf516 Mon Sep 17 00:00:00 2001 From: Frank Osterfeld Date: Mon, 27 Apr 2009 16:12:50 +0200 Subject: [PATCH 021/114] use correct test data dir (cherry picked from commit ef471a74068b198ed10fe2a377520aa6a68b8370) --- cmake/bus/CMakeLists.txt | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/cmake/bus/CMakeLists.txt b/cmake/bus/CMakeLists.txt index a19ab82..15aca8e 100644 --- a/cmake/bus/CMakeLists.txt +++ b/cmake/bus/CMakeLists.txt @@ -129,7 +129,7 @@ if (DBUS_BUILD_TESTS) target_link_libraries(bus-test ${DBUS_1} ${LIBS}) endif(splitlib AND MSVC) #install_targets(/bin bus-test) - add_test(bus-test ${EXECUTABLE_OUTPUT_PATH}/bus-test ${CMAKE_SOURCE_DIR}/../test/data) + add_test(bus-test ${EXECUTABLE_OUTPUT_PATH}/bus-test ${CMAKE_BINARY_DIR}/test/data) endif (DBUS_BUILD_TESTS) if(MSVC) -- 1.6.4.msysgit.0 From 3393302ffb9ce3521e564c83dc458dbcc1553d53 Mon Sep 17 00:00:00 2001 From: Sebastian Sauer Date: Mon, 27 Apr 2009 17:06:37 +0200 Subject: [PATCH 022/114] use CMAKE_BUILD_TYPE to differ between debug and release. (cherry picked from commit 212268933438f3340e5c95905a2845d30cab1dd7) --- cmake/CMakeLists.txt | 16 +++++++--------- 1 files changed, 7 insertions(+), 9 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index c794056..d6384a1 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -360,23 +360,21 @@ if (WIN32) endif(WIN32) if (MSVC_IDE) - if (test_debug) - set(test_debug TRUE CACHE TYPE STRING FORCE) + if(CMAKE_BUILD_TYPE MATCHES Debug) set(IDE_BIN Debug/ ) message(STATUS) - message(STATUS "Using Visual Studio: test programs will only work with the 'Debug' configuration!") - message(STATUS "To run the tests with the 'Release' configuration use -Dtest_debug=0") + message(STATUS "Visual Studio: test programs will only work with 'Debug' configuration!") + message(STATUS "To run tests with 'Release' configuration use -DCMAKE_BUILD_TYPE=Release") message(STATUS "Add '..\\..\\test\\data' to the command line option of the test programs") message(STATUS) - else (test_debug) - set(test_debug FALSE CACHE TYPE STRING FORCE) + else(CMAKE_BUILD_TYPE MATCHES Debug) set(IDE_BIN Release/) message(STATUS) - message(STATUS "Using Visual Studio: test programs will only work with the 'Release' configuration!") - message(STATUS "To run the tests with the 'Debug' configuration use -Dtest_debug=1") + message(STATUS "Visual Studio: test programs will only work with 'Release' configuration!") + message(STATUS "To run tests with 'Debug' configuration use -DCMAKE_BUILD_TYPE=Debug") message(STATUS "Add '..\\..\\test\\data' to the command line option of the test programs") message(STATUS) - endif (test_debug) + endif(CMAKE_BUILD_TYPE MATCHES Debug) set (TEST_PATH_FORCE FORCE) FILE(REMOVE ${CMAKE_BINARY_DIR}/data/dbus-1/services) endif (MSVC_IDE) -- 1.6.4.msysgit.0 From 5984b0b8dd0fcfe6bfe7e15e2c535cbaf9d582c8 Mon Sep 17 00:00:00 2001 From: Frank Osterfeld Date: Mon, 27 Apr 2009 17:58:45 +0200 Subject: [PATCH 023/114] generate all config files from the .in files. Set some of the required variables replaced in the .in files by configure_file (cherry picked from commit 4980ffa1093877af182e032a13f6162df57be09f) --- cmake/CMakeLists.txt | 8 ++++++++ cmake/test/CMakeLists.txt | 19 +++++++++++++++++++ 2 files changed, 27 insertions(+), 0 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index d6384a1..2e1d091 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -494,6 +494,14 @@ else(splitlib AND MSVC) set(DBUS_1 dbus-1) endif(splitlib AND MSVC) +if (DBUS_BUILD_TESTS) + # set variables used for the .in files (substituted by configure_file) in test/data: + set(TEST_VALID_SERVICE_DIR ${CMAKE_BINARY_DIR}/test/data/valid-service-files) + set(TEST_VALID_SERVICE_SYSTEM_DIR ${CMAKE_BINARY_DIR}/test/data/valid-service-files-system) +# TODO: TEST_SOCKET_DIR +# TODO: TEST_LAUNCH_HELPER_BINARY +endif (DBUS_BUILD_TESTS) + ########### subdirs ############### add_subdirectory( dbus ) diff --git a/cmake/test/CMakeLists.txt b/cmake/test/CMakeLists.txt index 2540f3d..40b8f49 100644 --- a/cmake/test/CMakeLists.txt +++ b/cmake/test/CMakeLists.txt @@ -178,11 +178,30 @@ FOREACH(FILE_TYPE *.message *.message-raw *.auth-script *.sha1 *.txt *.conf *.se ENDFOREACH(DIR) ENDFOREACH(FILE_TYPE) + ### generate test files SET (CONFIG_FILES test/data/valid-config-files) configure_file(${CMAKE_SOURCE_DIR}/${CONFIG_FILES}/debug-allow-all-sha1.conf.cmake ${CMAKE_BINARY_DIR}/${CONFIG_FILES}/debug-allow-all-sha1.conf ) configure_file(${CMAKE_SOURCE_DIR}/${CONFIG_FILES}/debug-allow-all.conf.cmake ${CMAKE_BINARY_DIR}/${CONFIG_FILES}/debug-allow-all.conf ) +FOREACH(FILE_TYPE *.conf.in *.service.in) + FOREACH(DIR ${TESTDIRS}) + FILE(GLOB FILES "${CMAKE_SOURCE_DIR}/../${DIR}/${FILE_TYPE}" ) + FILE(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/${DIR}) + FOREACH(FILE ${FILES}) + GET_FILENAME_COMPONENT(FILENAME ${FILE} NAME) + STRING(REGEX REPLACE "\\.in$" "" FILENAME ${FILENAME}) + SET (TARGET ${CMAKE_BINARY_DIR}/${DIR}/${FILENAME}) + configure_file(${FILE} ${TARGET} @ONLY IMMEDIATE) + IF (CONFIG_VERBOSE) + MESSAGE("FROM: ${FILE}\nTO: ${TARGET}\n") + ENDIF (CONFIG_VERBOSE) + ENDFOREACH(FILE) + ENDFOREACH(DIR) +ENDFOREACH(FILE_TYPE) + + + # (rh) disabled copying because bus-test could not parse this files for unknown reasons FILE(GLOB FILES "${CMAKE_BINARY_DIR}/bus/*.conf" ) FOREACH(FILE ${FILES}) -- 1.6.4.msysgit.0 From a7d0b98cd9ecec2278d52d16b61ec791dd59c24a Mon Sep 17 00:00:00 2001 From: Frank Osterfeld Date: Mon, 27 Apr 2009 20:52:52 +0200 Subject: [PATCH 024/114] do not add d suffix on non-windows (cherry picked from commit 27980491d3cac6166c30c4adc2c71d80c3e4e13a) --- cmake/bus/CMakeLists.txt | 9 ++++++--- cmake/tools/CMakeLists.txt | 4 +++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/cmake/bus/CMakeLists.txt b/cmake/bus/CMakeLists.txt index 15aca8e..4d7e8a1 100644 --- a/cmake/bus/CMakeLists.txt +++ b/cmake/bus/CMakeLists.txt @@ -86,7 +86,9 @@ else(splitlib AND MSVC) 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) +if(WIN32) + set_target_properties(dbus-daemon PROPERTIES DEBUG_POSTFIX d) +endif(WIN32) install_targets(/bin dbus-daemon) install_files(/etc FILES ${config_DATA}) @@ -102,8 +104,9 @@ if (DBUS_SERVICE) 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) - + if(WIN32) + set_target_properties(dbus-service PROPERTIES DEBUG_POSTFIX d) + endif(WIN32) endif (DBUS_SERVICE) ## note that TESTS has special meaning (stuff to use in make check) diff --git a/cmake/tools/CMakeLists.txt b/cmake/tools/CMakeLists.txt index 976262c..4f8c50a 100644 --- a/cmake/tools/CMakeLists.txt +++ b/cmake/tools/CMakeLists.txt @@ -56,4 +56,6 @@ add_executable(dbus-monitor ${dbus_monitor_SOURCES}) target_link_libraries(dbus-monitor ${DBUS_1}) install_targets(/bin dbus-monitor ) -set_target_properties(dbus-send dbus-launch dbus-monitor PROPERTIES DEBUG_POSTFIX d) +if(WIN32) + set_target_properties(dbus-send dbus-launch dbus-monitor PROPERTIES DEBUG_POSTFIX d) +endif(WIN32) \ No newline at end of file -- 1.6.4.msysgit.0 From dc1a691e2a6854361571b522c67609e656d4a5a8 Mon Sep 17 00:00:00 2001 From: Frank Osterfeld Date: Mon, 27 Apr 2009 21:21:02 +0200 Subject: [PATCH 025/114] build dbus-daemon-launch-helper-test and friends set all TEST vars needed for the .in files (cherry picked from commit fcd9ba392927b0433e5e037d393230774edae303) --- cmake/CMakeLists.txt | 4 ++-- cmake/bus/CMakeLists.txt | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 2e1d091..c37d8d6 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -498,8 +498,8 @@ if (DBUS_BUILD_TESTS) # set variables used for the .in files (substituted by configure_file) in test/data: set(TEST_VALID_SERVICE_DIR ${CMAKE_BINARY_DIR}/test/data/valid-service-files) set(TEST_VALID_SERVICE_SYSTEM_DIR ${CMAKE_BINARY_DIR}/test/data/valid-service-files-system) -# TODO: TEST_SOCKET_DIR -# TODO: TEST_LAUNCH_HELPER_BINARY + set(TEST_SOCKET_DIR ${DBUS_SESSION_SOCKET_DIR} ) + set(TEST_LAUNCH_HELPER_BINARY ${EXECUTABLE_OUTPUT_PATH}/dbus-daemon-launch-helper-test) endif (DBUS_BUILD_TESTS) ########### subdirs ############### diff --git a/cmake/bus/CMakeLists.txt b/cmake/bus/CMakeLists.txt index 4d7e8a1..6be1235 100644 --- a/cmake/bus/CMakeLists.txt +++ b/cmake/bus/CMakeLists.txt @@ -151,6 +151,26 @@ endif(MSVC) ##install_file(${configdir}/system.d FILE +set(LAUNCH_HELPER_SOURCES ${XML_SOURCES} + ${BUS_DIR}/config-parser-common.c + ${BUS_DIR}/config-parser-trivial.c + ${BUS_DIR}/desktop-file.c + ${BUS_DIR}/utils.c + ${BUS_DIR}/activation-helper.c + +) + +add_executable(dbus-daemon-launch-helper ${LAUNCH_HELPER_SOURCES} ${BUS_DIR}/activation-helper-bin.c ) +target_link_libraries(dbus-daemon-launch-helper ${DBUS_1} ${LIBS} ) + +add_executable(dbus-daemon-launch-helper-test ${LAUNCH_HELPER_SOURCES} ${BUS_DIR}/activation-helper-bin.c) +set_target_properties(dbus-daemon-launch-helper-test PROPERTIES COMPILE_FLAGS "-DACTIVATION_LAUNCHER_TEST") +target_link_libraries(dbus-daemon-launch-helper-test ${DBUS_1} ${LIBS} ) + +add_executable(bus-test-launch-helper ${LAUNCH_HELPER_SOURCES} ${BUS_DIR}/test-launch-helper.c) +set_target_properties(bus-test-launch-helper PROPERTIES COMPILE_FLAGS "-DACTIVATION_LAUNCHER_TEST -DACTIVATION_LAUNCHER_DO_OOM") + +target_link_libraries(bus-test-launch-helper ${DBUS_1} ${LIBS} ) #### Init scripts fun #SCRIPT_IN_FILES=messagebus.in -- 1.6.4.msysgit.0 From 206727c78bfc451515c9ea07138428d67454298d Mon Sep 17 00:00:00 2001 From: Frank Osterfeld Date: Tue, 28 Apr 2009 10:19:47 +0200 Subject: [PATCH 026/114] cleanup: these files are already generated elsewhere (cherry picked from commit 21f66df24affd4a4d2fb3324fb51899c811530da) --- cmake/test/CMakeLists.txt | 16 ---------------- 1 files changed, 0 insertions(+), 16 deletions(-) diff --git a/cmake/test/CMakeLists.txt b/cmake/test/CMakeLists.txt index 40b8f49..af9a488 100644 --- a/cmake/test/CMakeLists.txt +++ b/cmake/test/CMakeLists.txt @@ -180,9 +180,6 @@ ENDFOREACH(FILE_TYPE) ### generate test files -SET (CONFIG_FILES test/data/valid-config-files) -configure_file(${CMAKE_SOURCE_DIR}/${CONFIG_FILES}/debug-allow-all-sha1.conf.cmake ${CMAKE_BINARY_DIR}/${CONFIG_FILES}/debug-allow-all-sha1.conf ) -configure_file(${CMAKE_SOURCE_DIR}/${CONFIG_FILES}/debug-allow-all.conf.cmake ${CMAKE_BINARY_DIR}/${CONFIG_FILES}/debug-allow-all.conf ) FOREACH(FILE_TYPE *.conf.in *.service.in) FOREACH(DIR ${TESTDIRS}) @@ -200,19 +197,6 @@ FOREACH(FILE_TYPE *.conf.in *.service.in) ENDFOREACH(DIR) ENDFOREACH(FILE_TYPE) - - -# (rh) disabled copying because bus-test could not parse this files for unknown reasons -FILE(GLOB FILES "${CMAKE_BINARY_DIR}/bus/*.conf" ) -FOREACH(FILE ${FILES}) - GET_FILENAME_COMPONENT(FILENAME ${FILE} NAME) - SET (TARGET ${CMAKE_BINARY_DIR}/${CONFIG_FILES}/${FILENAME}) - configure_file(${FILE} ${TARGET}) - IF (CONFIG_VERBOSE) - MESSAGE("FROM: ${FILE}\nTO: ${TARGET}\n") - ENDIF (CONFIG_VERBOSE) -ENDFOREACH(FILE) - # todo: for installation the TEST_..._BINARY variables must reflect the # installation dir or has to be defined relative # -- 1.6.4.msysgit.0 From f79c417f58d78bec8a5a09ee135b447ca0d40873 Mon Sep 17 00:00:00 2001 From: Frank Osterfeld Date: Tue, 28 Apr 2009 11:02:29 +0200 Subject: [PATCH 027/114] rename second test-names to test-names2 to avoid confusion (cherry picked from commit c83a2d79bb215b19b02987c9a45ed1bf07e5eeaf) --- cmake/test/name-test/CMakeLists.txt | 7 +++---- 1 files changed, 3 insertions(+), 4 deletions(-) diff --git a/cmake/test/name-test/CMakeLists.txt b/cmake/test/name-test/CMakeLists.txt index 3c392b6..1e542cc 100644 --- a/cmake/test/name-test/CMakeLists.txt +++ b/cmake/test/name-test/CMakeLists.txt @@ -5,10 +5,9 @@ set (NAMEtest-DIR ../../../test/name-test) add_definitions(-DDBUS_COMPILATION) # there is also a test-names executable, don't know if this is the same -add_executable(test-names1 ${NAMEtest-DIR}/test-names.c) -target_link_libraries(test-names1 ${DBUS_1}) -#install_targets(/bin test-names1) -ADD_TEST(test-names ${EXECUTABLE_OUTPUT_PATH}/test-names1) +add_executable(test-names2 ${NAMEtest-DIR}/test-names.c) +target_link_libraries(test-names2 ${DBUS_1}) +ADD_TEST(test-names2 ${EXECUTABLE_OUTPUT_PATH}/test-names2) add_executable(test-pending-call-dispatch ${NAMEtest-DIR}/test-pending-call-dispatch.c) target_link_libraries(test-pending-call-dispatch ${DBUS_1}) -- 1.6.4.msysgit.0 From 5428d8a456f92c5c5ff9912755e7a61208b9e0ab Mon Sep 17 00:00:00 2001 From: Frank Osterfeld Date: Tue, 28 Apr 2009 11:08:31 +0200 Subject: [PATCH 028/114] fix test and binary names (cherry picked from commit 18bcf5f2d474456c57cd94da234005a23e2589a7) --- cmake/test/name-test/CMakeLists.txt | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/test/name-test/CMakeLists.txt b/cmake/test/name-test/CMakeLists.txt index 1e542cc..45683a7 100644 --- a/cmake/test/name-test/CMakeLists.txt +++ b/cmake/test/name-test/CMakeLists.txt @@ -12,11 +12,11 @@ ADD_TEST(test-names2 ${EXECUTABLE_OUTPUT_PATH}/test-names2) add_executable(test-pending-call-dispatch ${NAMEtest-DIR}/test-pending-call-dispatch.c) target_link_libraries(test-pending-call-dispatch ${DBUS_1}) #install_targets(/bin test-pending-call-dispatch) -ADD_TEST(test-pending-call-dispatch ${EXECUTABLE_OUTPUT_PATH}/test-pending_call-dispatch) +ADD_TEST(test-pending-call-dispatch ${EXECUTABLE_OUTPUT_PATH}/test-pending-call-dispatch) add_executable(test-thread-init ${NAMEtest-DIR}/test-threads-init.c) target_link_libraries(test-thread-init ${DBUS_1}) #install_targets(/bin test-thread-init) -ADD_TEST(test-names ${EXECUTABLE_OUTPUT_PATH}/test-thread-init) +ADD_TEST(test-thread-init ${EXECUTABLE_OUTPUT_PATH}/test-thread-init) endif (DBUS_BUILD_TESTS) -- 1.6.4.msysgit.0 From 9b0b17585301e3eebdb53b9dcfd8a86689b68734 Mon Sep 17 00:00:00 2001 From: Frank Osterfeld Date: Tue, 28 Apr 2009 11:26:05 +0200 Subject: [PATCH 029/114] rename test-spawn to spawn-test, to match autotools. test-sleep-forever is not a stand-alone test but called from other tests (cherry picked from commit 41bf95167cfc17b564594eab0a1901e46eaab5fe) --- cmake/test/CMakeLists.txt | 10 ++++------ 1 files changed, 4 insertions(+), 6 deletions(-) diff --git a/cmake/test/CMakeLists.txt b/cmake/test/CMakeLists.txt index af9a488..e90de1c 100644 --- a/cmake/test/CMakeLists.txt +++ b/cmake/test/CMakeLists.txt @@ -66,7 +66,7 @@ set (test-shell_SOURCES ${CMAKE_SOURCE_DIR}/../test/shell-test.c ) -set (test-spawn_SOURCES +set (spawn-test_SOURCES ${CMAKE_SOURCE_DIR}/../test/spawn-test.c ) @@ -110,10 +110,10 @@ target_link_libraries(test-shell-service ${DBUS_1}) #install_targets(/bin test-shell-service) ADD_TEST(test-shell-service ${EXECUTABLE_OUTPUT_PATH}/test-shell-service${EXT}) -add_executable(test-spawn ${test-spawn_SOURCES}) -target_link_libraries(test-spawn ${DBUS_1}) +add_executable(spawn-test ${spawn-test_SOURCES}) +target_link_libraries(spawn-test ${DBUS_1}) # (rh) does not work now -#ADD_TEST(test-spawn ${EXECUTABLE_OUTPUT_PATH}/test-spawn${EXT}) +ADD_TEST(spawn-test ${EXECUTABLE_OUTPUT_PATH}/spawn-test${EXT}) add_executable(test-exit ${test-exit_SOURCES}) target_link_libraries(test-exit ${DBUS_1}) @@ -127,8 +127,6 @@ ADD_TEST(test-segfault ${EXECUTABLE_OUTPUT_PATH}/test-segfault${EXT}) add_executable(test-sleep-forever ${test-sleep-forever_SOURCES}) target_link_libraries(test-sleep-forever ${DBUS_1}) -# (rh) don't know for what this test is good -#ADD_TEST(test-sleep-forever ${EXECUTABLE_OUTPUT_PATH}/test-sleep-forever${EXT}) #add_executable(decode-gcov ${decode_gcov_SOURCES}) #target_link_libraries(decode-gcov ${DBUS_1}) -- 1.6.4.msysgit.0 From 2db7d247df18425ab12db3b6205dd7dd0bf5f768 Mon Sep 17 00:00:00 2001 From: Frank Osterfeld Date: Tue, 28 Apr 2009 15:46:19 +0200 Subject: [PATCH 030/114] Use correct sources to build test-shell-service, fixes a hang in bus-test (cherry picked from commit 0afe04db5152b57582863bef83a55d78020a79c6) --- cmake/test/CMakeLists.txt | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/cmake/test/CMakeLists.txt b/cmake/test/CMakeLists.txt index e90de1c..013963e 100644 --- a/cmake/test/CMakeLists.txt +++ b/cmake/test/CMakeLists.txt @@ -105,7 +105,7 @@ target_link_libraries(test-shell ${DBUS_1}) #install_targets(/bin test-shell) ADD_TEST(test-shell ${EXECUTABLE_OUTPUT_PATH}/test-shell${EXT}) -add_executable(test-shell-service ${test-shell_SOURCES}) +add_executable(test-shell-service ${test-shell-service_SOURCES}) target_link_libraries(test-shell-service ${DBUS_1}) #install_targets(/bin test-shell-service) ADD_TEST(test-shell-service ${EXECUTABLE_OUTPUT_PATH}/test-shell-service${EXT}) -- 1.6.4.msysgit.0 From b6a821394f0aaafb44476f234edff7acccdaabfa Mon Sep 17 00:00:00 2001 From: Frank Osterfeld Date: Tue, 28 Apr 2009 16:14:13 +0200 Subject: [PATCH 031/114] bus-test-launch-helper is a unit test, test-service and test-shell-service are not. Rename test-shell to shell-test to match autotools (cherry picked from commit b106387b73d6a300a013a15f6507244e82f007ed) --- cmake/bus/CMakeLists.txt | 2 +- cmake/test/CMakeLists.txt | 15 ++++----------- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/cmake/bus/CMakeLists.txt b/cmake/bus/CMakeLists.txt index 6be1235..eb48e72 100644 --- a/cmake/bus/CMakeLists.txt +++ b/cmake/bus/CMakeLists.txt @@ -169,8 +169,8 @@ target_link_libraries(dbus-daemon-launch-helper-test ${DBUS_1} ${LIBS} ) add_executable(bus-test-launch-helper ${LAUNCH_HELPER_SOURCES} ${BUS_DIR}/test-launch-helper.c) set_target_properties(bus-test-launch-helper PROPERTIES COMPILE_FLAGS "-DACTIVATION_LAUNCHER_TEST -DACTIVATION_LAUNCHER_DO_OOM") - target_link_libraries(bus-test-launch-helper ${DBUS_1} ${LIBS} ) +add_test(bus-test-launch-helper ${EXECUTABLE_OUTPUT_PATH}/bus-test-launch-helper ) #### Init scripts fun #SCRIPT_IN_FILES=messagebus.in diff --git a/cmake/test/CMakeLists.txt b/cmake/test/CMakeLists.txt index 013963e..c0c9bc7 100644 --- a/cmake/test/CMakeLists.txt +++ b/cmake/test/CMakeLists.txt @@ -62,7 +62,7 @@ set (test-shell-service_SOURCES ${CMAKE_SOURCE_DIR}/../test/test-utils.h ) -set (test-shell_SOURCES +set (shell-test_SOURCES ${CMAKE_SOURCE_DIR}/../test/shell-test.c ) @@ -90,25 +90,18 @@ add_executable(test-service ${test-service_SOURCES}) target_link_libraries(test-service ${DBUS_1}) #install_targets(/bin test-service) -# (rh) does not work at now -ADD_TEST(test-service ${EXECUTABLE_OUTPUT_PATH}/test-service${EXT}) - - - add_executable(test-names ${test-names_SOURCES}) target_link_libraries(test-names ${DBUS_1}) #install_targets(/bin test-names) ADD_TEST(test-names ${EXECUTABLE_OUTPUT_PATH}/test-names${EXT}) -add_executable(test-shell ${test-shell_SOURCES}) -target_link_libraries(test-shell ${DBUS_1}) -#install_targets(/bin test-shell) -ADD_TEST(test-shell ${EXECUTABLE_OUTPUT_PATH}/test-shell${EXT}) +add_executable(shell-test ${shell-test_SOURCES}) +target_link_libraries(shell-test ${DBUS_1}) +ADD_TEST(shell-test ${EXECUTABLE_OUTPUT_PATH}/shell-test${EXT}) add_executable(test-shell-service ${test-shell-service_SOURCES}) target_link_libraries(test-shell-service ${DBUS_1}) #install_targets(/bin test-shell-service) -ADD_TEST(test-shell-service ${EXECUTABLE_OUTPUT_PATH}/test-shell-service${EXT}) add_executable(spawn-test ${spawn-test_SOURCES}) target_link_libraries(spawn-test ${DBUS_1}) -- 1.6.4.msysgit.0 From 6b65f83973414da210ec0b7803da5614be72729e Mon Sep 17 00:00:00 2001 From: Frank Osterfeld Date: Tue, 28 Apr 2009 15:45:03 +0100 Subject: [PATCH 032/114] disable launch-helper on windows for now until it builds (cherry picked from commit 48da3a0450172f711c25a459ce70c2521d22ee27) --- cmake/bus/CMakeLists.txt | 26 +++++++++++++++----------- 1 files changed, 15 insertions(+), 11 deletions(-) diff --git a/cmake/bus/CMakeLists.txt b/cmake/bus/CMakeLists.txt index eb48e72..5b4c0bd 100644 --- a/cmake/bus/CMakeLists.txt +++ b/cmake/bus/CMakeLists.txt @@ -160,17 +160,21 @@ set(LAUNCH_HELPER_SOURCES ${XML_SOURCES} ) -add_executable(dbus-daemon-launch-helper ${LAUNCH_HELPER_SOURCES} ${BUS_DIR}/activation-helper-bin.c ) -target_link_libraries(dbus-daemon-launch-helper ${DBUS_1} ${LIBS} ) - -add_executable(dbus-daemon-launch-helper-test ${LAUNCH_HELPER_SOURCES} ${BUS_DIR}/activation-helper-bin.c) -set_target_properties(dbus-daemon-launch-helper-test PROPERTIES COMPILE_FLAGS "-DACTIVATION_LAUNCHER_TEST") -target_link_libraries(dbus-daemon-launch-helper-test ${DBUS_1} ${LIBS} ) - -add_executable(bus-test-launch-helper ${LAUNCH_HELPER_SOURCES} ${BUS_DIR}/test-launch-helper.c) -set_target_properties(bus-test-launch-helper PROPERTIES COMPILE_FLAGS "-DACTIVATION_LAUNCHER_TEST -DACTIVATION_LAUNCHER_DO_OOM") -target_link_libraries(bus-test-launch-helper ${DBUS_1} ${LIBS} ) -add_test(bus-test-launch-helper ${EXECUTABLE_OUTPUT_PATH}/bus-test-launch-helper ) +if(NOT WIN32) +#PENDING(kdab) fix build on windows (activation-helper.c) + add_executable(dbus-daemon-launch-helper ${LAUNCH_HELPER_SOURCES} ${BUS_DIR}/activation-helper-bin.c ) + target_link_libraries(dbus-daemon-launch-helper ${DBUS_1} ${LIBS} ) + + add_executable(dbus-daemon-launch-helper-test ${LAUNCH_HELPER_SOURCES} ${BUS_DIR}/activation-helper-bin.c) + set_target_properties(dbus-daemon-launch-helper-test PROPERTIES COMPILE_FLAGS "-DACTIVATION_LAUNCHER_TEST") + target_link_libraries(dbus-daemon-launch-helper-test ${DBUS_1} ${LIBS} ) + + add_executable(bus-test-launch-helper ${LAUNCH_HELPER_SOURCES} ${BUS_DIR}/test-launch-helper.c) + set_target_properties(bus-test-launch-helper PROPERTIES COMPILE_FLAGS "-DACTIVATION_LAUNCHER_TEST -DACTIVATION_LAUNCHER_DO_OOM") + target_link_libraries(bus-test-launch-helper ${DBUS_1} ${LIBS} ) + add_test(bus-test-launch-helper ${EXECUTABLE_OUTPUT_PATH}/bus-test-launch-helper ) + +endif(NOT WIN32) #### Init scripts fun #SCRIPT_IN_FILES=messagebus.in -- 1.6.4.msysgit.0 From ea4f1931725302a2e1454858f90714d90b67ab35 Mon Sep 17 00:00:00 2001 From: Frank Osterfeld Date: Tue, 28 Apr 2009 18:12:09 +0100 Subject: [PATCH 033/114] fix TEST_SOCKET_DIR on windows, do not override value from top-level in test/ (cherry picked from commit fde144333281348cda2d533331946996d7a09bff) --- cmake/CMakeLists.txt | 33 ++++++++++++++++++--------------- cmake/test/CMakeLists.txt | 2 -- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index c37d8d6..f9fd563 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -387,21 +387,24 @@ set(TEST_SEGFAULT_BINARY ${CMAKE_BINARY_DIR}/bin/${IDE_BIN}test-segfault${E set(TEST_SLEEP_FOREVER_BINARY ${CMAKE_BINARY_DIR}/bin/${IDE_BIN}test-sleep-forever${EXT} CACHE STRING "Full path to test file test/test-sleep-forever in builddir" ${TEST_PATH_FORCE}) #### Find socket directories -if (NOT WIN32) - if (NOT $ENV{TMPDIR} STREQUAL "") - set (DBUS_SESSION_SOCKET_DIR $ENV{TMPDIR}) - else (NOT $ENV{TMPDIR} STREQUAL "") - if (NOT $ENV{TEMP} STREQUAL "") - set (DBUS_SESSION_SOCKET_DIR $ENV{TEMP}) - else (NOT $ENV{TEMP} STREQUAL "") - if (NOT $ENV{TMP} STREQUAL "") - set (DBUS_SESSION_SOCKET_DIR $ENV{TMP}) - else (NOT $ENV{TMP} STREQUAL "") - set (DBUS_SESSION_SOCKET_DIR /tmp) - endif (NOT $ENV{TMP} STREQUAL "") - endif (NOT $ENV{TEMP} STREQUAL "") - endif (NOT $ENV{TMPDIR} STREQUAL "") -endif (NOT WIN32) + if (NOT $ENV{TMPDIR} STREQUAL "") + set (DBUS_SESSION_SOCKET_DIR $ENV{TMPDIR}) + else (NOT $ENV{TMPDIR} STREQUAL "") + if (NOT $ENV{TEMP} STREQUAL "") + set (DBUS_SESSION_SOCKET_DIR $ENV{TEMP}) + else (NOT $ENV{TEMP} STREQUAL "") + if (NOT $ENV{TMP} STREQUAL "") + set (DBUS_SESSION_SOCKET_DIR $ENV{TMP}) + else (NOT $ENV{TMP} STREQUAL "") + if (WIN32) + #Should never happen, both TMP and TEMP seem always set on Windows + message(FATAL "Could not determine a usable temporary directory") + else(WIN32) + set (DBUS_SESSION_SOCKET_DIR /tmp) + endif(WIN32) + endif (NOT $ENV{TMP} STREQUAL "") + endif (NOT $ENV{TEMP} STREQUAL "") + endif (NOT $ENV{TMPDIR} STREQUAL "") #AC_ARG_WITH(test-socket-dir, AS_HELP_STRING([--with-test-socket-dir=[dirname]],[Where to put sockets for make check])) diff --git a/cmake/test/CMakeLists.txt b/cmake/test/CMakeLists.txt index c0c9bc7..7011d31 100644 --- a/cmake/test/CMakeLists.txt +++ b/cmake/test/CMakeLists.txt @@ -21,8 +21,6 @@ if (WIN32) add_definitions(-Dsleep=_sleep) endif (WIN32) -set (TEST_SOCKET_DIR "/") - #if (DBUS_BUILD_TESTS) ## break-loader removed for now #test-BINARIES=test-service test-names test-shell-service shell-test spawn-test test-segfault test-exit test-sleep-forever -- 1.6.4.msysgit.0 From f92d211bfc40656a53377592d10dbdef7787ce38 Mon Sep 17 00:00:00 2001 From: Frank Osterfeld Date: Wed, 29 Apr 2009 13:22:44 +0200 Subject: [PATCH 034/114] define DBUS_BUILD_TESTS only if the option is enabled (cherry picked from commit 46c3a4e653c17c1daaabf164663856f373330f29) --- cmake/CMakeLists.txt | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index f9fd563..cff6f65 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -233,7 +233,10 @@ set (DBUS_DAEMONDIR ${EXPANDED_BINDIR}) #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) - add_definitions(-DDBUS_BUILD_TESTS) + +if(DBUS_BUILD_TESTS) + add_definitions(-DDBUS_BUILD_TESTS) +endif(DBUS_BUILD_TESTS) # win32 dbus service support - this support is not complete OPTION(DBUS_SERVICE "enable dbus service installer" OFF) -- 1.6.4.msysgit.0 From 4ddbfa4e9ca08eef3b3759c1b9511ac6cf372300 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Fri, 17 Apr 2009 14:07:25 +0200 Subject: [PATCH 035/114] WIN32: add versioninfo, and export symbols * dbus/versioninfo.rc.in: (new file) copied and modified from libgpg-error * configure.in: enable libtool's W32 support, extract version information for use in versioninfo.rc.in, define DBUS_WIN, define DBUS_UNIX only on unix (adapted from libgpg-error) * dbus/Makefile.am: switch sources depending on platform, compile versioninfo.rc, add dbus-1.def (not used since buildsystem creates its own .def file apparently) (cherry picked from commit cfa717ddb7b9258a862d87cd5b3bdbe582ce106c) --- configure.in | 38 +++++++++++++++++- dbus/Makefile.am | 98 +++++++++++++++++++++++++++++++++++++++++------- dbus/versioninfo.rc.in | 52 +++++++++++++++++++++++++ 3 files changed, 172 insertions(+), 16 deletions(-) create mode 100644 dbus/versioninfo.rc.in diff --git a/configure.in b/configure.in index 24ad554..4360e2d 100644 --- a/configure.in +++ b/configure.in @@ -9,6 +9,8 @@ m4_define([dbus_version], AC_INIT(dbus, [dbus_version]) AC_CANONICAL_HOST +AC_LIBTOOL_WIN32_DLL +AC_LIBTOOL_RC AM_INIT_AUTOMAKE([1.9 tar-ustar]) AM_CONFIG_HEADER(config.h) @@ -63,6 +65,39 @@ AC_HEADER_STDC AC_C_INLINE AM_PROG_LIBTOOL +# Set some internal variables depending on the platform for later use. +dbus_win=no +dbus_unix=no +case "${host}" in + *-mingw32*) + dbus_win=yes + ;; + *) + dbus_unix=yes + ;; +esac + +# Special defines for certain platforms +if test "$dbus_win" = yes; then + AC_DEFINE(DBUS_WIN,1,[Defined if we run on a W32 API based system]) + BUILD_TIMESTAMP=`date --iso-8601=minutes` + AC_SUBST(BUILD_TIMESTAMP) + changequote(,)dnl + BUILD_FILEVERSION=`echo "$DBUS_VERSION" | sed 's/\([0-9.]*\).*/\1./;s/\./,/g'` + changequote([,])dnl + case "$DBUS_VERSION" in + *-rc*) BUILD_FILEVERSION="${BUILD_FILEVERSION}1" ;; + *) BUILD_FILEVERSION="${BUILD_FILEVERSION}2" ;; + esac +else + AC_DEFINE(DBUS_UNIX,1,[Defined if we run on a Unix-based system]) +fi +AC_SUBST(BUILD_TIMESTAMP) +AC_SUBST(BUILD_FILEVERSION) +AM_CONDITIONAL(DBUS_WIN, test "$dbus_win" = yes) +AM_CONDITIONAL(DBUS_UNIX, test "$dbus_unix" = yes) + + AC_ARG_ENABLE(tests, AS_HELP_STRING([--enable-tests],[enable unit test code]),enable_tests=$enableval,enable_tests=$USE_MAINTAINER_MODE) AC_ARG_ENABLE(ansi, AS_HELP_STRING([--enable-ansi],[enable -ansi -pedantic gcc flags]),enable_ansi=$enableval,enable_ansi=no) 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) @@ -91,8 +126,6 @@ AC_ARG_WITH(console-owner-file, AS_HELP_STRING([--with-console-owner-file=[filen AC_ARG_WITH(dbus_user, AS_HELP_STRING([--with-dbus-user=],[User for running the DBUS daemon (messagebus)])) AC_ARG_WITH(dbus_daemondir, AS_HELP_STRING([--with-dbus-daemondir=[dirname]],[Directory for installing the DBUS daemon])) -AC_DEFINE(DBUS_UNIX,1,[dbus on unix]) - dnl DBUS_BUILD_TESTS controls unit tests built in to .c files dnl and also some stuff in the test/ subdir AM_CONDITIONAL(DBUS_BUILD_TESTS, test x$enable_tests = xyes) @@ -1430,6 +1463,7 @@ AH_VERBATIM(_DARWIN_ENVIRON, AC_OUTPUT([ Doxyfile +dbus/versioninfo.rc dbus/dbus-arch-deps.h bus/system.conf bus/session.conf diff --git a/dbus/Makefile.am b/dbus/Makefile.am index e966a43..9daa8a9 100644 --- a/dbus/Makefile.am +++ b/dbus/Makefile.am @@ -11,6 +11,84 @@ dbusarchincludedir=$(libdir)/dbus-1.0/include/dbus lib_LTLIBRARIES=libdbus-1.la +# +# Deal with W32 .def and version-info.rc stuff +# +if DBUS_WIN +LTRCCOMPILE = $(LIBTOOL) --mode=compile $(RC) \ + `echo $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) | \ + sed -e 's/-I/--include-dir /g;s/-D/--define /g'` + +SUFFIXES = rc + +.rc.o: + $(LTRCCOMPILE) -i $< -o $@ + +dbus_res = versioninfo.o +dbus_res_ldflag = -Wl,$(dbus_res) +no_undefined = -no-undefined +export_symbols = -export-symbols $(srcdir)/dbus-1.def + +install-def-file: + $(INSTALL) dbus-1.def $(DESTDIR)$(libdir)/dbus-1.def + +uninstall-def-file: + -rm $(DESTDIR)$(libdir)/dbus-1.def + +libdbus_1_la_DEPENDENCIES = $(dbus_res) dbus-1.def +intllibs = + +else +dbus_res = +dbus_res_ldflag = +no_undefined = +export_symbols = +install-def-file: +uninstall-def-file: + +intllibs = @LTLIBINTL@ + +endif + + +# +# Platform-dependent sources: +# +if DBUS_WIN +DBUS_LIB_arch_sources = \ + dbus-server-win.c \ + dbus-server-win.h + +DBUS_SHARED_arch_sources = \ + dbus-sysdeps-win.c \ + dbus-sysdeps-win.h \ + dbus-sysdeps-thread-win.c \ + dbus-transport-win.c \ + dbus-transport-win.h + +DBUS_UTIL_arch_sources = \ + dbus-sysdeps-util-win.c \ + dbus-spawn-win.c +else +DBUS_LIB_arch_sources = \ + dbus-server-unix.c \ + dbus-server-unix.h + +DBUS_SHARED_arch_sources = \ + dbus-sysdeps-unix.c \ + dbus-sysdeps-unix.h \ + dbus-sysdeps-pthread.c \ + dbus-transport-unix.c \ + dbus-transport-unix.h \ + dbus-userdb.c \ + dbus-userdb.h + +DBUS_UTIL_arch_sources = \ + dbus-sysdeps-util-unix.c \ + dbus-userdb-util.c \ + dbus-spawn.c +endif + dbusinclude_HEADERS= \ dbus.h \ dbus-address.h \ @@ -26,6 +104,7 @@ dbusinclude_HEADERS= \ dbus-server.h \ dbus-shared.h \ dbus-signature.h \ + dbus-spawn.h \ dbus-threads.h \ dbus-types.h @@ -73,8 +152,7 @@ DBUS_LIB_SOURCES= \ dbus-server-protected.h \ dbus-server-socket.c \ dbus-server-socket.h \ - dbus-server-unix.c \ - dbus-server-unix.h \ + $(DBUS_LIB_arch_sources) \ dbus-sha.c \ dbus-sha.h \ dbus-signature.c \ @@ -87,8 +165,6 @@ DBUS_LIB_SOURCES= \ dbus-transport-protected.h \ dbus-transport-socket.c \ dbus-transport-socket.h \ - dbus-transport-unix.c \ - dbus-transport-unix.h \ dbus-uuidgen.c \ dbus-uuidgen.h \ dbus-watch.c \ @@ -118,13 +194,9 @@ DBUS_SHARED_SOURCES= \ dbus-string.c \ dbus-string.h \ dbus-string-private.h \ + $(DBUS_SHARED_arch_sources) \ dbus-sysdeps.c \ - dbus-sysdeps.h \ - dbus-sysdeps-pthread.c \ - dbus-sysdeps-unix.c \ - dbus-sysdeps-unix.h \ - dbus-userdb.c \ - dbus-userdb.h + dbus-sysdeps.h ### source code that is generic utility functionality used ### by the bus daemon or test apps, but is NOT included @@ -144,14 +216,12 @@ DBUS_UTIL_SOURCES= \ dbus-message-util.c \ dbus-shell.c \ dbus-shell.h \ - dbus-spawn.c \ + $(DBUS_UTIL_arch_sources) \ dbus-spawn.h \ dbus-string-util.c \ dbus-sysdeps-util.c \ - dbus-sysdeps-util-unix.c \ dbus-test.c \ - dbus-test.h \ - dbus-userdb-util.c + dbus-test.h libdbus_1_la_SOURCES= \ $(DBUS_LIB_SOURCES) \ diff --git a/dbus/versioninfo.rc.in b/dbus/versioninfo.rc.in new file mode 100644 index 0000000..b745b39 --- /dev/null +++ b/dbus/versioninfo.rc.in @@ -0,0 +1,52 @@ +/* versioninfo.rc.in - for dbus + * Copyright (C) 2005 g10 Code GmbH + * + * This file is free software; as a special exception the author gives + * unlimited permission to copy and/or distribute it, with or without + * modifications, as long as this notice is preserved. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY, to the extent permitted by law; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + */ + +/* This file is processed by configure to create versioninfo.rc */ + +#line __LINE__ "versioninfo.rc.in" + +#include + + +VS_VERSION_INFO VERSIONINFO + FILEVERSION @BUILD_FILEVERSION@ + PRODUCTVERSION @BUILD_FILEVERSION@ + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x21L +#else + FILEFLAGS 0x20L +#endif + FILEOS 0x40004L + FILETYPE 0x1L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "Comments", "Provided under the terms of the GNU Lesser General Public License.\0" + VALUE "CompanyName", "FreeDesktop.org\0" + VALUE "FileDescription", "dbus - FreeDesktop message bus system\0" + VALUE "FileVersion", "@DBUS_VERSION@\0" + VALUE "InternalName", "dbus\0" + VALUE "LegalCopyright", "Copyright © 2009 FreeDesktop.org\0" + VALUE "LegalTrademarks", "\0" + VALUE "OriginalFilename", "dbus-1.dll\0" + VALUE "PrivateBuild", "\0" + VALUE "ProductName", "dbus\0" + VALUE "ProductVersion", "@DBUS_VERSION@\0" + VALUE "SpecialBuild", "@BUILD_TIMESTAMP@\0" + END + END +END + -- 1.6.4.msysgit.0 From bfa3c0a93f14275ff1d91ea0df3371baf3684d50 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Mon, 20 Apr 2009 14:08:23 +0200 Subject: [PATCH 036/114] configure.in: add W32 extra libs (cherry picked from commit 909f2b23596247aaef4c5945853eebf607f7d329) --- configure.in | 13 +++++++++---- 1 files changed, 9 insertions(+), 4 deletions(-) diff --git a/configure.in b/configure.in index 4360e2d..a8177db 100644 --- a/configure.in +++ b/configure.in @@ -917,24 +917,29 @@ static int x = SCM_RIGHTS; AC_DEFINE([HAVE_UNIX_FD_PASSING], [1], [Supports sending UNIX file descriptors]) ], [ AC_MSG_RESULT([not supported]) ]) +NETWORK_libs= +if test x$dbus_win = xyes ; then + NETWORK_libs="-lws2_32" +fi + #### Set up final flags DBUS_CLIENT_CFLAGS= -DBUS_CLIENT_LIBS="$THREAD_LIBS" +DBUS_CLIENT_LIBS="$THREAD_LIBS $NETWORK_libs" AC_SUBST(DBUS_CLIENT_CFLAGS) AC_SUBST(DBUS_CLIENT_LIBS) DBUS_BUS_CFLAGS="$XML_CFLAGS" -DBUS_BUS_LIBS="$XML_LIBS $SELINUX_LIBS $INTLLIBS $THREAD_LIBS $ADT_LIBS" +DBUS_BUS_LIBS="$XML_LIBS $SELINUX_LIBS $INTLLIBS $THREAD_LIBS $ADT_LIBS $NETWORK_libs" AC_SUBST(DBUS_BUS_CFLAGS) AC_SUBST(DBUS_BUS_LIBS) DBUS_LAUNCHER_CFLAGS="$XML_CFLAGS" -DBUS_LAUNCHER_LIBS="$XML_LIBS $THREAD_LIBS" +DBUS_LAUNCHER_LIBS="$XML_LIBS $THREAD_LIBS $NETWORK_libs" AC_SUBST(DBUS_LAUNCHER_CFLAGS) AC_SUBST(DBUS_LAUNCHER_LIBS) DBUS_TEST_CFLAGS= -DBUS_TEST_LIBS="$THREAD_LIBS" +DBUS_TEST_LIBS="$THREAD_LIBS $NETWORK_libs" AC_SUBST(DBUS_TEST_CFLAGS) AC_SUBST(DBUS_TEST_LIBS) -- 1.6.4.msysgit.0 From 9f17adf989b603564b143a6876a77afd5a4af539 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Fri, 17 Apr 2009 20:02:36 +0200 Subject: [PATCH 037/114] configure.in: don't look for X11 on W32 (cherry picked from commit 73730866ec198ac4c24dc69c9f62b4a3a2f05bf1) --- configure.in | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/configure.in b/configure.in index a8177db..f71c474 100644 --- a/configure.in +++ b/configure.in @@ -944,6 +944,9 @@ AC_SUBST(DBUS_TEST_CFLAGS) AC_SUBST(DBUS_TEST_LIBS) ### X11 detection +if test x$dbus_win = xyes ; then + enable_x11=no +else AC_PATH_XTRA ## for now enable_x11 just tracks have_x11, @@ -967,6 +970,7 @@ fi AC_SUBST(DBUS_X_CFLAGS) AC_SUBST(DBUS_X_LIBS) +fi #### gcc warning flags -- 1.6.4.msysgit.0 From 93e19170d2b0de12b924abf50b7c327be4f3ebfe Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 21 Apr 2009 12:33:50 +0200 Subject: [PATCH 038/114] Makefile.am's: reorder libraries so static libs come first (fixes linking on W32) (cherry picked from commit f88bd88d6b4b318f9401fae595343c8b1bacf654) --- bus/Makefile.am | 4 ++-- test/Makefile.am | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/bus/Makefile.am b/bus/Makefile.am index 3b4f69d..496e286 100644 --- a/bus/Makefile.am +++ b/bus/Makefile.am @@ -77,9 +77,9 @@ dbus_daemon_SOURCES= \ main.c dbus_daemon_LDADD= \ + $(top_builddir)/dbus/libdbus-convenience.la \ $(EFENCE) \ - $(DBUS_BUS_LIBS) \ - $(top_builddir)/dbus/libdbus-convenience.la + $(DBUS_BUS_LIBS) dbus_daemon_LDFLAGS=@R_DYNAMIC_LDFLAG@ @SECTION_LDFLAGS@ @PIE_LDFLAGS@ diff --git a/test/Makefile.am b/test/Makefile.am index a7f0597..ead399b 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -61,17 +61,17 @@ test_sleep_forever_SOURCES = \ decode_gcov_SOURCES= \ decode-gcov.c -TEST_LIBS=$(DBUS_TEST_LIBS) $(top_builddir)/dbus/libdbus-convenience.la +TEST_LIBS=$(top_builddir)/dbus/libdbus-convenience.la $(DBUS_TEST_LIBS) -test_service_LDADD=$(TEST_LIBS) libdbus-testutils.la +test_service_LDADD=libdbus-testutils.la $(TEST_LIBS) test_service_LDFLAGS=@R_DYNAMIC_LDFLAG@ -test_names_LDADD=$(TEST_LIBS) libdbus-testutils.la +test_names_LDADD=libdbus-testutils.la $(TEST_LIBS) test_names_LDFLAGS=@R_DYNAMIC_LDFLAG@ ## break_loader_LDADD= $(TEST_LIBS) ## break_loader_LDFLAGS=@R_DYNAMIC_LDFLAG@ -test_shell_service_LDADD=$(TEST_LIBS) libdbus-testutils.la +test_shell_service_LDADD=libdbus-testutils.la $(TEST_LIBS) test_shell_service_LDFLAGS=@R_DYNAMIC_LDFLAG@ -shell_test_LDADD=$(TEST_LIBS) libdbus-testutils.la +shell_test_LDADD=libdbus-testutils.la $(TEST_LIBS) shell_test_LDFLAGS=@R_DYNAMIC_LDFLAG@ spawn_test_LDADD=$(TEST_LIBS) spawn_test_LDFLAGS=@R_DYNAMIC_LDFLAG@ -- 1.6.4.msysgit.0 From a34745e22a91be46e1e26ef78463a6155ecabe97 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 21 Apr 2009 16:22:11 +0200 Subject: [PATCH 039/114] tools/Makefile.am: conditional compilation for W32 (cherry picked from commit 8b2f7581ef46b6e9bd29b8399657c039cb49f030) --- tools/Makefile.am | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-) diff --git a/tools/Makefile.am b/tools/Makefile.am index 9fad7a7..f597d59 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -2,7 +2,12 @@ configdir=$(sysconfdir)/dbus-1 INCLUDES=-I$(top_srcdir) $(DBUS_CLIENT_CFLAGS) $(DBUS_X_CFLAGS) -DDBUS_LOCALEDIR=\"@EXPANDED_DATADIR@/locale\" -DDBUS_COMPILATION -DDBUS_DAEMONDIR=\"@DBUS_DAEMONDIR@\" -DDBUS_MACHINE_UUID_FILE=\""$(localstatedir)/lib/dbus/machine-id"\" -bin_PROGRAMS=dbus-send dbus-monitor dbus-launch dbus-cleanup-sockets dbus-uuidgen +extra_bin_programs= +if DBUS_UNIX +extra_bin_programs += dbus-launch dbus-cleanup-sockets +endif + +bin_PROGRAMS=dbus-send dbus-monitor $(extra_bin_programs) dbus-uuidgen dbus_send_SOURCES= \ dbus-print-message.c \ -- 1.6.4.msysgit.0 From fa636eb006022af6c5a979fa8779c97582ab10e1 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 21 Apr 2009 16:24:51 +0200 Subject: [PATCH 040/114] bus/Makefile.am: conditional compilation for W32, use EXEEXT in install hooks (cherry picked from commit 551a9c446b782167aa8b0a74a41a1b7ffb42c6eb) --- bus/Makefile.am | 21 +++++++++++++++------ 1 files changed, 15 insertions(+), 6 deletions(-) diff --git a/bus/Makefile.am b/bus/Makefile.am index 496e286..66fb103 100644 --- a/bus/Makefile.am +++ b/bus/Makefile.am @@ -137,19 +137,26 @@ bus_test_launch_helper_CPPFLAGS= \ -DACTIVATION_LAUNCHER_TEST \ -DACTIVATION_LAUNCHER_DO_OOM +extra_tests= +extra_noinst_programs= +if DBUS_UNIX +extra_tests+=bus-test-launch-helper +extra_noinst_programs+=dbus-daemon-launch-helper dbus-daemon-launch-helper-test +endif + ## note that TESTS has special meaning (stuff to use in make check) ## so if adding tests not to be run in make check, don't add them to ## TESTS if DBUS_BUILD_TESTS TESTS_ENVIRONMENT=DBUS_TEST_DATA=$(top_builddir)/test/data DBUS_TEST_HOMEDIR=$(top_builddir)/dbus DBUS_FATAL_WARNINGS=1 DBUS_BLOCK_ON_ABORT=1 -TESTS=bus-test bus-test-system bus-test-launch-helper +TESTS=bus-test bus-test-system $(extra_tests) else TESTS= endif ## we use noinst_PROGRAMS not check_PROGRAMS so that we build ## even when not doing "make check" -noinst_PROGRAMS=$(TESTS) dbus-daemon dbus-daemon-launch-helper-test dbus-daemon-launch-helper +noinst_PROGRAMS=$(TESTS) dbus-daemon $(extra_noinst_programs) bus_test_system_SOURCES= \ $(XML_SOURCES) \ @@ -176,28 +183,30 @@ clean-local: /bin/rm *.bb *.bbg *.da *.gcov || true uninstall-hook: - rm -f $(DESTDIR)$(DBUS_DAEMONDIR)/dbus-daemon - rm -f $(DESTDIR)$(libexecdir)/dbus-daemon-launch-helper + rm -f $(DESTDIR)$(DBUS_DAEMONDIR)/dbus-daemon$(EXEEXT) + rm -f $(DESTDIR)$(libexecdir)/dbus-daemon-launch-helper$(EXEEXT) install-data-hook: if test '!' -d $(DESTDIR)$(DBUS_DAEMONDIR); then \ $(mkinstalldirs) $(DESTDIR)$(DBUS_DAEMONDIR); \ chmod 755 $(DESTDIR)$(DBUS_DAEMONDIR); \ fi - $(INSTALL_PROGRAM) dbus-daemon $(DESTDIR)$(DBUS_DAEMONDIR) + $(INSTALL_PROGRAM) dbus-daemon$(EXEEXT) $(DESTDIR)$(DBUS_DAEMONDIR) $(mkinstalldirs) $(DESTDIR)$(localstatedir)/run/dbus $(mkinstalldirs) $(DESTDIR)$(configdir)/system.d $(mkinstalldirs) $(DESTDIR)$(configdir)/session.d $(mkinstalldirs) $(DESTDIR)$(datadir)/dbus-1/services $(mkinstalldirs) $(DESTDIR)$(datadir)/dbus-1/system-services $(mkinstalldirs) $(DESTDIR)$(libexecdir)/dbus-1 - $(INSTALL_PROGRAM) dbus-daemon-launch-helper $(DESTDIR)$(libexecdir) + if test -f dbus-daemin-launch-helper$(EXEEXT) ; then \ + $(INSTALL_PROGRAM) dbus-daemon-launch-helper$(EXEEXT) $(DESTDIR)$(libexecdir); \ if test `id -u` -eq 0; then \ chown root:$(DBUS_USER) $(DESTDIR)$(libexecdir)/dbus-daemon-launch-helper; \ chmod 4750 $(DESTDIR)$(libexecdir)/dbus-daemon-launch-helper; \ else \ echo "Not installing $(DESTDIR)$(libexecdir)/dbus-daemon-launch-helper binary setuid!"; \ echo "You'll need to manually set permissions to root:$(DBUS_USER) and permissions 4750"; \ + fi \ fi #### Init scripts fun -- 1.6.4.msysgit.0 From 8a7a80c8c1bdac4a438ca81de118c5e03a098dfa Mon Sep 17 00:00:00 2001 From: Frank Osterfeld Date: Sun, 3 May 2009 19:52:48 +0100 Subject: [PATCH 041/114] fix warning, use Sleep, not _sleep on windows (cherry picked from commit ea36c743ad60a2dd5c6286571d1a475903519809) --- cmake/test/CMakeLists.txt | 4 ---- test/test-sleep-forever.c | 8 +++++++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/cmake/test/CMakeLists.txt b/cmake/test/CMakeLists.txt index 7011d31..e700f76 100644 --- a/cmake/test/CMakeLists.txt +++ b/cmake/test/CMakeLists.txt @@ -17,10 +17,6 @@ add_subdirectory( name-test ) #INCLUDES=-I$(top_srcdir) $(DBUS_test-CFLAGS) -if (WIN32) -add_definitions(-Dsleep=_sleep) -endif (WIN32) - #if (DBUS_BUILD_TESTS) ## break-loader removed for now #test-BINARIES=test-service test-names test-shell-service shell-test spawn-test test-segfault test-exit test-sleep-forever diff --git a/test/test-sleep-forever.c b/test/test-sleep-forever.c index ff0d8e2..d54769a 100644 --- a/test/test-sleep-forever.c +++ b/test/test-sleep-forever.c @@ -6,11 +6,17 @@ #include #endif +#ifdef DBUS_WIN +# include +# define sleep Sleep +#endif + + int main (int argc, char **argv) { while (1) sleep (10000000); - + return 1; } -- 1.6.4.msysgit.0 From cd8ef58d9cb14a2b5c7aa7a8fca642f185478940 Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Wed, 22 Apr 2009 09:31:26 +0200 Subject: [PATCH 042/114] tools/dbus-launch-win.c: fix typo (cherry picked from commit 81a7a0e9309e5929857fdf44b8b51a4f8df097e6) --- tools/dbus-launch-win.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/tools/dbus-launch-win.c b/tools/dbus-launch-win.c index 27fabbc..9a792c9 100644 --- a/tools/dbus-launch-win.c +++ b/tools/dbus-launch-win.c @@ -112,7 +112,7 @@ int main(int argc,char **argv) if (result == 0) { if (verbose) - fprintf(stderr,"could not start dbus-daemon error=%d",GetLastError()); + fprintf(stderr, "Could not start dbus-daemon error=%d",GetLastError()); return 4; } -- 1.6.4.msysgit.0 From ff07bf46a07247837839e162c473958cb201473c Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Wed, 22 Apr 2009 09:53:11 +0200 Subject: [PATCH 043/114] dbus/dbus-sysdeps-util-win.c: DBUS_WIN is always defined here (cherry picked from commit 1046f3b0eb57ef746aaff3a8da87020bb1b19a44) --- dbus/dbus-sysdeps-util-win.c | 6 ------ 1 files changed, 0 insertions(+), 6 deletions(-) diff --git a/dbus/dbus-sysdeps-util-win.c b/dbus/dbus-sysdeps-util-win.c index d589a21..ce4af8a 100644 --- a/dbus/dbus-sysdeps-util-win.c +++ b/dbus/dbus-sysdeps-util-win.c @@ -465,17 +465,11 @@ _dbus_stat(const DBusString *filename, //TODO #else const char *filename_c; -#if !defined(DBUS_WIN) && !defined(DBUS_WINCE) - - struct stat sb; -#else - WIN32_FILE_ATTRIBUTE_DATA wfad; char *lastdot; DWORD rc; PSID owner_sid, group_sid; PSECURITY_DESCRIPTOR sd; -#endif _DBUS_ASSERT_ERROR_IS_CLEAR (error); -- 1.6.4.msysgit.0 From a530dcfccef3bf8128d150fa376a9fabb9a9ef49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole=20Andr=C3=A9=20Vadla=20Ravn=C3=A5s?= Date: Sun, 29 Mar 2009 00:39:29 +0100 Subject: [PATCH 044/114] Fix DBusMessage compiler warnings by adding some missing casts. Basically the case where the address of a const pointer is passed as a non-const void pointer. (cherry picked from commit dab3ec2abe7fbeea4dab873c8575a45b3b18882d) --- dbus/dbus-message.c | 16 ++++++++-------- 1 files changed, 8 insertions(+), 8 deletions(-) diff --git a/dbus/dbus-message.c b/dbus/dbus-message.c index 72d3be8..f4e0573 100644 --- a/dbus/dbus-message.c +++ b/dbus/dbus-message.c @@ -825,7 +825,7 @@ _dbus_message_iter_get_args_valist (DBusMessageIter *iter, _dbus_type_reader_recurse (&real->u.reader, &array); _dbus_type_reader_read_fixed_multi (&array, - ptr, n_elements_p); + (void *) ptr, n_elements_p); } else if (spec_element_type == DBUS_TYPE_STRING || spec_element_type == DBUS_TYPE_SIGNATURE || @@ -866,7 +866,7 @@ _dbus_message_iter_get_args_valist (DBusMessageIter *iter, { const char *s; _dbus_type_reader_read_basic (&array, - &s); + (void *) &s); str_array[i] = _dbus_strdup (s); if (str_array[i] == NULL) @@ -2907,7 +2907,7 @@ dbus_message_get_path (DBusMessage *message) _dbus_header_get_field_basic (&message->header, DBUS_HEADER_FIELD_PATH, DBUS_TYPE_OBJECT_PATH, - &v); + (void *) &v); return v; } @@ -3038,7 +3038,7 @@ dbus_message_get_interface (DBusMessage *message) _dbus_header_get_field_basic (&message->header, DBUS_HEADER_FIELD_INTERFACE, DBUS_TYPE_STRING, - &v); + (void *) &v); return v; } @@ -3124,7 +3124,7 @@ dbus_message_get_member (DBusMessage *message) _dbus_header_get_field_basic (&message->header, DBUS_HEADER_FIELD_MEMBER, DBUS_TYPE_STRING, - &v); + (void *) &v); return v; } @@ -3208,7 +3208,7 @@ dbus_message_get_error_name (DBusMessage *message) _dbus_header_get_field_basic (&message->header, DBUS_HEADER_FIELD_ERROR_NAME, DBUS_TYPE_STRING, - &v); + (void *) &v); return v; } @@ -3261,7 +3261,7 @@ dbus_message_get_destination (DBusMessage *message) _dbus_header_get_field_basic (&message->header, DBUS_HEADER_FIELD_DESTINATION, DBUS_TYPE_STRING, - &v); + (void *) &v); return v; } @@ -3321,7 +3321,7 @@ dbus_message_get_sender (DBusMessage *message) _dbus_header_get_field_basic (&message->header, DBUS_HEADER_FIELD_SENDER, DBUS_TYPE_STRING, - &v); + (void *) &v); return v; } -- 1.6.4.msysgit.0 From ec5d95c9dc7c55f31f09df7e052106a0b5981c19 Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Wed, 22 Apr 2009 09:29:45 +0200 Subject: [PATCH 045/114] tools/dbus-launch-win.c: strrchr -> _mbsrchr (cherry picked from commit b8b9fc300242ff25071df4166173baae7d2b4f0f) --- tools/dbus-launch-win.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/tools/dbus-launch-win.c b/tools/dbus-launch-win.c index 9a792c9..3cf26e5 100644 --- a/tools/dbus-launch-win.c +++ b/tools/dbus-launch-win.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #if defined __MINGW32__ || (defined _MSC_VER && _MSC_VER <= 1310) @@ -74,7 +75,7 @@ int main(int argc,char **argv) #else daemon_name = "dbus-daemon.exe"; #endif - if ((p = strrchr(dbusDaemonPath,'\\'))) + if ((p = _mbsrchr (dbusDaemonPath, '\\'))) { *(p+1)= '\0'; strcat_s(dbusDaemonPath,sizeof(dbusDaemonPath),daemon_name); -- 1.6.4.msysgit.0 From 881b51653c2f8c50a0a1f75532dc494ef884dfea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole=20Andr=C3=A9=20Vadla=20Ravn=C3=A5s?= Date: Sun, 29 Mar 2009 00:47:42 +0100 Subject: [PATCH 046/114] Only define _WIN32_WINNT if not already defined. (cherry picked from commit 98bb071819ab9f886317627b6688876f40ed694e) --- dbus/dbus-sysdeps-win.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/dbus/dbus-sysdeps-win.c b/dbus/dbus-sysdeps-win.c index ab71981..ade8044 100644 --- a/dbus/dbus-sysdeps-win.c +++ b/dbus/dbus-sysdeps-win.c @@ -31,8 +31,10 @@ #define STRSAFE_NO_DEPRECATE #ifndef DBUS_WINCE +#ifndef _WIN32_WINNT #define _WIN32_WINNT 0x0501 #endif +#endif #include "dbus-internals.h" #include "dbus-sysdeps.h" -- 1.6.4.msysgit.0 From 67fa8bbbd3af9ae104528f09ad906211ad0bb61e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole=20Andr=C3=A9=20Vadla=20Ravn=C3=A5s?= Date: Sun, 29 Mar 2009 00:49:34 +0100 Subject: [PATCH 047/114] Add missing stdio.h include needed for _vsnprintf(). (cherry picked from commit dddd412402657fa5ac6de225e8d5a00fb290589c) --- dbus/dbus-sysdeps-win.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/dbus/dbus-sysdeps-win.c b/dbus/dbus-sysdeps-win.c index ade8044..34af24a 100644 --- a/dbus/dbus-sysdeps-win.c +++ b/dbus/dbus-sysdeps-win.c @@ -53,6 +53,7 @@ #include #include +#include #include #include -- 1.6.4.msysgit.0 From 67f86293e72ef6c22188eaf41e96778bc9bd6b75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole=20Andr=C3=A9=20Vadla=20Ravn=C3=A5s?= Date: Sun, 29 Mar 2009 01:06:54 +0100 Subject: [PATCH 048/114] Remove a misleading comment. errno.h is present and needed on Windows. (It's not present on Windows CE though.) (cherry picked from commit cef676c0c7ea8ad352e1ecf1c3643edb1abd7ad6) --- dbus/dbus-sysdeps.c | 4 ---- 1 files changed, 0 insertions(+), 4 deletions(-) diff --git a/dbus/dbus-sysdeps.c b/dbus/dbus-sysdeps.c index 0fdf33c..240589f 100644 --- a/dbus/dbus-sysdeps.c +++ b/dbus/dbus-sysdeps.c @@ -39,10 +39,6 @@ #include #include -/* This is UNIX-specific (on windows it's just in stdlib.h I believe) - * but OK since the same stuff does exist on Windows in stdlib.h - * and covered by a configure check. - */ #ifdef HAVE_ERRNO_H #include #endif -- 1.6.4.msysgit.0 From c79b7371b6f079dbad5f697570ddd23e8c3962db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole=20Andr=C3=A9=20Vadla=20Ravn=C3=A5s?= Date: Sun, 29 Mar 2009 01:20:02 +0100 Subject: [PATCH 049/114] Use CreateDirectory() instead of complicating things. This is Windows sysdeps after all, and _dbus_mkdir() wasn't used anywhere else. (cherry picked from commit 0bbe3787ce1e9e992f2bcbbdfcab1dcdb0b41f24) --- dbus/dbus-sysdeps-win.c | 15 ++------------- 1 files changed, 2 insertions(+), 13 deletions(-) diff --git a/dbus/dbus-sysdeps-win.c b/dbus/dbus-sysdeps-win.c index 34af24a..126ffee 100644 --- a/dbus/dbus-sysdeps-win.c +++ b/dbus/dbus-sysdeps-win.c @@ -1433,17 +1433,6 @@ Original CVS version of dbus-sysdeps.c /** - * @addtogroup DBusInternalsUtils - * @{ - */ - -int _dbus_mkdir (const char *path, - mode_t mode) -{ - return _mkdir(path); -} - -/** * Exit the process, returning the given value. * * @param code the exit code @@ -2417,9 +2406,9 @@ _dbus_create_directory (const DBusString *filename, filename_c = _dbus_string_get_const_data (filename); - if (_dbus_mkdir (filename_c, 0700) < 0) + if (!CreateDirectory (filename_c, NULL)) { - if (errno == EEXIST) + if (GetLastError () == ERROR_ALREADY_EXISTS) return TRUE; dbus_set_error (error, DBUS_ERROR_FAILED, -- 1.6.4.msysgit.0 From 923024ecee752ef1ab61ee50204a4c8ae8641fe1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole=20Andr=C3=A9=20Vadla=20Ravn=C3=A5s?= Date: Sun, 29 Mar 2009 01:44:44 +0100 Subject: [PATCH 050/114] Fix broken Windows implementation of _dbus_printf_string_upper_bound(). Pass the correct buffer size when trying again, and keep trying with larger buffer sizes, doubling the size each time. (cherry picked from commit 95832a94607eea609de994467b7d64e36af72e6b) --- dbus/dbus-sysdeps-win.c | 27 ++++++++++++++------------- 1 files changed, 14 insertions(+), 13 deletions(-) diff --git a/dbus/dbus-sysdeps-win.c b/dbus/dbus-sysdeps-win.c index 126ffee..5dd1ca9 100644 --- a/dbus/dbus-sysdeps-win.c +++ b/dbus/dbus-sysdeps-win.c @@ -658,23 +658,24 @@ int _dbus_printf_string_upper_bound (const char *format, va_list args) { /* MSVCRT's vsnprintf semantics are a bit different */ - /* The C library source in the Platform SDK indicates that this - * would work, but alas, it doesn't. At least not on Windows - * 2000. Presumably those sources correspond to the C library on - * some newer or even future Windows version. - * - len = _vsnprintf (NULL, _DBUS_INT_MAX, format, args); - */ - char p[1024]; + char buf[1024]; + int bufsize; int len; - len = _vsnprintf (p, sizeof(p)-1, format, args); - if (len == -1) // try again + + bufsize = sizeof (buf); + len = _vsnprintf (buf, bufsize - 1, format, args); + + while (len == -1) /* try again */ { char *p; - p = malloc (strlen(format)*3); - len = _vsnprintf (p, sizeof(p)-1, format, args); - free(p); + + bufsize *= 2; + + p = malloc (bufsize); + len = _vsnprintf (p, bufsize - 1, format, args); + free (p); } + return len; } -- 1.6.4.msysgit.0 From 5351d5456c89adddf7c8c0622f535a92718409cd Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Wed, 22 Apr 2009 09:20:04 +0200 Subject: [PATCH 051/114] dbus/dbus-connection.c: use dbus_message_type_to_string instead of printing the naked message type (cherry picked from commit 33d858e83e3cb1f55ed257ffef930b8f49c3ffc7) --- dbus/dbus-connection.c | 32 ++++++++++++++++---------------- 1 files changed, 16 insertions(+), 16 deletions(-) diff --git a/dbus/dbus-connection.c b/dbus/dbus-connection.c index dffc16f..55e4cc2 100644 --- a/dbus/dbus-connection.c +++ b/dbus/dbus-connection.c @@ -485,9 +485,9 @@ _dbus_connection_queue_received_message_link (DBusConnection *connection, _dbus_connection_wakeup_mainloop (connection); - _dbus_verbose ("Message %p (%d %s %s %s '%s' reply to %u) added to incoming queue %p, %d incoming\n", + _dbus_verbose ("Message %p (%s %s %s %s '%s' reply to %u) added to incoming queue %p, %d incoming\n", message, - dbus_message_get_type (message), + dbus_message_type_to_string (dbus_message_get_type (message)), dbus_message_get_path (message) ? dbus_message_get_path (message) : "no path", @@ -611,9 +611,9 @@ _dbus_connection_message_sent (DBusConnection *connection, connection->n_outgoing -= 1; - _dbus_verbose ("Message %p (%d %s %s %s '%s') removed from outgoing queue %p, %d left to send\n", + _dbus_verbose ("Message %p (%s %s %s %s '%s') removed from outgoing queue %p, %d left to send\n", message, - dbus_message_get_type (message), + dbus_message_type_to_string (dbus_message_get_type (message)), dbus_message_get_path (message) ? dbus_message_get_path (message) : "no path", @@ -1947,9 +1947,9 @@ _dbus_connection_send_preallocated_unlocked_no_update (DBusConnection *con sig = dbus_message_get_signature (message); - _dbus_verbose ("Message %p (%d %s %s %s '%s') for %s added to outgoing queue %p, %d pending to send\n", + _dbus_verbose ("Message %p (%s %s %s %s '%s') for %s added to outgoing queue %p, %d pending to send\n", message, - dbus_message_get_type (message), + dbus_message_type_to_string (dbus_message_get_type (message)), dbus_message_get_path (message) ? dbus_message_get_path (message) : "no path", @@ -3865,9 +3865,9 @@ _dbus_connection_pop_message_link_unlocked (DBusConnection *connection) link = _dbus_list_pop_first_link (&connection->incoming_messages); connection->n_incoming -= 1; - _dbus_verbose ("Message %p (%d %s %s %s '%s') removed from incoming queue %p, %d incoming\n", + _dbus_verbose ("Message %p (%s %s %s %s '%s') removed from incoming queue %p, %d incoming\n", link->data, - dbus_message_get_type (link->data), + dbus_message_type_to_string (dbus_message_get_type (link->data)), dbus_message_get_path (link->data) ? dbus_message_get_path (link->data) : "no path", @@ -3930,9 +3930,9 @@ _dbus_connection_putback_message_link_unlocked (DBusConnection *connection, message_link); connection->n_incoming += 1; - _dbus_verbose ("Message %p (%d %s %s '%s') put back into queue %p, %d incoming\n", + _dbus_verbose ("Message %p (%s %s %s '%s') put back into queue %p, %d incoming\n", message_link->data, - dbus_message_get_type (message_link->data), + dbus_message_type_to_string (dbus_message_get_type (message_link->data)), dbus_message_get_interface (message_link->data) ? dbus_message_get_interface (message_link->data) : "no interface", @@ -4473,9 +4473,9 @@ dbus_connection_dispatch (DBusConnection *connection) message = message_link->data; - _dbus_verbose (" dispatching message %p (%d %s %s '%s')\n", + _dbus_verbose (" dispatching message %p (%s %s %s '%s')\n", message, - dbus_message_get_type (message), + dbus_message_type_to_string (dbus_message_get_type (message)), dbus_message_get_interface (message) ? dbus_message_get_interface (message) : "no interface", @@ -4582,9 +4582,9 @@ dbus_connection_dispatch (DBusConnection *connection) /* We're still protected from dispatch() reentrancy here * since we acquired the dispatcher */ - _dbus_verbose (" running object path dispatch on message %p (%d %s %s '%s')\n", + _dbus_verbose (" running object path dispatch on message %p (%s %s %s '%s')\n", message, - dbus_message_get_type (message), + dbus_message_type_to_string (dbus_message_get_type (message)), dbus_message_get_interface (message) ? dbus_message_get_interface (message) : "no interface", @@ -4663,8 +4663,8 @@ dbus_connection_dispatch (DBusConnection *connection) result = DBUS_HANDLER_RESULT_HANDLED; } - _dbus_verbose (" done dispatching %p (%d %s %s '%s') on connection %p\n", message, - dbus_message_get_type (message), + _dbus_verbose (" done dispatching %p (%s %s %s '%s') on connection %p\n", message, + dbus_message_type_to_string (dbus_message_get_type (message)), dbus_message_get_interface (message) ? dbus_message_get_interface (message) : "no interface", -- 1.6.4.msysgit.0 From f4840e63b582f679f7c57b5cfedc55c5a665c08a Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Wed, 22 Apr 2009 09:30:23 +0200 Subject: [PATCH 052/114] tools/dbus-launch-win.c: TODO++ (cherry picked from commit 0f5dbec6407975d6a93fbb2cbcd58ab192961cf8) --- tools/dbus-launch-win.c | 14 +++++++++++++- 1 files changed, 13 insertions(+), 1 deletions(-) diff --git a/tools/dbus-launch-win.c b/tools/dbus-launch-win.c index 3cf26e5..8156aa1 100644 --- a/tools/dbus-launch-win.c +++ b/tools/dbus-launch-win.c @@ -46,7 +46,19 @@ errno_t strcpy_s(char *dest, size_t size, char *src) } #endif -/* TODO: use unicode version as suggested by Tor Lillqvist */ +/* TODO: Use Unicode APIs */ + +/* TODO: This Windows version of dbus-launch is curretly rather + * pointless as it doesn't take the same command-line options as the + * UNIX dbus-launch does. A main point of the dbus-launch command is + * to pass it for instance a --config-file option to make the started + * dbus-daemon use that config file. + * + * This version also doesn't print out any information, which is a + * main point of the UNIX one. It should at least support the + * --sh-syntax option, and maybe also a --cmd-syntax to print out the + * variable settings in cmd.exe syntax? + */ #define AUTO_ACTIVATE_CONSOLE_WHEN_VERBOSE_MODE 1 -- 1.6.4.msysgit.0 From 28f160063b11adaf10f9d64d26f56aec19fabb94 Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Wed, 22 Apr 2009 09:40:35 +0200 Subject: [PATCH 053/114] dbus/dbus-transport.c: fix {our,auth}_identity mismatch (cherry picked from commit e15f1cde3b5893357f640e360f64c0a1ae37f93b) --- dbus/dbus-transport.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dbus/dbus-transport.c b/dbus/dbus-transport.c index 3c67621..40a1ce1 100644 --- a/dbus/dbus-transport.c +++ b/dbus/dbus-transport.c @@ -660,12 +660,12 @@ auth_via_default_rules (DBusTransport *transport) 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; -- 1.6.4.msysgit.0 From f54a706607ec51a30d9e02fdf9ea20026e99954c Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Wed, 22 Apr 2009 09:42:01 +0200 Subject: [PATCH 054/114] dbus/dbus-transport.c: _dbus_credentials_get_windows_sid might return NULL (cherry picked from commit 8d8d5fa1babc8f51f1d1bb95b8116850978c60d9) --- dbus/dbus-transport.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-) diff --git a/dbus/dbus-transport.c b/dbus/dbus-transport.c index 40a1ce1..d8f34ee 100644 --- a/dbus/dbus-transport.c +++ b/dbus/dbus-transport.c @@ -660,8 +660,10 @@ auth_via_default_rules (DBusTransport *transport) 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(auth_identity), - _dbus_credentials_get_windows_sid(our_identity)); + (_dbus_credentials_get_windows_sid(auth_identity) ? + _dbus_credentials_get_windows_sid(auth_identity) : ""), + (_dbus_credentials_get_windows_sid(our_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", -- 1.6.4.msysgit.0 From 0bc3e8d60350f3bdb414e8788ce7f7d8237af6fc Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Wed, 22 Apr 2009 10:07:47 +0200 Subject: [PATCH 055/114] dbus/dbus-internals.h: 2x const char foo[] -> const char foo * (cherry picked from commit 62eaf8c91160abdeab6a46bb7bff737e13a390cf) --- dbus/dbus-internals.c | 4 ++-- dbus/dbus-internals.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/dbus/dbus-internals.c b/dbus/dbus-internals.c index 061b637..895b9ac 100644 --- a/dbus/dbus-internals.c +++ b/dbus/dbus-internals.c @@ -192,7 +192,7 @@ * making up a different string every time and wasting * space. */ -const char _dbus_no_memory_message[] = "Not enough memory"; +const char *_dbus_no_memory_message = "Not enough memory"; static dbus_bool_t warn_initted = FALSE; static dbus_bool_t fatal_warnings = FALSE; @@ -824,7 +824,7 @@ _dbus_header_field_to_string (int header_field) #ifndef DBUS_DISABLE_CHECKS /** String used in _dbus_return_if_fail macro */ -const char _dbus_return_if_fail_warning_format[] = +const char *_dbus_return_if_fail_warning_format = "arguments to %s() were incorrect, assertion \"%s\" failed in file %s line %d.\n" "This is normally a bug in some application using the D-Bus library.\n"; #endif diff --git a/dbus/dbus-internals.h b/dbus/dbus-internals.h index faa2429..8b5af8d 100644 --- a/dbus/dbus-internals.h +++ b/dbus/dbus-internals.h @@ -131,7 +131,7 @@ void _dbus_real_assert_not_reached (const char *explanation, #define _dbus_return_if_fail(condition) #define _dbus_return_val_if_fail(condition, val) #else -extern const char _dbus_return_if_fail_warning_format[]; +extern const char *_dbus_return_if_fail_warning_format; #define _dbus_return_if_fail(condition) do { \ _dbus_assert ((*(const char*)_DBUS_FUNCTION_NAME) != '_'); \ @@ -245,7 +245,7 @@ void _dbus_verbose_bytes_of_string (const DBusString *str, const char* _dbus_header_field_to_string (int header_field); -extern const char _dbus_no_memory_message[]; +extern const char *_dbus_no_memory_message; #define _DBUS_SET_OOM(error) dbus_set_error_const ((error), DBUS_ERROR_NO_MEMORY, _dbus_no_memory_message) #ifdef DBUS_BUILD_TESTS -- 1.6.4.msysgit.0 From 99ee9a061bfa36277d9b3812b325ca49d0531d50 Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Wed, 22 Apr 2009 10:08:41 +0200 Subject: [PATCH 056/114] dbus/dbus-internals.c: "#define inline" is only needed on MSVC, not mingw (cherry picked from commit 314e91e3ee2566477918a51dbddd9eb141b33a23) --- dbus/dbus-internals.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/dbus/dbus-internals.c b/dbus/dbus-internals.c index 895b9ac..b70f332 100644 --- a/dbus/dbus-internals.c +++ b/dbus/dbus-internals.c @@ -298,7 +298,7 @@ static dbus_bool_t verbose = TRUE; #include #endif -#ifdef DBUS_WIN +#ifdef _MSC_VER #define inline #endif #ifdef USE_OUTPUTDEBUGSTRING -- 1.6.4.msysgit.0 From ae9bd5798c4937bbd658ee38dfc487d847e47d1d Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Wed, 22 Apr 2009 10:11:27 +0200 Subject: [PATCH 057/114] dbus/dbus-spawn-win.c: implement missing _dbus_babysitter_get_child_exit_status (cherry picked from commit 7a9863b9847380dbb8400f895934d7f282ebdbf2) --- dbus/dbus-spawn-win.c | 16 ++++++++++++++++ 1 files changed, 16 insertions(+), 0 deletions(-) diff --git a/dbus/dbus-spawn-win.c b/dbus/dbus-spawn-win.c index de07789..2d58a12 100644 --- a/dbus/dbus-spawn-win.c +++ b/dbus/dbus-spawn-win.c @@ -268,6 +268,22 @@ _dbus_babysitter_get_child_exited (DBusBabysitter *sitter) return (sitter->child_handle == NULL); } +dbus_bool_t +_dbus_babysitter_get_child_exit_status (DBusBabysitter *sitter, + int *status) +{ + PING(); + + if (!_dbus_babysitter_get_child_exited (sitter)) + _dbus_assert_not_reached ("Child has not exited"); + + if (!sitter->have_child_status) + return FALSE; + + *status = sitter->child_status; + return TRUE; +} + /** * Gets the exit status of the child. We do this so implementation specific * detail is not cluttering up dbus, for example the system launcher code. -- 1.6.4.msysgit.0 From f2481044d403e281bc179328537c2f504d9df883 Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Wed, 22 Apr 2009 10:48:59 +0200 Subject: [PATCH 058/114] dbus/dbus-sysdeps-win.h: add _dbus_win_get_dll-module (cherry picked from commit da5e8e14029cb64a65fe482e232be1d786a8ee19) --- dbus/dbus-sysdeps-thread-win.c | 11 +++++++++++ dbus/dbus-sysdeps-win.h | 1 + 2 files changed, 12 insertions(+), 0 deletions(-) diff --git a/dbus/dbus-sysdeps-thread-win.c b/dbus/dbus-sysdeps-thread-win.c index a4f45c0..891b1bb 100644 --- a/dbus/dbus-sysdeps-thread-win.c +++ b/dbus/dbus-sysdeps-thread-win.c @@ -36,6 +36,14 @@ struct DBusCondVar { static DWORD dbus_cond_event_tls = TLS_OUT_OF_INDEXES; +static HMODULE dbus_dll_hmodule; + +void * +_dbus_win_get_dll_hmodule (void) +{ + return dbus_dll_hmodule; +} + BOOL WINAPI DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved); @@ -49,6 +57,9 @@ DllMain (HINSTANCE hinstDLL, HANDLE event; switch (fdwReason) { + case DLL_PROCESS_ATTACH: + dbus_dll_hmodule = hinstDLL; + break; case DLL_THREAD_DETACH: if (dbus_cond_event_tls != TLS_OUT_OF_INDEXES) { diff --git a/dbus/dbus-sysdeps-win.h b/dbus/dbus-sysdeps-win.h index 161a819..032b9a2 100644 --- a/dbus/dbus-sysdeps-win.h +++ b/dbus/dbus-sysdeps-win.h @@ -26,6 +26,7 @@ #ifndef DBUS_SYSDEPS_WIN_H #define DBUS_SYSDEPS_WIN_H +extern void *_dbus_win_get_dll_hmodule (void); #define _WINSOCKAPI_ #include "dbus-hash.h" -- 1.6.4.msysgit.0 From 457a6c0f95dedde144f6769f8cd976e63bd77fcc Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Wed, 22 Apr 2009 11:54:24 +0200 Subject: [PATCH 059/114] dbus/dbus-sysdeps-win.c: #define socklen_t -> typedef (cherry picked from commit eb104f4573fcbcbf3a87d673a023b5db4a249867) --- dbus/dbus-sysdeps-win.c | 4 +--- 1 files changed, 1 insertions(+), 3 deletions(-) diff --git a/dbus/dbus-sysdeps-win.c b/dbus/dbus-sysdeps-win.c index 5dd1ca9..7487085 100644 --- a/dbus/dbus-sysdeps-win.c +++ b/dbus/dbus-sysdeps-win.c @@ -71,9 +71,7 @@ #define O_BINARY 0 #endif -#ifndef HAVE_SOCKLEN_T -#define socklen_t int -#endif +typedef int socklen_t; /** * File interface -- 1.6.4.msysgit.0 From 04ffd8e4c33c374618518ea5cd998de9bfa7a239 Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Wed, 22 Apr 2009 12:17:35 +0200 Subject: [PATCH 060/114] dbus/dbus-sysdeps-*win.c: remove DBusFile abstraction (cherry picked from commit 2895660b0e683d71dd51911819c0f31aff8517c3) --- dbus/dbus-sysdeps-util-win.c | 24 ++-- dbus/dbus-sysdeps-win.c | 317 ++++++++++++++++-------------------------- dbus/dbus-sysdeps-win.h | 28 ---- 3 files changed, 130 insertions(+), 239 deletions(-) diff --git a/dbus/dbus-sysdeps-util-win.c b/dbus/dbus-sysdeps-util-win.c index ce4af8a..2c0b816 100644 --- a/dbus/dbus-sysdeps-util-win.c +++ b/dbus/dbus-sysdeps-util-win.c @@ -99,24 +99,26 @@ _dbus_write_pid_file (const DBusString *filename, DBusError *error) { const char *cfilename; - DBusFile file; + int fd; FILE *f; cfilename = _dbus_string_get_const_data (filename); - - if (!_dbus_file_open(&file, cfilename, O_WRONLY|O_CREAT|O_EXCL|O_BINARY, 0644)) + + fd = _open (cfilename, O_WRONLY|O_CREAT|O_EXCL|O_BINARY, 0644); + + if (fd < 0) { dbus_set_error (error, _dbus_error_from_errno (errno), "Failed to open \"%s\": %s", cfilename, - _dbus_strerror (errno)); + strerror (errno)); return FALSE; } - if ((f = fdopen (file.FDATA, "w")) == NULL) + if ((f = fdopen (fd, "w")) == NULL) { dbus_set_error (error, _dbus_error_from_errno (errno), - "Failed to fdopen fd %d: %s", file.FDATA, _dbus_strerror (errno)); - _dbus_file_close (&file, NULL); + "Failed to fdopen fd %d: %s", fd, strerror (errno)); + _close (fd); return FALSE; } @@ -124,7 +126,7 @@ _dbus_write_pid_file (const DBusString *filename, { dbus_set_error (error, _dbus_error_from_errno (errno), "Failed to write to \"%s\": %s", cfilename, - _dbus_strerror (errno)); + strerror (errno)); fclose (f); return FALSE; @@ -134,7 +136,7 @@ _dbus_write_pid_file (const DBusString *filename, { dbus_set_error (error, _dbus_error_from_errno (errno), "Failed to close \"%s\": %s", cfilename, - _dbus_strerror (errno)); + strerror (errno)); return FALSE; } @@ -364,11 +366,11 @@ _dbus_delete_directory (const DBusString *filename, filename_c = _dbus_string_get_const_data (filename); - if (rmdir (filename_c) != 0) + if (_rmdir (filename_c) != 0) { dbus_set_error (error, DBUS_ERROR_FAILED, "Failed to remove directory %s: %s\n", - filename_c, _dbus_strerror (errno)); + filename_c, strerror (errno)); return FALSE; } diff --git a/dbus/dbus-sysdeps-win.c b/dbus/dbus-sysdeps-win.c index 7487085..b8adeba 100644 --- a/dbus/dbus-sysdeps-win.c +++ b/dbus/dbus-sysdeps-win.c @@ -54,6 +54,10 @@ #include #include +#include + +#include +#include #include #include @@ -74,148 +78,6 @@ typedef int socklen_t; /** - * File interface - * - */ -dbus_bool_t -_dbus_file_open (DBusFile *file, - const char *filename, - int oflag, - int pmode) -{ - if (pmode!=-1) - file->FDATA = _open (filename, oflag, pmode); - else - file->FDATA = _open (filename, oflag); - if (file->FDATA >= 0) - return TRUE; - else - { - file->FDATA = -1; - return FALSE; - } -} - -dbus_bool_t -_dbus_file_close (DBusFile *file, - DBusError *error) -{ - const int fd = file->FDATA; - - _DBUS_ASSERT_ERROR_IS_CLEAR (error); - - _dbus_assert (fd >= 0); - - if (_close (fd) == -1) - { - dbus_set_error (error, _dbus_error_from_errno (errno), - "Could not close fd %d: %s", fd, - _dbus_strerror (errno)); - return FALSE; - } - - file->FDATA = -1; - _dbus_verbose ("closed C file descriptor %d:\n",fd); - - return TRUE; -} - -int -_dbus_file_read(DBusFile *file, - DBusString *buffer, - int count) -{ - const int fd = file->FDATA; - int bytes_read; - int start; - char *data; - _dbus_assert (count >= 0); - - start = _dbus_string_get_length (buffer); - - if (!_dbus_string_lengthen (buffer, count)) - { - errno = ENOMEM; - return -1; - } - - data = _dbus_string_get_data_len (buffer, start, count); - - _dbus_assert (fd >= 0); - - _dbus_verbose ("read: count=%d fd=%d\n", count, fd); - bytes_read = read (fd, data, count); - - if (bytes_read == -1) - _dbus_verbose ("read: failed: %s\n", _dbus_strerror (errno)); - else - _dbus_verbose ("read: = %d\n", bytes_read); - - if (bytes_read < 0) - { - /* put length back (note that this doesn't actually realloc anything) */ - _dbus_string_set_length (buffer, start); - return -1; - } - else - { - /* put length back (doesn't actually realloc) */ - _dbus_string_set_length (buffer, start + bytes_read); - -#if 0 - - if (bytes_read > 0) - _dbus_verbose_bytes_of_string (buffer, start, bytes_read); -#endif - - return bytes_read; - } -} - -int -_dbus_file_write (DBusFile *file, - const DBusString *buffer, - int start, - int len) -{ - const int fd = file->FDATA; - const char *data; - int bytes_written; - - data = _dbus_string_get_const_data_len (buffer, start, len); - - _dbus_assert (fd >= 0); - - _dbus_verbose ("write: len=%d fd=%d\n", len, fd); - bytes_written = write (fd, data, len); - - if (bytes_written == -1) - _dbus_verbose ("write: failed: %s\n", _dbus_strerror (errno)); - else - _dbus_verbose ("write: = %d\n", bytes_written); - -#if 0 - - if (bytes_written > 0) - _dbus_verbose_bytes_of_string (buffer, start, bytes_written); -#endif - - return bytes_written; -} - -dbus_bool_t -_dbus_is_valid_file (DBusFile* file) -{ - return file->FDATA >= 0; -} - -dbus_bool_t _dbus_fstat (DBusFile *file, - struct stat *sb) -{ - return fstat(file->FDATA, sb) >= 0; -} - -/** * write data to a pipe. * * @param pipe the pipe instance @@ -233,14 +95,14 @@ _dbus_pipe_write (DBusPipe *pipe, DBusError *error) { int written; - DBusFile file; - file.FDATA = pipe->fd_or_handle; - written = _dbus_file_write (&file, buffer, start, len); + const char *buffer_c = _dbus_string_get_const_data (buffer); + + written = _write (pipe->fd_or_handle, buffer_c + start, len); if (written < 0) { dbus_set_error (error, DBUS_ERROR_FAILED, "Writing to pipe: %s\n", - _dbus_strerror (errno)); + strerror (errno)); } return written; } @@ -256,9 +118,9 @@ int _dbus_pipe_close (DBusPipe *pipe, DBusError *error) { - DBusFile file; - file.FDATA = pipe->fd_or_handle; - if (_dbus_file_close (&file, error) < 0) + _DBUS_ASSERT_ERROR_IS_CLEAR (error); + + if (_close (pipe->fd_or_handle) < 0) { return -1; } @@ -269,8 +131,6 @@ _dbus_pipe_close (DBusPipe *pipe, } } -#undef FDATA - /** * Socket interface * @@ -525,7 +385,6 @@ _dbus_write_socket_two (int fd, const char *data2; int rc; DWORD bytes_written; - int ret1; _dbus_assert (buffer1 != NULL); _dbus_assert (start1 >= 0); @@ -1204,7 +1063,7 @@ _dbus_poll (DBusPollFD *fds, { DBUS_SOCKET_SET_ERRNO (); if (errno != EWOULDBLOCK) - _dbus_verbose ("WSAWaitForMultipleEvents: failed: %s\n", _dbus_strerror (errno)); + _dbus_verbose ("WSAWaitForMultipleEvents: failed: %s\n", strerror (errno)); ret = -1; } else if (ready == WSA_WAIT_TIMEOUT) @@ -2097,10 +1956,61 @@ _dbus_get_current_time (long *tv_sec, void _dbus_disable_sigpipe (void) { - _dbus_verbose("FIXME: implement _dbus_disable_sigpipe (void)\n"); } +/* _dbus_read() is static on Windows, only used below in this file. + */ +static int +_dbus_read (int fd, + DBusString *buffer, + int count) +{ + int bytes_read; + int start; + char *data; + + _dbus_assert (count >= 0); + + start = _dbus_string_get_length (buffer); + + if (!_dbus_string_lengthen (buffer, count)) + { + errno = ENOMEM; + return -1; + } + + data = _dbus_string_get_data_len (buffer, start, count); + + again: + + bytes_read = _read (fd, data, count); + + if (bytes_read < 0) + { + if (errno == EINTR) + goto again; + else + { + /* put length back (note that this doesn't actually realloc anything) */ + _dbus_string_set_length (buffer, start); + return -1; + } + } + else + { + /* put length back (doesn't actually realloc) */ + _dbus_string_set_length (buffer, start + bytes_read); + +#if 0 + if (bytes_read > 0) + _dbus_verbose_bytes_of_string (buffer, start, bytes_read); +#endif + + return bytes_read; + } +} + /** * Appends the contents of the given file to the string, * returning error code. At the moment, won't open a file @@ -2116,8 +2026,8 @@ _dbus_file_get_contents (DBusString *str, const DBusString *filename, DBusError *error) { - DBusFile file; - struct stat sb; + int fd; + struct _stati64 sb; int orig_len; int total; const char *filename_c; @@ -2126,27 +2036,29 @@ _dbus_file_get_contents (DBusString *str, filename_c = _dbus_string_get_const_data (filename); - /* O_BINARY useful on Cygwin and Win32 */ - if (!_dbus_file_open (&file, filename_c, O_RDONLY | O_BINARY, -1)) + fd = _open (filename_c, O_RDONLY | O_BINARY); + if (fd < 0) { dbus_set_error (error, _dbus_error_from_errno (errno), "Failed to open \"%s\": %s", filename_c, - _dbus_strerror (errno)); + strerror (errno)); return FALSE; } - if (!_dbus_fstat (&file, &sb)) + _dbus_verbose ("file %s fd %d opened\n", filename_c, fd); + + if (_fstati64 (fd, &sb) < 0) { dbus_set_error (error, _dbus_error_from_errno (errno), "Failed to stat \"%s\": %s", filename_c, - _dbus_strerror (errno)); + strerror (errno)); _dbus_verbose ("fstat() failed: %s", - _dbus_strerror (errno)); + strerror (errno)); - _dbus_file_close (&file, NULL); + _close (fd); return FALSE; } @@ -2156,7 +2068,7 @@ _dbus_file_get_contents (DBusString *str, dbus_set_error (error, DBUS_ERROR_FAILED, "File size %lu of \"%s\" is too large.", (unsigned long) sb.st_size, filename_c); - _dbus_file_close (&file, NULL); + _close (fd); return FALSE; } @@ -2168,19 +2080,18 @@ _dbus_file_get_contents (DBusString *str, while (total < (int) sb.st_size) { - bytes_read = _dbus_file_read (&file, str, - sb.st_size - total); + bytes_read = _dbus_read (fd, str, sb.st_size - total); if (bytes_read <= 0) { dbus_set_error (error, _dbus_error_from_errno (errno), "Error reading \"%s\": %s", filename_c, - _dbus_strerror (errno)); + strerror (errno)); _dbus_verbose ("read() failed: %s", - _dbus_strerror (errno)); + strerror (errno)); - _dbus_file_close (&file, NULL); + _close (fd); _dbus_string_set_length (str, orig_len); return FALSE; } @@ -2188,7 +2099,7 @@ _dbus_file_get_contents (DBusString *str, total += bytes_read; } - _dbus_file_close (&file, NULL); + _close (fd); return TRUE; } else if (sb.st_size != 0) @@ -2197,12 +2108,12 @@ _dbus_file_get_contents (DBusString *str, dbus_set_error (error, DBUS_ERROR_FAILED, "\"%s\" is not a regular file", filename_c); - _dbus_file_close (&file, NULL); + _close (fd); return FALSE; } else { - _dbus_file_close (&file, NULL); + _close (fd); return TRUE; } } @@ -2221,17 +2132,19 @@ _dbus_string_save_to_file (const DBusString *str, const DBusString *filename, DBusError *error) { - DBusFile file; + int fd; int bytes_to_write; const char *filename_c; DBusString tmp_filename; const char *tmp_filename_c; int total; + const char *str_c; dbus_bool_t need_unlink; dbus_bool_t retval; _DBUS_ASSERT_ERROR_IS_CLEAR (error); + fd = -1; retval = FALSE; need_unlink = FALSE; @@ -2266,48 +2179,51 @@ _dbus_string_save_to_file (const DBusString *str, filename_c = _dbus_string_get_const_data (filename); tmp_filename_c = _dbus_string_get_const_data (&tmp_filename); - if (!_dbus_file_open (&file, tmp_filename_c, O_WRONLY | O_BINARY | O_EXCL | O_CREAT, - 0600)) + fd = _open (tmp_filename_c, O_WRONLY | O_BINARY | O_EXCL | O_CREAT, + 0600); + if (fd < 0) { dbus_set_error (error, _dbus_error_from_errno (errno), "Could not create %s: %s", tmp_filename_c, - _dbus_strerror (errno)); + strerror (errno)); goto out; } + _dbus_verbose ("tmp file %s fd %d opened\n", tmp_filename_c, fd); + need_unlink = TRUE; total = 0; bytes_to_write = _dbus_string_get_length (str); + str_c = _dbus_string_get_const_data (str); while (total < bytes_to_write) { int bytes_written; - bytes_written = _dbus_file_write (&file, str, total, - bytes_to_write - total); + bytes_written = _write (fd, str_c + total, bytes_to_write - total); if (bytes_written <= 0) { dbus_set_error (error, _dbus_error_from_errno (errno), "Could not write to %s: %s", tmp_filename_c, - _dbus_strerror (errno)); - + strerror (errno)); goto out; } total += bytes_written; } - if (!_dbus_file_close (&file, NULL)) + if (_close (fd) < 0) { dbus_set_error (error, _dbus_error_from_errno (errno), "Could not close file %s: %s", - tmp_filename_c, _dbus_strerror (errno)); + tmp_filename_c, strerror (errno)); goto out; } + fd = -1; if ((unlink (filename_c) == -1 && errno != ENOENT) || rename (tmp_filename_c, filename_c) < 0) @@ -2324,17 +2240,15 @@ _dbus_string_save_to_file (const DBusString *str, retval = TRUE; -out: - /* close first, then unlink, to prevent ".nfs34234235" garbage - * files - */ + out: + /* close first, then unlink */ - if (_dbus_is_valid_file(&file)) - _dbus_file_close (&file, NULL); + if (fd >= 0) + _close (fd); - if (need_unlink && unlink (tmp_filename_c) < 0) - _dbus_verbose ("Failed to unlink temp file %s: %s\n", - tmp_filename_c, _dbus_strerror (errno)); + if (need_unlink && _unlink (tmp_filename_c) < 0) + _dbus_verbose ("failed to unlink temp file %s: %s\n", + tmp_filename_c, strerror (errno)); _dbus_string_free (&tmp_filename); @@ -2355,31 +2269,34 @@ dbus_bool_t _dbus_create_file_exclusively (const DBusString *filename, DBusError *error) { - DBusFile file; + int fd; const char *filename_c; _DBUS_ASSERT_ERROR_IS_CLEAR (error); filename_c = _dbus_string_get_const_data (filename); - if (!_dbus_file_open (&file, filename_c, O_WRONLY | O_BINARY | O_EXCL | O_CREAT, - 0600)) + fd = _open (filename_c, O_WRONLY | O_BINARY | O_EXCL | O_CREAT, + 0600); + if (fd < 0) { dbus_set_error (error, DBUS_ERROR_FAILED, "Could not create file %s: %s\n", filename_c, - _dbus_strerror (errno)); + strerror (errno)); return FALSE; } - if (!_dbus_file_close (&file, NULL)) + _dbus_verbose ("exclusive file %s fd %d opened\n", filename_c, fd); + + if (_close (fd) < 0) { dbus_set_error (error, DBUS_ERROR_FAILED, "Could not close file %s: %s\n", filename_c, - _dbus_strerror (errno)); + strerror (errno)); return FALSE; } @@ -2412,7 +2329,7 @@ _dbus_create_directory (const DBusString *filename, dbus_set_error (error, DBUS_ERROR_FAILED, "Failed to create directory %s: %s\n", - filename_c, _dbus_strerror (errno)); + filename_c, strerror (errno)); return FALSE; } else @@ -2515,11 +2432,11 @@ _dbus_delete_file (const DBusString *filename, filename_c = _dbus_string_get_const_data (filename); - if (unlink (filename_c) < 0) + if (_unlink (filename_c) < 0) { dbus_set_error (error, DBUS_ERROR_FAILED, "Failed to delete file %s: %s\n", - filename_c, _dbus_strerror (errno)); + filename_c, strerror (errno)); return FALSE; } else diff --git a/dbus/dbus-sysdeps-win.h b/dbus/dbus-sysdeps-win.h index 032b9a2..d41e1fb 100644 --- a/dbus/dbus-sysdeps-win.h +++ b/dbus/dbus-sysdeps-win.h @@ -90,36 +90,8 @@ _dbus_win_sid_to_name_and_domain (dbus_uid_t uid, wchar_t **wdomain, DBusError *error); -typedef struct DBusFile DBusFile; - -dbus_bool_t _dbus_file_open (DBusFile *file, - const char *filename, - int oflag, - int pmode); - -dbus_bool_t _dbus_file_close (DBusFile *file, - DBusError *error); - - -int _dbus_file_read (DBusFile *file, - DBusString *buffer, - int count); - -int _dbus_file_write (DBusFile *file, - const DBusString *buffer, - int start, - int len); - dbus_bool_t _dbus_file_exists (const char *filename); - -#define FDATA private_data -struct DBusFile - { - int FDATA; - }; - - dbus_bool_t _dbus_get_config_file_name(DBusString *config_file, char *s); -- 1.6.4.msysgit.0 From 9e00cca46fdd4cee0ee0f91249d1f208c78c3068 Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Wed, 22 Apr 2009 12:22:33 +0200 Subject: [PATCH 061/114] dbus/dbus-sysdeps-win.c: Use CryptoApi to get random numbers (cherry picked from commit 5f7ae46398818200b3fdcdfe80b78bee31a3e89b) --- dbus/dbus-sysdeps-win.c | 72 +++++++++++++++------------------------------- 1 files changed, 24 insertions(+), 48 deletions(-) diff --git a/dbus/dbus-sysdeps-win.c b/dbus/dbus-sysdeps-win.c index b8adeba..acdd7bd 100644 --- a/dbus/dbus-sysdeps-win.c +++ b/dbus/dbus-sysdeps-win.c @@ -50,6 +50,8 @@ #include #include +#include + #include #include @@ -2337,41 +2339,21 @@ _dbus_create_directory (const DBusString *filename, } -static void -pseudorandom_generate_random_bytes_buffer (char *buffer, - int n_bytes) -{ - long tv_usec; - int i; - - /* fall back to pseudorandom */ - _dbus_verbose ("Falling back to pseudorandom for %d bytes\n", - n_bytes); - - _dbus_get_current_time (NULL, &tv_usec); - srand (tv_usec); - - i = 0; - while (i < n_bytes) - { - double r; - unsigned int b; - - r = rand (); - b = (r / (double) RAND_MAX) * 255.0; - - buffer[i] = b; - - ++i; - } -} - -static dbus_bool_t -pseudorandom_generate_random_bytes (DBusString *str, - int n_bytes) +/** + * Generates the given number of random bytes, + * using the best mechanism we can come up with. + * + * @param str the string + * @param n_bytes the number of random bytes to append to string + * @returns #TRUE on success, #FALSE if no memory + */ +dbus_bool_t +_dbus_generate_random_bytes (DBusString *str, + int n_bytes) { int old_len; char *p; + HCRYPTPROV hprov; old_len = _dbus_string_get_length (str); @@ -2380,7 +2362,16 @@ pseudorandom_generate_random_bytes (DBusString *str, p = _dbus_string_get_data_len (str, old_len, n_bytes); - pseudorandom_generate_random_bytes_buffer (p, n_bytes); + if (!CryptAcquireContext (&hprov, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT)) + return FALSE; + + if (!CryptGenRandom (hprov, n_bytes, p)) + { + CryptReleaseContext (hprov, 0); + return FALSE; + } + + CryptReleaseContext (hprov, 0); return TRUE; } @@ -2443,21 +2434,6 @@ _dbus_delete_file (const DBusString *filename, return TRUE; } -/** - * Generates the given number of random bytes, - * using the best mechanism we can come up with. - * - * @param str the string - * @param n_bytes the number of random bytes to append to string - * @returns #TRUE on success, #FALSE if no memory - */ -dbus_bool_t -_dbus_generate_random_bytes (DBusString *str, - int n_bytes) -{ - return pseudorandom_generate_random_bytes (str, n_bytes); -} - #if !defined (DBUS_DISABLE_ASSERT) || defined(DBUS_BUILD_TESTS) #ifdef _MSC_VER -- 1.6.4.msysgit.0 From 7b21f5ef8c12ef5bd9a005c593336659d845b79d Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Wed, 22 Apr 2009 12:24:40 +0200 Subject: [PATCH 062/114] dbus/dbus-sysdeps-win.c: set an error when _close fails in _dbus_pipe_close (cherry picked from commit 6671b4a20da468bad6842815a1161a98251b66fc) --- dbus/dbus-sysdeps-win.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/dbus/dbus-sysdeps-win.c b/dbus/dbus-sysdeps-win.c index acdd7bd..f96d40a 100644 --- a/dbus/dbus-sysdeps-win.c +++ b/dbus/dbus-sysdeps-win.c @@ -124,6 +124,8 @@ _dbus_pipe_close (DBusPipe *pipe, if (_close (pipe->fd_or_handle) < 0) { + dbus_set_error (error, _dbus_error_from_errno (errno), + "Could not close pipe %d: %s", pipe->fd_or_handle, strerror (errno)); return -1; } else -- 1.6.4.msysgit.0 From 4b5efaddba36e94291c02d8eea536d1182aa83d8 Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Wed, 22 Apr 2009 12:26:04 +0200 Subject: [PATCH 063/114] dbus/dbus-sysdeps-win.c: _dbus_getpid() returns dbus_pid_t (cherry picked from commit 40a01bf6d2c6d216093d309ca4c48602a585960b) --- dbus/dbus-sysdeps-win.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/dbus/dbus-sysdeps-win.c b/dbus/dbus-sysdeps-win.c index f96d40a..9a29a39 100644 --- a/dbus/dbus-sysdeps-win.c +++ b/dbus/dbus-sysdeps-win.c @@ -1897,7 +1897,7 @@ _dbus_append_user_from_current_process (DBusString *str) * Gets our process ID * @returns process ID */ -unsigned long +dbus_pid_t _dbus_getpid (void) { return GetCurrentProcessId (); -- 1.6.4.msysgit.0 From e57bc4f3d0de4d85b00cc209a3b8488622ea07d8 Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Wed, 22 Apr 2009 13:27:44 +0200 Subject: [PATCH 064/114] dbus/dbus-sysdeps-win.c: use GetTempPath, not getenv, in _dbus_get_tmpdir (cherry picked from commit c2366c5410149e896cb56c3d17bb995308e18292) --- dbus/dbus-sysdeps-win.c | 13 +++++-------- 1 files changed, 5 insertions(+), 8 deletions(-) diff --git a/dbus/dbus-sysdeps-win.c b/dbus/dbus-sysdeps-win.c index 9a29a39..2aec554 100644 --- a/dbus/dbus-sysdeps-win.c +++ b/dbus/dbus-sysdeps-win.c @@ -2388,17 +2388,14 @@ const char* _dbus_get_tmpdir(void) { static const char* tmpdir = NULL; + static char buf[1000]; if (tmpdir == NULL) { - if (tmpdir == NULL) - tmpdir = getenv("TMP"); - if (tmpdir == NULL) - tmpdir = getenv("TEMP"); - if (tmpdir == NULL) - tmpdir = getenv("TMPDIR"); - if (tmpdir == NULL) - tmpdir = "C:\\Temp"; + if (!GetTempPath (sizeof (buf), buf)) + strcpy (buf, "\\"); + + tmpdir = buf; } _dbus_assert(tmpdir != NULL); -- 1.6.4.msysgit.0 From fad2ed39e09a82a89df03a0d7c570d172063c4fb Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Wed, 22 Apr 2009 13:32:29 +0200 Subject: [PATCH 065/114] dbus/dbus-sysdeps-win.c: use MoveFileEx, not unlink+rename, in _dbus_string_save_to_file (cherry picked from commit c31bb3c262db1e6e42ec1bc9a6e8063c625a7cb2) --- dbus/dbus-sysdeps-win.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dbus/dbus-sysdeps-win.c b/dbus/dbus-sysdeps-win.c index 2aec554..7d9fc4a 100644 --- a/dbus/dbus-sysdeps-win.c +++ b/dbus/dbus-sysdeps-win.c @@ -2229,8 +2229,8 @@ _dbus_string_save_to_file (const DBusString *str, fd = -1; - if ((unlink (filename_c) == -1 && errno != ENOENT) || - rename (tmp_filename_c, filename_c) < 0) + /* Unlike rename(), MoveFileEx() can replace existing files */ + if (MoveFileExA (tmp_filename_c, filename_c, MOVEFILE_REPLACE_EXISTING) < 0) { dbus_set_error (error, _dbus_error_from_errno (errno), "Could not rename %s to %s: %s", -- 1.6.4.msysgit.0 From 77f448f1a489ab2bc58934d0afb922ecb45e3b07 Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Wed, 22 Apr 2009 13:35:11 +0200 Subject: [PATCH 066/114] dbus/dbus-sysdeps-win.c: add _dbus_win_error_string, and use after MoveFileEx instead of _dbus_error_from_errno (cherry picked from commit 1d0b2dacf52faffbeba09af2b309683ccc71547a) --- dbus/dbus-sysdeps-win.c | 31 +++++++++++++++++++++++++++++-- 1 files changed, 29 insertions(+), 2 deletions(-) diff --git a/dbus/dbus-sysdeps-win.c b/dbus/dbus-sysdeps-win.c index 7d9fc4a..46a4b79 100644 --- a/dbus/dbus-sysdeps-win.c +++ b/dbus/dbus-sysdeps-win.c @@ -79,6 +79,31 @@ typedef int socklen_t; +static char* +_dbus_win_error_string (int error_number) +{ + char *msg; + + FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER | + FORMAT_MESSAGE_IGNORE_INSERTS | + FORMAT_MESSAGE_FROM_SYSTEM, + NULL, error_number, 0, + (LPSTR) &msg, 0, NULL); + + if (msg[strlen (msg) - 1] == '\n') + msg[strlen (msg) - 1] = '\0'; + if (msg[strlen (msg) - 1] == '\r') + msg[strlen (msg) - 1] = '\0'; + + return msg; +} + +static void +_dbus_win_free_error_string (char *string) +{ + LocalFree (string); +} + /** * write data to a pipe. * @@ -2232,10 +2257,12 @@ _dbus_string_save_to_file (const DBusString *str, /* Unlike rename(), MoveFileEx() can replace existing files */ if (MoveFileExA (tmp_filename_c, filename_c, MOVEFILE_REPLACE_EXISTING) < 0) { - dbus_set_error (error, _dbus_error_from_errno (errno), + char *emsg = _dbus_win_error_string (GetLastError ()); + dbus_set_error (error, DBUS_ERROR_FAILED, "Could not rename %s to %s: %s", tmp_filename_c, filename_c, - _dbus_strerror (errno)); + emsg); + _dbus_win_free_error_string (emsg); goto out; } -- 1.6.4.msysgit.0 From 1d13153582e53dc5527f22f393c656134f2710e9 Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Wed, 22 Apr 2009 13:37:38 +0200 Subject: [PATCH 067/114] dbus/dbus-sysdeps-win.h: move declarations into .c (used nowhere else) (cherry picked from commit 0ea30b511e5b099c43bfdf2cbff0f3935917e057) --- dbus/dbus-sysdeps-win.c | 4 ++++ dbus/dbus-sysdeps-win.h | 4 ---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/dbus/dbus-sysdeps-win.c b/dbus/dbus-sysdeps-win.c index 46a4b79..7d1ae18 100644 --- a/dbus/dbus-sysdeps-win.c +++ b/dbus/dbus-sysdeps-win.c @@ -52,6 +52,10 @@ #include #include +/* Declarations missing in mingw's headers */ +extern BOOL WINAPI ConvertStringSidToSidA (LPCSTR StringSid, PSID *Sid); +extern BOOL WINAPI ConvertSidToStringSidA (PSID Sid, LPSTR *StringSid); + #include #include diff --git a/dbus/dbus-sysdeps-win.h b/dbus/dbus-sysdeps-win.h index d41e1fb..e6ebfc6 100644 --- a/dbus/dbus-sysdeps-win.h +++ b/dbus/dbus-sysdeps-win.h @@ -50,10 +50,6 @@ extern void *_dbus_win_get_dll_hmodule (void); #endif #endif -/* Declarations missing in mingw's headers */ -extern BOOL WINAPI ConvertStringSidToSidA (LPCSTR StringSid, PSID *Sid); -extern BOOL WINAPI ConvertSidToStringSidA (PSID Sid, LPSTR *StringSid); - #define DBUS_CONSOLE_DIR "/var/run/console/" -- 1.6.4.msysgit.0 From 27dba2cf43c8184be65fdfd35b138efbb95e8c84 Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Wed, 22 Apr 2009 13:54:10 +0200 Subject: [PATCH 068/114] dbus/dbus-sysdeps-*win.c: remove #undef open, which has no effect (cherry picked from commit 737e3782cd16424a6f1b941b64867178bb5634be) --- dbus/dbus-sysdeps-util-win.c | 2 -- dbus/dbus-sysdeps-win.c | 2 -- 2 files changed, 0 insertions(+), 4 deletions(-) diff --git a/dbus/dbus-sysdeps-util-win.c b/dbus/dbus-sysdeps-util-win.c index 2c0b816..d5c2ddc 100644 --- a/dbus/dbus-sysdeps-util-win.c +++ b/dbus/dbus-sysdeps-util-win.c @@ -22,8 +22,6 @@ * */ -#undef open - #define STRSAFE_NO_DEPRECATE #include "dbus-sysdeps.h" diff --git a/dbus/dbus-sysdeps-win.c b/dbus/dbus-sysdeps-win.c index 7d1ae18..60e2552 100644 --- a/dbus/dbus-sysdeps-win.c +++ b/dbus/dbus-sysdeps-win.c @@ -26,8 +26,6 @@ * */ -#undef open - #define STRSAFE_NO_DEPRECATE #ifndef DBUS_WINCE -- 1.6.4.msysgit.0 From 83f34795d3a52d879fa11a1029677ffff7345a57 Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Wed, 22 Apr 2009 16:16:53 +0200 Subject: [PATCH 069/114] dbus/dbus-sysdeps-util-win.c: remove unused str*_s definitions (cherry picked from commit 373214317c33031547f3788cffed8a832142fc43) --- dbus/dbus-sysdeps-util-win.c | 21 --------------------- 1 files changed, 0 insertions(+), 21 deletions(-) diff --git a/dbus/dbus-sysdeps-util-win.c b/dbus/dbus-sysdeps-util-win.c index d5c2ddc..620862f 100644 --- a/dbus/dbus-sysdeps-util-win.c +++ b/dbus/dbus-sysdeps-util-win.c @@ -44,27 +44,6 @@ #include #include // WSA error codes -#if defined __MINGW32__ || (defined _MSC_VER && _MSC_VER <= 1310) -/* save string functions version - using DBusString needs to much time because of uncommon api -*/ -#define errno_t int - -errno_t strcat_s(char *dest, size_t size, char *src) -{ - _dbus_assert(strlen(dest) + strlen(src) +1 <= size); - strcat(dest,src); - return 0; -} - -errno_t strcpy_s(char *dest, size_t size, char *src) -{ - _dbus_assert(strlen(src) +1 <= size); - strcpy(dest,src); - return 0; -} -#endif - /** * Does the chdir, fork, setsid, etc. to become a daemon process. * -- 1.6.4.msysgit.0 From f93d4de32c0a75e18e98774ea37983a83f0dc897 Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Wed, 22 Apr 2009 15:28:58 +0200 Subject: [PATCH 070/114] dbus/dbus-sysdeps-win.c: tighter "scoping" for alternate _dbus_poll implementations (cherry picked from commit 6828a25073c16fb5af55c4aaf16a08eb90e4676d) --- dbus/dbus-sysdeps-win.c | 17 ++++++----------- 1 files changed, 6 insertions(+), 11 deletions(-) diff --git a/dbus/dbus-sysdeps-win.c b/dbus/dbus-sysdeps-win.c index 60e2552..bca2f1c 100644 --- a/dbus/dbus-sysdeps-win.c +++ b/dbus/dbus-sysdeps-win.c @@ -1015,13 +1015,15 @@ out0: * @param timeout_milliseconds timeout or -1 for infinite * @returns numbers of fds with revents, or <0 on error */ -#define USE_CHRIS_IMPL 0 -#if USE_CHRIS_IMPL int _dbus_poll (DBusPollFD *fds, int n_fds, int timeout_milliseconds) { +#define USE_CHRIS_IMPL 0 + +#if USE_CHRIS_IMPL + #define DBUS_POLL_CHAR_BUFFER_SIZE 2000 char msg[DBUS_POLL_CHAR_BUFFER_SIZE]; char *msgp; @@ -1160,15 +1162,9 @@ _dbus_poll (DBusPollFD *fds, free(pEvents); return ret; -} -#else // USE_CHRIS_IMPL +#else /* USE_CHRIS_IMPL */ -int -_dbus_poll (DBusPollFD *fds, - int n_fds, - int timeout_milliseconds) -{ #define DBUS_POLL_CHAR_BUFFER_SIZE 2000 char msg[DBUS_POLL_CHAR_BUFFER_SIZE]; char *msgp; @@ -1283,10 +1279,9 @@ _dbus_poll (DBusPollFD *fds, } } return ready; +#endif /* USE_CHRIS_IMPL */ } -#endif // USE_CHRIS_IMPL - -- 1.6.4.msysgit.0 From a0f3c78ef799aea51cbd472c8740d05a172b7b2b Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Wed, 22 Apr 2009 16:35:43 +0200 Subject: [PATCH 071/114] dbus/dbus-sysdeps-util-win.c: use GetFileAttributes instead of CreateFile in _dbus_file_exists (cherry picked from commit 3ba582b91361785c3eb0121e8b9e85d046eea75f) --- dbus/dbus-sysdeps-util-win.c | 24 ++++++------------------ 1 files changed, 6 insertions(+), 18 deletions(-) diff --git a/dbus/dbus-sysdeps-util-win.c b/dbus/dbus-sysdeps-util-win.c index 620862f..51fcb39 100644 --- a/dbus/dbus-sysdeps-util-win.c +++ b/dbus/dbus-sysdeps-util-win.c @@ -406,24 +406,12 @@ _dbus_set_signal_handler (int sig, dbus_bool_t _dbus_file_exists (const char *file) { - HANDLE h = CreateFile( - file, /* LPCTSTR lpFileName*/ - 0, /* DWORD dwDesiredAccess */ - 0, /* DWORD dwShareMode*/ - NULL, /* LPSECURITY_ATTRIBUTES lpSecurityAttributes */ - OPEN_EXISTING, /* DWORD dwCreationDisposition */ - FILE_ATTRIBUTE_NORMAL, /* DWORD dwFlagsAndAttributes */ - NULL /* HANDLE hTemplateFile */ - ); - - /* file not found, use local copy of session.conf */ - if (h != INVALID_HANDLE_VALUE && GetLastError() != ERROR_PATH_NOT_FOUND) - { - CloseHandle(h); - return TRUE; - } - else - return FALSE; + DWORD attributes = GetFileAttributes (file); + + if (attributes != INVALID_FILE_ATTRIBUTES && GetLastError() != ERROR_PATH_NOT_FOUND) + return TRUE; + else + return FALSE; } /** -- 1.6.4.msysgit.0 From b9d04c1c503c0cb740e45638b614f6884f5dc396 Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Wed, 22 Apr 2009 16:49:00 +0200 Subject: [PATCH 072/114] dbus/dbus-sysdeps-win.c: _dbus_windows_user_is_process_owner belongs to -util-win.c (cherry picked from commit 952caf475334b7c38084d4a992abef3f4e0d4cfb) --- dbus/dbus-sysdeps-util-win.c | 5 +++++ dbus/dbus-sysdeps-win.c | 6 ------ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/dbus/dbus-sysdeps-util-win.c b/dbus/dbus-sysdeps-util-win.c index 51fcb39..51f5ad3 100644 --- a/dbus/dbus-sysdeps-util-win.c +++ b/dbus/dbus-sysdeps-util-win.c @@ -875,6 +875,11 @@ _dbus_unix_user_is_process_owner (dbus_uid_t uid) return FALSE; } +dbus_bool_t _dbus_windows_user_is_process_owner (const char *windows_sid) +{ + return TRUE; +} + /*===================================================================== unix emulation functions - should be removed sometime in the future =====================================================================*/ diff --git a/dbus/dbus-sysdeps-win.c b/dbus/dbus-sysdeps-win.c index bca2f1c..f7d4856 100644 --- a/dbus/dbus-sysdeps-win.c +++ b/dbus/dbus-sysdeps-win.c @@ -3220,12 +3220,6 @@ _dbus_atomic_dec (DBusAtomic *atomic) void _dbus_flush_caches (void) { - -} - -dbus_bool_t _dbus_windows_user_is_process_owner (const char *windows_sid) -{ - return TRUE; } /** -- 1.6.4.msysgit.0 From 1214fc95bc193cc804c9b5ff0037043784933d34 Mon Sep 17 00:00:00 2001 From: Frank Osterfeld Date: Wed, 29 Apr 2009 13:21:30 +0100 Subject: [PATCH 073/114] remove duplicate dbus_babysitter_get_child_exit_status impl (cherry picked from commit c2d044dc1216d73e70a6e69280b9ce413260b03d) --- dbus/dbus-spawn-win.c | 16 ---------------- 1 files changed, 0 insertions(+), 16 deletions(-) diff --git a/dbus/dbus-spawn-win.c b/dbus/dbus-spawn-win.c index 2d58a12..de07789 100644 --- a/dbus/dbus-spawn-win.c +++ b/dbus/dbus-spawn-win.c @@ -268,22 +268,6 @@ _dbus_babysitter_get_child_exited (DBusBabysitter *sitter) return (sitter->child_handle == NULL); } -dbus_bool_t -_dbus_babysitter_get_child_exit_status (DBusBabysitter *sitter, - int *status) -{ - PING(); - - if (!_dbus_babysitter_get_child_exited (sitter)) - _dbus_assert_not_reached ("Child has not exited"); - - if (!sitter->have_child_status) - return FALSE; - - *status = sitter->child_status; - return TRUE; -} - /** * Gets the exit status of the child. We do this so implementation specific * detail is not cluttering up dbus, for example the system launcher code. -- 1.6.4.msysgit.0 From a5b172fd8965a19fae5e9c3731851214cd4ae7ff Mon Sep 17 00:00:00 2001 From: Frank Osterfeld Date: Thu, 30 Apr 2009 10:16:42 +0200 Subject: [PATCH 074/114] do not run test binaries as unit tests if they aren't unit tests (cherry picked from commit 5281f5b113bd97152d1c9eac050432bda3274748) --- cmake/test/CMakeLists.txt | 10 ---------- 1 files changed, 0 insertions(+), 10 deletions(-) diff --git a/cmake/test/CMakeLists.txt b/cmake/test/CMakeLists.txt index e700f76..310d084 100644 --- a/cmake/test/CMakeLists.txt +++ b/cmake/test/CMakeLists.txt @@ -82,12 +82,9 @@ set (decode_gcov_SOURCES add_executable(test-service ${test-service_SOURCES}) target_link_libraries(test-service ${DBUS_1}) -#install_targets(/bin test-service) add_executable(test-names ${test-names_SOURCES}) target_link_libraries(test-names ${DBUS_1}) -#install_targets(/bin test-names) -ADD_TEST(test-names ${EXECUTABLE_OUTPUT_PATH}/test-names${EXT}) add_executable(shell-test ${shell-test_SOURCES}) target_link_libraries(shell-test ${DBUS_1}) @@ -95,22 +92,15 @@ ADD_TEST(shell-test ${EXECUTABLE_OUTPUT_PATH}/shell-test${EXT}) add_executable(test-shell-service ${test-shell-service_SOURCES}) target_link_libraries(test-shell-service ${DBUS_1}) -#install_targets(/bin test-shell-service) add_executable(spawn-test ${spawn-test_SOURCES}) target_link_libraries(spawn-test ${DBUS_1}) -# (rh) does not work now -ADD_TEST(spawn-test ${EXECUTABLE_OUTPUT_PATH}/spawn-test${EXT}) add_executable(test-exit ${test-exit_SOURCES}) target_link_libraries(test-exit ${DBUS_1}) -#install_targets(/bin test-exit) -ADD_TEST(test-exit ${EXECUTABLE_OUTPUT_PATH}/test-exit${EXT}) add_executable(test-segfault ${test-segfault_SOURCES}) target_link_libraries(test-segfault ${DBUS_1}) -#install_targets(/bin test-segfault) -ADD_TEST(test-segfault ${EXECUTABLE_OUTPUT_PATH}/test-segfault${EXT}) add_executable(test-sleep-forever ${test-sleep-forever_SOURCES}) target_link_libraries(test-sleep-forever ${DBUS_1}) -- 1.6.4.msysgit.0 From ab8802d23481f57663208d7d287917ffcd9ff419 Mon Sep 17 00:00:00 2001 From: Frank Osterfeld Date: Thu, 30 Apr 2009 10:02:07 +0100 Subject: [PATCH 075/114] define _DEBUG for debug builds (cherry picked from commit 3e261c022623306d4dba0cb11fa342abff61aee9) --- cmake/CMakeLists.txt | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index cff6f65..0240c42 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -110,6 +110,8 @@ if(WIN32) set (CMAKE_DEBUG_POSTFIX "d") endif(WIN32) +SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_DEBUG") + ######################################################################### # Windows CE # -- 1.6.4.msysgit.0 From ffe2d0886ba2767b700a3f4e475e41fa7180777f Mon Sep 17 00:00:00 2001 From: Frank Osterfeld Date: Wed, 29 Apr 2009 18:03:32 +0200 Subject: [PATCH 076/114] _dbus_get_install_root assumes that dbus-daemon is in a bin/ subdirectory. That's not a common directory structure on windows, so weaken the assumption: $somepath/bin/dbus-daemon.exe -> $somepath $somepath/dbus-daemon.exe, where somepath doesn't end in /bin/: -> $somepath i.e., use dbus-daemon.exe's directory as root if that directory is not a "bin" directory (cherry picked from commit 2d2055b2fa7f92c144e9a182a9a091ebe5215d7d) --- dbus/dbus-sysdeps-win.c | 43 +++++++++++++++++++++++++------------------ 1 files changed, 25 insertions(+), 18 deletions(-) diff --git a/dbus/dbus-sysdeps-win.c b/dbus/dbus-sysdeps-win.c index f7d4856..d42d837 100644 --- a/dbus/dbus-sysdeps-win.c +++ b/dbus/dbus-sysdeps-win.c @@ -3242,26 +3242,33 @@ _dbus_get_is_errno_eagain_or_ewouldblock (void) * @returns #FALSE on failure */ dbus_bool_t -_dbus_get_install_root(char *s, int len) -{ - char *p = NULL; - int ret = GetModuleFileName(NULL,s,len); - if ( ret == 0 - || ret == len && GetLastError() == ERROR_INSUFFICIENT_BUFFER) - { - *s = '\0'; - return FALSE; - } - else if ((p = strstr(s,"\\bin\\"))) - { - *(p+1)= '\0'; - return TRUE; +_dbus_get_install_root(char *prefix, int len) +{ + //To find the prefix, we cut the filename and also \bin\ if present + char* p = 0; + int i; + DWORD pathLength; + int lastSlash; + SetLastError( 0 ); + pathLength = GetModuleFileName(NULL, prefix, len); + if ( pathLength == 0 || GetLastError() != 0 ) { + *prefix = '\0'; + return FALSE; } - else - { - *s = '\0'; - return FALSE; + lastSlash = -1; + for (i = 0; i < pathLength; ++i) + if (prefix[i] == '\\') + lastSlash = i; + if (lastSlash == -1) { + *prefix = '\0'; + return FALSE; } + //cut off binary name + prefix[lastSlash+1] = 0; + //cut possible "\\bin" + if (lastSlash > 3 && strncmp(prefix + lastSlash - 4, "\\bin", 4) == 0) + prefix[lastSlash-3] = 0; + return TRUE; } /** -- 1.6.4.msysgit.0 From 88ff6e09d32f2be4e5351ca3a377032602a3668b Mon Sep 17 00:00:00 2001 From: Frank Osterfeld Date: Fri, 29 May 2009 11:59:33 +0100 Subject: [PATCH 077/114] msvc build fix: update .def (cherry picked from commit f5deb4532ea19746d3b2c0b52b835770a434231c) --- cmake/dbus/dbus-1.def.cmake | 12 +----------- 1 files changed, 1 insertions(+), 11 deletions(-) diff --git a/cmake/dbus/dbus-1.def.cmake b/cmake/dbus/dbus-1.def.cmake index bee3a67..be93993 100755 --- a/cmake/dbus/dbus-1.def.cmake +++ b/cmake/dbus/dbus-1.def.cmake @@ -118,8 +118,7 @@ _dbus_credentials_same_user _dbus_credentials_test _dbus_credentials_unref _dbus_current_generation DATA -_dbus_daemon_init -_dbus_daemon_release +_dbus_daemon_publish_session_bus_address _dbus_data_slot_allocator_alloc _dbus_data_slot_allocator_free _dbus_data_slot_allocator_init @@ -142,16 +141,11 @@ _dbus_dup_string_array _dbus_error_from_errno _dbus_exit _dbus_fd_set_close_on_exec -_dbus_file_close _dbus_file_exists _dbus_file_get_contents -_dbus_file_open -_dbus_file_read -_dbus_file_write _dbus_first_type_in_signature _dbus_first_type_in_signature_c_str _dbus_flush_caches -_dbus_fstat _dbus_full_duplex_pipe _dbus_generate_pseudorandom_bytes_buffer _dbus_generate_random_ascii @@ -234,7 +228,6 @@ _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 _dbus_keyring_get_hex_key @@ -347,12 +340,9 @@ _dbus_message_loader_ref _dbus_message_loader_return_buffer _dbus_message_loader_set_max_message_size _dbus_message_loader_unref -_dbus_message_lock _dbus_message_remove_size_counter -_dbus_message_set_serial _dbus_message_test _dbus_misc_test -_dbus_mkdir _dbus_mutex_free _dbus_mutex_free_at_location _dbus_mutex_lock -- 1.6.4.msysgit.0 From f356fc1c8f26deb0d38d004ed4b8917a4cfdf25c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Date: Tue, 9 Jun 2009 21:45:10 +1000 Subject: [PATCH 078/114] configure.in: do not define DBUS_UNIX unconditionally (cherry picked from commit 5c072b8c4d912dfe34b72c2b7bbcb4ea359c98d7) --- configure.in | 2 -- 1 files changed, 0 insertions(+), 2 deletions(-) diff --git a/configure.in b/configure.in index f71c474..fabb6d3 100644 --- a/configure.in +++ b/configure.in @@ -1456,8 +1456,6 @@ fi AC_DEFINE_UNQUOTED(DBUS_SESSION_SOCKET_DIR, "$DBUS_SESSION_SOCKET_DIR", [Where per-session bus puts its sockets]) AC_SUBST(DBUS_SESSION_SOCKET_DIR) -AC_DEFINE_UNQUOTED(DBUS_UNIX, "1", [Defined on UNIX and Linux systems and not on Windows]) - # darwin needs this to initialize the environment AC_CHECK_HEADERS(crt_externs.h) AC_CHECK_FUNC(_NSGetEnviron, [AC_DEFINE(HAVE_NSGETENVIRON, 1, [Define if your system needs _NSGetEnviron to set up the environment])]) -- 1.6.4.msysgit.0 From 7d078b5bd188737580df1cd49fc5b16c49f99089 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Date: Tue, 9 Jun 2009 21:52:05 +1000 Subject: [PATCH 079/114] remove dbus-uuidgen from Windows build (cherry picked from commit 73873e002ac9ba6159388b2c7b4190c30961ec68) --- dbus/Makefile.am | 4 ++-- tools/Makefile.am | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/dbus/Makefile.am b/dbus/Makefile.am index 9daa8a9..4dc53e3 100644 --- a/dbus/Makefile.am +++ b/dbus/Makefile.am @@ -71,6 +71,8 @@ DBUS_UTIL_arch_sources = \ dbus-spawn-win.c else DBUS_LIB_arch_sources = \ + dbus-uuidgen.c \ + dbus-uuidgen.h \ dbus-server-unix.c \ dbus-server-unix.h @@ -165,8 +167,6 @@ DBUS_LIB_SOURCES= \ dbus-transport-protected.h \ dbus-transport-socket.c \ dbus-transport-socket.h \ - dbus-uuidgen.c \ - dbus-uuidgen.h \ dbus-watch.c \ dbus-watch.h diff --git a/tools/Makefile.am b/tools/Makefile.am index f597d59..08b5d6a 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -4,10 +4,10 @@ INCLUDES=-I$(top_srcdir) $(DBUS_CLIENT_CFLAGS) $(DBUS_X_CFLAGS) -DDBUS_LOCALEDIR extra_bin_programs= if DBUS_UNIX -extra_bin_programs += dbus-launch dbus-cleanup-sockets +extra_bin_programs += dbus-launch dbus-cleanup-sockets dbus-uuidgen endif -bin_PROGRAMS=dbus-send dbus-monitor $(extra_bin_programs) dbus-uuidgen +bin_PROGRAMS=dbus-send dbus-monitor $(extra_bin_programs) dbus_send_SOURCES= \ dbus-print-message.c \ -- 1.6.4.msysgit.0 From 71a1f8ca66bf6c61d806e14487934fbdc79300fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Date: Tue, 9 Jun 2009 21:46:11 +1000 Subject: [PATCH 080/114] use WINDRES instead of RC to compile rc file This is the way used by GTK+ and other packages. I don't know much about "RC" though. (cherry picked from commit d5b993ebc1411b15e4563d05fbd92cf8b29cbb4c) --- configure.in | 4 ++++ dbus/Makefile.am | 6 +----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/configure.in b/configure.in index fabb6d3..0fd11ec 100644 --- a/configure.in +++ b/configure.in @@ -89,6 +89,10 @@ if test "$dbus_win" = yes; then *-rc*) BUILD_FILEVERSION="${BUILD_FILEVERSION}1" ;; *) BUILD_FILEVERSION="${BUILD_FILEVERSION}2" ;; esac + AC_CHECK_TOOL(WINDRES, windres, no) + if test "$WINDRES" = no; then + AC_MSG_ERROR([*** Could not find an implementation of windres in your PATH.]) + fi else AC_DEFINE(DBUS_UNIX,1,[Defined if we run on a Unix-based system]) fi diff --git a/dbus/Makefile.am b/dbus/Makefile.am index 4dc53e3..5f8d703 100644 --- a/dbus/Makefile.am +++ b/dbus/Makefile.am @@ -15,14 +15,10 @@ lib_LTLIBRARIES=libdbus-1.la # Deal with W32 .def and version-info.rc stuff # if DBUS_WIN -LTRCCOMPILE = $(LIBTOOL) --mode=compile $(RC) \ - `echo $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) | \ - sed -e 's/-I/--include-dir /g;s/-D/--define /g'` - SUFFIXES = rc .rc.o: - $(LTRCCOMPILE) -i $< -o $@ + $(WINDRES) $< -o $@ dbus_res = versioninfo.o dbus_res_ldflag = -Wl,$(dbus_res) -- 1.6.4.msysgit.0 From 643351983b7a69293b8d88ad7a8050c50eedfec5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Date: Tue, 9 Jun 2009 21:48:53 +1000 Subject: [PATCH 081/114] Move some functions from dbus-sysdeps-util-win.c to dbus-sysdeps-win.c These are used by dbus-sysdeps-win.c and it is not linked together with dbus-sysdeps-util-win.c (cherry picked from commit 24b612adbf8045b8b00af15f8d44eb38f964641f) --- dbus/dbus-sysdeps-util-win.c | 197 ------------------------------------------ dbus/dbus-sysdeps-win.c | 197 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 197 insertions(+), 197 deletions(-) diff --git a/dbus/dbus-sysdeps-util-win.c b/dbus/dbus-sysdeps-util-win.c index 51f5ad3..e73dcbf 100644 --- a/dbus/dbus-sysdeps-util-win.c +++ b/dbus/dbus-sysdeps-util-win.c @@ -398,22 +398,6 @@ _dbus_set_signal_handler (int sig, _dbus_verbose ("_dbus_set_signal_handler() has to be implemented\n"); } -/** Checks if a file exists -* -* @param file full path to the file -* @returns #TRUE if file exists -*/ -dbus_bool_t -_dbus_file_exists (const char *file) -{ - DWORD attributes = GetFileAttributes (file); - - if (attributes != INVALID_FILE_ATTRIBUTES && GetLastError() != ERROR_PATH_NOT_FOUND) - return TRUE; - else - return FALSE; -} - /** * stat() wrapper. * @@ -961,187 +945,6 @@ _dbus_unix_groups_from_uid (dbus_uid_t uid, ************************************************************************/ -/** - * Assigns an error name and message corresponding to a Win32 error - * code to a DBusError. Does nothing if error is #NULL. - * - * @param error the error. - * @param code the Win32 error code - */ -void -_dbus_win_set_error_from_win_error (DBusError *error, - int code) -{ - char *msg; - - /* As we want the English message, use the A API */ - FormatMessageA (FORMAT_MESSAGE_ALLOCATE_BUFFER | - FORMAT_MESSAGE_IGNORE_INSERTS | - FORMAT_MESSAGE_FROM_SYSTEM, - NULL, code, MAKELANGID (LANG_ENGLISH, SUBLANG_ENGLISH_US), - (LPTSTR) &msg, 0, NULL); - if (msg) - { - char *msg_copy; - - msg_copy = dbus_malloc (strlen (msg)); - strcpy (msg_copy, msg); - LocalFree (msg); - - dbus_set_error (error, "win32.error", "%s", msg_copy); - } - else - dbus_set_error (error, "win32.error", "Unknown error code %d or FormatMessage failed", code); -} - -void -_dbus_win_warn_win_error (const char *message, - int code) -{ - DBusError error; - - dbus_error_init (&error); - _dbus_win_set_error_from_win_error (&error, code); - _dbus_warn ("%s: %s\n", message, error.message); - dbus_error_free (&error); -} - -/** - * A wrapper around strerror() because some platforms - * may be lame and not have strerror(). - * - * @param error_number errno. - * @returns error description. - */ -const char* -_dbus_strerror (int error_number) -{ -#ifdef DBUS_WINCE - // TODO - return "unknown"; -#else - const char *msg; - - switch (error_number) - { - case WSAEINTR: - return "Interrupted function call"; - case WSAEACCES: - return "Permission denied"; - case WSAEFAULT: - return "Bad address"; - case WSAEINVAL: - return "Invalid argument"; - case WSAEMFILE: - return "Too many open files"; - case WSAEWOULDBLOCK: - return "Resource temporarily unavailable"; - case WSAEINPROGRESS: - return "Operation now in progress"; - case WSAEALREADY: - return "Operation already in progress"; - case WSAENOTSOCK: - return "Socket operation on nonsocket"; - case WSAEDESTADDRREQ: - return "Destination address required"; - case WSAEMSGSIZE: - return "Message too long"; - case WSAEPROTOTYPE: - return "Protocol wrong type for socket"; - case WSAENOPROTOOPT: - return "Bad protocol option"; - case WSAEPROTONOSUPPORT: - return "Protocol not supported"; - case WSAESOCKTNOSUPPORT: - return "Socket type not supported"; - case WSAEOPNOTSUPP: - return "Operation not supported"; - case WSAEPFNOSUPPORT: - return "Protocol family not supported"; - case WSAEAFNOSUPPORT: - return "Address family not supported by protocol family"; - case WSAEADDRINUSE: - return "Address already in use"; - case WSAEADDRNOTAVAIL: - return "Cannot assign requested address"; - case WSAENETDOWN: - return "Network is down"; - case WSAENETUNREACH: - return "Network is unreachable"; - case WSAENETRESET: - return "Network dropped connection on reset"; - case WSAECONNABORTED: - return "Software caused connection abort"; - case WSAECONNRESET: - return "Connection reset by peer"; - case WSAENOBUFS: - return "No buffer space available"; - case WSAEISCONN: - return "Socket is already connected"; - case WSAENOTCONN: - return "Socket is not connected"; - case WSAESHUTDOWN: - return "Cannot send after socket shutdown"; - case WSAETIMEDOUT: - return "Connection timed out"; - case WSAECONNREFUSED: - return "Connection refused"; - case WSAEHOSTDOWN: - return "Host is down"; - case WSAEHOSTUNREACH: - return "No route to host"; - case WSAEPROCLIM: - return "Too many processes"; - case WSAEDISCON: - return "Graceful shutdown in progress"; - case WSATYPE_NOT_FOUND: - return "Class type not found"; - case WSAHOST_NOT_FOUND: - return "Host not found"; - case WSATRY_AGAIN: - return "Nonauthoritative host not found"; - case WSANO_RECOVERY: - return "This is a nonrecoverable error"; - case WSANO_DATA: - return "Valid name, no data record of requested type"; - case WSA_INVALID_HANDLE: - return "Specified event object handle is invalid"; - case WSA_INVALID_PARAMETER: - return "One or more parameters are invalid"; - case WSA_IO_INCOMPLETE: - return "Overlapped I/O event object not in signaled state"; - case WSA_IO_PENDING: - return "Overlapped operations will complete later"; - case WSA_NOT_ENOUGH_MEMORY: - return "Insufficient memory available"; - case WSA_OPERATION_ABORTED: - return "Overlapped operation aborted"; -#ifdef WSAINVALIDPROCTABLE - - case WSAINVALIDPROCTABLE: - return "Invalid procedure table from service provider"; -#endif -#ifdef WSAINVALIDPROVIDER - - case WSAINVALIDPROVIDER: - return "Invalid service provider version number"; -#endif -#ifdef WSAPROVIDERFAILEDINIT - - case WSAPROVIDERFAILEDINIT: - return "Unable to initialize a service provider"; -#endif - - case WSASYSCALLFAILURE: - return "System call failure"; - } - msg = strerror (error_number); - if (msg == NULL) - msg = "unknown"; - - return msg; -#endif //DBUS_WINCE -} diff --git a/dbus/dbus-sysdeps-win.c b/dbus/dbus-sysdeps-win.c index d42d837..7d3c7f6 100644 --- a/dbus/dbus-sysdeps-win.c +++ b/dbus/dbus-sysdeps-win.c @@ -3435,6 +3435,203 @@ _dbus_append_keyring_directory_for_credentials (DBusString *directory, return FALSE; } +/** Checks if a file exists +* +* @param file full path to the file +* @returns #TRUE if file exists +*/ +dbus_bool_t +_dbus_file_exists (const char *file) +{ + DWORD attributes = GetFileAttributes (file); + + if (attributes != INVALID_FILE_ATTRIBUTES && GetLastError() != ERROR_PATH_NOT_FOUND) + return TRUE; + else + return FALSE; +} + +/** + * A wrapper around strerror() because some platforms + * may be lame and not have strerror(). + * + * @param error_number errno. + * @returns error description. + */ +const char* +_dbus_strerror (int error_number) +{ +#ifdef DBUS_WINCE + // TODO + return "unknown"; +#else + const char *msg; + + switch (error_number) + { + case WSAEINTR: + return "Interrupted function call"; + case WSAEACCES: + return "Permission denied"; + case WSAEFAULT: + return "Bad address"; + case WSAEINVAL: + return "Invalid argument"; + case WSAEMFILE: + return "Too many open files"; + case WSAEWOULDBLOCK: + return "Resource temporarily unavailable"; + case WSAEINPROGRESS: + return "Operation now in progress"; + case WSAEALREADY: + return "Operation already in progress"; + case WSAENOTSOCK: + return "Socket operation on nonsocket"; + case WSAEDESTADDRREQ: + return "Destination address required"; + case WSAEMSGSIZE: + return "Message too long"; + case WSAEPROTOTYPE: + return "Protocol wrong type for socket"; + case WSAENOPROTOOPT: + return "Bad protocol option"; + case WSAEPROTONOSUPPORT: + return "Protocol not supported"; + case WSAESOCKTNOSUPPORT: + return "Socket type not supported"; + case WSAEOPNOTSUPP: + return "Operation not supported"; + case WSAEPFNOSUPPORT: + return "Protocol family not supported"; + case WSAEAFNOSUPPORT: + return "Address family not supported by protocol family"; + case WSAEADDRINUSE: + return "Address already in use"; + case WSAEADDRNOTAVAIL: + return "Cannot assign requested address"; + case WSAENETDOWN: + return "Network is down"; + case WSAENETUNREACH: + return "Network is unreachable"; + case WSAENETRESET: + return "Network dropped connection on reset"; + case WSAECONNABORTED: + return "Software caused connection abort"; + case WSAECONNRESET: + return "Connection reset by peer"; + case WSAENOBUFS: + return "No buffer space available"; + case WSAEISCONN: + return "Socket is already connected"; + case WSAENOTCONN: + return "Socket is not connected"; + case WSAESHUTDOWN: + return "Cannot send after socket shutdown"; + case WSAETIMEDOUT: + return "Connection timed out"; + case WSAECONNREFUSED: + return "Connection refused"; + case WSAEHOSTDOWN: + return "Host is down"; + case WSAEHOSTUNREACH: + return "No route to host"; + case WSAEPROCLIM: + return "Too many processes"; + case WSAEDISCON: + return "Graceful shutdown in progress"; + case WSATYPE_NOT_FOUND: + return "Class type not found"; + case WSAHOST_NOT_FOUND: + return "Host not found"; + case WSATRY_AGAIN: + return "Nonauthoritative host not found"; + case WSANO_RECOVERY: + return "This is a nonrecoverable error"; + case WSANO_DATA: + return "Valid name, no data record of requested type"; + case WSA_INVALID_HANDLE: + return "Specified event object handle is invalid"; + case WSA_INVALID_PARAMETER: + return "One or more parameters are invalid"; + case WSA_IO_INCOMPLETE: + return "Overlapped I/O event object not in signaled state"; + case WSA_IO_PENDING: + return "Overlapped operations will complete later"; + case WSA_NOT_ENOUGH_MEMORY: + return "Insufficient memory available"; + case WSA_OPERATION_ABORTED: + return "Overlapped operation aborted"; +#ifdef WSAINVALIDPROCTABLE + + case WSAINVALIDPROCTABLE: + return "Invalid procedure table from service provider"; +#endif +#ifdef WSAINVALIDPROVIDER + + case WSAINVALIDPROVIDER: + return "Invalid service provider version number"; +#endif +#ifdef WSAPROVIDERFAILEDINIT + + case WSAPROVIDERFAILEDINIT: + return "Unable to initialize a service provider"; +#endif + + case WSASYSCALLFAILURE: + return "System call failure"; + } + msg = strerror (error_number); + if (msg == NULL) + msg = "unknown"; + + return msg; +#endif //DBUS_WINCE +} + +/** + * Assigns an error name and message corresponding to a Win32 error + * code to a DBusError. Does nothing if error is #NULL. + * + * @param error the error. + * @param code the Win32 error code + */ +void +_dbus_win_set_error_from_win_error (DBusError *error, + int code) +{ + char *msg; + + /* As we want the English message, use the A API */ + FormatMessageA (FORMAT_MESSAGE_ALLOCATE_BUFFER | + FORMAT_MESSAGE_IGNORE_INSERTS | + FORMAT_MESSAGE_FROM_SYSTEM, + NULL, code, MAKELANGID (LANG_ENGLISH, SUBLANG_ENGLISH_US), + (LPTSTR) &msg, 0, NULL); + if (msg) + { + char *msg_copy; + + msg_copy = dbus_malloc (strlen (msg)); + strcpy (msg_copy, msg); + LocalFree (msg); + + dbus_set_error (error, "win32.error", "%s", msg_copy); + } + else + dbus_set_error (error, "win32.error", "Unknown error code %d or FormatMessage failed", code); +} + +void +_dbus_win_warn_win_error (const char *message, + int code) +{ + DBusError error; + + dbus_error_init (&error); + _dbus_win_set_error_from_win_error (&error, code); + _dbus_warn ("%s: %s\n", message, error.message); + dbus_error_free (&error); +} /** @} end of sysdeps-win */ /* tests in dbus-sysdeps-util.c */ -- 1.6.4.msysgit.0 From 5e0a4f767db314dcaffdc2b1166640a91b3757d7 Mon Sep 17 00:00:00 2001 From: Frank Osterfeld Date: Thu, 11 Jun 2009 10:53:24 +0200 Subject: [PATCH 082/114] -util.c doesn't belong into the lib (cherry picked from commit 6191f6dda62e43765d5f48d677f7a2349e616a63) --- cmake/dbus/CMakeLists.txt | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/cmake/dbus/CMakeLists.txt b/cmake/dbus/CMakeLists.txt index b88d588..ce113a2 100644 --- a/cmake/dbus/CMakeLists.txt +++ b/cmake/dbus/CMakeLists.txt @@ -132,7 +132,6 @@ set (DBUS_SHARED_SOURCES ${DBUS_DIR}/dbus-mempool.c ${DBUS_DIR}/dbus-string.c ${DBUS_DIR}/dbus-sysdeps.c - ${DBUS_DIR}/dbus-sysdeps-util.c ) set (DBUS_SHARED_HEADERS @@ -163,6 +162,7 @@ set (DBUS_UTIL_SOURCES ${DBUS_DIR}/dbus-message-util.c ${DBUS_DIR}/dbus-shell.c ${DBUS_DIR}/dbus-string-util.c + ${DBUS_DIR}/dbus-sysdeps-util.c ) if (DBUS_BUILD_TESTS) -- 1.6.4.msysgit.0 From 03055aa8343a0ebf7dadc1d9980068028f56fb8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Date: Thu, 11 Jun 2009 21:06:19 +1000 Subject: [PATCH 083/114] bus/Makefile.am: make dbus-daemon and friends bin_PROGRAMS on Windows On Linux, dbus-daemon and dbus-daemon-launch-helper are treated specially because they need permission adjustment. On Windows, all executables are stubs, created by libtool. The real executables are in .libs. We need to use libtool to install them properly. So let's make them bin_PROGRAMS on Windows. (cherry picked from commit 7fb35992d67433ac3ba82e9e2e786e123323456d) --- bus/Makefile.am | 21 ++++++++++++++------- 1 files changed, 14 insertions(+), 7 deletions(-) diff --git a/bus/Makefile.am b/bus/Makefile.am index 66fb103..b1ee36c 100644 --- a/bus/Makefile.am +++ b/bus/Makefile.am @@ -139,9 +139,13 @@ bus_test_launch_helper_CPPFLAGS= \ extra_tests= extra_noinst_programs= +extra_inst_programs= if DBUS_UNIX extra_tests+=bus-test-launch-helper -extra_noinst_programs+=dbus-daemon-launch-helper dbus-daemon-launch-helper-test +extra_noinst_programs+=dbus-daemon-launch-helper dbus-daemon-launch-helper-test dbus-daemon +endif +if DBUS_WIN +extra_inst_programs+=dbus-daemon endif ## note that TESTS has special meaning (stuff to use in make check) @@ -156,7 +160,8 @@ endif ## we use noinst_PROGRAMS not check_PROGRAMS so that we build ## even when not doing "make check" -noinst_PROGRAMS=$(TESTS) dbus-daemon $(extra_noinst_programs) +noinst_PROGRAMS=$(TESTS) $(extra_noinst_programs) +bin_PROGRAMS=$(extra_inst_programs) bus_test_system_SOURCES= \ $(XML_SOURCES) \ @@ -187,16 +192,17 @@ uninstall-hook: rm -f $(DESTDIR)$(libexecdir)/dbus-daemon-launch-helper$(EXEEXT) install-data-hook: - if test '!' -d $(DESTDIR)$(DBUS_DAEMONDIR); then \ - $(mkinstalldirs) $(DESTDIR)$(DBUS_DAEMONDIR); \ - chmod 755 $(DESTDIR)$(DBUS_DAEMONDIR); \ - fi - $(INSTALL_PROGRAM) dbus-daemon$(EXEEXT) $(DESTDIR)$(DBUS_DAEMONDIR) $(mkinstalldirs) $(DESTDIR)$(localstatedir)/run/dbus $(mkinstalldirs) $(DESTDIR)$(configdir)/system.d $(mkinstalldirs) $(DESTDIR)$(configdir)/session.d $(mkinstalldirs) $(DESTDIR)$(datadir)/dbus-1/services $(mkinstalldirs) $(DESTDIR)$(datadir)/dbus-1/system-services +if DBUS_UNIX + if test '!' -d $(DESTDIR)$(DBUS_DAEMONDIR); then \ + $(mkinstalldirs) $(DESTDIR)$(DBUS_DAEMONDIR); \ + chmod 755 $(DESTDIR)$(DBUS_DAEMONDIR); \ + fi + $(INSTALL_PROGRAM) dbus-daemon$(EXEEXT) $(DESTDIR)$(DBUS_DAEMONDIR) $(mkinstalldirs) $(DESTDIR)$(libexecdir)/dbus-1 if test -f dbus-daemin-launch-helper$(EXEEXT) ; then \ $(INSTALL_PROGRAM) dbus-daemon-launch-helper$(EXEEXT) $(DESTDIR)$(libexecdir); \ @@ -208,6 +214,7 @@ install-data-hook: echo "You'll need to manually set permissions to root:$(DBUS_USER) and permissions 4750"; \ fi \ fi +endif #### Init scripts fun SCRIPT_IN_FILES=messagebus.in \ -- 1.6.4.msysgit.0 From d7b7502cfe1db64f9599161762ea2313441ddf0d Mon Sep 17 00:00:00 2001 From: Frank Osterfeld Date: Wed, 21 Oct 2009 19:52:49 +0300 Subject: [PATCH 084/114] The current state of the nonce-tcp implementation Merged and cleaned up patch from my [Frank Osterfeld's] local work branch. Cherry-picked from commit e2801eca57b2d9e09afd662ed5ef6fc83be73afc and edited by tml@iki.fi to make it apply, and fixing whitespace issues. --- cmake/CMakeLists.txt | 4 +- cmake/dbus/CMakeLists.txt | 1 + dbus/Makefile.am | 1 + dbus/dbus-nonce.c | 239 ++++++++++++++++++++++++++++++++++++++++++ dbus/dbus-nonce.h | 55 ++++++++++ dbus/dbus-server-socket.c | 66 ++++++++++-- dbus/dbus-server-socket.h | 6 +- dbus/dbus-server-unix.c | 2 +- dbus/dbus-server-win.c | 39 ++++++- dbus/dbus-sysdeps-unix.c | 60 ++++++++++- dbus/dbus-sysdeps-win.c | 46 ++++++++- dbus/dbus-sysdeps-win.h | 8 +- dbus/dbus-sysdeps.h | 20 ++++ dbus/dbus-transport-socket.c | 31 +++++- dbus/dbus-transport-socket.h | 1 + dbus/dbus-transport-win.c | 31 ++++++ 16 files changed, 577 insertions(+), 33 deletions(-) create mode 100644 dbus/dbus-nonce.c create mode 100644 dbus/dbus-nonce.h diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 0240c42..10ff6ce 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -446,8 +446,8 @@ set (DBUS_USER ) if (WIN32) - set (DBUS_SESSION_BUS_DEFAULT_ADDRESS "tcp:host=localhost,port=0") - set (DBUS_SYSTEM_BUS_DEFAULT_ADDRESS "tcp:host=localhost,port=0") + set (DBUS_SESSION_BUS_DEFAULT_ADDRESS "nonce-tcp:host=localhost,port=0") + set (DBUS_SYSTEM_BUS_DEFAULT_ADDRESS "nonce-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 diff --git a/cmake/dbus/CMakeLists.txt b/cmake/dbus/CMakeLists.txt index ce113a2..c1c2251 100644 --- a/cmake/dbus/CMakeLists.txt +++ b/cmake/dbus/CMakeLists.txt @@ -46,6 +46,7 @@ set (DBUS_LIB_SOURCES ${DBUS_DIR}/dbus-marshal-validate.c ${DBUS_DIR}/dbus-message.c ${DBUS_DIR}/dbus-misc.c + ${DBUS_DIR}/dbus-nonce.c ${DBUS_DIR}/dbus-object-tree.c ${DBUS_DIR}/dbus-pending-call.c ${DBUS_DIR}/dbus-resources.c diff --git a/dbus/Makefile.am b/dbus/Makefile.am index 5f8d703..c85556a 100644 --- a/dbus/Makefile.am +++ b/dbus/Makefile.am @@ -138,6 +138,7 @@ DBUS_LIB_SOURCES= \ dbus-message-internal.h \ dbus-message-private.h \ dbus-misc.c \ + dbus-nonce.c \ dbus-object-tree.c \ dbus-object-tree.h \ dbus-pending-call.c \ diff --git a/dbus/dbus-nonce.c b/dbus/dbus-nonce.c new file mode 100644 index 0000000..e8de059 --- /dev/null +++ b/dbus/dbus-nonce.c @@ -0,0 +1,239 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ +/* dbus-nonce.c Nonce handling functions used by nonce-tcp (internal to D-Bus implementation) + * + * Copyright (C) 2009 Klaralvdalens Datakonsult AB, a KDAB Group company, info@kdab.net + * + * 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 + * + */ + +// major sections of this file are modified code from libassuan, (C) FSF +#include "dbus-nonce.h" +#include "dbus-internals.h" +#include "dbus-protocol.h" +#include "dbus-sysdeps.h" + +#include + +#ifdef HAVE_ERRNO_H +#include +#endif + +#ifndef ENOFILE +# define ENOFILE ENOENT +#endif + +dbus_bool_t +_dbus_check_nonce (int fd, const DBusString *nonce) +{ + DBusString buffer; + DBusString p; + size_t nleft; + dbus_bool_t result; + int n; + + nleft = 16; + + _dbus_string_init (&buffer); + _dbus_string_init (&p); +//PENDING(kdab) replace errno by DBusError + while (nleft) + { + n = _dbus_read_socket (fd, &p, nleft); + if (n == -1 && _dbus_get_is_errno_eintr()) + ; + else if (n == -1 && _dbus_get_is_errno_eagain_or_ewouldblock()) + _dbus_sleep_milliseconds (100); + else if (n==-1) + { + _dbus_string_free (&p); + _dbus_string_free (&buffer); + return FALSE; + } + else if (!n) + { + _dbus_string_free (&p); + _dbus_string_free (&buffer); + errno = EIO; + return FALSE; + } + else + { + _dbus_string_append_len(&buffer, _dbus_string_get_const_data (&p), n); + nleft -= n; + } + } + + result = _dbus_string_equal_len (&buffer, nonce, 16); + if (!result) + errno = EACCES; + + _dbus_string_free (&p); + _dbus_string_free (&buffer); + + return result; +} + +//PENDING(kdab) document +dbus_bool_t +_dbus_read_nonce (const DBusString *fname, DBusString *nonce) +{ + //PENDING(kdab) replace errno by DBusError + FILE *fp; + char buffer[17]; + buffer[sizeof buffer - 1] = '\0'; + size_t nread; + _dbus_verbose ("reading nonce from file: %s\n", _dbus_string_get_const_data (fname)); + + + fp = fopen (_dbus_string_get_const_data (fname), "rb"); + if (!fp) + return FALSE; + nread = fread (buffer, 1, sizeof buffer - 1, fp); + fclose (fp); + if (!nread) + { + errno = ENOFILE; + return FALSE; + } + + if (!_dbus_string_append_len (nonce, buffer, sizeof buffer - 1 )) + { + errno = ENOMEM; + return FALSE; + } + return TRUE; +} + +int +_dbus_accept_with_nonce (int listen_fd, const DBusString *nonce) +{ + _dbus_assert (nonce != NULL); + int fd; + fd = _dbus_accept (listen_fd); + if (_dbus_socket_is_invalid (fd)) + return fd; + if (_dbus_check_nonce(fd, nonce) != TRUE) { + _dbus_verbose ("nonce check failed. Closing socket.\n"); + _dbus_close_socket(fd, NULL); + return -1; + } + + return fd; +} + +int +_dbus_accept_with_noncefile (int listen_fd, const DBusString *noncefile) +{ + _dbus_assert (noncefile != NULL); + DBusString nonce; + _dbus_string_init (&nonce); + //PENDING(kdab): set better errors + if (_dbus_read_nonce (noncefile, &nonce) != TRUE) + return -1; + return _dbus_accept_with_nonce (listen_fd, &nonce); +} + +dbus_bool_t +_dbus_generate_noncefilename (DBusString *buf) +{ + dbus_bool_t ret; + DBusString randomStr; + ret = _dbus_string_init (&randomStr); + if (!ret) + return FALSE; + ret = _dbus_generate_random_ascii (&randomStr, 8); + if (!ret) + goto oom; + if (!_dbus_string_append (buf, _dbus_get_tmpdir()) + || !_dbus_string_append (buf, DBUS_DIR_SEPARATOR "dbus_nonce-") + || !_dbus_string_append (buf, _dbus_string_get_const_data (&randomStr)) ) + goto oom; + + _dbus_string_free (&randomStr); + return TRUE; +oom: + _dbus_string_free (&randomStr); + return FALSE; +} + +int +_dbus_generate_and_write_nonce (const DBusString *filename) +{ + DBusString nonce; + int ret; + + _dbus_string_init (&nonce); + + if (!_dbus_generate_random_bytes (&nonce, 16)) + return -1; + + ret = _dbus_write_to_file (_dbus_string_get_const_data (filename), _dbus_string_get_const_data (&nonce), 16); + + _dbus_string_free (&nonce); + + return ret; +} + +dbus_bool_t +_dbus_send_nonce(int fd, const DBusString *noncefile, DBusError *error) +{ + dbus_bool_t read_result; + int send_result; + size_t sendLen; + DBusString nonce; + + _DBUS_ASSERT_ERROR_IS_CLEAR (error); + + if (_dbus_string_get_length (noncefile) == 0) + return FALSE; + + if ( !_dbus_string_init (&nonce) ) + { + dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL); + return FALSE; + } + + read_result = _dbus_read_nonce (noncefile, &nonce); + + if (!read_result) + { + dbus_set_error (error, + _dbus_error_from_errno (errno), + "Could not read nonce from file %s (%s)", + _dbus_string_get_const_data (noncefile), _dbus_strerror(errno)); + _dbus_string_free (&nonce); + return FALSE; + } + + send_result = _dbus_write_socket (fd, &nonce, 0, _dbus_string_get_length (&nonce)); + + _dbus_string_free (&nonce); + + if (send_result == -1) + { + dbus_set_error (error, + _dbus_error_from_errno (errno), + "Failed to send nonce (fd=%d): %s", + fd, _dbus_strerror(errno)); + return FALSE; + } + + return TRUE; +} + +/** @} end of nonce */ diff --git a/dbus/dbus-nonce.h b/dbus/dbus-nonce.h new file mode 100644 index 0000000..441a59e --- /dev/null +++ b/dbus/dbus-nonce.h @@ -0,0 +1,55 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ +/* dbus-nonce.h Nonce handling functions used by nonce-tcp (internal to D-Bus implementation) + * + * Copyright (C) 2009 Klaralvdalens Datakonsult AB, a KDAB Group company, info@kdab.net + * + * 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 + * + */ +#ifndef DBUS_NONCE_H +#define DBUS_NONCE_H + +#include +#include +#include +#include + +DBUS_BEGIN_DECLS + +dbus_bool_t _dbus_check_nonce (int fd, + const DBusString *nonce); + +dbus_bool_t _dbus_read_nonce (const DBusString *fname, + DBusString *nonce); + +int _dbus_accept_with_nonce (int listen_fd, + const DBusString *nonce); + +int _dbus_accept_with_noncefile (int listen_fd, + const DBusString *noncefile); + +dbus_bool_t _dbus_generate_noncefilename (DBusString *buf); + +int _dbus_generate_and_write_nonce (const DBusString *filename); + +dbus_bool_t _dbus_send_nonce (int fd, + const DBusString *noncefile, + DBusError *error); + +DBUS_END_DECLS + +#endif /* DBUS_NONCE_H */ diff --git a/dbus/dbus-server-socket.c b/dbus/dbus-server-socket.c index 132fdb7..2c9d81c 100644 --- a/dbus/dbus-server-socket.c +++ b/dbus/dbus-server-socket.c @@ -51,6 +51,7 @@ struct DBusServerSocket int *fds; /**< File descriptor or -1 if disconnected. */ DBusWatch **watch; /**< File descriptor watch. */ char *socket_name; /**< Name of domain socket, to unlink if appropriate */ + DBusString noncefile; /**< Nonce file used to authenticate clients */ }; static void @@ -71,6 +72,11 @@ socket_finalize (DBusServer *server) dbus_free (socket_server->fds); dbus_free (socket_server->watch); dbus_free (socket_server->socket_name); + if (_dbus_string_get_length(&socket_server->noncefile) > 0) + { + _dbus_delete_file(&socket_server->noncefile, NULL); + } + _dbus_string_free (&socket_server->noncefile); dbus_free (server); } @@ -82,8 +88,10 @@ handle_new_client_fd_and_unlock (DBusServer *server, DBusConnection *connection; DBusTransport *transport; DBusNewConnectionFunction new_connection_function; + DBusServerSocket* socket_server; void *new_connection_data; + socket_server = (DBusServerSocket*)server; _dbus_verbose ("Creating new client connection with fd %d\n", client_fd); HAVE_LOCK_CHECK (server); @@ -179,7 +187,7 @@ socket_handle_watch (DBusWatch *watch, listen_fd = dbus_watch_get_socket (watch); - client_fd = _dbus_accept (listen_fd); + client_fd = _dbus_accept_with_noncefile (listen_fd, &socket_server->noncefile); if (client_fd < 0) { @@ -257,13 +265,15 @@ static const DBusServerVTable socket_vtable = { * @param fds list of file descriptors. * @param n_fds number of file descriptors * @param address the server's address + * @param noncefile the noncefile to use, NULL if without nonce * @returns the new server, or #NULL if no memory. * */ DBusServer* _dbus_server_new_for_socket (int *fds, int n_fds, - const DBusString *address) + const DBusString *address, + const DBusString *noncefile) { DBusServerSocket *socket_server; DBusServer *server; @@ -302,6 +312,12 @@ _dbus_server_new_for_socket (int *fds, &socket_vtable, address)) goto failed_2; + if (!_dbus_string_init (&socket_server->noncefile)) + goto failed_2; + + if (noncefile && !_dbus_string_copy (noncefile, 0, &socket_server->noncefile, 0)) + goto failed_3; + server = (DBusServer*)socket_server; SERVER_LOCK (server); @@ -326,6 +342,8 @@ _dbus_server_new_for_socket (int *fds, return (DBusServer*) socket_server; + failed_3: + _dbus_string_free (&socket_server->noncefile); failed_2: for (i = 0 ; i < n_fds ; i++) { @@ -368,7 +386,8 @@ _dbus_server_new_for_tcp_socket (const char *host, const char *bind, const char *port, const char *family, - DBusError *error) + DBusError *error, + dbus_bool_t use_nonce) { DBusServer *server; int *listen_fds = NULL; @@ -376,6 +395,7 @@ _dbus_server_new_for_tcp_socket (const char *host, DBusString address; DBusString host_str; DBusString port_str; + DBusString noncefile; _DBUS_ASSERT_ERROR_IS_CLEAR (error); @@ -412,7 +432,7 @@ _dbus_server_new_for_tcp_socket (const char *host, } _dbus_string_init_const (&host_str, host); - if (!_dbus_string_append (&address, "tcp:host=") || + if (!_dbus_string_append (&address, use_nonce ? "nonce-tcp:host=" : "tcp:host=") || !_dbus_address_append_escaped (&address, &host_str) || !_dbus_string_append (&address, ",port=") || !_dbus_string_append (&address, _dbus_string_get_const_data(&port_str))) @@ -428,7 +448,36 @@ _dbus_server_new_for_tcp_socket (const char *host, goto failed_2; } - server = _dbus_server_new_for_socket (listen_fds, nlisten_fds, &address); + if (!_dbus_string_init (&noncefile)) + { + dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL); + goto failed_2; + } + + if (use_nonce) + { + if (!_dbus_generate_noncefilename (&noncefile)) + { + dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL); + goto failed_2; + } + + if (_dbus_string_get_length(&noncefile) == 0 || + !_dbus_string_append (&address, ",noncefile=") || + !_dbus_address_append_escaped (&address, &noncefile)) + { + dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL); + goto failed_2; + } + + if (_dbus_generate_and_write_nonce (&noncefile) != 0) + { + dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL); + goto failed_2; + } + } + + server = _dbus_server_new_for_socket (listen_fds, nlisten_fds, &address, &noncefile); if (server == NULL) { dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL); @@ -445,6 +494,7 @@ _dbus_server_new_for_tcp_socket (const char *host, for (i = 0 ; i < nlisten_fds ; i++) _dbus_close_socket (listen_fds[i], NULL); dbus_free(listen_fds); + _dbus_string_free (&noncefile); failed_1: _dbus_string_free (&port_str); @@ -457,7 +507,7 @@ _dbus_server_new_for_tcp_socket (const char *host, /** * Tries to interpret the address entry for various socket-related - * addresses (well, currently only tcp). + * addresses (well, currently only tcp and nonce-tcp). * * Sets error if the result is not OK. * @@ -478,7 +528,7 @@ _dbus_server_listen_socket (DBusAddressEntry *entry, method = dbus_address_entry_get_method (entry); - if (strcmp (method, "tcp") == 0) + if (strcmp (method, "tcp") == 0 || strcmp (method, "nonce-tcp") == 0) { const char *host; const char *port; @@ -491,7 +541,7 @@ _dbus_server_listen_socket (DBusAddressEntry *entry, family = dbus_address_entry_get_value (entry, "family"); *server_p = _dbus_server_new_for_tcp_socket (host, bind, port, - family, error); + family, error, strcmp (method, "nonce-tcp") == 0 ? TRUE : FALSE); if (*server_p) { diff --git a/dbus/dbus-server-socket.h b/dbus/dbus-server-socket.h index 5918658..891f56f 100644 --- a/dbus/dbus-server-socket.h +++ b/dbus/dbus-server-socket.h @@ -30,12 +30,14 @@ DBUS_BEGIN_DECLS DBusServer* _dbus_server_new_for_socket (int *fds, int n_fds, - const DBusString *address); + const DBusString *address, + const DBusString *noncefile); DBusServer* _dbus_server_new_for_tcp_socket (const char *host, const char *bind, const char *port, const char *family, - DBusError *error); + DBusError *error, + dbus_bool_t use_nonce); DBusServerListenResult _dbus_server_listen_socket (DBusAddressEntry *entry, DBusServer **server_p, DBusError *error); diff --git a/dbus/dbus-server-unix.c b/dbus/dbus-server-unix.c index 07800c8..597d0f8 100644 --- a/dbus/dbus-server-unix.c +++ b/dbus/dbus-server-unix.c @@ -208,7 +208,7 @@ _dbus_server_new_for_domain_socket (const char *path, goto failed_1; } - server = _dbus_server_new_for_socket (&listen_fd, 1, &address); + server = _dbus_server_new_for_socket (&listen_fd, 1, &address, 0); if (server == NULL) { dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL); diff --git a/dbus/dbus-server-win.c b/dbus/dbus-server-win.c index d6acc1e..ca37669 100644 --- a/dbus/dbus-server-win.c +++ b/dbus/dbus-server-win.c @@ -25,8 +25,6 @@ #include "dbus-internals.h" #include "dbus-server-win.h" #include "dbus-server-socket.h" -#include "dbus-connection-internal.h" -#include "dbus-sysdeps-win.h" /** * @defgroup DBusServerWin DBusServer implementations for Windows @@ -52,13 +50,44 @@ _dbus_server_listen_platform_specific (DBusAddressEntry *entry, DBusServer **server_p, DBusError *error) { - /* don't handle any method yet, return NULL with the error unset, - ** for a sample implementation see dbus-server-unix.c - */ + const char *method; + *server_p = NULL; + + method = dbus_address_entry_get_method (entry); + + if (strcmp (method, "nonce-tcp") == 0) + { + const char *host; + const char *port; + const char *bind; + const char *family; + + host = dbus_address_entry_get_value (entry, "host"); + bind = dbus_address_entry_get_value (entry, "bind"); + port = dbus_address_entry_get_value (entry, "port"); + family = dbus_address_entry_get_value (entry, "family"); + + *server_p = _dbus_server_new_for_tcp_socket (host, bind, port, + family, error, TRUE); + + if (*server_p) + { + _DBUS_ASSERT_ERROR_IS_CLEAR(error); + return DBUS_SERVER_LISTEN_OK; + } + else + { + _DBUS_ASSERT_ERROR_IS_SET(error); + return DBUS_SERVER_LISTEN_DID_NOT_CONNECT; + } + } + else + { _DBUS_ASSERT_ERROR_IS_CLEAR(error); return DBUS_SERVER_LISTEN_NOT_HANDLED; } +} /** @} */ diff --git a/dbus/dbus-sysdeps-unix.c b/dbus/dbus-sysdeps-unix.c index e60e614..fc51709 100644 --- a/dbus/dbus-sysdeps-unix.c +++ b/dbus/dbus-sysdeps-unix.c @@ -577,6 +577,11 @@ _dbus_write_socket_two (int fd, #endif } +dbus_bool_t +_dbus_socket_is_invalid (int fd) +{ + return fd < 0 ? TRUE : FALSE; +} /** * Thin wrapper around the read() system call that appends @@ -1082,6 +1087,16 @@ _dbus_connect_tcp_socket (const char *host, const char *family, DBusError *error) { + return _dbus_connect_tcp_socket_with_nonce (host, port, family, (const char*)NULL, error); +} + +int +_dbus_connect_tcp_socket_with_nonce (const char *host, + const char *port, + const char *family, + const char *noncefile, + DBusError *error) +{ int saved_errno = 0; int fd = -1, res; struct addrinfo hints; @@ -1159,12 +1174,24 @@ _dbus_connect_tcp_socket (const char *host, return -1; } + if (noncefile != NULL) + { + DBusString noncefileStr; + dbus_bool_t ret; + _dbus_string_init_const (&noncefileStr, noncefile); + ret = _dbus_send_nonce (fd, &noncefileStr, error); + _dbus_string_free (&noncefileStr); - if (!_dbus_set_fd_nonblocking (fd, error)) + if (!ret) { _dbus_close (fd, NULL); - fd = -1; + return -1; + } + } + if (!_dbus_set_fd_nonblocking (fd, error)) + { + _dbus_close (fd, NULL); return -1; } @@ -3881,6 +3908,35 @@ _dbus_get_is_errno_eagain_or_ewouldblock (void) return errno == EAGAIN || errno == EWOULDBLOCK; } +int +_dbus_write_to_file (const char* filename, const char* buf, size_t len) +{ + int filefd; + FILE *fp; + size_t written; + + filefd = open (filename, + (O_WRONLY|O_CREAT|O_EXCL|O_BINARY), + (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP)); + if (filefd == -1) + { + return -1; + } + fp = fdopen (filefd, "wb"); + if (!fp) + { + int save_e = errno; + close (filefd); + errno = save_e; + return -1; + } + + written = fwrite (buf, len, 1, fp); + fclose (fp); + + return written == 1 ? 0 : -1; +} + /** * Checks whether file descriptors may be passed via the socket * diff --git a/dbus/dbus-sysdeps-win.c b/dbus/dbus-sysdeps-win.c index 7d3c7f6..f34e57f 100644 --- a/dbus/dbus-sysdeps-win.c +++ b/dbus/dbus-sysdeps-win.c @@ -180,6 +180,7 @@ _dbus_pipe_close (DBusPipe *pipe, * @param count the amount of data to read * @returns the number of bytes read or -1 */ + int _dbus_read_socket (int fd, DBusString *buffer, @@ -209,7 +210,7 @@ _dbus_read_socket (int fd, if (bytes_read == SOCKET_ERROR) { DBUS_SOCKET_SET_ERRNO(); - _dbus_verbose ("recv: failed: %s\n", _dbus_strerror (errno)); + _dbus_verbose ("recv: failed: %s (%d)\n", _dbus_strerror (errno), errno); bytes_read = -1; } else @@ -466,6 +467,12 @@ _dbus_write_socket_two (int fd, return bytes_written; } +dbus_bool_t +_dbus_socket_is_invalid (int fd) +{ + return fd == INVALID_SOCKET ? TRUE : FALSE; +} + #if 0 /** @@ -1344,6 +1351,16 @@ _dbus_connect_tcp_socket (const char *host, const char *family, DBusError *error) { + return _dbus_connect_tcp_socket_with_nonce (host, port, family, (const char*)NULL, error); +} + +int +_dbus_connect_tcp_socket_with_nonce (const char *host, + const char *port, + const char *family, + const char *noncefile, + DBusError *error) +{ int fd = -1, res; struct addrinfo hints; struct addrinfo *ai, *tmp; @@ -1414,7 +1431,7 @@ _dbus_connect_tcp_socket (const char *host, } _DBUS_ASSERT_ERROR_IS_CLEAR(error); - if (connect (fd, (struct sockaddr*) tmp->ai_addr, tmp->ai_addrlen) < 0) + if (connect (fd, (struct sockaddr*) tmp->ai_addr, tmp->ai_addrlen) != 0) { closesocket(fd); fd = -1; @@ -1435,12 +1452,32 @@ _dbus_connect_tcp_socket (const char *host, return -1; } + if ( noncefile != NULL ) + { + DBusString noncefileStr; + dbus_bool_t ret; + if (!_dbus_string_init (&noncefileStr) || + !_dbus_string_append(&noncefileStr, noncefile)) + { + closesocket (fd); + dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL); + return -1; + } + + ret = _dbus_send_nonce (fd, &noncefileStr, error); - if (!_dbus_set_fd_nonblocking (fd, error)) + _dbus_string_free (&noncefileStr); + + if (!ret) { closesocket (fd); - fd = -1; + return -1; + } + } + if (!_dbus_set_fd_nonblocking (fd, error) ) + { + closesocket (fd); return -1; } @@ -3632,6 +3669,7 @@ _dbus_win_warn_win_error (const char *message, _dbus_warn ("%s: %s\n", message, error.message); dbus_error_free (&error); } + /** @} end of sysdeps-win */ /* tests in dbus-sysdeps-util.c */ diff --git a/dbus/dbus-sysdeps-win.h b/dbus/dbus-sysdeps-win.h index e6ebfc6..ed118b0 100644 --- a/dbus/dbus-sysdeps-win.h +++ b/dbus/dbus-sysdeps-win.h @@ -91,10 +91,12 @@ dbus_bool_t _dbus_file_exists (const char *filename); dbus_bool_t _dbus_get_config_file_name(DBusString *config_file, char *s); - +int _dbus_connect_tcp_socket_with_nonce (const char *host, + const char *port, + const char *family, + const char *noncefile, + DBusError *error); #endif /** @} end of sysdeps-win.h */ - - diff --git a/dbus/dbus-sysdeps.h b/dbus/dbus-sysdeps.h index 739a454..999aade 100644 --- a/dbus/dbus-sysdeps.h +++ b/dbus/dbus-sysdeps.h @@ -175,6 +175,8 @@ int _dbus_write_socket_with_unix_fds_two (int fd, const int *fds, int n_fds); +dbus_bool_t _dbus_socket_is_invalid (int fd); + int _dbus_connect_tcp_socket (const char *host, const char *port, const char *family, @@ -540,6 +542,24 @@ dbus_pid_t _dbus_getpid (void); void _dbus_flush_caches (void); +dbus_bool_t _dbus_generate_noncefilename (DBusString *buf); + +int _dbus_generate_and_write_nonce (const DBusString *filename); + +int _dbus_generate_nonce (char *buffer, size_t nbytes); + +dbus_bool_t _dbus_check_nonce (int fd, const DBusString *nonce); + +dbus_bool_t dbus_read_nonce (const DBusString *noncefile, DBusString *nonce); + +int _dbus_accept_with_nonce (int listen_fd, const DBusString *nonce); + +int _dbus_accept_with_noncefile (int listen_fd, const DBusString *noncefile); + +dbus_bool_t _dbus_send_nonce (int fd, const DBusString *noncefile, DBusError* error); + +int _dbus_write_to_file (const char *filename, const char *buf, size_t len); + /** @} */ DBUS_END_DECLS diff --git a/dbus/dbus-transport-socket.c b/dbus/dbus-transport-socket.c index 4b88af7..96a7eba 100644 --- a/dbus/dbus-transport-socket.c +++ b/dbus/dbus-transport-socket.c @@ -1297,6 +1297,7 @@ _dbus_transport_new_for_socket (int fd, * @param host the host to connect to * @param port the port to connect to * @param family the address family to connect to + * @param path to nonce file * @param error location to store reason for failure. * @returns a new transport, or #NULL on failure. */ @@ -1304,6 +1305,7 @@ DBusTransport* _dbus_transport_new_for_tcp_socket (const char *host, const char *port, const char *family, + const char *noncefile, DBusError *error) { int fd; @@ -1321,7 +1323,7 @@ _dbus_transport_new_for_tcp_socket (const char *host, if (host == NULL) host = "localhost"; - if (!_dbus_string_append (&address, "tcp:")) + if (!_dbus_string_append (&address, noncefile ? "nonce-tcp:" : "tcp:")) goto error; if (!_dbus_string_append (&address, "host=") || @@ -1337,7 +1339,12 @@ _dbus_transport_new_for_tcp_socket (const char *host, !_dbus_string_append (&address, family))) goto error; - fd = _dbus_connect_tcp_socket (host, port, family, error); + if (noncefile != NULL && + (!_dbus_string_append (&address, "noncefile=") || + !_dbus_string_append (&address, noncefile))) + goto error; + + fd = _dbus_connect_tcp_socket_with_nonce (host, port, family, noncefile, error); if (fd < 0) { _DBUS_ASSERT_ERROR_IS_SET (error); @@ -1381,26 +1388,38 @@ _dbus_transport_open_socket(DBusAddressEntry *entry, DBusError *error) { const char *method; + dbus_bool_t isTcp; + dbus_bool_t isNonceTcp; method = dbus_address_entry_get_method (entry); _dbus_assert (method != NULL); - if (strcmp (method, "tcp") == 0) + isTcp = strcmp (method, "tcp") == 0; + isNonceTcp = strcmp (method, "nonce-tcp") == 0; + + if (isTcp || isNonceTcp) { const char *host = dbus_address_entry_get_value (entry, "host"); const char *port = dbus_address_entry_get_value (entry, "port"); const char *family = dbus_address_entry_get_value (entry, "family"); + const char *noncefile = dbus_address_entry_get_value (entry, "noncefile"); + + if ((isNonceTcp == TRUE) != (noncefile != NULL)) { + _dbus_set_bad_address (error, method, "noncefile", NULL); + return DBUS_TRANSPORT_OPEN_BAD_ADDRESS; + } if (port == NULL) { - _dbus_set_bad_address (error, "tcp", "port", NULL); + _dbus_set_bad_address (error, method, "port", NULL); return DBUS_TRANSPORT_OPEN_BAD_ADDRESS; } - *transport_p = _dbus_transport_new_for_tcp_socket (host, port, family, error); + *transport_p = _dbus_transport_new_for_tcp_socket (host, port, family, noncefile, error); if (*transport_p == NULL) { - _DBUS_ASSERT_ERROR_IS_SET (error); + //PENDING(kdab) + //_DBUS_ASSERT_ERROR_IS_SET (error); return DBUS_TRANSPORT_OPEN_DID_NOT_CONNECT; } else diff --git a/dbus/dbus-transport-socket.h b/dbus/dbus-transport-socket.h index eb83326..8aefae3 100644 --- a/dbus/dbus-transport-socket.h +++ b/dbus/dbus-transport-socket.h @@ -33,6 +33,7 @@ DBusTransport* _dbus_transport_new_for_socket (int f DBusTransport* _dbus_transport_new_for_tcp_socket (const char *host, const char *port, const char *family, + const char *noncefile, DBusError *error); DBusTransportOpenResult _dbus_transport_open_socket (DBusAddressEntry *entry, DBusTransport **transport_p, diff --git a/dbus/dbus-transport-win.c b/dbus/dbus-transport-win.c index 6a99b07..cd28204 100644 --- a/dbus/dbus-transport-win.c +++ b/dbus/dbus-transport-win.c @@ -50,8 +50,39 @@ _dbus_transport_open_platform_specific (DBusAddressEntry *entry, DBusTransport **transport_p, DBusError *error) { + const char *method; + + method = dbus_address_entry_get_method (entry); + _dbus_assert (method != NULL); + + if (strcmp (method, "nonce-tcp") != 0) + { _DBUS_ASSERT_ERROR_IS_CLEAR (error); return DBUS_TRANSPORT_OPEN_NOT_HANDLED; } + const char *host = dbus_address_entry_get_value (entry, "host"); + const char *port = dbus_address_entry_get_value (entry, "port"); + const char *family = dbus_address_entry_get_value (entry, "family"); + const char *noncefile = dbus_address_entry_get_value (entry, "noncefile"); + + if (port == NULL) + { + _dbus_set_bad_address (error, "nonce-tcp", "port", NULL); + return DBUS_TRANSPORT_OPEN_BAD_ADDRESS; + } + + *transport_p = _dbus_transport_new_for_tcp_socket (host, port, family, noncefile, error); + if (*transport_p == NULL) + { + _DBUS_ASSERT_ERROR_IS_SET (error); + return DBUS_TRANSPORT_OPEN_DID_NOT_CONNECT; + } + else + { + _DBUS_ASSERT_ERROR_IS_CLEAR (error); + return DBUS_TRANSPORT_OPEN_OK; + } +} + /** @} */ -- 1.6.4.msysgit.0 From f3ed9764b232a418e703411080b4d5c68725418a Mon Sep 17 00:00:00 2001 From: Frank Osterfeld Date: Wed, 21 Oct 2009 20:04:01 +0300 Subject: [PATCH 085/114] Cleanup of nonce code Remove the write_file function and use the existing _dbus_string_save_to_file, improve error handling Cherry picked from commit 0f7b026d01be7e0fd444cdb56e5f9b7a5137a062 in the dbus4win repository. Edited to apply and fix whitespace issues by tml@iki.fi. --- dbus/dbus-nonce.c | 24 +++++++++++++++++------- dbus/dbus-nonce.h | 6 ++++-- dbus/dbus-server-socket.c | 3 +-- dbus/dbus-sysdeps-unix.c | 29 ----------------------------- dbus/dbus-sysdeps.h | 18 ------------------ 5 files changed, 22 insertions(+), 58 deletions(-) diff --git a/dbus/dbus-nonce.c b/dbus/dbus-nonce.c index e8de059..bca60e0 100644 --- a/dbus/dbus-nonce.c +++ b/dbus/dbus-nonce.c @@ -149,13 +149,16 @@ _dbus_accept_with_noncefile (int listen_fd, const DBusString *noncefile) } dbus_bool_t -_dbus_generate_noncefilename (DBusString *buf) +_dbus_generate_noncefilename (DBusString *buf, DBusError *error) { dbus_bool_t ret; DBusString randomStr; + + _DBUS_ASSERT_ERROR_IS_CLEAR (error); + ret = _dbus_string_init (&randomStr); if (!ret) - return FALSE; + goto oom; ret = _dbus_generate_random_ascii (&randomStr, 8); if (!ret) goto oom; @@ -167,22 +170,29 @@ _dbus_generate_noncefilename (DBusString *buf) _dbus_string_free (&randomStr); return TRUE; oom: + dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL); _dbus_string_free (&randomStr); return FALSE; } -int -_dbus_generate_and_write_nonce (const DBusString *filename) +dbus_bool_t +_dbus_generate_and_write_nonce (const DBusString *filename, DBusError *error) { DBusString nonce; - int ret; + dbus_bool_t ret; + + _DBUS_ASSERT_ERROR_IS_CLEAR (error); _dbus_string_init (&nonce); if (!_dbus_generate_random_bytes (&nonce, 16)) - return -1; + { + dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL); + _dbus_string_free (&nonce); + return FALSE; + } - ret = _dbus_write_to_file (_dbus_string_get_const_data (filename), _dbus_string_get_const_data (&nonce), 16); + ret = _dbus_string_save_to_file (filename, &nonce, error); _dbus_string_free (&nonce); diff --git a/dbus/dbus-nonce.h b/dbus/dbus-nonce.h index 441a59e..85cfd7f 100644 --- a/dbus/dbus-nonce.h +++ b/dbus/dbus-nonce.h @@ -42,9 +42,11 @@ int _dbus_accept_with_nonce (int listen_fd, int _dbus_accept_with_noncefile (int listen_fd, const DBusString *noncefile); -dbus_bool_t _dbus_generate_noncefilename (DBusString *buf); +dbus_bool_t _dbus_generate_noncefilename (DBusString *buf, + DBusError *error); -int _dbus_generate_and_write_nonce (const DBusString *filename); +dbus_bool_t _dbus_generate_and_write_nonce (const DBusString *filename, + DBusError *error); dbus_bool_t _dbus_send_nonce (int fd, const DBusString *noncefile, diff --git a/dbus/dbus-server-socket.c b/dbus/dbus-server-socket.c index 2c9d81c..a142e33 100644 --- a/dbus/dbus-server-socket.c +++ b/dbus/dbus-server-socket.c @@ -470,9 +470,8 @@ _dbus_server_new_for_tcp_socket (const char *host, goto failed_2; } - if (_dbus_generate_and_write_nonce (&noncefile) != 0) + if (!_dbus_generate_and_write_nonce (&noncefile, error)) { - dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL); goto failed_2; } } diff --git a/dbus/dbus-sysdeps-unix.c b/dbus/dbus-sysdeps-unix.c index fc51709..26c3aab 100644 --- a/dbus/dbus-sysdeps-unix.c +++ b/dbus/dbus-sysdeps-unix.c @@ -3908,35 +3908,6 @@ _dbus_get_is_errno_eagain_or_ewouldblock (void) return errno == EAGAIN || errno == EWOULDBLOCK; } -int -_dbus_write_to_file (const char* filename, const char* buf, size_t len) -{ - int filefd; - FILE *fp; - size_t written; - - filefd = open (filename, - (O_WRONLY|O_CREAT|O_EXCL|O_BINARY), - (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP)); - if (filefd == -1) - { - return -1; - } - fp = fdopen (filefd, "wb"); - if (!fp) - { - int save_e = errno; - close (filefd); - errno = save_e; - return -1; - } - - written = fwrite (buf, len, 1, fp); - fclose (fp); - - return written == 1 ? 0 : -1; -} - /** * Checks whether file descriptors may be passed via the socket * diff --git a/dbus/dbus-sysdeps.h b/dbus/dbus-sysdeps.h index 999aade..1eebfde 100644 --- a/dbus/dbus-sysdeps.h +++ b/dbus/dbus-sysdeps.h @@ -542,24 +542,6 @@ dbus_pid_t _dbus_getpid (void); void _dbus_flush_caches (void); -dbus_bool_t _dbus_generate_noncefilename (DBusString *buf); - -int _dbus_generate_and_write_nonce (const DBusString *filename); - -int _dbus_generate_nonce (char *buffer, size_t nbytes); - -dbus_bool_t _dbus_check_nonce (int fd, const DBusString *nonce); - -dbus_bool_t dbus_read_nonce (const DBusString *noncefile, DBusString *nonce); - -int _dbus_accept_with_nonce (int listen_fd, const DBusString *nonce); - -int _dbus_accept_with_noncefile (int listen_fd, const DBusString *noncefile); - -dbus_bool_t _dbus_send_nonce (int fd, const DBusString *noncefile, DBusError* error); - -int _dbus_write_to_file (const char *filename, const char *buf, size_t len); - /** @} */ DBUS_END_DECLS -- 1.6.4.msysgit.0 From c58829f198dcd76fede10cc1e9f14074860728d0 Mon Sep 17 00:00:00 2001 From: Frank Osterfeld Date: Wed, 21 Oct 2009 20:08:12 +0300 Subject: [PATCH 086/114] Improve error handling in nonce code Replace errno (from assuan code) by DBusError. Errors are not passed through dbus_accept_with_nonce atm, as the original _dbus_accept() has no error arg either. Cherry-picked from commit 8082e92bb3a6304362e730f8b6e324860e1bb26c in the dbus4win repository, edited to apply and fix whitespace issues by tml@iki.fi. --- dbus/dbus-nonce.c | 43 +++++++++++++++++++++++++------------------ dbus/dbus-nonce.h | 6 ++++-- 2 files changed, 29 insertions(+), 20 deletions(-) diff --git a/dbus/dbus-nonce.c b/dbus/dbus-nonce.c index bca60e0..2ed0072 100644 --- a/dbus/dbus-nonce.c +++ b/dbus/dbus-nonce.c @@ -33,12 +33,8 @@ #include #endif -#ifndef ENOFILE -# define ENOFILE ENOENT -#endif - dbus_bool_t -_dbus_check_nonce (int fd, const DBusString *nonce) +_dbus_check_nonce (int fd, const DBusString *nonce, DBusError *error) { DBusString buffer; DBusString p; @@ -46,11 +42,18 @@ _dbus_check_nonce (int fd, const DBusString *nonce) dbus_bool_t result; int n; + _DBUS_ASSERT_ERROR_IS_CLEAR (error); + nleft = 16; - _dbus_string_init (&buffer); - _dbus_string_init (&p); -//PENDING(kdab) replace errno by DBusError + if ( !_dbus_string_init (&buffer) + || !_dbus_string_init (&p) ) { + dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL); + _dbus_string_free (&p); + _dbus_string_free (&buffer); + return; + } + while (nleft) { n = _dbus_read_socket (fd, &p, nleft); @@ -60,15 +63,16 @@ _dbus_check_nonce (int fd, const DBusString *nonce) _dbus_sleep_milliseconds (100); else if (n==-1) { + dbus_set_error (error, DBUS_ERROR_IO_ERROR, "Could not read nonce from socket (fd=%d)", fd ); _dbus_string_free (&p); _dbus_string_free (&buffer); return FALSE; } else if (!n) { - _dbus_string_free (&p); - _dbus_string_free (&buffer); - errno = EIO; + _dbus_string_free (&p); + _dbus_string_free (&buffer); + dbus_set_error (error, DBUS_ERROR_IO_ERROR, "Could not read nonce from socket (fd=%d)", fd ); return FALSE; } else @@ -80,7 +84,7 @@ _dbus_check_nonce (int fd, const DBusString *nonce) result = _dbus_string_equal_len (&buffer, nonce, 16); if (!result) - errno = EACCES; + dbus_set_error (error, DBUS_ERROR_ACCESS_DENIED, "Nonces do not match, access denied (fd=%d)", fd ); _dbus_string_free (&p); _dbus_string_free (&buffer); @@ -90,13 +94,16 @@ _dbus_check_nonce (int fd, const DBusString *nonce) //PENDING(kdab) document dbus_bool_t -_dbus_read_nonce (const DBusString *fname, DBusString *nonce) +_dbus_read_nonce (const DBusString *fname, DBusString *nonce, DBusError* error) { //PENDING(kdab) replace errno by DBusError FILE *fp; char buffer[17]; buffer[sizeof buffer - 1] = '\0'; size_t nread; + + _DBUS_ASSERT_ERROR_IS_CLEAR (error); + _dbus_verbose ("reading nonce from file: %s\n", _dbus_string_get_const_data (fname)); @@ -107,13 +114,13 @@ _dbus_read_nonce (const DBusString *fname, DBusString *nonce) fclose (fp); if (!nread) { - errno = ENOFILE; + dbus_set_error (error, DBUS_ERROR_FILE_NOT_FOUND, "Could not read nonce from file %s", _dbus_string_get_const_data (fname)); return FALSE; } if (!_dbus_string_append_len (nonce, buffer, sizeof buffer - 1 )) { - errno = ENOMEM; + dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL); return FALSE; } return TRUE; @@ -127,7 +134,7 @@ _dbus_accept_with_nonce (int listen_fd, const DBusString *nonce) fd = _dbus_accept (listen_fd); if (_dbus_socket_is_invalid (fd)) return fd; - if (_dbus_check_nonce(fd, nonce) != TRUE) { + if (_dbus_check_nonce(fd, nonce, NULL) != TRUE) { _dbus_verbose ("nonce check failed. Closing socket.\n"); _dbus_close_socket(fd, NULL); return -1; @@ -143,7 +150,7 @@ _dbus_accept_with_noncefile (int listen_fd, const DBusString *noncefile) DBusString nonce; _dbus_string_init (&nonce); //PENDING(kdab): set better errors - if (_dbus_read_nonce (noncefile, &nonce) != TRUE) + if (_dbus_read_nonce (noncefile, &nonce, NULL) != TRUE) return -1; return _dbus_accept_with_nonce (listen_fd, &nonce); } @@ -218,7 +225,7 @@ _dbus_send_nonce(int fd, const DBusString *noncefile, DBusError *error) return FALSE; } - read_result = _dbus_read_nonce (noncefile, &nonce); + read_result = _dbus_read_nonce (noncefile, &nonce, NULL); if (!read_result) { diff --git a/dbus/dbus-nonce.h b/dbus/dbus-nonce.h index 85cfd7f..f91dc57 100644 --- a/dbus/dbus-nonce.h +++ b/dbus/dbus-nonce.h @@ -31,10 +31,12 @@ DBUS_BEGIN_DECLS dbus_bool_t _dbus_check_nonce (int fd, - const DBusString *nonce); + const DBusString *nonce, + DBusError *error); dbus_bool_t _dbus_read_nonce (const DBusString *fname, - DBusString *nonce); + DBusString *nonce, + DBusError *error); int _dbus_accept_with_nonce (int listen_fd, const DBusString *nonce); -- 1.6.4.msysgit.0 From 69b8532e742af497ef3299e6a0ea737e59e0cfc2 Mon Sep 17 00:00:00 2001 From: Frank Osterfeld Date: Tue, 9 Jun 2009 11:56:38 +0200 Subject: [PATCH 087/114] Add nonce-tcp section to the specification (draft) (cherry picked from commit 7015b2db6c8744c88da9cb0fab8d5e0fcfc0220b) --- doc/dbus-specification.xml | 33 +++++++++++++++++++++++++++++++++ 1 files changed, 33 insertions(+), 0 deletions(-) diff --git a/doc/dbus-specification.xml b/doc/dbus-specification.xml index 8d10aad..7b802dc 100644 --- a/doc/dbus-specification.xml +++ b/doc/dbus-specification.xml @@ -2426,6 +2426,39 @@ would be padded by Nul bytes. + + Nonce-secured TCP Sockets + + The nonce-tcp transport provides a secured TCP transport, using a + simple authentication mechanism to ensure that only clients with read + access to a certain location in the filesystem can connect to the server. + The server writes a secret, the nonce, to a file and an incoming client + connection is only accepted if the client sends the nonce right after + the connect. The nonce mechanism requires no setup and is orthogonal to + the higher-level authentication mechanisms described in the + Authentication section. + + + + On start, the server generates a random 16 byte nonce and writes it + to a file in the user's temporary directory. The nonce file location + is published as part of the server's D-Bus address using the + "noncefile" key-value pair. + + After an accept, the server reads 16 bytes from the socket. If the + read bytes do not match the nonce stored in the nonce file, the + server MUST immediately drop the connection. + If the nonce match the received byte sequence, the client is accepted + and the transport behaves like an unsecured tcp transport. + + + After a successful connect to the server socket, the client MUST read + the nonce from the file published by the server via the noncefile= + key-value pair and send it over the socket. After that, the + transport behaves like an unsecured tcp transport. + + + -- 1.6.4.msysgit.0 From d15f4d0bd20d14c129ee1981d0b72c90e11f5779 Mon Sep 17 00:00:00 2001 From: Frank Osterfeld Date: Wed, 21 Oct 2009 20:21:37 +0300 Subject: [PATCH 088/114] Fixes to the nonce code On Unix, we create a 700 subdir in /tmp only readable by the user, on Windows we use the user-specific tmpdir and create the noncefile directly. Add NonceFile to abstract this behaviour and to delete the noncefile and possibly tmpdir on shutdown. Cherry-picked from commit 885f16b90c4f769ae29f432d0ed2a63bb2e4dab8 in the dbus4win repository. Fixed to apply and correct whitespace issues by tml@iki.fi. --- dbus/dbus-nonce.c | 181 +++++++++++++++++++++++++++++++++++++++----- dbus/dbus-nonce.h | 39 +++++++--- dbus/dbus-server-socket.c | 127 ++++++++++++++----------------- dbus/dbus-server-socket.h | 3 +- 4 files changed, 246 insertions(+), 104 deletions(-) diff --git a/dbus/dbus-nonce.c b/dbus/dbus-nonce.c index 2ed0072..58e723c 100644 --- a/dbus/dbus-nonce.c +++ b/dbus/dbus-nonce.c @@ -30,11 +30,11 @@ #include #ifdef HAVE_ERRNO_H -#include +# include #endif -dbus_bool_t -_dbus_check_nonce (int fd, const DBusString *nonce, DBusError *error) +static dbus_bool_t +do_check_nonce (int fd, const DBusString *nonce, DBusError *error) { DBusString buffer; DBusString p; @@ -126,15 +126,27 @@ _dbus_read_nonce (const DBusString *fname, DBusString *nonce, DBusError* error) return TRUE; } +static int +accept_with_nonce (int listen_fd, const DBusString *nonce) +{ + +} + int -_dbus_accept_with_nonce (int listen_fd, const DBusString *nonce) +_dbus_accept_with_noncefile (int listen_fd, const DBusNonceFile *noncefile) { - _dbus_assert (nonce != NULL); int fd; + DBusString nonce; + + _dbus_assert (noncefile != NULL); + _dbus_string_init (&nonce); + //PENDING(kdab): set better errors + if (_dbus_read_nonce (_dbus_noncefile_get_path(noncefile), &nonce, NULL) != TRUE) + return -1; fd = _dbus_accept (listen_fd); if (_dbus_socket_is_invalid (fd)) return fd; - if (_dbus_check_nonce(fd, nonce, NULL) != TRUE) { + if (do_check_nonce(fd, &nonce, NULL) != TRUE) { _dbus_verbose ("nonce check failed. Closing socket.\n"); _dbus_close_socket(fd, NULL); return -1; @@ -143,18 +155,6 @@ _dbus_accept_with_nonce (int listen_fd, const DBusString *nonce) return fd; } -int -_dbus_accept_with_noncefile (int listen_fd, const DBusString *noncefile) -{ - _dbus_assert (noncefile != NULL); - DBusString nonce; - _dbus_string_init (&nonce); - //PENDING(kdab): set better errors - if (_dbus_read_nonce (noncefile, &nonce, NULL) != TRUE) - return -1; - return _dbus_accept_with_nonce (listen_fd, &nonce); -} - dbus_bool_t _dbus_generate_noncefilename (DBusString *buf, DBusError *error) { @@ -182,8 +182,8 @@ oom: return FALSE; } -dbus_bool_t -_dbus_generate_and_write_nonce (const DBusString *filename, DBusError *error) +static dbus_bool_t +generate_and_write_nonce (const DBusString *filename, DBusError *error) { DBusString nonce; dbus_bool_t ret; @@ -199,7 +199,7 @@ _dbus_generate_and_write_nonce (const DBusString *filename, DBusError *error) return FALSE; } - ret = _dbus_string_save_to_file (filename, &nonce, error); + ret = _dbus_string_save_to_file (&nonce, filename, error); _dbus_string_free (&nonce); @@ -253,4 +253,143 @@ _dbus_send_nonce(int fd, const DBusString *noncefile, DBusError *error) return TRUE; } +static dbus_bool_t +do_noncefile_create (DBusNonceFile *noncefile, + DBusError *error, + dbus_bool_t use_subdir) +{ + dbus_bool_t ret; + DBusString randomStr; + + _DBUS_ASSERT_ERROR_IS_CLEAR (error); + + _dbus_assert (noncefile); + + if (!_dbus_string_init (&randomStr)) + { + dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL); + goto on_error; + } + + if (!_dbus_generate_random_ascii (&randomStr, 8)) + { + dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL); + goto on_error; + } + + if (!_dbus_string_init (&noncefile->dir) + || !_dbus_string_append (&noncefile->dir, _dbus_get_tmpdir())) + { + dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL); + goto on_error; + } + if (use_subdir) + { + if (!_dbus_string_append (&noncefile->dir, DBUS_DIR_SEPARATOR "dbus_nonce-") + || !_dbus_string_append (&noncefile->dir, _dbus_string_get_const_data (&randomStr)) ) + { + dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL); + goto on_error; + } + if (!_dbus_string_init (&noncefile->path) + || !_dbus_string_copy (&noncefile->dir, 0, &noncefile->path, 0) + || !_dbus_string_append (&noncefile->dir, DBUS_DIR_SEPARATOR "nonce")) + { + dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL); + goto on_error; + } + if (!_dbus_create_directory (&noncefile->dir, error)) + { + goto on_error; + } + + } + else + { + if (!_dbus_string_init (&noncefile->path) + || !_dbus_string_copy (&noncefile->dir, 0, &noncefile->path, 0) + || !_dbus_string_append (&noncefile->path, DBUS_DIR_SEPARATOR "dbus_nonce-") + || !_dbus_string_append (&noncefile->path, _dbus_string_get_const_data (&randomStr))) + { + dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL); + goto on_error; + } + + } + + if (!generate_and_write_nonce (&noncefile->path, error)) + { + if (use_subdir) + _dbus_delete_directory (&noncefile->dir, NULL); //we ignore possible errors deleting the dir and return the write error instead + goto on_error; + } + + _dbus_string_free (&randomStr); + + return TRUE; + on_error: + if (use_subdir) + _dbus_delete_directory (&noncefile->dir, NULL); + _dbus_string_free (&noncefile->dir); + _dbus_string_free (&noncefile->path); + _dbus_string_free (&randomStr); + return FALSE; +} + +#ifdef DBUS_WIN +dbus_bool_t +_dbus_noncefile_create (DBusNonceFile *noncefile, + DBusError *error) +{ + return do_noncefile_create (noncefile, error, /*use_subdir=*/FALSE); +} + +dbus_bool_t +_dbus_noncefile_delete (DBusNonceFile *noncefile, + DBusError *error) +{ + _DBUS_ASSERT_ERROR_IS_CLEAR (error); + + _dbus_delete_file (&noncefile->path, error); + _dbus_string_free (&noncefile->dir); + _dbus_string_free (&noncefile->path); +} + +#else +dbus_bool_t +_dbus_noncefile_create (DBusNonceFile *noncefile, + DBusError *error) +{ + return do_noncefile_create (noncefile, error, /*use_subdir=*/TRUE); +} + +dbus_bool_t +_dbus_noncefile_delete (DBusNonceFile *noncefile, + DBusError *error) +{ + _DBUS_ASSERT_ERROR_IS_CLEAR (error); + + _dbus_delete_directory (&noncefile->dir, error); + _dbus_string_free (&noncefile->dir); + _dbus_string_free (&noncefile->path); +} +#endif + + +const DBusString* +_dbus_noncefile_get_path (const DBusNonceFile *noncefile) +{ + _dbus_assert (noncefile); + return &noncefile->path; +} + +dbus_bool_t +_dbus_noncefile_check_nonce (int fd, + const DBusNonceFile *noncefile, + DBusError* error) +{ + return do_check_nonce (fd, _dbus_noncefile_get_path (noncefile), error); +} + + /** @} end of nonce */ diff --git a/dbus/dbus-nonce.h b/dbus/dbus-nonce.h index f91dc57..474ea72 100644 --- a/dbus/dbus-nonce.h +++ b/dbus/dbus-nonce.h @@ -30,25 +30,38 @@ DBUS_BEGIN_DECLS -dbus_bool_t _dbus_check_nonce (int fd, - const DBusString *nonce, - DBusError *error); +typedef struct DBusNonceFile DBusNonceFile; -dbus_bool_t _dbus_read_nonce (const DBusString *fname, - DBusString *nonce, - DBusError *error); +struct DBusNonceFile +{ + DBusString path; + DBusString dir; +}; + +// server + +dbus_bool_t _dbus_noncefile_create (DBusNonceFile *noncefile, + DBusError *error); + +dbus_bool_t _dbus_noncefile_delete (DBusNonceFile *noncefile, + DBusError *error); -int _dbus_accept_with_nonce (int listen_fd, - const DBusString *nonce); +dbus_bool_t _dbus_noncefile_check_nonce (int fd, + const DBusNonceFile *noncefile, + DBusError *error); + +const DBusString* _dbus_noncefile_get_path (const DBusNonceFile *noncefile); int _dbus_accept_with_noncefile (int listen_fd, - const DBusString *noncefile); + const DBusNonceFile *noncefile); + +// shared -dbus_bool_t _dbus_generate_noncefilename (DBusString *buf, - DBusError *error); +dbus_bool_t _dbus_read_nonce (const DBusString *fname, + DBusString *nonce, + DBusError *error); -dbus_bool_t _dbus_generate_and_write_nonce (const DBusString *filename, - DBusError *error); +// client dbus_bool_t _dbus_send_nonce (int fd, const DBusString *noncefile, diff --git a/dbus/dbus-server-socket.c b/dbus/dbus-server-socket.c index a142e33..9fe0374 100644 --- a/dbus/dbus-server-socket.c +++ b/dbus/dbus-server-socket.c @@ -4,7 +4,7 @@ * Copyright (C) 2002, 2003, 2004, 2006 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 @@ -14,7 +14,7 @@ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA @@ -25,6 +25,7 @@ #include "dbus-server-socket.h" #include "dbus-transport-socket.h" #include "dbus-connection-internal.h" +#include "dbus-nonce.h" #include "dbus-string.h" /** @@ -35,7 +36,7 @@ * @{ */ /** - * + * * Opaque object representing a Socket server implementation. */ typedef struct DBusServerSocket DBusServerSocket; @@ -51,7 +52,7 @@ struct DBusServerSocket int *fds; /**< File descriptor or -1 if disconnected. */ DBusWatch **watch; /**< File descriptor watch. */ char *socket_name; /**< Name of domain socket, to unlink if appropriate */ - DBusString noncefile; /**< Nonce file used to authenticate clients */ + DBusNonceFile *noncefile; /**< Nonce file used to authenticate clients */ }; static void @@ -59,7 +60,7 @@ socket_finalize (DBusServer *server) { DBusServerSocket *socket_server = (DBusServerSocket*) server; int i; - + _dbus_server_finalize_base (server); for (i = 0 ; i < socket_server->n_fds ; i++) @@ -68,15 +69,12 @@ socket_finalize (DBusServer *server) _dbus_watch_unref (socket_server->watch[i]); socket_server->watch[i] = NULL; } - + dbus_free (socket_server->fds); dbus_free (socket_server->watch); dbus_free (socket_server->socket_name); - if (_dbus_string_get_length(&socket_server->noncefile) > 0) - { - _dbus_delete_file(&socket_server->noncefile, NULL); - } - _dbus_string_free (&socket_server->noncefile); + _dbus_noncefile_delete (socket_server->noncefile, NULL); //PENDING(kdab) review error ignore + dbus_free (socket_server->noncefile); dbus_free (server); } @@ -90,19 +88,19 @@ handle_new_client_fd_and_unlock (DBusServer *server, DBusNewConnectionFunction new_connection_function; DBusServerSocket* socket_server; void *new_connection_data; - + socket_server = (DBusServerSocket*)server; _dbus_verbose ("Creating new client connection with fd %d\n", client_fd); HAVE_LOCK_CHECK (server); - + if (!_dbus_set_fd_nonblocking (client_fd, NULL)) { SERVER_UNLOCK (server); return TRUE; } - - transport = _dbus_transport_new_for_socket (client_fd, &server->guid_hex, NULL); + + transport = _dbus_transport_new_for_socket (client_fd, &server->guid_hex, FALSE); if (transport == NULL) { _dbus_close_socket (client_fd, NULL); @@ -117,21 +115,21 @@ handle_new_client_fd_and_unlock (DBusServer *server, SERVER_UNLOCK (server); return FALSE; } - + /* note that client_fd is now owned by the transport, and will be * closed on transport disconnection/finalization */ - + connection = _dbus_connection_new_for_transport (transport); _dbus_transport_unref (transport); transport = NULL; /* now under the connection lock */ - + if (connection == NULL) { SERVER_UNLOCK (server); return FALSE; } - + /* See if someone wants to handle this new connection, self-referencing * for paranoia. */ @@ -140,14 +138,14 @@ handle_new_client_fd_and_unlock (DBusServer *server, _dbus_server_ref_unlocked (server); SERVER_UNLOCK (server); - + if (new_connection_function) { (* new_connection_function) (server, connection, new_connection_data); } dbus_server_unref (server); - + /* If no one grabbed a reference, the connection will die. */ _dbus_connection_close_if_only_one_ref (connection); dbus_connection_unref (connection); @@ -161,14 +159,15 @@ socket_handle_watch (DBusWatch *watch, void *data) { DBusServer *server = data; -#ifndef DBUS_DISABLE_ASSERT DBusServerSocket *socket_server = data; + +#ifndef DBUS_DISABLE_ASSERT int i; dbus_bool_t found = FALSE; #endif SERVER_LOCK (server); - + #ifndef DBUS_DISABLE_ASSERT for (i = 0 ; i < socket_server->n_fds ; i++) { @@ -179,20 +178,20 @@ socket_handle_watch (DBusWatch *watch, #endif _dbus_verbose ("Handling client connection, flags 0x%x\n", flags); - + if (flags & DBUS_WATCH_READABLE) { int client_fd; int listen_fd; - + listen_fd = dbus_watch_get_socket (watch); - client_fd = _dbus_accept_with_noncefile (listen_fd, &socket_server->noncefile); - + client_fd = _dbus_accept_with_noncefile (listen_fd, socket_server->noncefile); + if (client_fd < 0) { /* EINTR handled for us */ - + if (_dbus_get_is_errno_eagain_or_ewouldblock ()) _dbus_verbose ("No client available to accept after all\n"); else @@ -216,7 +215,7 @@ socket_handle_watch (DBusWatch *watch, return TRUE; } - + static void socket_disconnect (DBusServer *server) { @@ -224,7 +223,7 @@ socket_disconnect (DBusServer *server) int i; HAVE_LOCK_CHECK (server); - + for (i = 0 ; i < socket_server->n_fds ; i++) { if (socket_server->watch[i]) @@ -265,24 +264,26 @@ static const DBusServerVTable socket_vtable = { * @param fds list of file descriptors. * @param n_fds number of file descriptors * @param address the server's address - * @param noncefile the noncefile to use, NULL if without nonce + * @param use_nonce whether to create and use a nonce for authentication * @returns the new server, or #NULL if no memory. - * + * */ DBusServer* _dbus_server_new_for_socket (int *fds, int n_fds, const DBusString *address, - const DBusString *noncefile) + DBusNonceFile *noncefile) { DBusServerSocket *socket_server; DBusServer *server; int i; - + socket_server = dbus_new0 (DBusServerSocket, 1); if (socket_server == NULL) return NULL; + socket_server->noncefile = noncefile; + socket_server->fds = dbus_new (int, n_fds); if (!socket_server->fds) goto failed_0; @@ -312,16 +313,10 @@ _dbus_server_new_for_socket (int *fds, &socket_vtable, address)) goto failed_2; - if (!_dbus_string_init (&socket_server->noncefile)) - goto failed_2; - - if (noncefile && !_dbus_string_copy (noncefile, 0, &socket_server->noncefile, 0)) - goto failed_3; - server = (DBusServer*)socket_server; SERVER_LOCK (server); - + for (i = 0 ; i < n_fds ; i++) { if (!_dbus_server_add_watch (&socket_server->base, @@ -339,11 +334,12 @@ _dbus_server_new_for_socket (int *fds, } SERVER_UNLOCK (server); - + return (DBusServer*) socket_server; failed_3: - _dbus_string_free (&socket_server->noncefile); + _dbus_noncefile_delete (socket_server->noncefile, NULL); + _dbus_free (socket_server->noncefile ); failed_2: for (i = 0 ; i < n_fds ; i++) { @@ -377,8 +373,9 @@ _dbus_server_new_for_socket (int *fds, * @param host the hostname to report for the listen address * @param bind the hostname to listen on * @param port the port to listen on or 0 to let the OS choose - * @param family + * @param family * @param error location to store reason for failure. + * @param use_nonce whether to use a nonce for low-level authentication (nonce-tcp transport) or not (tcp transport) * @returns the new server, or #NULL on failure. */ DBusServer* @@ -395,10 +392,12 @@ _dbus_server_new_for_tcp_socket (const char *host, DBusString address; DBusString host_str; DBusString port_str; - DBusString noncefile; + DBusNonceFile *noncefile; _DBUS_ASSERT_ERROR_IS_CLEAR (error); + noncefile = NULL; + if (!_dbus_string_init (&address)) { dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL); @@ -447,36 +446,27 @@ _dbus_server_new_for_tcp_socket (const char *host, dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL); goto failed_2; } - - if (!_dbus_string_init (&noncefile)) - { - dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL); - goto failed_2; - } if (use_nonce) { - if (!_dbus_generate_noncefilename (&noncefile)) + noncefile = dbus_new0 (DBusNonceFile, 1); + if (noncefile == NULL) { - dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL); goto failed_2; } - if (_dbus_string_get_length(&noncefile) == 0 || - !_dbus_string_append (&address, ",noncefile=") || - !_dbus_address_append_escaped (&address, &noncefile)) - { - dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL); + if (!_dbus_noncefile_create (noncefile, NULL)) goto failed_2; - } - if (!_dbus_generate_and_write_nonce (&noncefile, error)) + if (!_dbus_string_append (&address, ",noncefile=") || + !_dbus_address_append_escaped (&address, _dbus_noncefile_get_path (noncefile))) { goto failed_2; } + } - server = _dbus_server_new_for_socket (listen_fds, nlisten_fds, &address, &noncefile); + server = _dbus_server_new_for_socket (listen_fds, nlisten_fds, &address, noncefile); if (server == NULL) { dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL); @@ -493,7 +483,6 @@ _dbus_server_new_for_tcp_socket (const char *host, for (i = 0 ; i < nlisten_fds ; i++) _dbus_close_socket (listen_fds[i], NULL); dbus_free(listen_fds); - _dbus_string_free (&noncefile); failed_1: _dbus_string_free (&port_str); @@ -507,14 +496,14 @@ _dbus_server_new_for_tcp_socket (const char *host, /** * Tries to interpret the address entry for various socket-related * addresses (well, currently only tcp and nonce-tcp). - * + * * Sets error if the result is not OK. - * + * * @param entry an address entry * @param server_p a new DBusServer, or #NULL on failure. * @param error location to store rationale for failure on bad address * @returns the outcome - * + * */ DBusServerListenResult _dbus_server_listen_socket (DBusAddressEntry *entry, @@ -524,9 +513,9 @@ _dbus_server_listen_socket (DBusAddressEntry *entry, const char *method; *server_p = NULL; - + method = dbus_address_entry_get_method (entry); - + if (strcmp (method, "tcp") == 0 || strcmp (method, "nonce-tcp") == 0) { const char *host; @@ -564,10 +553,10 @@ _dbus_server_listen_socket (DBusAddressEntry *entry, * This is a bad hack since it's really unix domain socket * specific. Also, the function weirdly adopts ownership * of the passed-in string. - * + * * @param server a socket server * @param filename socket filename to report/delete - * + * */ void _dbus_server_socket_own_filename (DBusServer *server, diff --git a/dbus/dbus-server-socket.h b/dbus/dbus-server-socket.h index 891f56f..0a7c789 100644 --- a/dbus/dbus-server-socket.h +++ b/dbus/dbus-server-socket.h @@ -25,13 +25,14 @@ #include #include +#include DBUS_BEGIN_DECLS DBusServer* _dbus_server_new_for_socket (int *fds, int n_fds, const DBusString *address, - const DBusString *noncefile); + DBusNonceFile *noncefile); DBusServer* _dbus_server_new_for_tcp_socket (const char *host, const char *bind, const char *port, -- 1.6.4.msysgit.0 From e2f810808544d157c995c674f35cbdb4ca7e4a33 Mon Sep 17 00:00:00 2001 From: Frank Osterfeld Date: Wed, 21 Oct 2009 20:25:36 +0300 Subject: [PATCH 089/114] Add api dox for nonce-tcp Cherry-picked from commit e7a070db22ed4a84dc04a062255356c9f6c4c9c5 in the dbus4win repository, trailing whitespace issues corrected by tml@iki.fi. --- dbus/dbus-nonce.c | 91 ++++++++++++++++++++++++++++------------- dbus/dbus-server-socket.c | 2 +- dbus/dbus-sysdeps-win.c | 1 + dbus/dbus-transport-socket.c | 3 +- dbus/dbus-transport-win.c | 16 ++++---- 5 files changed, 73 insertions(+), 40 deletions(-) diff --git a/dbus/dbus-nonce.c b/dbus/dbus-nonce.c index 58e723c..192c510 100644 --- a/dbus/dbus-nonce.c +++ b/dbus/dbus-nonce.c @@ -92,11 +92,17 @@ do_check_nonce (int fd, const DBusString *nonce, DBusError *error) return result; } -//PENDING(kdab) document +/** + * reads the nonce from the nonce file and stores it in a string + * + * @param fname the file to read the nonce from + * @param nonce returns the nonce. Must be an initialized string, the nonce will be appended. + * @param error error object to report possible errors + * @return FALSE iff reading the nonce fails (error is set then) + */ dbus_bool_t _dbus_read_nonce (const DBusString *fname, DBusString *nonce, DBusError* error) { - //PENDING(kdab) replace errno by DBusError FILE *fp; char buffer[17]; buffer[sizeof buffer - 1] = '\0'; @@ -155,33 +161,6 @@ _dbus_accept_with_noncefile (int listen_fd, const DBusNonceFile *noncefile) return fd; } -dbus_bool_t -_dbus_generate_noncefilename (DBusString *buf, DBusError *error) -{ - dbus_bool_t ret; - DBusString randomStr; - - _DBUS_ASSERT_ERROR_IS_CLEAR (error); - - ret = _dbus_string_init (&randomStr); - if (!ret) - goto oom; - ret = _dbus_generate_random_ascii (&randomStr, 8); - if (!ret) - goto oom; - if (!_dbus_string_append (buf, _dbus_get_tmpdir()) - || !_dbus_string_append (buf, DBUS_DIR_SEPARATOR "dbus_nonce-") - || !_dbus_string_append (buf, _dbus_string_get_const_data (&randomStr)) ) - goto oom; - - _dbus_string_free (&randomStr); - return TRUE; -oom: - dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL); - _dbus_string_free (&randomStr); - return FALSE; -} - static dbus_bool_t generate_and_write_nonce (const DBusString *filename, DBusError *error) { @@ -206,6 +185,15 @@ generate_and_write_nonce (const DBusString *filename, DBusError *error) return ret; } +/** + * sends the nonce over a given socket. Blocks while doing so. + * + * @param fd the file descriptor to write the nonce data to (usually a socket) + * @param noncefile the noncefile location to read the nonce from + * @param error contains error details if FALSE is returned + * @return TRUE iff the nonce was successfully sent. Note that this does not + * indicate whether the server accepted the nonce. + */ dbus_bool_t _dbus_send_nonce(int fd, const DBusString *noncefile, DBusError *error) { @@ -337,6 +325,13 @@ do_noncefile_create (DBusNonceFile *noncefile, } #ifdef DBUS_WIN +/** + * creates a nonce file in a user-readable location and writes a generated nonce to it + * + * @param noncefile returns the nonce file location + * @param error error details if creating the nonce file fails + * @return TRUE iff the nonce file was successfully created + */ dbus_bool_t _dbus_noncefile_create (DBusNonceFile *noncefile, DBusError *error) @@ -344,6 +339,13 @@ _dbus_noncefile_create (DBusNonceFile *noncefile, return do_noncefile_create (noncefile, error, /*use_subdir=*/FALSE); } +/** + * deletes the noncefile and frees the DBusNonceFile object. + * + * @param noncefile the nonce file to delete. Contents will be freed. + * @param error error details if the nonce file could not be deleted + * @return TRUE + */ dbus_bool_t _dbus_noncefile_delete (DBusNonceFile *noncefile, DBusError *error) @@ -356,6 +358,14 @@ _dbus_noncefile_delete (DBusNonceFile *noncefile, } #else +/** + * creates a nonce file in a user-readable location and writes a generated nonce to it. + * Initializes the noncefile object. + * + * @param noncefile returns the nonce file location + * @param error error details if creating the nonce file fails + * @return TRUE iff the nonce file was successfully created + */ dbus_bool_t _dbus_noncefile_create (DBusNonceFile *noncefile, DBusError *error) @@ -363,6 +373,13 @@ _dbus_noncefile_create (DBusNonceFile *noncefile, return do_noncefile_create (noncefile, error, /*use_subdir=*/TRUE); } +/** + * deletes the noncefile and frees the DBusNonceFile object. + * + * @param noncefile the nonce file to delete. Contents will be freed. + * @param error error details if the nonce file could not be deleted + * @return TRUE + */ dbus_bool_t _dbus_noncefile_delete (DBusNonceFile *noncefile, DBusError *error) @@ -376,6 +393,12 @@ _dbus_noncefile_delete (DBusNonceFile *noncefile, #endif +/** + * returns the absolute file path of the nonce file + * + * @param noncefile an initialized noncefile object + * @return the absolute path of the nonce file + */ const DBusString* _dbus_noncefile_get_path (const DBusNonceFile *noncefile) { @@ -383,6 +406,16 @@ _dbus_noncefile_get_path (const DBusNonceFile *noncefile) return &noncefile->path; } +/** + * reads data from a file descriptor and checks if the received data matches + * the data in the given noncefile. + * + * @param fd the file descriptor to read the nonce from + * @param noncefile the nonce file to check the received data against + * @param error error details on fail + * @return TRUE iff a nonce could be successfully read from the file descriptor + * and matches the nonce from the given nonce file + */ dbus_bool_t _dbus_noncefile_check_nonce (int fd, const DBusNonceFile *noncefile, diff --git a/dbus/dbus-server-socket.c b/dbus/dbus-server-socket.c index 9fe0374..92064ef 100644 --- a/dbus/dbus-server-socket.c +++ b/dbus/dbus-server-socket.c @@ -73,7 +73,7 @@ socket_finalize (DBusServer *server) dbus_free (socket_server->fds); dbus_free (socket_server->watch); dbus_free (socket_server->socket_name); - _dbus_noncefile_delete (socket_server->noncefile, NULL); //PENDING(kdab) review error ignore + _dbus_noncefile_delete (socket_server->noncefile, NULL); dbus_free (socket_server->noncefile); dbus_free (server); } diff --git a/dbus/dbus-sysdeps-win.c b/dbus/dbus-sysdeps-win.c index f34e57f..b81e2ea 100644 --- a/dbus/dbus-sysdeps-win.c +++ b/dbus/dbus-sysdeps-win.c @@ -44,6 +44,7 @@ #include "dbus-hash.h" #include "dbus-sockets-win.h" #include "dbus-list.h" +#include "dbus-nonce.h" #include "dbus-credentials.h" #include diff --git a/dbus/dbus-transport-socket.c b/dbus/dbus-transport-socket.c index 96a7eba..0b6b006 100644 --- a/dbus/dbus-transport-socket.c +++ b/dbus/dbus-transport-socket.c @@ -1418,8 +1418,7 @@ _dbus_transport_open_socket(DBusAddressEntry *entry, *transport_p = _dbus_transport_new_for_tcp_socket (host, port, family, noncefile, error); if (*transport_p == NULL) { - //PENDING(kdab) - //_DBUS_ASSERT_ERROR_IS_SET (error); + _DBUS_ASSERT_ERROR_IS_SET (error); return DBUS_TRANSPORT_OPEN_DID_NOT_CONNECT; } else diff --git a/dbus/dbus-transport-win.c b/dbus/dbus-transport-win.c index cd28204..1545c71 100644 --- a/dbus/dbus-transport-win.c +++ b/dbus/dbus-transport-win.c @@ -52,19 +52,19 @@ _dbus_transport_open_platform_specific (DBusAddressEntry *entry, { const char *method; + const char *host = dbus_address_entry_get_value (entry, "host"); + const char *port = dbus_address_entry_get_value (entry, "port"); + const char *family = dbus_address_entry_get_value (entry, "family"); + const char *noncefile = dbus_address_entry_get_value (entry, "noncefile"); + method = dbus_address_entry_get_method (entry); _dbus_assert (method != NULL); if (strcmp (method, "nonce-tcp") != 0) { - _DBUS_ASSERT_ERROR_IS_CLEAR (error); - return DBUS_TRANSPORT_OPEN_NOT_HANDLED; -} - - const char *host = dbus_address_entry_get_value (entry, "host"); - const char *port = dbus_address_entry_get_value (entry, "port"); - const char *family = dbus_address_entry_get_value (entry, "family"); - const char *noncefile = dbus_address_entry_get_value (entry, "noncefile"); + _DBUS_ASSERT_ERROR_IS_CLEAR (error); + return DBUS_TRANSPORT_OPEN_NOT_HANDLED; + } if (port == NULL) { -- 1.6.4.msysgit.0 From a5042dd2566e02bbcdb079c4c6dfec8d3cf5b397 Mon Sep 17 00:00:00 2001 From: Frank Osterfeld Date: Wed, 21 Oct 2009 20:39:51 +0300 Subject: [PATCH 090/114] Fix IPv6 setup (the default on Vista) Ensure that the right struct is passed. Cherry-picked from commit 172d60d100d04e301e51ff475ada02007f1709dc in the dbus4win repository by tml@iki.fi. --- dbus/dbus-sysdeps-win.c | 12 +++++++++++- 1 files changed, 11 insertions(+), 1 deletions(-) diff --git a/dbus/dbus-sysdeps-win.c b/dbus/dbus-sysdeps-win.c index b81e2ea..f80bfd4 100644 --- a/dbus/dbus-sysdeps-win.c +++ b/dbus/dbus-sysdeps-win.c @@ -1516,6 +1516,16 @@ _dbus_listen_tcp_socket (const char *host, struct addrinfo hints; struct addrinfo *ai, *tmp; + // On Vista, sockaddr_gen must be a sockaddr_in6, and not a sockaddr_in6_old + //That's required for family == IPv6(which is the default on Vista if family is not given) + //So we use our own union instead of sockaddr_gen: + + typedef union { + struct sockaddr Address; + struct sockaddr_in AddressIn; + struct sockaddr_in6 AddressIn6; + } mysockaddr_gen; + *fds_p = NULL; _DBUS_ASSERT_ERROR_IS_CLEAR (error); @@ -1608,7 +1618,7 @@ _dbus_listen_tcp_socket (const char *host, to use the same port */ if (!port || !strcmp(port, "0")) { - sockaddr_gen addr; + mysockaddr_gen addr; socklen_t addrlen = sizeof(addr); char portbuf[10]; -- 1.6.4.msysgit.0 From b52508439866e5295f34a770546e5d01e0a041e9 Mon Sep 17 00:00:00 2001 From: Frank Osterfeld Date: Wed, 21 Oct 2009 20:45:24 +0300 Subject: [PATCH 091/114] Fixes to the nonce code Cherry-picked from commit f9bc0f4bd036f6ede5d9850fb0f8587178c85f44 in the dbus4win repository, slightly massaged to apply by tml@iki.fi. --- cmake/dbus/CMakeLists.txt | 7 ++++--- dbus/dbus-nonce.c | 7 +++++-- dbus/dbus-server-socket.c | 3 ++- dbus/dbus-sysdeps-unix.c | 29 +++++++++++++++++++++++++++++ dbus/dbus-sysdeps-util-unix.c | 29 ----------------------------- dbus/dbus-sysdeps-util-win.c | 28 ---------------------------- dbus/dbus-sysdeps-win.c | 28 ++++++++++++++++++++++++++++ dbus/dbus-sysdeps-win.h | 6 ------ dbus/dbus-sysdeps.h | 5 +++++ dbus/dbus-transport-socket.c | 1 + 10 files changed, 74 insertions(+), 69 deletions(-) diff --git a/cmake/dbus/CMakeLists.txt b/cmake/dbus/CMakeLists.txt index c1c2251..187d48d 100644 --- a/cmake/dbus/CMakeLists.txt +++ b/cmake/dbus/CMakeLists.txt @@ -186,20 +186,20 @@ if (WIN32) set (DBUS_SHARED_SOURCES ${DBUS_SHARED_SOURCES} ${DBUS_DIR}/dbus-sysdeps-win.c ${DBUS_DIR}/dbus-sysdeps-thread-win.c - ${DBUS_DIR}/dbus-sysdeps-util-win.c ${DBUS_DIR}/dbus-spawn-win.c ) set (DBUS_SHARED_HEADERS ${DBUS_SHARED_HEADERS} ${DBUS_DIR}/dbus-sockets-win.h ${DBUS_DIR}/dbus-sysdeps-win.h ) + set (DBUS_UTIL_SOURCES ${DBUS_UTIL_SOURCES} + ${DBUS_DIR}/dbus-sysdeps-util-win.c + ) set (LIBS ${LIBS} ws2_32 advapi32 netapi32) - else (WIN32) set (DBUS_SHARED_SOURCES ${DBUS_SHARED_SOURCES} ${DBUS_DIR}/dbus-sysdeps-unix.c ${DBUS_DIR}/dbus-sysdeps-pthread.c - ${DBUS_DIR}/dbus-sysdeps-util-unix.c ${DBUS_DIR}/dbus-spawn.c ${DBUS_DIR}/dbus-userdb.c ) @@ -211,6 +211,7 @@ else (WIN32) ) set (DBUS_UTIL_SOURCES ${DBUS_UTIL_SOURCES} ${DBUS_DIR}/dbus-userdb-util.c + ${DBUS_DIR}/dbus-sysdeps-util-unix.c ) endif (WIN32) diff --git a/dbus/dbus-nonce.c b/dbus/dbus-nonce.c index 192c510..8385340 100644 --- a/dbus/dbus-nonce.c +++ b/dbus/dbus-nonce.c @@ -51,7 +51,7 @@ do_check_nonce (int fd, const DBusString *nonce, DBusError *error) dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL); _dbus_string_free (&p); _dbus_string_free (&buffer); - return; + return FALSE; } while (nleft) @@ -105,9 +105,10 @@ _dbus_read_nonce (const DBusString *fname, DBusString *nonce, DBusError* error) { FILE *fp; char buffer[17]; - buffer[sizeof buffer - 1] = '\0'; size_t nread; + buffer[sizeof buffer - 1] = '\0'; + _DBUS_ASSERT_ERROR_IS_CLEAR (error); _dbus_verbose ("reading nonce from file: %s\n", _dbus_string_get_const_data (fname)); @@ -355,6 +356,7 @@ _dbus_noncefile_delete (DBusNonceFile *noncefile, _dbus_delete_file (&noncefile->path, error); _dbus_string_free (&noncefile->dir); _dbus_string_free (&noncefile->path); + return TRUE; } #else @@ -389,6 +391,7 @@ _dbus_noncefile_delete (DBusNonceFile *noncefile, _dbus_delete_directory (&noncefile->dir, error); _dbus_string_free (&noncefile->dir); _dbus_string_free (&noncefile->path); + return TRUE; } #endif diff --git a/dbus/dbus-server-socket.c b/dbus/dbus-server-socket.c index 92064ef..c89189d 100644 --- a/dbus/dbus-server-socket.c +++ b/dbus/dbus-server-socket.c @@ -25,6 +25,7 @@ #include "dbus-server-socket.h" #include "dbus-transport-socket.h" #include "dbus-connection-internal.h" +#include "dbus-memory.h" #include "dbus-nonce.h" #include "dbus-string.h" @@ -339,7 +340,7 @@ _dbus_server_new_for_socket (int *fds, failed_3: _dbus_noncefile_delete (socket_server->noncefile, NULL); - _dbus_free (socket_server->noncefile ); + dbus_free (socket_server->noncefile ); failed_2: for (i = 0 ; i < n_fds ; i++) { diff --git a/dbus/dbus-sysdeps-unix.c b/dbus/dbus-sysdeps-unix.c index 26c3aab..91f8a35 100644 --- a/dbus/dbus-sysdeps-unix.c +++ b/dbus/dbus-sysdeps-unix.c @@ -34,6 +34,7 @@ #include "dbus-userdb.h" #include "dbus-list.h" #include "dbus-credentials.h" +#include "dbus-nonce.h" #include #include @@ -3909,6 +3910,34 @@ _dbus_get_is_errno_eagain_or_ewouldblock (void) } /** + * Removes a directory; Directory must be empty + * + * @param filename directory filename + * @param error initialized error object + * @returns #TRUE on success + */ +dbus_bool_t +_dbus_delete_directory (const DBusString *filename, + DBusError *error) +{ + const char *filename_c; + + _DBUS_ASSERT_ERROR_IS_CLEAR (error); + + filename_c = _dbus_string_get_const_data (filename); + + if (rmdir (filename_c) != 0) + { + dbus_set_error (error, DBUS_ERROR_FAILED, + "Failed to remove directory %s: %s\n", + filename_c, _dbus_strerror (errno)); + return FALSE; + } + + return TRUE; +} + +/** * Checks whether file descriptors may be passed via the socket * * @param fd the socket diff --git a/dbus/dbus-sysdeps-util-unix.c b/dbus/dbus-sysdeps-util-unix.c index 9fa27a1..d969d0a 100644 --- a/dbus/dbus-sysdeps-util-unix.c +++ b/dbus/dbus-sysdeps-util-unix.c @@ -509,35 +509,6 @@ _dbus_set_signal_handler (int sig, sigaction (sig, &act, NULL); } - -/** - * Removes a directory; Directory must be empty - * - * @param filename directory filename - * @param error initialized error object - * @returns #TRUE on success - */ -dbus_bool_t -_dbus_delete_directory (const DBusString *filename, - DBusError *error) -{ - const char *filename_c; - - _DBUS_ASSERT_ERROR_IS_CLEAR (error); - - filename_c = _dbus_string_get_const_data (filename); - - if (rmdir (filename_c) != 0) - { - dbus_set_error (error, DBUS_ERROR_FAILED, - "Failed to remove directory %s: %s\n", - filename_c, _dbus_strerror (errno)); - return FALSE; - } - - return TRUE; -} - /** Checks if a file exists * * @param file full path to the file diff --git a/dbus/dbus-sysdeps-util-win.c b/dbus/dbus-sysdeps-util-win.c index e73dcbf..fe277e4 100644 --- a/dbus/dbus-sysdeps-util-win.c +++ b/dbus/dbus-sysdeps-util-win.c @@ -326,34 +326,6 @@ out0: #endif //DBUS_WINCE } -/** - * Removes a directory; Directory must be empty - * - * @param filename directory filename - * @param error initialized error object - * @returns #TRUE on success - */ -dbus_bool_t -_dbus_delete_directory (const DBusString *filename, - DBusError *error) -{ - const char *filename_c; - - _DBUS_ASSERT_ERROR_IS_CLEAR (error); - - filename_c = _dbus_string_get_const_data (filename); - - if (_rmdir (filename_c) != 0) - { - dbus_set_error (error, DBUS_ERROR_FAILED, - "Failed to remove directory %s: %s\n", - filename_c, strerror (errno)); - return FALSE; - } - - return TRUE; -} - void _dbus_init_system_log (void) { diff --git a/dbus/dbus-sysdeps-win.c b/dbus/dbus-sysdeps-win.c index f80bfd4..0cc7790 100644 --- a/dbus/dbus-sysdeps-win.c +++ b/dbus/dbus-sysdeps-win.c @@ -3681,6 +3681,34 @@ _dbus_win_warn_win_error (const char *message, dbus_error_free (&error); } +/** + * Removes a directory; Directory must be empty + * + * @param filename directory filename + * @param error initialized error object + * @returns #TRUE on success + */ +dbus_bool_t +_dbus_delete_directory (const DBusString *filename, + DBusError *error) +{ + const char *filename_c; + + _DBUS_ASSERT_ERROR_IS_CLEAR (error); + + filename_c = _dbus_string_get_const_data (filename); + + if (_rmdir (filename_c) != 0) + { + dbus_set_error (error, DBUS_ERROR_FAILED, + "Failed to remove directory %s: %s\n", + filename_c, strerror (errno)); + return FALSE; + } + + return TRUE; +} + /** @} end of sysdeps-win */ /* tests in dbus-sysdeps-util.c */ diff --git a/dbus/dbus-sysdeps-win.h b/dbus/dbus-sysdeps-win.h index ed118b0..c65caa8 100644 --- a/dbus/dbus-sysdeps-win.h +++ b/dbus/dbus-sysdeps-win.h @@ -91,12 +91,6 @@ dbus_bool_t _dbus_file_exists (const char *filename); dbus_bool_t _dbus_get_config_file_name(DBusString *config_file, char *s); -int _dbus_connect_tcp_socket_with_nonce (const char *host, - const char *port, - const char *family, - const char *noncefile, - DBusError *error); - #endif /** @} end of sysdeps-win.h */ diff --git a/dbus/dbus-sysdeps.h b/dbus/dbus-sysdeps.h index 1eebfde..7dd6c82 100644 --- a/dbus/dbus-sysdeps.h +++ b/dbus/dbus-sysdeps.h @@ -181,6 +181,11 @@ int _dbus_connect_tcp_socket (const char *host, const char *port, const char *family, DBusError *error); +int _dbus_connect_tcp_socket_with_nonce (const char *host, + const char *port, + const char *family, + const char *noncefile, + DBusError *error); int _dbus_listen_tcp_socket (const char *host, const char *port, const char *family, diff --git a/dbus/dbus-transport-socket.c b/dbus/dbus-transport-socket.c index 0b6b006..dc9933d 100644 --- a/dbus/dbus-transport-socket.c +++ b/dbus/dbus-transport-socket.c @@ -23,6 +23,7 @@ #include "dbus-internals.h" #include "dbus-connection-internal.h" +#include "dbus-nonce.h" #include "dbus-transport-socket.h" #include "dbus-transport-protected.h" #include "dbus-watch.h" -- 1.6.4.msysgit.0 From 09ab1c0f2ef40cbb4866e8c41e4f1ad29ae97671 Mon Sep 17 00:00:00 2001 From: Frank Osterfeld Date: Fri, 24 Jul 2009 10:39:54 +0100 Subject: [PATCH 092/114] with msvc, replace va_copy by assigning the va_lists (cherry picked from commit 42d613fc9284afaa9543549be26f32e503a58348) --- cmake/ConfigureChecks.cmake | 5 ++++- cmake/config.h.cmake | 2 ++ 2 files changed, 6 insertions(+), 1 deletions(-) diff --git a/cmake/ConfigureChecks.cmake b/cmake/ConfigureChecks.cmake index f42ce76..1e83d80 100644 --- a/cmake/ConfigureChecks.cmake +++ b/cmake/ConfigureChecks.cmake @@ -86,6 +86,9 @@ endif(SIZEOF_INT EQUAL 2) find_program(DOXYGEN doxygen) find_program(XMLTO xmlto) +if(MSVC) + SET(DBUS_VA_COPY_FUNC "_DBUS_VA_COPY_ASSIGN";) +else(MSVC) write_file("${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/cmake_try_compile.c" "#include void f (int i, ...) { va_list args1, args2; @@ -130,7 +133,7 @@ else(DBUS_HAVE_VA_COPY) SET(DBUS_VA_COPY_AS_ARRAY "1" CACHE STRING "'va_lists' cannot be copies as values") endif(DBUS_HAVE___VA_COPY) endif(DBUS_HAVE_VA_COPY) - +endif(MSVC) # _not_ MSVC #### Abstract sockets if (DBUS_ENABLE_ABSTRACT_SOCKETS) diff --git a/cmake/config.h.cmake b/cmake/config.h.cmake index 3461338..1a4e7fe 100644 --- a/cmake/config.h.cmake +++ b/cmake/config.h.cmake @@ -78,6 +78,8 @@ #cmakedefine DBUS_BUILD_X11 1 +#define _DBUS_VA_COPY_ASSIGN(a1,a2) { a1 = a2; } + #cmakedefine DBUS_VA_COPY_FUNC #if (defined DBUS_VA_COPY_FUNC) # define DBUS_VA_COPY @DBUS_VA_COPY_FUNC@ -- 1.6.4.msysgit.0 From bd1a545d57ba62e9d9fa067db9e5fd0deb3273b4 Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Wed, 21 Oct 2009 20:48:35 +0300 Subject: [PATCH 093/114] Don't bother with -Werror on Windows for now We have so many warnings --- configure.in | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/configure.in b/configure.in index 0fd11ec..2c74f61 100644 --- a/configure.in +++ b/configure.in @@ -1023,7 +1023,8 @@ ld_supports_flag() { fi } -if test x$USE_MAINTAINER_MODE = xyes; then +# Don't bother with -Werror on Windows for now, too many warnings +if test x$dbus_win != xyes -a x$USE_MAINTAINER_MODE = xyes; then if cc_supports_flag "-Werror"; then CFLAGS="$CFLAGS -Werror" fi -- 1.6.4.msysgit.0 From 2d0e19318edc39b4fb1a24435692a9d75bc7212d Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Wed, 21 Oct 2009 15:31:34 +0300 Subject: [PATCH 094/114] Use multi-byte string functions on Windows Don't walk through char arrays that contain strings in the system codepage char by char looking for '\\'. There are double-byte characters in East Asian codepages where the second byte is a '\\'. (cherry picked from commit 61316262da466993abbcba010c6bac90bb0b1d43) --- dbus/dbus-sysdeps-win.c | 22 +++++++++++++--------- 1 files changed, 13 insertions(+), 9 deletions(-) diff --git a/dbus/dbus-sysdeps-win.c b/dbus/dbus-sysdeps-win.c index 0cc7790..2a2619d 100644 --- a/dbus/dbus-sysdeps-win.c +++ b/dbus/dbus-sysdeps-win.c @@ -62,6 +62,7 @@ extern BOOL WINAPI ConvertSidToStringSidA (PSID Sid, LPSTR *StringSid); #include #include +#include #include #include #include @@ -3296,26 +3297,29 @@ _dbus_get_install_root(char *prefix, int len) char* p = 0; int i; DWORD pathLength; - int lastSlash; + char *lastSlash; SetLastError( 0 ); pathLength = GetModuleFileName(NULL, prefix, len); if ( pathLength == 0 || GetLastError() != 0 ) { *prefix = '\0'; return FALSE; } - lastSlash = -1; - for (i = 0; i < pathLength; ++i) - if (prefix[i] == '\\') - lastSlash = i; - if (lastSlash == -1) { + lastSlash = _mbsrchr(prefix, '\\'); + if (lastSlash == NULL) { *prefix = '\0'; return FALSE; } //cut off binary name - prefix[lastSlash+1] = 0; + lastSlash[1] = 0; + //cut possible "\\bin" - if (lastSlash > 3 && strncmp(prefix + lastSlash - 4, "\\bin", 4) == 0) - prefix[lastSlash-3] = 0; + + //this fails if we are in a double-byte system codepage and the + //folder's name happens to end with the *bytes* + //"\\bin"... (I.e. the second byte of some Han character and then + //the Latin "bin", but that is not likely I think... + if (lastSlash - prefix > 3 && strncmp(lastSlash - 4, "\\bin", 4) == 0) + lastSlash[-3] = 0; return TRUE; } -- 1.6.4.msysgit.0 From 541fbbc87da5ccf9eb6ff4e2eaa087f9b699f17c Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Wed, 21 Oct 2009 15:49:03 +0300 Subject: [PATCH 095/114] Look for config files also in the normal Unix-style location (cherry picked from commit 445d1f780fb916f9087c0d95e7594ee5a425d43f) --- dbus/dbus-sysdeps-win.c | 26 +++++++++++++++++++++----- 1 files changed, 21 insertions(+), 5 deletions(-) diff --git a/dbus/dbus-sysdeps-win.c b/dbus/dbus-sysdeps-win.c index 2a2619d..7939008 100644 --- a/dbus/dbus-sysdeps-win.c +++ b/dbus/dbus-sysdeps-win.c @@ -3328,7 +3328,9 @@ _dbus_get_install_root(char *prefix, int len) the following path layout install-root/ bin/dbus-daemon[d].exe - etc/.conf + etc/.conf *or* etc/dbus-1/.conf + (the former above is what dbus4win uses, the latter above is + what a "normal" Unix-style "make install" uses) build-root/ bin/dbus-daemon[d].exe @@ -3339,12 +3341,11 @@ _dbus_get_config_file_name(DBusString *config_file, char *s) { char path[MAX_PATH*2]; int path_size = sizeof(path); - int len = 4 + strlen(s); if (!_dbus_get_install_root(path,path_size)) return FALSE; - if(len > sizeof(path)-2) + if(strlen(s) + 4 + strlen(path) > sizeof(path)-2) return FALSE; strcat(path,"etc\\"); strcat(path,s); @@ -3358,9 +3359,9 @@ _dbus_get_config_file_name(DBusString *config_file, char *s) { if (!_dbus_get_install_root(path,path_size)) return FALSE; - if(len + strlen(path) > sizeof(path)-2) + if(strlen(s) + 11 + strlen(path) > sizeof(path)-2) return FALSE; - strcat(path,"bus\\"); + strcat(path,"etc\\dbus-1\\"); strcat(path,s); if (_dbus_file_exists(path)) @@ -3368,6 +3369,21 @@ _dbus_get_config_file_name(DBusString *config_file, char *s) if (!_dbus_string_append (config_file, path)) return FALSE; } + else + { + if (!_dbus_get_install_root(path,path_size)) + return FALSE; + if(strlen(s) + 4 + strlen(path) > sizeof(path)-2) + return FALSE; + strcat(path,"bus\\"); + strcat(path,s); + + if (_dbus_file_exists(path)) + { + if (!_dbus_string_append (config_file, path)) + return FALSE; + } + } } return TRUE; } -- 1.6.4.msysgit.0 From 9b246c1db774d4e36613dbc6be0bed6219d91875 Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Wed, 21 Oct 2009 21:07:31 +0300 Subject: [PATCH 096/114] Rename README.win to README.windbus to match its origin Also add it to EXTRA_DIST. --- Makefile.am | 3 +- README.win | 164 -------------------------------------------------------- README.windbus | 164 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 166 insertions(+), 165 deletions(-) delete mode 100644 README.win create mode 100644 README.windbus diff --git a/Makefile.am b/Makefile.am index ac31a7f..f521470 100644 --- a/Makefile.am +++ b/Makefile.am @@ -14,7 +14,8 @@ EXTRA_DIST = \ ChangeLog.pre-1-0 \ NEWS.pre-1-0 \ ChangeLog.pre-1-2 \ - NEWS.pre-1-2 + NEWS.pre-1-2 \ + README.windbus all-local: Doxyfile diff --git a/README.win b/README.win deleted file mode 100644 index 7646974..0000000 --- a/README.win +++ /dev/null @@ -1,164 +0,0 @@ ----------------------------------------- -Windows port of the freedesktop.org D-Bus ----------------------------------------- - -Requirements ------------- -- cmake version >= 2.4.4 see http://www.cmake.org -- installed libxml2 or libexpat from http://82.149.170.66/kde-windows/win32libs - -Build ------ - -unix -1. install cmake and libxml or libexpat -2. get dbus sources -3. mkdir dbus-build -4. cd dbus-build -5. cmake /cmake or cmake -DDBUS_USE_EXPAT=on /cmake in case libexpat should de used -5. make -6. make install - -win32 -1. Install your prefered compiler - - Mingw from www.mingw.org - - Visual C++ 2005 Express/Studio - -2. Install libxml2 or libexpat packages from - http://82.149.170.66/kde-windows/win32libs - into a subdir win32libs in your program installation eg - - german => "c:\Programme\win32libs" - - english => "c:\Program Files\win32libs" - -3. download and install the most recent CMake version from http://www.cmake.org/files/ - -4. apply dbus-win.patch: 'patch -p0 -i dbus-win.patch' - -5. open command shell and run in the created build folder which resides side by side - to the D-Bus sources: - - for mingw: - cmake -G "MinGW Makefiles" ..\\cmake - - for Visual C++ - cmake ..\\cmake - -7. build - - -Tests ------ -(when build with the Visual C++ IDE the *.exe files are -in the bin/Debug and bin/Release folder) - - - dbus library check - bin\dbus-test.exe .\test\data - - - bus daemon check - bin\bus-test.exe .\test\data - - - check available names - bin\test_names.exe - - - check if dbus-daemon is accessable - bin\dbus-send.exe --session --type=method_call --print-reply --dest=org.freedesktop.DBus / org.freedesktop.DBus.ListNames method return sender=org.freedesktop.DBus -> dest=:1.4 array [ string "org.freedesktop.DBus"string ":1.4"] - - - start dbus-daemon - * set DBUS_VERBOSE=0 (=1 for getting debug infos) - * start bin\dbus-daemon --session - * bin\dbus-send.exe --dest=org.freedesktop.DBus --print-reply --type=method_call / org.freedesktop.DBus.StartServiceByName string:org.freedesktop.DBus.TestSuiteEchoService uint32:455 method return sender=org.freedesktop.DBus -> dest=:1.8 uint32 2 - - - -Some build options -------------- - key description default value - --- ----------- ------------- -DBUS_USE_EXPAT "Use expat (== ON) or libxml2 (==OFF) OFF -DBUS_DISABLE_ASSERTS "Disable assertion checking" OFF -DBUS_BUILD_TESTS "enable unit test code" ON -DBUS_ENABLE_ANSI "enable -ansi -pedantic gcc flags" OFF -DBUS_ENABLE_GCOV "compile with coverage profiling - instrumentation (gcc only)" OFF -DBUS_ENABLE_VERBOSE_MODE "support verbose debug mode" ON -DBUS_DISABLE_CHECKS "Disable public API sanity checking" OFF -DBUS_INSTALL_SYSTEM_LIBS "install required system libraries - (mingw: libxml2, libiconv, mingw10)" OFF -CMAKE_BUILD_TYPE "build type (== debug) or (== release) release - - - -Developers ----------- - -Running the tests in Visual Studio: - - To successfully run the tests by the IDE you must add - the FULL patch to test\data in your build directory - (e.g. c:\dbus\build\test\data) - in something like - -> Project Settings - -> Debugging - -> Command line arguments - - - -FAQ ---- - -- How much work remains till DBUS win32 can be merged with the main project? - -There are some patches outstanding and the most effort is required in -discussions with the main dbus team how to implement some parts. One of -the main dbus team estimated the open work to one fulltime week. -http://lists.freedesktop.org/archives/dbus/2006-November/006264.html - -I assume they will answer ALL your questions, and they are very -interested in fully supporting win32. - -- How far is WinDBus from being usable for production ? -dbus comes with a test suite which is used on unix to guarantate -production quality and this test suite runs mostly. There are some -test not running and we need help to get them running. - -In the pratice I and some other people are using dbus for at least more -than a half year in conjunction with kde on windows without any problems. - - -- On UNIX D-Bus uses UNIX sockets to communicate (correct me if I'm wrong). - What is used on Windows ? - -tcp sockets, there are some efforts to get named pipe running, but some -design problems of the win32 api, we are not able to solve without -bigger changes to the dbus code base let us stop this effort. - - -- Do you have any clue if dbus-win32 can run in a Windows CE environment? - -I was told that windows ce does not have posix function -open/close/select/... and dbus code uses such function in some area. - - -- Do you know if the C++ binding made by OpenWengo will be easily portable to Windows? - -We have already ported the OpenWengo dbus-c++ binding, see in WinDBus svn (http://sf.net/projects/windbus) -The related test applicationa are running well. - - -TODO ----- - -February 2007: - -- all changes of dbus-win.patch should become part of the official D-Bus code - -- all code currently disabled by DBUS_WIN_FIXME should work - -- clean up: - * bus/bus-service-win.c - * bus/dir-watch.c - * dbus/dbus-spawn-win.c - * dbus/dbus-sysdeps-util-win.c - * dbus/dbus-sysdeps-win.c - - -see also: -http://lists.freedesktop.org/archives/dbus/2006-July/005076.html diff --git a/README.windbus b/README.windbus new file mode 100644 index 0000000..7646974 --- /dev/null +++ b/README.windbus @@ -0,0 +1,164 @@ +---------------------------------------- +Windows port of the freedesktop.org D-Bus +---------------------------------------- + +Requirements +------------ +- cmake version >= 2.4.4 see http://www.cmake.org +- installed libxml2 or libexpat from http://82.149.170.66/kde-windows/win32libs + +Build +----- + +unix +1. install cmake and libxml or libexpat +2. get dbus sources +3. mkdir dbus-build +4. cd dbus-build +5. cmake /cmake or cmake -DDBUS_USE_EXPAT=on /cmake in case libexpat should de used +5. make +6. make install + +win32 +1. Install your prefered compiler + - Mingw from www.mingw.org + - Visual C++ 2005 Express/Studio + +2. Install libxml2 or libexpat packages from + http://82.149.170.66/kde-windows/win32libs + into a subdir win32libs in your program installation eg + - german => "c:\Programme\win32libs" + - english => "c:\Program Files\win32libs" + +3. download and install the most recent CMake version from http://www.cmake.org/files/ + +4. apply dbus-win.patch: 'patch -p0 -i dbus-win.patch' + +5. open command shell and run in the created build folder which resides side by side + to the D-Bus sources: + - for mingw: + cmake -G "MinGW Makefiles" ..\\cmake + - for Visual C++ + cmake ..\\cmake + +7. build + + +Tests +----- +(when build with the Visual C++ IDE the *.exe files are +in the bin/Debug and bin/Release folder) + + - dbus library check + bin\dbus-test.exe .\test\data + + - bus daemon check + bin\bus-test.exe .\test\data + + - check available names + bin\test_names.exe + + - check if dbus-daemon is accessable + bin\dbus-send.exe --session --type=method_call --print-reply --dest=org.freedesktop.DBus / org.freedesktop.DBus.ListNames method return sender=org.freedesktop.DBus -> dest=:1.4 array [ string "org.freedesktop.DBus"string ":1.4"] + + - start dbus-daemon + * set DBUS_VERBOSE=0 (=1 for getting debug infos) + * start bin\dbus-daemon --session + * bin\dbus-send.exe --dest=org.freedesktop.DBus --print-reply --type=method_call / org.freedesktop.DBus.StartServiceByName string:org.freedesktop.DBus.TestSuiteEchoService uint32:455 method return sender=org.freedesktop.DBus -> dest=:1.8 uint32 2 + + + +Some build options +------------- + key description default value + --- ----------- ------------- +DBUS_USE_EXPAT "Use expat (== ON) or libxml2 (==OFF) OFF +DBUS_DISABLE_ASSERTS "Disable assertion checking" OFF +DBUS_BUILD_TESTS "enable unit test code" ON +DBUS_ENABLE_ANSI "enable -ansi -pedantic gcc flags" OFF +DBUS_ENABLE_GCOV "compile with coverage profiling + instrumentation (gcc only)" OFF +DBUS_ENABLE_VERBOSE_MODE "support verbose debug mode" ON +DBUS_DISABLE_CHECKS "Disable public API sanity checking" OFF +DBUS_INSTALL_SYSTEM_LIBS "install required system libraries + (mingw: libxml2, libiconv, mingw10)" OFF +CMAKE_BUILD_TYPE "build type (== debug) or (== release) release + + + +Developers +---------- + +Running the tests in Visual Studio: + + To successfully run the tests by the IDE you must add + the FULL patch to test\data in your build directory + (e.g. c:\dbus\build\test\data) + in something like + -> Project Settings + -> Debugging + -> Command line arguments + + + +FAQ +--- + +- How much work remains till DBUS win32 can be merged with the main project? + +There are some patches outstanding and the most effort is required in +discussions with the main dbus team how to implement some parts. One of +the main dbus team estimated the open work to one fulltime week. +http://lists.freedesktop.org/archives/dbus/2006-November/006264.html + +I assume they will answer ALL your questions, and they are very +interested in fully supporting win32. + +- How far is WinDBus from being usable for production ? +dbus comes with a test suite which is used on unix to guarantate +production quality and this test suite runs mostly. There are some +test not running and we need help to get them running. + +In the pratice I and some other people are using dbus for at least more +than a half year in conjunction with kde on windows without any problems. + + +- On UNIX D-Bus uses UNIX sockets to communicate (correct me if I'm wrong). + What is used on Windows ? + +tcp sockets, there are some efforts to get named pipe running, but some +design problems of the win32 api, we are not able to solve without +bigger changes to the dbus code base let us stop this effort. + + +- Do you have any clue if dbus-win32 can run in a Windows CE environment? + +I was told that windows ce does not have posix function +open/close/select/... and dbus code uses such function in some area. + + +- Do you know if the C++ binding made by OpenWengo will be easily portable to Windows? + +We have already ported the OpenWengo dbus-c++ binding, see in WinDBus svn (http://sf.net/projects/windbus) +The related test applicationa are running well. + + +TODO +---- + +February 2007: + +- all changes of dbus-win.patch should become part of the official D-Bus code + +- all code currently disabled by DBUS_WIN_FIXME should work + +- clean up: + * bus/bus-service-win.c + * bus/dir-watch.c + * dbus/dbus-spawn-win.c + * dbus/dbus-sysdeps-util-win.c + * dbus/dbus-sysdeps-win.c + + +see also: +http://lists.freedesktop.org/archives/dbus/2006-July/005076.html -- 1.6.4.msysgit.0 From d028bf6f3b6764147961ba7c865a4d19153dda1b Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Wed, 21 Oct 2009 21:11:10 +0300 Subject: [PATCH 097/114] Tell where the file comes from and that it might not be reliable --- README.windbus | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-) diff --git a/README.windbus b/README.windbus index 7646974..1dde5c8 100644 --- a/README.windbus +++ b/README.windbus @@ -1,3 +1,8 @@ +This README.windbus file below originates from the "windbus" fork. It +does not reflect reality here. Changes from both windbus and the +separate "dbus4win" fork have been merged into this code repository, +as applicable. + ---------------------------------------- Windows port of the freedesktop.org D-Bus ---------------------------------------- -- 1.6.4.msysgit.0 From 091c4d6dea58ee486eb296bdebceed556e84d33d Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Wed, 21 Oct 2009 21:14:22 +0300 Subject: [PATCH 098/114] Add file describing the merge of the dbus4win code --- README.dbus4win | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 71 insertions(+), 0 deletions(-) create mode 100644 README.dbus4win diff --git a/README.dbus4win b/README.dbus4win new file mode 100644 index 0000000..19c4e0c --- /dev/null +++ b/README.dbus4win @@ -0,0 +1,71 @@ +On 2009-10-21 I (Tor Lillqvist ) cherry-picked a bunch of +commits from the dbus4win-noncetcp branch of the dbus4win repository +to (my clone of) dbus upstream's master branch. + +The dbus4win repository is at least currently at +git://repo.or.cz/dbus4win.git + +I went through the commits done to the dbus4win-noncetcp branch since +the dbus-1.2.14 tag, i.e. commit f719d454329a1a54ff2d569feaf10ceee7cead50. + +The following commits were left out because they either 0) were +already upstream, 1) seemed broken, or 2) seemed pointless to me, +especially if the commit message didn't say much. For each commit left +out, below is three lines: its id, the first log comment line, and an +explanation why I left it out. + +f719d454329a1a54ff2d569feaf10ceee7cead50 +configure.in: not all gccs support -Wno-pointer-sign +already upstream + +6eddb6e1229b617ad44c8d61107983229dc7d589 +configure.in: fail abstract socket test gracefully when cross-compilin +already upstream + +c54dd9eefa5ed0d54be3b09cf30c12f05130fda1 +r783: one ifdef lesser +probably pointless + +93c288ca3e86e7760d3ac3fa6490257c1b6dc544 +r783: compile if ENOMEM or EINTR is undefined. +huh, ENOMEM and EINTR is defined in the Microsoft C library + +4f4ba13357da15c35a9d4ad111bf972a5d0d5db0 +r783: introduced _dbus_daemon_release() function called in _dbus_loop_quit()... +this can't be right, there can be nested dbus loops afaik + +124eb334324472a10de2c7e0a1455d353431f08f +unix build fixes against windbus-svn +can't be right to make a char* const when the code below then assigns through it + +594bd19a0c45822d8763871e3491d99beb4d22cb +introduce DBUS_DIR_SEPERATOR and make use of it. On windows, disable some system service tests +"forward" slashes work fine on Windows, no need to uglify code with DBUS_DIR_SEPARATOR + +cd2cdb3457f72cf058d5b19796ee691ceca6b52c +r783: introduced DBUS_CLEANUP_OLD_SERVICES that does cleanup prev zombie-instances... +unsure about this. something specific to KDE-on-Windows? + +eeedba5b2f5b008819619764943caddd52441adf +build fixes for OS X, xcode 3.1.2, gcc 4.2.1 +doesn't apply, seems to be upstream? + +7dc7f71cf3003e006f6e177b5460d14a7cdbf2de +configure.in: fix pthread detection +doesn't apply + +05b37fa87b1f6aa670de9007879f53a8198a7a89 +configure.in: suppress -fPIC, -fPIE for W32 +doesn't apply + +b0d14fed92d9f539cd3478e72dc2f3ea75f3941a +configure.in: only check for wspiapi.h on Windows +nah, no harm checking for it on UNIX too + +23945513e9a4da61d286ebfbce3897aa061ddbfe +replace dbus_daemon_init by dbus_publish_session_bus_address, publishing the... +doesn't apply, too complex, split into separate chunks + +1724fc10e516e2d570537d522d8608abba90be5e +prototypes cleanup +related to cd2cdb3457f72cf058d5b19796ee691ceca6b52c which was skipped above -- 1.6.4.msysgit.0 From 6f70e6ae4f0f303070eedd622b3a607df0ae58b1 Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Wed, 21 Oct 2009 21:49:50 +0300 Subject: [PATCH 099/114] Don't use -fPIC and -fPIE on Windows The MinGW compiler recognizes them but emits a warning "-fPIC ignored for target (all code is position independent)" --- configure.in | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.in b/configure.in index 2c74f61..30b7252 100644 --- a/configure.in +++ b/configure.in @@ -1093,7 +1093,7 @@ if test "x$GCC" = "xyes"; then case " $CFLAGS " in *[\ \ ]-fPIC[\ \ ]*) ;; - *) if cc_supports_flag -fPIC; then + *) if test x$dbus_win = xno && cc_supports_flag -fPIC; then PIC_CFLAGS="-fPIC" if ld_supports_flag -z,relro; then PIC_LDFLAGS="-Wl,-z,relro" @@ -1104,7 +1104,7 @@ if test "x$GCC" = "xyes"; then case " $CFLAGS " in *[\ \ ]-fPIE[\ \ ]*) ;; - *) if cc_supports_flag -fPIE; then + *) if test x$dbus_win = xno && cc_supports_flag -fPIE; then PIE_CFLAGS="-fPIE" if ld_supports_flag -z,relro; then PIE_LDFLAGS="-pie -Wl,-z,relro" -- 1.6.4.msysgit.0 From 82af675d2ea52c82a88a6b44ef7503ee1647c389 Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Wed, 21 Oct 2009 21:52:59 +0300 Subject: [PATCH 100/114] Don't use DBUS_DIR_SEPARATOR I didn't cherry-pick the commit from dbus4win that introduced DBUS_DIR_SEPARATOR, as I think it just uglifies the code with little gain. (Forward) slashes work fine on Windows. --- dbus/dbus-nonce.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/dbus/dbus-nonce.c b/dbus/dbus-nonce.c index 8385340..14afc2e 100644 --- a/dbus/dbus-nonce.c +++ b/dbus/dbus-nonce.c @@ -274,7 +274,7 @@ do_noncefile_create (DBusNonceFile *noncefile, } if (use_subdir) { - if (!_dbus_string_append (&noncefile->dir, DBUS_DIR_SEPARATOR "dbus_nonce-") + if (!_dbus_string_append (&noncefile->dir, "/dbus_nonce-") || !_dbus_string_append (&noncefile->dir, _dbus_string_get_const_data (&randomStr)) ) { dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL); @@ -282,7 +282,7 @@ do_noncefile_create (DBusNonceFile *noncefile, } if (!_dbus_string_init (&noncefile->path) || !_dbus_string_copy (&noncefile->dir, 0, &noncefile->path, 0) - || !_dbus_string_append (&noncefile->dir, DBUS_DIR_SEPARATOR "nonce")) + || !_dbus_string_append (&noncefile->dir, "/nonce")) { dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL); goto on_error; @@ -297,7 +297,7 @@ do_noncefile_create (DBusNonceFile *noncefile, { if (!_dbus_string_init (&noncefile->path) || !_dbus_string_copy (&noncefile->dir, 0, &noncefile->path, 0) - || !_dbus_string_append (&noncefile->path, DBUS_DIR_SEPARATOR "dbus_nonce-") + || !_dbus_string_append (&noncefile->path, "/dbus_nonce-") || !_dbus_string_append (&noncefile->path, _dbus_string_get_const_data (&randomStr))) { dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL); -- 1.6.4.msysgit.0 From d8cdc5f02d33049e52aa62f9d6f0b34489fbdead Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Wed, 21 Oct 2009 21:56:27 +0300 Subject: [PATCH 101/114] Add a dbus/dbus-1.def file From cmake/dbus/dbus-1.def.cmake --- dbus/dbus-1.def | 869 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 869 insertions(+), 0 deletions(-) create mode 100644 dbus/dbus-1.def diff --git a/dbus/dbus-1.def b/dbus/dbus-1.def new file mode 100644 index 0000000..1dd0e76 --- /dev/null +++ b/dbus/dbus-1.def @@ -0,0 +1,869 @@ +EXPORTS +_dbus_abort +_dbus_accept +_dbus_address_append_escaped +_dbus_address_test +_dbus_append_keyring_directory_for_credentials +_dbus_append_session_config_file +_dbus_append_system_config_file +_dbus_append_user_from_current_process +_dbus_atomic_dec +_dbus_atomic_inc +_dbus_auth_bytes_sent +_dbus_auth_client_new +_dbus_auth_decode_data +_dbus_auth_delete_unused_bytes +_dbus_auth_do_work +_dbus_auth_encode_data +_dbus_auth_get_buffer +_dbus_auth_get_bytes_to_send +_dbus_auth_get_guid_from_server +_dbus_auth_get_identity +_dbus_auth_get_unused_bytes +_dbus_auth_needs_decoding +_dbus_auth_needs_encoding +_dbus_auth_ref +_dbus_auth_return_buffer +_dbus_auth_script_run +_dbus_auth_server_new +_dbus_auth_set_context +_dbus_auth_set_credentials +_dbus_auth_set_mechanisms +_dbus_auth_test +_dbus_auth_unref +_dbus_babysitter_get_child_exited +_dbus_babysitter_get_child_exit_status +_dbus_babysitter_kill_child +_dbus_babysitter_ref +_dbus_babysitter_set_child_exit_error +_dbus_babysitter_set_watch_functions +_dbus_babysitter_unref +_dbus_become_daemon +_dbus_bus_notify_shared_connection_disconnected_unlocked +_dbus_change_identity +_dbus_change_to_daemon_user +_dbus_check_dir_is_private_to_user +_dbus_check_is_valid_bus_name +_dbus_check_is_valid_error_name +_dbus_check_is_valid_interface +_dbus_check_is_valid_member +_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 +_dbus_condvar_new +_dbus_condvar_new_at_location +_dbus_condvar_wait +_dbus_condvar_wait_timeout +_dbus_condvar_wake_all +_dbus_condvar_wake_one +_dbus_connect_tcp_socket +_dbus_connection_add_timeout_unlocked +_dbus_connection_add_watch_unlocked +_dbus_connection_block_pending_call +_dbus_connection_close_if_only_one_ref +_dbus_connection_close_possibly_shared +_dbus_connection_do_iteration_unlocked +_dbus_connection_get_message_to_send +_dbus_connection_handle_watch +_dbus_connection_has_messages_to_send_unlocked +_dbus_connection_lock +_dbus_connection_message_sent +_dbus_connection_new_for_transport +_dbus_connection_queue_received_message +_dbus_connection_queue_received_message_link +_dbus_connection_queue_synthesized_message_link +_dbus_connection_ref_unlocked +_dbus_connection_remove_pending_call +_dbus_connection_remove_timeout_unlocked +_dbus_connection_remove_watch_unlocked +_dbus_connection_send_and_unlock +_dbus_connection_test_get_locks +_dbus_connection_toggle_timeout_unlocked +_dbus_connection_toggle_watch_unlocked +_dbus_connection_unlock +_dbus_connection_unref_unlocked +_dbus_counter_adjust +_dbus_counter_get_value +_dbus_counter_new +_dbus_counter_ref +_dbus_counter_set_notify +_dbus_counter_unref +_dbus_create_directory +_dbus_create_file_exclusively +_dbus_credentials_add_credential +_dbus_credentials_add_credentials +_dbus_credentials_add_from_current_process +_dbus_credentials_add_from_user +_dbus_credentials_add_unix_pid +_dbus_credentials_add_unix_uid +_dbus_credentials_add_windows_sid +_dbus_credentials_are_anonymous +_dbus_credentials_are_empty +_dbus_credentials_are_superset +_dbus_credentials_clear +_dbus_credentials_copy +_dbus_credentials_get_unix_pid +_dbus_credentials_get_unix_uid +_dbus_credentials_get_windows_sid +_dbus_credentials_include +_dbus_credentials_new +_dbus_credentials_new_from_current_process +_dbus_credentials_ref +_dbus_credentials_same_user +_dbus_credentials_test +_dbus_credentials_unref +_dbus_current_generation DATA +_dbus_daemon_publish_session_bus_address +_dbus_data_slot_allocator_alloc +_dbus_data_slot_allocator_free +_dbus_data_slot_allocator_init +_dbus_data_slot_list_clear +_dbus_data_slot_list_free +_dbus_data_slot_list_get +_dbus_data_slot_list_init +_dbus_data_slot_list_set +_dbus_data_slot_test +_dbus_decompose_path +_dbus_decrement_fail_alloc_counter +_dbus_delete_directory +_dbus_delete_file +_dbus_directory_close +_dbus_directory_get_next_file +_dbus_directory_open +_dbus_disable_mem_pools +_dbus_disable_sigpipe +_dbus_dup_string_array +_dbus_error_from_errno +_dbus_exit +_dbus_fd_set_close_on_exec +_dbus_file_exists +_dbus_file_get_contents +_dbus_first_type_in_signature +_dbus_first_type_in_signature_c_str +_dbus_flush_caches +_dbus_full_duplex_pipe +_dbus_generate_pseudorandom_bytes_buffer +_dbus_generate_random_ascii +_dbus_generate_random_bytes +_dbus_generate_random_bytes_buffer +_dbus_generate_uuid +_dbus_get_autolaunch_address +_dbus_get_config_file_name +_dbus_get_current_time +_dbus_get_environment +_dbus_get_fail_alloc_counter +_dbus_get_fail_alloc_failures +_dbus_get_install_root +_dbus_get_is_errno_eagain_or_ewouldblock +_dbus_get_is_errno_eintr +_dbus_get_is_errno_enomem +_dbus_get_is_errno_nonzero +_dbus_get_local_machine_uuid_encoded +_dbus_get_malloc_blocks_outstanding +_dbus_get_oom_wait +_dbus_get_standard_session_servicedirs +_dbus_get_standard_system_servicedirs +_dbus_get_tmpdir +_dbus_getenv +_dbus_getgid +_dbus_getpid +_dbus_getsid +_dbus_getuid +_dbus_hash_iter_get_int_key +_dbus_hash_iter_get_string_key +_dbus_hash_iter_get_two_strings_key +_dbus_hash_iter_get_ulong_key +_dbus_hash_iter_get_value +_dbus_hash_iter_init +_dbus_hash_iter_lookup +_dbus_hash_iter_next +_dbus_hash_iter_remove_entry +_dbus_hash_iter_set_value +_dbus_hash_table_free_preallocated_entry +_dbus_hash_table_get_n_entries +_dbus_hash_table_insert_int +_dbus_hash_table_insert_pointer +_dbus_hash_table_insert_string +_dbus_hash_table_insert_string_preallocated +_dbus_hash_table_insert_two_strings +_dbus_hash_table_insert_ulong +_dbus_hash_table_lookup_int +_dbus_hash_table_lookup_pointer +_dbus_hash_table_lookup_string +_dbus_hash_table_lookup_two_strings +_dbus_hash_table_lookup_ulong +_dbus_hash_table_new +_dbus_hash_table_preallocate_entry +_dbus_hash_table_ref +_dbus_hash_table_remove_all +_dbus_hash_table_remove_int +_dbus_hash_table_remove_pointer +_dbus_hash_table_remove_string +_dbus_hash_table_remove_two_strings +_dbus_hash_table_remove_ulong +_dbus_hash_table_unref +_dbus_hash_test +_dbus_header_byteswap +_dbus_header_copy +_dbus_header_create +_dbus_header_delete_field +_dbus_header_field_to_string +_dbus_header_free +_dbus_header_get_field_basic +_dbus_header_get_field_raw +_dbus_header_get_flag +_dbus_header_get_message_type +_dbus_header_get_serial +_dbus_header_have_message_untrusted +_dbus_header_init +_dbus_header_load +_dbus_header_reinit +_dbus_header_set_field_basic +_dbus_header_set_serial +_dbus_header_toggle_flag +_dbus_header_update_lengths +_dbus_init_system_log +_dbus_is_verbose_real +_dbus_keyring_get_best_key +_dbus_keyring_get_hex_key +_dbus_keyring_is_for_credentials +_dbus_keyring_new_for_credentials +_dbus_keyring_ref +_dbus_keyring_test +_dbus_keyring_unref +_dbus_keyring_validate_context +_dbus_list_alloc_link +_dbus_list_append +_dbus_list_append_link +_dbus_list_clear +_dbus_list_copy +_dbus_list_find_last +_dbus_list_foreach +_dbus_list_free_link +_dbus_list_get_first +_dbus_list_get_first_link +_dbus_list_get_last +_dbus_list_get_last_link +_dbus_list_get_length +_dbus_list_insert_after +_dbus_list_insert_after_link +_dbus_list_insert_before +_dbus_list_insert_before_link +_dbus_list_length_is_one +_dbus_list_pop_first +_dbus_list_pop_first_link +_dbus_list_pop_last +_dbus_list_pop_last_link +_dbus_list_prepend +_dbus_list_prepend_link +_dbus_list_remove +_dbus_list_remove_last +_dbus_list_remove_link +_dbus_list_test +_dbus_list_unlink +_dbus_listen_tcp_socket +_dbus_lm_strerror +_dbus_lock_atomic DATA +_dbus_lock_bus DATA +_dbus_lock_bus_datas DATA +_dbus_lock_connection_slots DATA +_dbus_lock_list DATA +_dbus_lock_machine_uuid DATA +_dbus_lock_message_cache DATA +_dbus_lock_message_slots DATA +_dbus_lock_pending_call_slots DATA +_dbus_lock_server_slots DATA +_dbus_lock_shared_connections DATA +_dbus_lock_shutdown_funcs DATA +_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 +_dbus_loop_iterate +_dbus_loop_new +_dbus_loop_queue_dispatch +_dbus_loop_quit +_dbus_loop_ref +_dbus_loop_remove_timeout +_dbus_loop_remove_watch +_dbus_loop_run +_dbus_loop_unref +_dbus_make_file_world_readable +_dbus_marshal_byteswap +_dbus_marshal_byteswap_test +_dbus_marshal_header_test +_dbus_marshal_read_basic +_dbus_marshal_read_fixed_multi +_dbus_marshal_read_uint32 +_dbus_marshal_recursive_test +_dbus_marshal_set_basic +_dbus_marshal_set_uint32 +_dbus_marshal_skip_array +_dbus_marshal_skip_basic +_dbus_marshal_test +_dbus_marshal_validate_test +_dbus_marshal_write_basic +_dbus_marshal_write_fixed_multi +_dbus_mem_pool_alloc +_dbus_mem_pool_dealloc +_dbus_mem_pool_free +_dbus_mem_pool_new +_dbus_mem_pool_test +_dbus_memdup +_dbus_memory_test +_dbus_message_add_size_counter +_dbus_message_add_size_counter_link +_dbus_message_data_free +_dbus_message_data_iter_get_and_next +_dbus_message_data_iter_init +_dbus_message_get_network_data +_dbus_message_iter_get_args_valist +_dbus_message_loader_get_buffer +_dbus_message_loader_get_is_corrupted +_dbus_message_loader_get_max_message_size +_dbus_message_loader_new +_dbus_message_loader_peek_message +_dbus_message_loader_pop_message +_dbus_message_loader_pop_message_link +_dbus_message_loader_putback_message_link +_dbus_message_loader_queue_messages +_dbus_message_loader_ref +_dbus_message_loader_return_buffer +_dbus_message_loader_set_max_message_size +_dbus_message_loader_unref +_dbus_message_remove_size_counter +_dbus_message_test +_dbus_misc_test +_dbus_mutex_free +_dbus_mutex_free_at_location +_dbus_mutex_lock +_dbus_mutex_new +_dbus_mutex_new_at_location +_dbus_mutex_unlock +_dbus_no_memory_message +_dbus_object_tree_dispatch_and_unlock +_dbus_object_tree_free_all_unlocked +_dbus_object_tree_get_user_data_unlocked +_dbus_object_tree_list_registered_and_unlock +_dbus_object_tree_new +_dbus_object_tree_ref +_dbus_object_tree_register +_dbus_object_tree_test +_dbus_object_tree_unref +_dbus_object_tree_unregister_and_unlock +_dbus_pack_uint32 +_dbus_parse_unix_group_from_config +_dbus_parse_unix_user_from_config +_dbus_path_is_absolute +_dbus_pending_call_complete +_dbus_pending_call_get_completed_unlocked +_dbus_pending_call_get_connection_and_lock +_dbus_pending_call_get_connection_unlocked +_dbus_pending_call_get_reply_serial_unlocked +_dbus_pending_call_get_timeout_unlocked +_dbus_pending_call_is_timeout_added_unlocked +_dbus_pending_call_new_unlocked +_dbus_pending_call_queue_timeout_error_unlocked +_dbus_pending_call_ref_unlocked +_dbus_pending_call_set_data_unlocked +_dbus_pending_call_set_reply_serial_unlocked +_dbus_pending_call_set_reply_unlocked +_dbus_pending_call_set_timeout_added_unlocked +_dbus_pending_call_set_timeout_error_unlocked +_dbus_pending_call_test +_dbus_pending_call_unref_and_unlock +_dbus_pid_for_log +_dbus_pipe_close +_dbus_pipe_init +_dbus_pipe_init_stdout +_dbus_pipe_invalidate +_dbus_pipe_is_stdout_or_stderr +_dbus_pipe_is_valid +_dbus_pipe_write +_dbus_poll +_dbus_print_backtrace +_dbus_printf_string_upper_bound +_dbus_read_credentials_socket +_dbus_read_local_machine_uuid +_dbus_read_socket +_dbus_read_uuid_file +_dbus_real_assert +_dbus_real_assert_not_reached +_dbus_register_shutdown_func +_dbus_return_if_fail_warning_format DATA +_dbus_send_credentials_socket +_dbus_server_add_timeout +_dbus_server_add_watch +_dbus_server_debug_pipe_new +_dbus_server_finalize_base +_dbus_server_init_base +_dbus_server_listen_debug_pipe +_dbus_server_listen_platform_specific +_dbus_server_listen_socket +_dbus_server_new_for_socket +_dbus_server_new_for_tcp_socket +_dbus_server_ref_unlocked +_dbus_server_remove_timeout +_dbus_server_remove_watch +_dbus_server_socket_own_filename +_dbus_server_test +_dbus_server_toggle_timeout +_dbus_server_toggle_watch +_dbus_server_unref_unlocked +_dbus_set_bad_address +_dbus_set_errno_to_zero +_dbus_set_fail_alloc_counter +_dbus_set_fail_alloc_failures +_dbus_set_fd_nonblocking +_dbus_set_signal_handler +_dbus_setenv +_dbus_sha_compute +_dbus_sha_final +_dbus_sha_init +_dbus_sha_test +_dbus_sha_update +_dbus_shell_parse_argv +_dbus_shell_unquote +_dbus_signature_test +_dbus_sleep_milliseconds +_dbus_spawn_async_with_babysitter +_dbus_spawn_test +_dbus_split_paths_and_append +_dbus_stat +_dbus_strdup +_dbus_strerror +_dbus_strerror_from_errno +_dbus_string_align_length +_dbus_string_alloc_space +_dbus_string_append +_dbus_string_append_4_aligned +_dbus_string_append_8_aligned +_dbus_string_append_byte +_dbus_string_append_byte_as_hex +_dbus_string_append_double +_dbus_string_append_int +_dbus_string_append_len +_dbus_string_append_printf +_dbus_string_append_printf_valist +_dbus_string_append_uint +_dbus_string_append_unichar +_dbus_string_array_contains +_dbus_string_chop_white +_dbus_string_copy +_dbus_string_copy_data +_dbus_string_copy_data_len +_dbus_string_copy_len +_dbus_string_copy_to_buffer +_dbus_string_delete +_dbus_string_delete_first_word +_dbus_string_delete_leading_blanks +_dbus_string_ends_with_c_str +_dbus_string_equal +_dbus_string_equal_c_str +_dbus_string_equal_len +_dbus_string_equal_substring +_dbus_string_find +_dbus_string_find_blank +_dbus_string_find_byte_backward +_dbus_string_find_eol +_dbus_string_find_to +_dbus_string_free +_dbus_string_get_byte +_dbus_string_get_const_data +_dbus_string_get_const_data_len +_dbus_string_get_data +_dbus_string_get_data_len +_dbus_string_get_dirname +_dbus_string_get_length +_dbus_string_get_unichar +_dbus_string_hex_decode +_dbus_string_hex_encode +_dbus_string_init +_dbus_string_init_const +_dbus_string_init_const_len +_dbus_string_init_preallocated +_dbus_string_insert_2_aligned +_dbus_string_insert_4_aligned +_dbus_string_insert_8_aligned +_dbus_string_insert_alignment +_dbus_string_insert_byte +_dbus_string_insert_bytes +_dbus_string_lengthen +_dbus_string_lock +_dbus_string_move +_dbus_string_move_len +_dbus_string_parse_double +_dbus_string_parse_int +_dbus_string_parse_uint +_dbus_string_pop_line +_dbus_string_replace_len +_dbus_string_save_to_file +_dbus_string_set_byte +_dbus_string_set_length +_dbus_string_shorten +_dbus_string_skip_blank +_dbus_string_skip_white +_dbus_string_skip_white_reverse +_dbus_string_split_on_byte +_dbus_string_starts_with_c_str +_dbus_string_steal_data +_dbus_string_steal_data_len +_dbus_string_test +_dbus_string_validate_ascii +_dbus_string_validate_nul +_dbus_string_validate_utf8 +_dbus_string_zero +_dbus_swap_array +_dbus_sysdeps_test +_dbus_test_oom_handling +_dbus_threads_init_debug +_dbus_threads_init_platform_specific +_dbus_timeout_list_add_timeout +_dbus_timeout_list_free +_dbus_timeout_list_new +_dbus_timeout_list_remove_timeout +_dbus_timeout_list_set_functions +_dbus_timeout_list_toggle_timeout +_dbus_timeout_new +_dbus_timeout_ref +_dbus_timeout_set_enabled +_dbus_timeout_set_interval +_dbus_timeout_unref +_dbus_transport_debug_pipe_new +_dbus_transport_disconnect +_dbus_transport_do_iteration +_dbus_transport_finalize_base +_dbus_transport_get_address +_dbus_transport_get_adt_audit_session_data +_dbus_transport_get_dispatch_status +_dbus_transport_get_is_anonymous +_dbus_transport_get_is_authenticated +_dbus_transport_get_is_connected +_dbus_transport_get_max_message_size +_dbus_transport_get_max_received_size +_dbus_transport_get_server_id +_dbus_transport_get_socket_fd +_dbus_transport_get_unix_process_id +_dbus_transport_get_unix_user +_dbus_transport_get_windows_user +_dbus_transport_handle_watch +_dbus_transport_init_base +_dbus_transport_new_for_socket +_dbus_transport_new_for_tcp_socket +_dbus_transport_open +_dbus_transport_open_debug_pipe +_dbus_transport_open_platform_specific +_dbus_transport_open_socket +_dbus_transport_queue_messages +_dbus_transport_ref +_dbus_transport_set_allow_anonymous +_dbus_transport_set_auth_mechanisms +_dbus_transport_set_connection +_dbus_transport_set_max_message_size +_dbus_transport_set_max_received_size +_dbus_transport_set_unix_user_function +_dbus_transport_set_windows_user_function +_dbus_transport_unref +_dbus_type_get_alignment +_dbus_type_is_valid +_dbus_type_reader_delete +_dbus_type_reader_equal_values +_dbus_type_reader_get_array_length +_dbus_type_reader_get_current_type +_dbus_type_reader_get_element_type +_dbus_type_reader_get_signature +_dbus_type_reader_get_value_pos +_dbus_type_reader_greater_than +_dbus_type_reader_has_next +_dbus_type_reader_init +_dbus_type_reader_init_types_only +_dbus_type_reader_next +_dbus_type_reader_read_basic +_dbus_type_reader_read_fixed_multi +_dbus_type_reader_read_raw +_dbus_type_reader_recurse +_dbus_type_reader_set_basic +_dbus_type_signature_next +_dbus_type_to_string +_dbus_type_writer_add_types +_dbus_type_writer_append_array +_dbus_type_writer_init +_dbus_type_writer_init_types_delayed +_dbus_type_writer_init_values_only +_dbus_type_writer_recurse +_dbus_type_writer_remove_types +_dbus_type_writer_set_enabled +_dbus_type_writer_unrecurse +_dbus_type_writer_write_basic +_dbus_type_writer_write_fixed_multi +_dbus_type_writer_write_reader +_dbus_type_writer_write_reader_partial +_dbus_unix_groups_from_uid +_dbus_unix_user_is_at_console +_dbus_unix_user_is_process_owner +_dbus_unpack_uint16 +_dbus_unpack_uint32 +_dbus_user_at_console +_dbus_uuid_encode +_dbus_validate_body_with_reason +_dbus_validate_bus_name +_dbus_validate_error_name +_dbus_validate_interface +_dbus_validate_member +_dbus_validate_path +_dbus_validate_signature +_dbus_validate_signature_with_reason +_dbus_verbose_bytes +_dbus_verbose_bytes_of_string +_dbus_verbose_real +_dbus_verbose_reset_real +_dbus_verify_daemon_user +_dbus_wait_for_memory +_dbus_warn +_dbus_warn_check_failed +_dbus_watch_invalidate +_dbus_watch_list_add_watch +_dbus_watch_list_free +_dbus_watch_list_new +_dbus_watch_list_remove_watch +_dbus_watch_list_set_functions +_dbus_watch_list_toggle_watch +_dbus_watch_new +_dbus_watch_ref +_dbus_watch_sanitize_condition +_dbus_watch_set_handler +_dbus_watch_unref +_dbus_win_account_to_sid +_dbus_win_set_error_from_win_error +_dbus_win_startup_winsock +_dbus_win_utf16_to_utf8 +_dbus_win_utf8_to_utf16 +_dbus_win_warn_win_error +_dbus_windows_user_is_process_owner +_dbus_write_pid_to_file_and_pipe +_dbus_write_socket +_dbus_write_socket_two +dbus_address_entries_free +dbus_address_entry_get_method +dbus_address_entry_get_value +dbus_address_escape_value +dbus_address_unescape_value +dbus_bus_add_match +dbus_bus_get +dbus_bus_get_id +dbus_bus_get_private +dbus_bus_get_unique_name +dbus_bus_get_unix_user +dbus_bus_name_has_owner +dbus_bus_register +dbus_bus_release_name +dbus_bus_remove_match +dbus_bus_request_name +dbus_bus_set_unique_name +dbus_bus_start_service_by_name +dbus_connection_add_filter +dbus_connection_allocate_data_slot +dbus_connection_borrow_message +dbus_connection_close +dbus_connection_dispatch +dbus_connection_flush +dbus_connection_free_data_slot +dbus_connection_free_preallocated_send +dbus_connection_get_adt_audit_session_data +dbus_connection_get_data +dbus_connection_get_dispatch_status +dbus_connection_get_is_anonymous +dbus_connection_get_is_authenticated +dbus_connection_get_is_connected +dbus_connection_get_max_message_size +dbus_connection_get_max_received_size +dbus_connection_get_object_path_data +dbus_connection_get_outgoing_size +dbus_connection_get_server_id +dbus_connection_get_socket +dbus_connection_get_unix_fd +dbus_connection_get_unix_process_id +dbus_connection_get_unix_user +dbus_connection_get_windows_user +dbus_connection_has_messages_to_send +dbus_connection_list_registered +dbus_connection_open +dbus_connection_open_private +dbus_connection_pop_message +dbus_connection_preallocate_send +dbus_connection_read_write +dbus_connection_read_write_dispatch +dbus_connection_ref +dbus_connection_register_fallback +dbus_connection_register_object_path +dbus_connection_remove_filter +dbus_connection_return_message +dbus_connection_send +dbus_connection_send_preallocated +dbus_connection_send_with_reply +dbus_connection_send_with_reply_and_block +dbus_connection_set_allow_anonymous +dbus_connection_set_change_sigpipe +dbus_connection_set_data +dbus_connection_set_dispatch_status_function +dbus_connection_set_exit_on_disconnect +dbus_connection_set_max_message_size +dbus_connection_set_max_received_size +dbus_connection_set_route_peer_messages +dbus_connection_set_timeout_functions +dbus_connection_set_unix_user_function +dbus_connection_set_wakeup_main_function +dbus_connection_set_watch_functions +dbus_connection_set_windows_user_function +dbus_connection_steal_borrowed_message +dbus_connection_unref +dbus_connection_unregister_object_path +dbus_error_free +dbus_error_has_name +dbus_error_init +dbus_error_is_set +dbus_free +dbus_free_string_array +dbus_get_local_machine_id +dbus_internal_do_not_use_foreach_message_file +dbus_internal_do_not_use_generate_bodies +dbus_internal_do_not_use_load_message_file +dbus_internal_do_not_use_run_tests +dbus_internal_do_not_use_try_message_data +dbus_internal_do_not_use_try_message_file +dbus_malloc +dbus_malloc0 +dbus_message_allocate_data_slot +dbus_message_append_args +dbus_message_append_args_valist +dbus_message_copy +dbus_message_demarshal +dbus_message_free_data_slot +dbus_message_get_args +dbus_message_get_args_valist +dbus_message_get_auto_start +dbus_message_get_data +dbus_message_get_destination +dbus_message_get_error_name +dbus_message_get_interface +dbus_message_get_member +dbus_message_get_no_reply +dbus_message_get_path +dbus_message_get_path_decomposed +dbus_message_get_reply_serial +dbus_message_get_sender +dbus_message_get_serial +dbus_message_get_signature +dbus_message_get_type +dbus_message_has_destination +dbus_message_has_interface +dbus_message_has_member +dbus_message_has_path +dbus_message_has_sender +dbus_message_has_signature +dbus_message_is_error +dbus_message_is_method_call +dbus_message_is_signal +dbus_message_iter_append_basic +dbus_message_iter_append_fixed_array +dbus_message_iter_close_container +dbus_message_iter_get_arg_type +dbus_message_iter_get_array_len +dbus_message_iter_get_basic +dbus_message_iter_get_element_type +dbus_message_iter_get_fixed_array +dbus_message_iter_get_signature +dbus_message_iter_has_next +dbus_message_iter_init +dbus_message_iter_init_append +dbus_message_iter_next +dbus_message_iter_open_container +dbus_message_iter_recurse +dbus_message_marshal +dbus_message_new +dbus_message_new_error +dbus_message_new_error_printf +dbus_message_new_method_call +dbus_message_new_method_return +dbus_message_new_signal +dbus_message_ref +dbus_message_set_auto_start +dbus_message_set_data +dbus_message_set_destination +dbus_message_set_error_name +dbus_message_set_interface +dbus_message_set_member +dbus_message_set_no_reply +dbus_message_set_path +dbus_message_set_reply_serial +dbus_message_set_sender +dbus_message_type_from_string +dbus_message_type_to_string +dbus_message_unref +dbus_move_error +dbus_parse_address +dbus_pending_call_allocate_data_slot +dbus_pending_call_block +dbus_pending_call_cancel +dbus_pending_call_free_data_slot +dbus_pending_call_get_completed +dbus_pending_call_get_data +dbus_pending_call_ref +dbus_pending_call_set_data +dbus_pending_call_set_notify +dbus_pending_call_steal_reply +dbus_pending_call_unref +dbus_realloc +dbus_server_allocate_data_slot +dbus_server_disconnect +dbus_server_free_data_slot +dbus_server_get_address +dbus_server_get_data +dbus_server_get_id +dbus_server_get_is_connected +dbus_server_listen +dbus_server_ref +dbus_server_set_auth_mechanisms +dbus_server_set_data +dbus_server_set_new_connection_function +dbus_server_set_timeout_functions +dbus_server_set_watch_functions +dbus_server_unref +dbus_set_error +dbus_set_error_const +dbus_set_error_from_message +dbus_shutdown +dbus_signature_iter_get_current_type +dbus_signature_iter_get_element_type +dbus_signature_iter_get_signature +dbus_signature_iter_init +dbus_signature_iter_next +dbus_signature_iter_recurse +dbus_signature_validate +dbus_signature_validate_single +dbus_threads_init +dbus_threads_init_default +dbus_timeout_get_data +dbus_timeout_get_enabled +dbus_timeout_get_interval +dbus_timeout_handle +dbus_timeout_set_data +dbus_type_is_basic +dbus_type_is_container +dbus_type_is_fixed +dbus_watch_get_data +dbus_watch_get_enabled +dbus_watch_get_fd +dbus_watch_get_flags +dbus_watch_get_socket +dbus_watch_get_unix_fd +dbus_watch_handle +dbus_watch_set_data -- 1.6.4.msysgit.0 From 22b47ae8e1ed005c5e6c95947750e54a73ce4825 Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Wed, 21 Oct 2009 22:03:17 +0300 Subject: [PATCH 102/114] Drop internal symbols, add missing symbols --- dbus/dbus-1.def | 672 ++----------------------------------------------------- 1 files changed, 14 insertions(+), 658 deletions(-) diff --git a/dbus/dbus-1.def b/dbus/dbus-1.def index 1dd0e76..48d1d1f 100644 --- a/dbus/dbus-1.def +++ b/dbus/dbus-1.def @@ -1,656 +1,4 @@ EXPORTS -_dbus_abort -_dbus_accept -_dbus_address_append_escaped -_dbus_address_test -_dbus_append_keyring_directory_for_credentials -_dbus_append_session_config_file -_dbus_append_system_config_file -_dbus_append_user_from_current_process -_dbus_atomic_dec -_dbus_atomic_inc -_dbus_auth_bytes_sent -_dbus_auth_client_new -_dbus_auth_decode_data -_dbus_auth_delete_unused_bytes -_dbus_auth_do_work -_dbus_auth_encode_data -_dbus_auth_get_buffer -_dbus_auth_get_bytes_to_send -_dbus_auth_get_guid_from_server -_dbus_auth_get_identity -_dbus_auth_get_unused_bytes -_dbus_auth_needs_decoding -_dbus_auth_needs_encoding -_dbus_auth_ref -_dbus_auth_return_buffer -_dbus_auth_script_run -_dbus_auth_server_new -_dbus_auth_set_context -_dbus_auth_set_credentials -_dbus_auth_set_mechanisms -_dbus_auth_test -_dbus_auth_unref -_dbus_babysitter_get_child_exited -_dbus_babysitter_get_child_exit_status -_dbus_babysitter_kill_child -_dbus_babysitter_ref -_dbus_babysitter_set_child_exit_error -_dbus_babysitter_set_watch_functions -_dbus_babysitter_unref -_dbus_become_daemon -_dbus_bus_notify_shared_connection_disconnected_unlocked -_dbus_change_identity -_dbus_change_to_daemon_user -_dbus_check_dir_is_private_to_user -_dbus_check_is_valid_bus_name -_dbus_check_is_valid_error_name -_dbus_check_is_valid_interface -_dbus_check_is_valid_member -_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 -_dbus_condvar_new -_dbus_condvar_new_at_location -_dbus_condvar_wait -_dbus_condvar_wait_timeout -_dbus_condvar_wake_all -_dbus_condvar_wake_one -_dbus_connect_tcp_socket -_dbus_connection_add_timeout_unlocked -_dbus_connection_add_watch_unlocked -_dbus_connection_block_pending_call -_dbus_connection_close_if_only_one_ref -_dbus_connection_close_possibly_shared -_dbus_connection_do_iteration_unlocked -_dbus_connection_get_message_to_send -_dbus_connection_handle_watch -_dbus_connection_has_messages_to_send_unlocked -_dbus_connection_lock -_dbus_connection_message_sent -_dbus_connection_new_for_transport -_dbus_connection_queue_received_message -_dbus_connection_queue_received_message_link -_dbus_connection_queue_synthesized_message_link -_dbus_connection_ref_unlocked -_dbus_connection_remove_pending_call -_dbus_connection_remove_timeout_unlocked -_dbus_connection_remove_watch_unlocked -_dbus_connection_send_and_unlock -_dbus_connection_test_get_locks -_dbus_connection_toggle_timeout_unlocked -_dbus_connection_toggle_watch_unlocked -_dbus_connection_unlock -_dbus_connection_unref_unlocked -_dbus_counter_adjust -_dbus_counter_get_value -_dbus_counter_new -_dbus_counter_ref -_dbus_counter_set_notify -_dbus_counter_unref -_dbus_create_directory -_dbus_create_file_exclusively -_dbus_credentials_add_credential -_dbus_credentials_add_credentials -_dbus_credentials_add_from_current_process -_dbus_credentials_add_from_user -_dbus_credentials_add_unix_pid -_dbus_credentials_add_unix_uid -_dbus_credentials_add_windows_sid -_dbus_credentials_are_anonymous -_dbus_credentials_are_empty -_dbus_credentials_are_superset -_dbus_credentials_clear -_dbus_credentials_copy -_dbus_credentials_get_unix_pid -_dbus_credentials_get_unix_uid -_dbus_credentials_get_windows_sid -_dbus_credentials_include -_dbus_credentials_new -_dbus_credentials_new_from_current_process -_dbus_credentials_ref -_dbus_credentials_same_user -_dbus_credentials_test -_dbus_credentials_unref -_dbus_current_generation DATA -_dbus_daemon_publish_session_bus_address -_dbus_data_slot_allocator_alloc -_dbus_data_slot_allocator_free -_dbus_data_slot_allocator_init -_dbus_data_slot_list_clear -_dbus_data_slot_list_free -_dbus_data_slot_list_get -_dbus_data_slot_list_init -_dbus_data_slot_list_set -_dbus_data_slot_test -_dbus_decompose_path -_dbus_decrement_fail_alloc_counter -_dbus_delete_directory -_dbus_delete_file -_dbus_directory_close -_dbus_directory_get_next_file -_dbus_directory_open -_dbus_disable_mem_pools -_dbus_disable_sigpipe -_dbus_dup_string_array -_dbus_error_from_errno -_dbus_exit -_dbus_fd_set_close_on_exec -_dbus_file_exists -_dbus_file_get_contents -_dbus_first_type_in_signature -_dbus_first_type_in_signature_c_str -_dbus_flush_caches -_dbus_full_duplex_pipe -_dbus_generate_pseudorandom_bytes_buffer -_dbus_generate_random_ascii -_dbus_generate_random_bytes -_dbus_generate_random_bytes_buffer -_dbus_generate_uuid -_dbus_get_autolaunch_address -_dbus_get_config_file_name -_dbus_get_current_time -_dbus_get_environment -_dbus_get_fail_alloc_counter -_dbus_get_fail_alloc_failures -_dbus_get_install_root -_dbus_get_is_errno_eagain_or_ewouldblock -_dbus_get_is_errno_eintr -_dbus_get_is_errno_enomem -_dbus_get_is_errno_nonzero -_dbus_get_local_machine_uuid_encoded -_dbus_get_malloc_blocks_outstanding -_dbus_get_oom_wait -_dbus_get_standard_session_servicedirs -_dbus_get_standard_system_servicedirs -_dbus_get_tmpdir -_dbus_getenv -_dbus_getgid -_dbus_getpid -_dbus_getsid -_dbus_getuid -_dbus_hash_iter_get_int_key -_dbus_hash_iter_get_string_key -_dbus_hash_iter_get_two_strings_key -_dbus_hash_iter_get_ulong_key -_dbus_hash_iter_get_value -_dbus_hash_iter_init -_dbus_hash_iter_lookup -_dbus_hash_iter_next -_dbus_hash_iter_remove_entry -_dbus_hash_iter_set_value -_dbus_hash_table_free_preallocated_entry -_dbus_hash_table_get_n_entries -_dbus_hash_table_insert_int -_dbus_hash_table_insert_pointer -_dbus_hash_table_insert_string -_dbus_hash_table_insert_string_preallocated -_dbus_hash_table_insert_two_strings -_dbus_hash_table_insert_ulong -_dbus_hash_table_lookup_int -_dbus_hash_table_lookup_pointer -_dbus_hash_table_lookup_string -_dbus_hash_table_lookup_two_strings -_dbus_hash_table_lookup_ulong -_dbus_hash_table_new -_dbus_hash_table_preallocate_entry -_dbus_hash_table_ref -_dbus_hash_table_remove_all -_dbus_hash_table_remove_int -_dbus_hash_table_remove_pointer -_dbus_hash_table_remove_string -_dbus_hash_table_remove_two_strings -_dbus_hash_table_remove_ulong -_dbus_hash_table_unref -_dbus_hash_test -_dbus_header_byteswap -_dbus_header_copy -_dbus_header_create -_dbus_header_delete_field -_dbus_header_field_to_string -_dbus_header_free -_dbus_header_get_field_basic -_dbus_header_get_field_raw -_dbus_header_get_flag -_dbus_header_get_message_type -_dbus_header_get_serial -_dbus_header_have_message_untrusted -_dbus_header_init -_dbus_header_load -_dbus_header_reinit -_dbus_header_set_field_basic -_dbus_header_set_serial -_dbus_header_toggle_flag -_dbus_header_update_lengths -_dbus_init_system_log -_dbus_is_verbose_real -_dbus_keyring_get_best_key -_dbus_keyring_get_hex_key -_dbus_keyring_is_for_credentials -_dbus_keyring_new_for_credentials -_dbus_keyring_ref -_dbus_keyring_test -_dbus_keyring_unref -_dbus_keyring_validate_context -_dbus_list_alloc_link -_dbus_list_append -_dbus_list_append_link -_dbus_list_clear -_dbus_list_copy -_dbus_list_find_last -_dbus_list_foreach -_dbus_list_free_link -_dbus_list_get_first -_dbus_list_get_first_link -_dbus_list_get_last -_dbus_list_get_last_link -_dbus_list_get_length -_dbus_list_insert_after -_dbus_list_insert_after_link -_dbus_list_insert_before -_dbus_list_insert_before_link -_dbus_list_length_is_one -_dbus_list_pop_first -_dbus_list_pop_first_link -_dbus_list_pop_last -_dbus_list_pop_last_link -_dbus_list_prepend -_dbus_list_prepend_link -_dbus_list_remove -_dbus_list_remove_last -_dbus_list_remove_link -_dbus_list_test -_dbus_list_unlink -_dbus_listen_tcp_socket -_dbus_lm_strerror -_dbus_lock_atomic DATA -_dbus_lock_bus DATA -_dbus_lock_bus_datas DATA -_dbus_lock_connection_slots DATA -_dbus_lock_list DATA -_dbus_lock_machine_uuid DATA -_dbus_lock_message_cache DATA -_dbus_lock_message_slots DATA -_dbus_lock_pending_call_slots DATA -_dbus_lock_server_slots DATA -_dbus_lock_shared_connections DATA -_dbus_lock_shutdown_funcs DATA -_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 -_dbus_loop_iterate -_dbus_loop_new -_dbus_loop_queue_dispatch -_dbus_loop_quit -_dbus_loop_ref -_dbus_loop_remove_timeout -_dbus_loop_remove_watch -_dbus_loop_run -_dbus_loop_unref -_dbus_make_file_world_readable -_dbus_marshal_byteswap -_dbus_marshal_byteswap_test -_dbus_marshal_header_test -_dbus_marshal_read_basic -_dbus_marshal_read_fixed_multi -_dbus_marshal_read_uint32 -_dbus_marshal_recursive_test -_dbus_marshal_set_basic -_dbus_marshal_set_uint32 -_dbus_marshal_skip_array -_dbus_marshal_skip_basic -_dbus_marshal_test -_dbus_marshal_validate_test -_dbus_marshal_write_basic -_dbus_marshal_write_fixed_multi -_dbus_mem_pool_alloc -_dbus_mem_pool_dealloc -_dbus_mem_pool_free -_dbus_mem_pool_new -_dbus_mem_pool_test -_dbus_memdup -_dbus_memory_test -_dbus_message_add_size_counter -_dbus_message_add_size_counter_link -_dbus_message_data_free -_dbus_message_data_iter_get_and_next -_dbus_message_data_iter_init -_dbus_message_get_network_data -_dbus_message_iter_get_args_valist -_dbus_message_loader_get_buffer -_dbus_message_loader_get_is_corrupted -_dbus_message_loader_get_max_message_size -_dbus_message_loader_new -_dbus_message_loader_peek_message -_dbus_message_loader_pop_message -_dbus_message_loader_pop_message_link -_dbus_message_loader_putback_message_link -_dbus_message_loader_queue_messages -_dbus_message_loader_ref -_dbus_message_loader_return_buffer -_dbus_message_loader_set_max_message_size -_dbus_message_loader_unref -_dbus_message_remove_size_counter -_dbus_message_test -_dbus_misc_test -_dbus_mutex_free -_dbus_mutex_free_at_location -_dbus_mutex_lock -_dbus_mutex_new -_dbus_mutex_new_at_location -_dbus_mutex_unlock -_dbus_no_memory_message -_dbus_object_tree_dispatch_and_unlock -_dbus_object_tree_free_all_unlocked -_dbus_object_tree_get_user_data_unlocked -_dbus_object_tree_list_registered_and_unlock -_dbus_object_tree_new -_dbus_object_tree_ref -_dbus_object_tree_register -_dbus_object_tree_test -_dbus_object_tree_unref -_dbus_object_tree_unregister_and_unlock -_dbus_pack_uint32 -_dbus_parse_unix_group_from_config -_dbus_parse_unix_user_from_config -_dbus_path_is_absolute -_dbus_pending_call_complete -_dbus_pending_call_get_completed_unlocked -_dbus_pending_call_get_connection_and_lock -_dbus_pending_call_get_connection_unlocked -_dbus_pending_call_get_reply_serial_unlocked -_dbus_pending_call_get_timeout_unlocked -_dbus_pending_call_is_timeout_added_unlocked -_dbus_pending_call_new_unlocked -_dbus_pending_call_queue_timeout_error_unlocked -_dbus_pending_call_ref_unlocked -_dbus_pending_call_set_data_unlocked -_dbus_pending_call_set_reply_serial_unlocked -_dbus_pending_call_set_reply_unlocked -_dbus_pending_call_set_timeout_added_unlocked -_dbus_pending_call_set_timeout_error_unlocked -_dbus_pending_call_test -_dbus_pending_call_unref_and_unlock -_dbus_pid_for_log -_dbus_pipe_close -_dbus_pipe_init -_dbus_pipe_init_stdout -_dbus_pipe_invalidate -_dbus_pipe_is_stdout_or_stderr -_dbus_pipe_is_valid -_dbus_pipe_write -_dbus_poll -_dbus_print_backtrace -_dbus_printf_string_upper_bound -_dbus_read_credentials_socket -_dbus_read_local_machine_uuid -_dbus_read_socket -_dbus_read_uuid_file -_dbus_real_assert -_dbus_real_assert_not_reached -_dbus_register_shutdown_func -_dbus_return_if_fail_warning_format DATA -_dbus_send_credentials_socket -_dbus_server_add_timeout -_dbus_server_add_watch -_dbus_server_debug_pipe_new -_dbus_server_finalize_base -_dbus_server_init_base -_dbus_server_listen_debug_pipe -_dbus_server_listen_platform_specific -_dbus_server_listen_socket -_dbus_server_new_for_socket -_dbus_server_new_for_tcp_socket -_dbus_server_ref_unlocked -_dbus_server_remove_timeout -_dbus_server_remove_watch -_dbus_server_socket_own_filename -_dbus_server_test -_dbus_server_toggle_timeout -_dbus_server_toggle_watch -_dbus_server_unref_unlocked -_dbus_set_bad_address -_dbus_set_errno_to_zero -_dbus_set_fail_alloc_counter -_dbus_set_fail_alloc_failures -_dbus_set_fd_nonblocking -_dbus_set_signal_handler -_dbus_setenv -_dbus_sha_compute -_dbus_sha_final -_dbus_sha_init -_dbus_sha_test -_dbus_sha_update -_dbus_shell_parse_argv -_dbus_shell_unquote -_dbus_signature_test -_dbus_sleep_milliseconds -_dbus_spawn_async_with_babysitter -_dbus_spawn_test -_dbus_split_paths_and_append -_dbus_stat -_dbus_strdup -_dbus_strerror -_dbus_strerror_from_errno -_dbus_string_align_length -_dbus_string_alloc_space -_dbus_string_append -_dbus_string_append_4_aligned -_dbus_string_append_8_aligned -_dbus_string_append_byte -_dbus_string_append_byte_as_hex -_dbus_string_append_double -_dbus_string_append_int -_dbus_string_append_len -_dbus_string_append_printf -_dbus_string_append_printf_valist -_dbus_string_append_uint -_dbus_string_append_unichar -_dbus_string_array_contains -_dbus_string_chop_white -_dbus_string_copy -_dbus_string_copy_data -_dbus_string_copy_data_len -_dbus_string_copy_len -_dbus_string_copy_to_buffer -_dbus_string_delete -_dbus_string_delete_first_word -_dbus_string_delete_leading_blanks -_dbus_string_ends_with_c_str -_dbus_string_equal -_dbus_string_equal_c_str -_dbus_string_equal_len -_dbus_string_equal_substring -_dbus_string_find -_dbus_string_find_blank -_dbus_string_find_byte_backward -_dbus_string_find_eol -_dbus_string_find_to -_dbus_string_free -_dbus_string_get_byte -_dbus_string_get_const_data -_dbus_string_get_const_data_len -_dbus_string_get_data -_dbus_string_get_data_len -_dbus_string_get_dirname -_dbus_string_get_length -_dbus_string_get_unichar -_dbus_string_hex_decode -_dbus_string_hex_encode -_dbus_string_init -_dbus_string_init_const -_dbus_string_init_const_len -_dbus_string_init_preallocated -_dbus_string_insert_2_aligned -_dbus_string_insert_4_aligned -_dbus_string_insert_8_aligned -_dbus_string_insert_alignment -_dbus_string_insert_byte -_dbus_string_insert_bytes -_dbus_string_lengthen -_dbus_string_lock -_dbus_string_move -_dbus_string_move_len -_dbus_string_parse_double -_dbus_string_parse_int -_dbus_string_parse_uint -_dbus_string_pop_line -_dbus_string_replace_len -_dbus_string_save_to_file -_dbus_string_set_byte -_dbus_string_set_length -_dbus_string_shorten -_dbus_string_skip_blank -_dbus_string_skip_white -_dbus_string_skip_white_reverse -_dbus_string_split_on_byte -_dbus_string_starts_with_c_str -_dbus_string_steal_data -_dbus_string_steal_data_len -_dbus_string_test -_dbus_string_validate_ascii -_dbus_string_validate_nul -_dbus_string_validate_utf8 -_dbus_string_zero -_dbus_swap_array -_dbus_sysdeps_test -_dbus_test_oom_handling -_dbus_threads_init_debug -_dbus_threads_init_platform_specific -_dbus_timeout_list_add_timeout -_dbus_timeout_list_free -_dbus_timeout_list_new -_dbus_timeout_list_remove_timeout -_dbus_timeout_list_set_functions -_dbus_timeout_list_toggle_timeout -_dbus_timeout_new -_dbus_timeout_ref -_dbus_timeout_set_enabled -_dbus_timeout_set_interval -_dbus_timeout_unref -_dbus_transport_debug_pipe_new -_dbus_transport_disconnect -_dbus_transport_do_iteration -_dbus_transport_finalize_base -_dbus_transport_get_address -_dbus_transport_get_adt_audit_session_data -_dbus_transport_get_dispatch_status -_dbus_transport_get_is_anonymous -_dbus_transport_get_is_authenticated -_dbus_transport_get_is_connected -_dbus_transport_get_max_message_size -_dbus_transport_get_max_received_size -_dbus_transport_get_server_id -_dbus_transport_get_socket_fd -_dbus_transport_get_unix_process_id -_dbus_transport_get_unix_user -_dbus_transport_get_windows_user -_dbus_transport_handle_watch -_dbus_transport_init_base -_dbus_transport_new_for_socket -_dbus_transport_new_for_tcp_socket -_dbus_transport_open -_dbus_transport_open_debug_pipe -_dbus_transport_open_platform_specific -_dbus_transport_open_socket -_dbus_transport_queue_messages -_dbus_transport_ref -_dbus_transport_set_allow_anonymous -_dbus_transport_set_auth_mechanisms -_dbus_transport_set_connection -_dbus_transport_set_max_message_size -_dbus_transport_set_max_received_size -_dbus_transport_set_unix_user_function -_dbus_transport_set_windows_user_function -_dbus_transport_unref -_dbus_type_get_alignment -_dbus_type_is_valid -_dbus_type_reader_delete -_dbus_type_reader_equal_values -_dbus_type_reader_get_array_length -_dbus_type_reader_get_current_type -_dbus_type_reader_get_element_type -_dbus_type_reader_get_signature -_dbus_type_reader_get_value_pos -_dbus_type_reader_greater_than -_dbus_type_reader_has_next -_dbus_type_reader_init -_dbus_type_reader_init_types_only -_dbus_type_reader_next -_dbus_type_reader_read_basic -_dbus_type_reader_read_fixed_multi -_dbus_type_reader_read_raw -_dbus_type_reader_recurse -_dbus_type_reader_set_basic -_dbus_type_signature_next -_dbus_type_to_string -_dbus_type_writer_add_types -_dbus_type_writer_append_array -_dbus_type_writer_init -_dbus_type_writer_init_types_delayed -_dbus_type_writer_init_values_only -_dbus_type_writer_recurse -_dbus_type_writer_remove_types -_dbus_type_writer_set_enabled -_dbus_type_writer_unrecurse -_dbus_type_writer_write_basic -_dbus_type_writer_write_fixed_multi -_dbus_type_writer_write_reader -_dbus_type_writer_write_reader_partial -_dbus_unix_groups_from_uid -_dbus_unix_user_is_at_console -_dbus_unix_user_is_process_owner -_dbus_unpack_uint16 -_dbus_unpack_uint32 -_dbus_user_at_console -_dbus_uuid_encode -_dbus_validate_body_with_reason -_dbus_validate_bus_name -_dbus_validate_error_name -_dbus_validate_interface -_dbus_validate_member -_dbus_validate_path -_dbus_validate_signature -_dbus_validate_signature_with_reason -_dbus_verbose_bytes -_dbus_verbose_bytes_of_string -_dbus_verbose_real -_dbus_verbose_reset_real -_dbus_verify_daemon_user -_dbus_wait_for_memory -_dbus_warn -_dbus_warn_check_failed -_dbus_watch_invalidate -_dbus_watch_list_add_watch -_dbus_watch_list_free -_dbus_watch_list_new -_dbus_watch_list_remove_watch -_dbus_watch_list_set_functions -_dbus_watch_list_toggle_watch -_dbus_watch_new -_dbus_watch_ref -_dbus_watch_sanitize_condition -_dbus_watch_set_handler -_dbus_watch_unref -_dbus_win_account_to_sid -_dbus_win_set_error_from_win_error -_dbus_win_startup_winsock -_dbus_win_utf16_to_utf8 -_dbus_win_utf8_to_utf16 -_dbus_win_warn_win_error -_dbus_windows_user_is_process_owner -_dbus_write_pid_to_file_and_pipe -_dbus_write_socket -_dbus_write_socket_two dbus_address_entries_free dbus_address_entry_get_method dbus_address_entry_get_value @@ -672,6 +20,7 @@ dbus_bus_start_service_by_name dbus_connection_add_filter dbus_connection_allocate_data_slot dbus_connection_borrow_message +dbus_connection_can_send_type dbus_connection_close dbus_connection_dispatch dbus_connection_flush @@ -684,9 +33,12 @@ dbus_connection_get_is_anonymous dbus_connection_get_is_authenticated dbus_connection_get_is_connected dbus_connection_get_max_message_size +dbus_connection_get_max_message_unix_fds dbus_connection_get_max_received_size +dbus_connection_get_max_received_unix_fds dbus_connection_get_object_path_data dbus_connection_get_outgoing_size +dbus_connection_get_outgoing_unix_fds dbus_connection_get_server_id dbus_connection_get_socket dbus_connection_get_unix_fd @@ -716,7 +68,9 @@ dbus_connection_set_data dbus_connection_set_dispatch_status_function dbus_connection_set_exit_on_disconnect dbus_connection_set_max_message_size +dbus_connection_set_max_message_unix_fds dbus_connection_set_max_received_size +dbus_connection_set_max_received_unix_fds dbus_connection_set_route_peer_messages dbus_connection_set_timeout_functions dbus_connection_set_unix_user_function @@ -724,6 +78,8 @@ dbus_connection_set_wakeup_main_function dbus_connection_set_watch_functions dbus_connection_set_windows_user_function dbus_connection_steal_borrowed_message +dbus_connection_try_register_fallback +dbus_connection_try_register_object_path dbus_connection_unref dbus_connection_unregister_object_path dbus_error_free @@ -733,19 +89,16 @@ dbus_error_is_set dbus_free dbus_free_string_array dbus_get_local_machine_id -dbus_internal_do_not_use_foreach_message_file -dbus_internal_do_not_use_generate_bodies -dbus_internal_do_not_use_load_message_file -dbus_internal_do_not_use_run_tests -dbus_internal_do_not_use_try_message_data -dbus_internal_do_not_use_try_message_file +dbus_get_version dbus_malloc dbus_malloc0 dbus_message_allocate_data_slot dbus_message_append_args dbus_message_append_args_valist +dbus_message_contains_unix_fds dbus_message_copy dbus_message_demarshal +dbus_message_demarshal_bytes_needed dbus_message_free_data_slot dbus_message_get_args dbus_message_get_args_valist @@ -772,6 +125,7 @@ dbus_message_has_signature dbus_message_is_error dbus_message_is_method_call dbus_message_is_signal +dbus_message_iter_abandon_container dbus_message_iter_append_basic dbus_message_iter_append_fixed_array dbus_message_iter_close_container @@ -787,6 +141,7 @@ dbus_message_iter_init_append dbus_message_iter_next dbus_message_iter_open_container dbus_message_iter_recurse +dbus_message_lock dbus_message_marshal dbus_message_new dbus_message_new_error @@ -805,6 +160,7 @@ dbus_message_set_no_reply dbus_message_set_path dbus_message_set_reply_serial dbus_message_set_sender +dbus_message_set_serial dbus_message_type_from_string dbus_message_type_to_string dbus_message_unref -- 1.6.4.msysgit.0 From 150cde7f0dac24658378d98eb3c32989f8e01194 Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Wed, 21 Oct 2009 22:04:52 +0300 Subject: [PATCH 103/114] Use dbus-1.def on Windows --- dbus/Makefile.am | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) diff --git a/dbus/Makefile.am b/dbus/Makefile.am index c85556a..4346de7 100644 --- a/dbus/Makefile.am +++ b/dbus/Makefile.am @@ -38,7 +38,9 @@ else dbus_res = dbus_res_ldflag = no_undefined = -export_symbols = +## don't export symbols that start with "_" (we use this +## convention for internal symbols) +export_symbols = -export-symbols-regex "^[^_].*" install-def-file: uninstall-def-file: @@ -238,9 +240,7 @@ EXTRA_DIST=dbus-arch-deps.h.in noinst_LTLIBRARIES=libdbus-convenience.la libdbus_1_la_LIBADD= $(DBUS_CLIENT_LIBS) -## don't export symbols that start with "_" (we use this -## convention for internal symbols) -libdbus_1_la_LDFLAGS= -export-symbols-regex "^[^_].*" -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) -no-undefined @R_DYNAMIC_LDFLAG@ @PIC_LDFLAGS@ +libdbus_1_la_LDFLAGS= $(export_symbols) -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) -no-undefined @R_DYNAMIC_LDFLAG@ @PIC_LDFLAGS@ libdbus_convenience_la_LDFLAGS=@R_DYNAMIC_LDFLAG@ -- 1.6.4.msysgit.0 From 04bf887b5d03368279990d70a28c64150ec9a642 Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Thu, 22 Oct 2009 02:03:07 +0300 Subject: [PATCH 104/114] Actually do install the .def file on Windows --- dbus/Makefile.am | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-) diff --git a/dbus/Makefile.am b/dbus/Makefile.am index 4346de7..db90b87 100644 --- a/dbus/Makefile.am +++ b/dbus/Makefile.am @@ -26,6 +26,7 @@ no_undefined = -no-undefined export_symbols = -export-symbols $(srcdir)/dbus-1.def install-def-file: + test -z "$(libdir)" || $(MKDIR_P) "$(DESTDIR)$(libdir)" $(INSTALL) dbus-1.def $(DESTDIR)$(libdir)/dbus-1.def uninstall-def-file: @@ -233,7 +234,7 @@ libdbus_convenience_la_SOURCES= \ BUILT_SOURCES=$(dbusarchinclude_HEADERS) -EXTRA_DIST=dbus-arch-deps.h.in +EXTRA_DIST=dbus-arch-deps.h.in dbus-1.def ## this library is the same as libdbus, but exports all the symbols ## and is only used for static linking within the dbus package. @@ -264,6 +265,10 @@ dbus_test_SOURCES= \ dbus_test_LDADD=libdbus-convenience.la $(DBUS_TEST_LIBS) dbus_test_LDFLAGS=@R_DYNAMIC_LDFLAG@ +install-data-local: install-def-file + +uninstall-local: uninstall-def-file + ## mop up the gcov files clean-local: /bin/rm *.bb *.bbg *.da *.gcov .libs/*.da .libs/*.bbg || true -- 1.6.4.msysgit.0 From 7e9de96f4621253ec626e41401085ee252dca085 Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Thu, 22 Oct 2009 02:25:19 +0300 Subject: [PATCH 105/114] DBUS_VERSION is always three numbers No *-rc* possible. So drop strange crap manipulating it for BUILD_FILEVERSION. Drop duplicate AC_SUBST. --- configure.in | 14 ++++---------- 1 files changed, 4 insertions(+), 10 deletions(-) diff --git a/configure.in b/configure.in index 30b7252..05fe061 100644 --- a/configure.in +++ b/configure.in @@ -82,13 +82,9 @@ if test "$dbus_win" = yes; then AC_DEFINE(DBUS_WIN,1,[Defined if we run on a W32 API based system]) BUILD_TIMESTAMP=`date --iso-8601=minutes` AC_SUBST(BUILD_TIMESTAMP) - changequote(,)dnl - BUILD_FILEVERSION=`echo "$DBUS_VERSION" | sed 's/\([0-9.]*\).*/\1./;s/\./,/g'` - changequote([,])dnl - case "$DBUS_VERSION" in - *-rc*) BUILD_FILEVERSION="${BUILD_FILEVERSION}1" ;; - *) BUILD_FILEVERSION="${BUILD_FILEVERSION}2" ;; - esac + # Assume DBUS_VERSION is always three numbers + BUILD_FILEVERSION=`echo "$DBUS_VERSION" | sed -e 's/\./,/g'`,0 + AC_SUBST(BUILD_FILEVERSION) AC_CHECK_TOOL(WINDRES, windres, no) if test "$WINDRES" = no; then AC_MSG_ERROR([*** Could not find an implementation of windres in your PATH.]) @@ -96,12 +92,10 @@ if test "$dbus_win" = yes; then else AC_DEFINE(DBUS_UNIX,1,[Defined if we run on a Unix-based system]) fi -AC_SUBST(BUILD_TIMESTAMP) -AC_SUBST(BUILD_FILEVERSION) + AM_CONDITIONAL(DBUS_WIN, test "$dbus_win" = yes) AM_CONDITIONAL(DBUS_UNIX, test "$dbus_unix" = yes) - AC_ARG_ENABLE(tests, AS_HELP_STRING([--enable-tests],[enable unit test code]),enable_tests=$enableval,enable_tests=$USE_MAINTAINER_MODE) AC_ARG_ENABLE(ansi, AS_HELP_STRING([--enable-ansi],[enable -ansi -pedantic gcc flags]),enable_ansi=$enableval,enable_ansi=no) 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) -- 1.6.4.msysgit.0 From b6d8418b1bee040282fd835ec2e462e15b6ab5dc Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Thu, 22 Oct 2009 02:56:18 +0300 Subject: [PATCH 106/114] Check for dirent.h --- configure.in | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/configure.in b/configure.in index 05fe061..974e9ce 100644 --- a/configure.in +++ b/configure.in @@ -466,6 +466,8 @@ closedir(dirp); fi fi +AC_CHECK_HEADERS(dirent.h) + AC_CHECK_HEADERS(execinfo.h, [AC_CHECK_FUNCS(backtrace)]) AC_CHECK_HEADERS(errno.h) -- 1.6.4.msysgit.0 From a9f08aba22d3858126f22d9fbe8073d1118a9378 Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Thu, 22 Oct 2009 03:22:54 +0300 Subject: [PATCH 107/114] Avoind warnings on Windows Remove unused functions, or put in #if 0 if potentially useful. Make internal functions used just in one file static. Use -Werror after all also on Windows. Construct the installation root from the location of the dbus DLL, not from the location of the program .exe of the process. --- configure.in | 3 +- dbus/dbus-internals.c | 21 ++++++++++------- dbus/dbus-nonce.c | 6 ----- dbus/dbus-sysdeps-thread-win.c | 1 + dbus/dbus-sysdeps-util-win.c | 24 +++----------------- dbus/dbus-sysdeps-win.c | 46 +++++++--------------------------------- dbus/dbus-sysdeps.c | 2 +- tools/Makefile.am | 2 +- 8 files changed, 28 insertions(+), 77 deletions(-) diff --git a/configure.in b/configure.in index 974e9ce..de74c9f 100644 --- a/configure.in +++ b/configure.in @@ -1019,8 +1019,7 @@ ld_supports_flag() { fi } -# Don't bother with -Werror on Windows for now, too many warnings -if test x$dbus_win != xyes -a x$USE_MAINTAINER_MODE = xyes; then +if test x$USE_MAINTAINER_MODE = xyes; then if cc_supports_flag "-Werror"; then CFLAGS="$CFLAGS -Werror" fi diff --git a/dbus/dbus-internals.c b/dbus/dbus-internals.c index b70f332..9830044 100644 --- a/dbus/dbus-internals.c +++ b/dbus/dbus-internals.c @@ -310,18 +310,21 @@ _dbus_verbose_init (void) { if (!verbose_initted) { - char *p = _dbus_getenv ("DBUS_VERBOSE"); + const 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,": "); + { + char *last_period, *last_slash; + GetModuleFileName(0,module_name,sizeof(module_name)-1); + last_period = _mbsrchr(module_name,'.'); + if (last_period) + *last_period ='\0'; + last_slash = _mbsrchr(module_name,'\\'); + if (last_slash) + strcpy(module_name,last_slash+1); + strcat(module_name,": "); + } #endif } } diff --git a/dbus/dbus-nonce.c b/dbus/dbus-nonce.c index 14afc2e..cf1424c 100644 --- a/dbus/dbus-nonce.c +++ b/dbus/dbus-nonce.c @@ -133,12 +133,6 @@ _dbus_read_nonce (const DBusString *fname, DBusString *nonce, DBusError* error) return TRUE; } -static int -accept_with_nonce (int listen_fd, const DBusString *nonce) -{ - -} - int _dbus_accept_with_noncefile (int listen_fd, const DBusNonceFile *noncefile) { diff --git a/dbus/dbus-sysdeps-thread-win.c b/dbus/dbus-sysdeps-thread-win.c index 891b1bb..4c4d22f 100644 --- a/dbus/dbus-sysdeps-thread-win.c +++ b/dbus/dbus-sysdeps-thread-win.c @@ -23,6 +23,7 @@ #include "dbus-internals.h" #include "dbus-sysdeps.h" +#include "dbus-sysdeps-win.h" #include "dbus-threads.h" #include "dbus-list.h" diff --git a/dbus/dbus-sysdeps-util-win.c b/dbus/dbus-sysdeps-util-win.c index fe277e4..81ce82d 100644 --- a/dbus/dbus-sysdeps-util-win.c +++ b/dbus/dbus-sysdeps-util-win.c @@ -70,7 +70,7 @@ _dbus_become_daemon (const DBusString *pidfile, * @param error return location for errors * @returns #FALSE on failure */ -dbus_bool_t +static dbus_bool_t _dbus_write_pid_file (const DBusString *filename, unsigned long pid, DBusError *error) @@ -224,22 +224,6 @@ _dbus_change_to_daemon_user (const char *user, return TRUE; } -/** - * Changes the user and group the bus is running as. - * - * @param uid the new user ID - * @param gid the new group ID - * @param error return location for errors - * @returns #FALSE on failure - */ -dbus_bool_t -_dbus_change_identity (dbus_uid_t uid, - dbus_gid_t gid, - DBusError *error) -{ - return TRUE; -} - /** Checks if user is at the console * * @param username user to check @@ -542,7 +526,7 @@ DIR; * The DIR typedef is not compatible with Unix. **********************************************************************/ -DIR * _dbus_opendir(const char *dir) +static DIR * _dbus_opendir(const char *dir) { DIR *dp; char *filespec; @@ -575,7 +559,7 @@ DIR * _dbus_opendir(const char *dir) return dp; } -struct dirent * _dbus_readdir(DIR *dp) +static struct dirent * _dbus_readdir(DIR *dp) { if (!dp || dp->finished) return NULL; @@ -600,7 +584,7 @@ struct dirent * _dbus_readdir(DIR *dp) } -int _dbus_closedir(DIR *dp) +static int _dbus_closedir(DIR *dp) { if (!dp) return 0; diff --git a/dbus/dbus-sysdeps-win.c b/dbus/dbus-sysdeps-win.c index 7939008..42e6204 100644 --- a/dbus/dbus-sysdeps-win.c +++ b/dbus/dbus-sysdeps-win.c @@ -742,15 +742,6 @@ out1: /** @} end of sysdeps-win */ -/** Gets our UID - * @returns process UID - */ -dbus_uid_t -_dbus_getuid (void) -{ - return DBUS_UID_UNSET; -} - /** * The only reason this is separate from _dbus_getpid() is to allow it * on Windows for logging but not for other purposes. @@ -767,7 +758,7 @@ _dbus_pid_for_log (void) * @param points to sid buffer, need to be freed with LocalFree() * @returns process sid */ -dbus_bool_t +static dbus_bool_t _dbus_getsid(char **sid) { HANDLE process_token = NULL; @@ -811,31 +802,6 @@ failed: return retval; } - -#ifdef DBUS_BUILD_TESTS -/** Gets our GID - * @returns process GID - */ -dbus_gid_t -_dbus_getgid (void) -{ - return DBUS_GID_UNSET; -} - -#if 0 -dbus_bool_t -_dbus_domain_test (const char *test_data_dir) -{ - if (!_dbus_test_oom_handling ("spawn_nonexistent", - check_spawn_nonexistent, - NULL)) - return FALSE; -} - -#endif - -#endif //DBUS_BUILD_TESTS - /************************************************************************ pipes @@ -1886,7 +1852,7 @@ _dbus_concat_dir_and_file (DBusString *dir, _dbus_string_get_length (dir)); } -/*---------------- DBusCredentials ---------------------------------- +/*---------------- DBusCredentials ----------------------------------*/ /** * Adds the credentials corresponding to the given username. @@ -2958,6 +2924,8 @@ _dbus_daemon_init(const char *host, dbus_uint32_t port) _dbus_global_unlock( lock ); } +#if 0 + void _dbus_daemon_release() { @@ -2979,6 +2947,8 @@ _dbus_daemon_release() _dbus_global_unlock( lock ); } +#endif + static dbus_bool_t _dbus_get_autolaunch_shm(DBusString *adress) { @@ -3290,7 +3260,7 @@ _dbus_get_is_errno_eagain_or_ewouldblock (void) * @param len length of buffer * @returns #FALSE on failure */ -dbus_bool_t +static dbus_bool_t _dbus_get_install_root(char *prefix, int len) { //To find the prefix, we cut the filename and also \bin\ if present @@ -3299,7 +3269,7 @@ _dbus_get_install_root(char *prefix, int len) DWORD pathLength; char *lastSlash; SetLastError( 0 ); - pathLength = GetModuleFileName(NULL, prefix, len); + pathLength = GetModuleFileName(_dbus_win_get_dll_hmodule(), prefix, len); if ( pathLength == 0 || GetLastError() != 0 ) { *prefix = '\0'; return FALSE; diff --git a/dbus/dbus-sysdeps.c b/dbus/dbus-sysdeps.c index 240589f..1daba92 100644 --- a/dbus/dbus-sysdeps.c +++ b/dbus/dbus-sysdeps.c @@ -47,7 +47,7 @@ _DBUS_DEFINE_GLOBAL_LOCK (win_fds); _DBUS_DEFINE_GLOBAL_LOCK (sid_atom_cache); _DBUS_DEFINE_GLOBAL_LOCK (system_users); -#ifdef WIN32 +#ifdef _WIN32 #include #else extern char **environ; diff --git a/tools/Makefile.am b/tools/Makefile.am index 08b5d6a..9cf3d72 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -1,6 +1,6 @@ configdir=$(sysconfdir)/dbus-1 -INCLUDES=-I$(top_srcdir) $(DBUS_CLIENT_CFLAGS) $(DBUS_X_CFLAGS) -DDBUS_LOCALEDIR=\"@EXPANDED_DATADIR@/locale\" -DDBUS_COMPILATION -DDBUS_DAEMONDIR=\"@DBUS_DAEMONDIR@\" -DDBUS_MACHINE_UUID_FILE=\""$(localstatedir)/lib/dbus/machine-id"\" +INCLUDES=-I$(top_srcdir) $(DBUS_CLIENT_CFLAGS) $(DBUS_X_CFLAGS) -DDBUS_LOCALEDIR=\"@EXPANDED_DATADIR@/locale\" -DDBUS_COMPILATION -DDBUS_MACHINE_UUID_FILE=\""$(localstatedir)/lib/dbus/machine-id"\" extra_bin_programs= if DBUS_UNIX -- 1.6.4.msysgit.0 From 2cf40b2376c50a48f7d3a5e9f581557623cdcb8a Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Thu, 22 Oct 2009 03:51:18 +0300 Subject: [PATCH 108/114] Use nonce-tcp default session bus on Windows --- bus/session.conf.in | 2 +- configure.in | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/bus/session.conf.in b/bus/session.conf.in index 85395c5..e121ff9 100644 --- a/bus/session.conf.in +++ b/bus/session.conf.in @@ -12,7 +12,7 @@ the behavior of child processes. --> - unix:tmpdir=@DBUS_SESSION_SOCKET_DIR@ + @DBUS_SESSION_BUS_DEFAULT_ADDRESS@ diff --git a/configure.in b/configure.in index de74c9f..8d10378 100644 --- a/configure.in +++ b/configure.in @@ -1456,6 +1456,13 @@ fi AC_DEFINE_UNQUOTED(DBUS_SESSION_SOCKET_DIR, "$DBUS_SESSION_SOCKET_DIR", [Where per-session bus puts its sockets]) AC_SUBST(DBUS_SESSION_SOCKET_DIR) +if test x$dbus_win = xyes; then + DBUS_SESSION_BUS_DEFAULT_ADDRESS="nonce-tcp:" +else + DBUS_SESSION_BUS_DEFAULT_ADDRESS="unix:tmpdir=$DBUS_SESSION_SOCKET_DIR" +fi +AC_SUBST(DBUS_SESSION_BUS_DEFAULT_ADDRESS) + # darwin needs this to initialize the environment AC_CHECK_HEADERS(crt_externs.h) AC_CHECK_FUNC(_NSGetEnviron, [AC_DEFINE(HAVE_NSGETENVIRON, 1, [Define if your system needs _NSGetEnviron to set up the environment])]) @@ -1549,7 +1556,7 @@ echo " System bus socket: ${DBUS_SYSTEM_SOCKET} System bus address: ${DBUS_SYSTEM_BUS_DEFAULT_ADDRESS} System bus PID file: ${DBUS_SYSTEM_PID_FILE} - Session bus socket dir: ${DBUS_SESSION_SOCKET_DIR} + Session bus address: ${DBUS_SESSION_BUS_DEFAULT_ADDRESS} Console auth dir: ${DBUS_CONSOLE_AUTH_DIR} Console owner file: ${have_console_owner_file} Console owner file path: ${DBUS_CONSOLE_OWNER_FILE} -- 1.6.4.msysgit.0 From 18f7df4f5f2267eed70acdca813a20744fb19206 Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Thu, 22 Oct 2009 04:14:04 +0300 Subject: [PATCH 109/114] Drop terminating slash in _dbus_get_tmpdir The callers will append strings starting with a slash anyway. --- dbus/dbus-sysdeps-win.c | 15 ++++++++++++++- 1 files changed, 14 insertions(+), 1 deletions(-) diff --git a/dbus/dbus-sysdeps-win.c b/dbus/dbus-sysdeps-win.c index 42e6204..7c68955 100644 --- a/dbus/dbus-sysdeps-win.c +++ b/dbus/dbus-sysdeps-win.c @@ -2431,8 +2431,21 @@ _dbus_get_tmpdir(void) if (tmpdir == NULL) { + char *last_slash; + if (!GetTempPath (sizeof (buf), buf)) - strcpy (buf, "\\"); + { + _dbus_warn ("GetTempPath failed\n"); + _dbus_abort (); + } + + /* Drop terminating backslash or slash */ + last_slash = _mbsrchr (buf, '\\'); + if (last_slash > buf && last_slash[1] == '\0') + last_slash[0] = '\0'; + last_slash = _mbsrchr (buf, '/'); + if (last_slash > buf && last_slash[1] == '\0') + last_slash[0] = '\0'; tmpdir = buf; } -- 1.6.4.msysgit.0 From d22c5c4a20a3efc40d0dd5e1ff47921728e3c2b6 Mon Sep 17 00:00:00 2001 From: Frank Osterfeld Date: Thu, 22 Oct 2009 13:03:11 +0300 Subject: [PATCH 110/114] Windows fixes Replace dbus_daemon_init() by dbus_publish_session_bus_address(), publishing the full address. Omit username from mutexes (not necessary as mutex names are local to session). Don't exit if publishing the address failed (allow multiple session bus instances per session). Based on 00ee92ae314 by Tor Lillqvist. Cherry-picked from commit 23945513e9a4da61d286ebfbce3897aa061ddbfe in the dbus4win repository by tml@iki.fi. Remove claim of that commit not being merged from README.dbus4win. --- README.dbus4win | 4 -- bus/main.c | 9 ++++ dbus/dbus-sysdeps-unix.c | 13 ++++++ dbus/dbus-sysdeps-win.c | 95 +++++++++++++-------------------------------- dbus/dbus-sysdeps.h | 4 ++ 5 files changed, 54 insertions(+), 71 deletions(-) diff --git a/README.dbus4win b/README.dbus4win index 19c4e0c..5a26fea 100644 --- a/README.dbus4win +++ b/README.dbus4win @@ -62,10 +62,6 @@ b0d14fed92d9f539cd3478e72dc2f3ea75f3941a configure.in: only check for wspiapi.h on Windows nah, no harm checking for it on UNIX too -23945513e9a4da61d286ebfbce3897aa061ddbfe -replace dbus_daemon_init by dbus_publish_session_bus_address, publishing the... -doesn't apply, too complex, split into separate chunks - 1724fc10e516e2d570537d522d8608abba90be5e prototypes cleanup related to cd2cdb3457f72cf058d5b19796ee691ceca6b52c which was skipped above diff --git a/bus/main.c b/bus/main.c index 5965195..edb6d95 100644 --- a/bus/main.c +++ b/bus/main.c @@ -254,6 +254,7 @@ main (int argc, char **argv) int i; dbus_bool_t print_address; dbus_bool_t print_pid; + dbus_bool_t is_session_bus; int force_fork; if (!_dbus_string_init (&config_file)) @@ -267,6 +268,7 @@ main (int argc, char **argv) print_address = FALSE; print_pid = FALSE; + is_session_bus = FALSE; force_fork = FORK_FOLLOW_CONFIG_FILE; prev_arg = NULL; @@ -296,6 +298,7 @@ main (int argc, char **argv) } else if (strcmp (arg, "--session") == 0) { + is_session_bus = TRUE; check_two_config_files (&config_file, "session"); if (!_dbus_append_session_config_file (&config_file)) @@ -452,6 +455,9 @@ main (int argc, char **argv) exit (1); } + if (is_session_bus) + _dbus_daemon_publish_session_bus_address (bus_context_get_address (context)); + /* bus_context_new() closes the print_addr_pipe and * print_pid_pipe */ @@ -473,5 +479,8 @@ main (int argc, char **argv) bus_context_unref (context); bus_selinux_shutdown (); + if (is_session_bus) + _dbus_daemon_unpublish_session_bus_address (); + return 0; } diff --git a/dbus/dbus-sysdeps-unix.c b/dbus/dbus-sysdeps-unix.c index 91f8a35..eb6f963 100644 --- a/dbus/dbus-sysdeps-unix.c +++ b/dbus/dbus-sysdeps-unix.c @@ -3896,6 +3896,19 @@ _dbus_append_keyring_directory_for_credentials (DBusString *directory, return FALSE; } +//PENDING(kdab) docs +void +_dbus_daemon_publish_session_bus_address (const char* addr) +{ + +} + +//PENDING(kdab) docs +void +_dbus_daemon_unpublish_session_bus_address (void) +{ + +} /** * See if errno is EAGAIN or EWOULDBLOCK (this has to be done differently diff --git a/dbus/dbus-sysdeps-win.c b/dbus/dbus-sysdeps-win.c index 7c68955..b720de4 100644 --- a/dbus/dbus-sysdeps-win.c +++ b/dbus/dbus-sysdeps-win.c @@ -1452,10 +1452,6 @@ _dbus_connect_tcp_socket_with_nonce (const char *host, return fd; } - -void -_dbus_daemon_init(const char *host, dbus_uint32_t port); - /** * Creates a socket and binds it to the given path, then listens on * the socket. The socket is set to be nonblocking. In case of port=0 @@ -1633,7 +1629,6 @@ _dbus_listen_tcp_socket (const char *host, } sscanf(_dbus_string_get_const_data(retport), "%d", &port_num); - _dbus_daemon_init(host, port_num); for (i = 0 ; i < nlisten_fd ; i++) { @@ -2873,7 +2868,7 @@ void _dbus_global_unlock (HANDLE mutex) // for proper cleanup in dbus-daemon static HANDLE hDBusDaemonMutex = NULL; static HANDLE hDBusSharedMem = NULL; -// sync _dbus_daemon_init, _dbus_daemon_uninit and _dbus_daemon_already_runs +// sync _dbus_daemon_publish_session_bus_address, _dbus_daemon_unpublish_session_bus_address and _dbus_daemon_already_runs static const char *cUniqueDBusInitMutex = "UniqueDBusInitMutex"; // sync _dbus_get_autolaunch_address static const char *cDBusAutolaunchMutex = "DBusAutolaunchMutex"; @@ -2886,65 +2881,49 @@ static const char *cDBusDaemonAddressInfo = "DBusDaemonAddressInfoDebug"; static const char *cDBusDaemonAddressInfo = "DBusDaemonAddressInfo"; #endif + void -_dbus_daemon_init(const char *host, dbus_uint32_t port) +_dbus_daemon_publish_session_bus_address (const char* address) { HANDLE lock; - char *adr = NULL; - char szUserName[64]; - DWORD dwUserNameSize = sizeof(szUserName); - char szDBusDaemonMutex[128]; - char szDBusDaemonAddressInfo[128]; - char szAddress[128]; + char *shared_addr = NULL; DWORD ret; - _dbus_assert(host); - _dbus_assert(port); - - _snprintf(szAddress, sizeof(szAddress) - 1, "tcp:host=%s,port=%d", host, port); - ret = GetUserName(szUserName, &dwUserNameSize); - _dbus_assert(ret != 0); - _snprintf(szDBusDaemonMutex, sizeof(szDBusDaemonMutex) - 1, "%s:%s", - cDBusDaemonMutex, szUserName); - _snprintf(szDBusDaemonAddressInfo, sizeof(szDBusDaemonAddressInfo) - 1, "%s:%s", - cDBusDaemonAddressInfo, szUserName); - + _dbus_assert (address); // before _dbus_global_lock to keep correct lock/release order - hDBusDaemonMutex = CreateMutex( NULL, FALSE, szDBusDaemonMutex ); + hDBusDaemonMutex = CreateMutex( NULL, FALSE, cDBusDaemonMutex ); ret = WaitForSingleObject( hDBusDaemonMutex, 1000 ); if ( ret != WAIT_OBJECT_0 ) { - _dbus_warn("Could not lock mutex %s (return code %d). daemon already running?\n", szDBusDaemonMutex, ret ); - _dbus_assert( !"Could not lock mutex, daemon already running?" ); + _dbus_warn("Could not lock mutex %s (return code %d). daemon already running? Bus address not published.\n", cDBusDaemonMutex, ret ); + return; } - // sync _dbus_daemon_init, _dbus_daemon_uninit and _dbus_daemon_already_runs + // sync _dbus_daemon_publish_session_bus_address, _dbus_daemon_unpublish_session_bus_address and _dbus_daemon_already_runs lock = _dbus_global_lock( cUniqueDBusInitMutex ); // create shm hDBusSharedMem = CreateFileMapping( INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, - 0, strlen( szAddress ) + 1, szDBusDaemonAddressInfo ); + 0, strlen( address ) + 1, cDBusDaemonAddressInfo ); _dbus_assert( hDBusSharedMem ); - adr = MapViewOfFile( hDBusSharedMem, FILE_MAP_WRITE, 0, 0, 0 ); + shared_addr = MapViewOfFile( hDBusSharedMem, FILE_MAP_WRITE, 0, 0, 0 ); - _dbus_assert( adr ); + _dbus_assert (shared_addr); - strcpy( adr, szAddress); + strcpy( shared_addr, address); // cleanup - UnmapViewOfFile( adr ); + UnmapViewOfFile( shared_addr ); _dbus_global_unlock( lock ); } -#if 0 - void -_dbus_daemon_release() +_dbus_daemon_unpublish_session_bus_address (void) { HANDLE lock; - // sync _dbus_daemon_init, _dbus_daemon_uninit and _dbus_daemon_already_runs + // sync _dbus_daemon_publish_session_bus_address, _dbus_daemon_unpublish_session_bus_address and _dbus_daemon_already_runs lock = _dbus_global_lock( cUniqueDBusInitMutex ); CloseHandle( hDBusSharedMem ); @@ -2960,27 +2939,17 @@ _dbus_daemon_release() _dbus_global_unlock( lock ); } -#endif - static dbus_bool_t -_dbus_get_autolaunch_shm(DBusString *adress) +_dbus_get_autolaunch_shm (DBusString *address) { HANDLE sharedMem; - char *adr; - char szUserName[64]; - DWORD dwUserNameSize = sizeof(szUserName); - char szDBusDaemonAddressInfo[128]; + char *shared_addr; int i; - if( !GetUserName(szUserName, &dwUserNameSize) ) - return FALSE; - _snprintf(szDBusDaemonAddressInfo, sizeof(szDBusDaemonAddressInfo) - 1, "%s:%s", - cDBusDaemonAddressInfo, szUserName); - // read shm 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 ); + sharedMem = OpenFileMapping( FILE_MAP_READ, FALSE, cDBusDaemonAddressInfo ); if( sharedMem == 0 ) Sleep( 100 ); if ( sharedMem != 0) @@ -2990,17 +2959,17 @@ _dbus_get_autolaunch_shm(DBusString *adress) if( sharedMem == 0 ) return FALSE; - adr = MapViewOfFile( sharedMem, FILE_MAP_READ, 0, 0, 0 ); + shared_addr = MapViewOfFile( sharedMem, FILE_MAP_READ, 0, 0, 0 ); - if( adr == 0 ) + if( !shared_addr ) return FALSE; - _dbus_string_init( adress ); + _dbus_string_init( address ); - _dbus_string_append( adress, adr ); + _dbus_string_append( address, shared_addr ); // cleanup - UnmapViewOfFile( adr ); + UnmapViewOfFile( shared_addr ); CloseHandle( sharedMem ); @@ -3008,25 +2977,17 @@ _dbus_get_autolaunch_shm(DBusString *adress) } static dbus_bool_t -_dbus_daemon_already_runs (DBusString *adress) +_dbus_daemon_already_runs (DBusString *address) { HANDLE lock; HANDLE daemon; dbus_bool_t bRet = TRUE; - char szUserName[64]; - DWORD dwUserNameSize = sizeof(szUserName); - char szDBusDaemonMutex[128]; - // sync _dbus_daemon_init, _dbus_daemon_uninit and _dbus_daemon_already_runs + // sync _dbus_daemon_publish_session_bus_address, _dbus_daemon_unpublish_session_bus_address and _dbus_daemon_already_runs lock = _dbus_global_lock( cUniqueDBusInitMutex ); - if( !GetUserName(szUserName, &dwUserNameSize) ) - return FALSE; - _snprintf(szDBusDaemonMutex, sizeof(szDBusDaemonMutex) - 1, "%s:%s", - cDBusDaemonMutex, szUserName); - // do checks - daemon = CreateMutex( NULL, FALSE, szDBusDaemonMutex ); + daemon = CreateMutex( NULL, FALSE, cDBusDaemonMutex ); if(WaitForSingleObject( daemon, 10 ) != WAIT_TIMEOUT) { ReleaseMutex (daemon); @@ -3037,7 +2998,7 @@ _dbus_daemon_already_runs (DBusString *adress) } // read shm - bRet = _dbus_get_autolaunch_shm( adress ); + bRet = _dbus_get_autolaunch_shm( address ); // cleanup CloseHandle ( daemon ); diff --git a/dbus/dbus-sysdeps.h b/dbus/dbus-sysdeps.h index 7dd6c82..7e52b51 100644 --- a/dbus/dbus-sysdeps.h +++ b/dbus/dbus-sysdeps.h @@ -221,6 +221,10 @@ dbus_bool_t _dbus_windows_user_is_process_owner (const char *windows_sid) dbus_bool_t _dbus_append_keyring_directory_for_credentials (DBusString *directory, DBusCredentials *credentials); +void _dbus_daemon_publish_session_bus_address (const char* address); + +void _dbus_daemon_unpublish_session_bus_address (void); + dbus_bool_t _dbus_socket_can_pass_unix_fd(int fd); /** Opaque type representing an atomically-modifiable integer -- 1.6.4.msysgit.0 From 140dc3c49e1b53566350d18a205182e30caa547c Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Thu, 22 Oct 2009 13:19:23 +0300 Subject: [PATCH 111/114] Handle also WinSock errors in _dbus_error_from_errno Handle those WinSock errors that match the errno values handled. Don't bother handling those errors that are mapped to DBUS_ERROR_FAILED in the switch as that is the default return value anyway. --- dbus/dbus-sysdeps.c | 48 ++++++++++++++++++++++++++---------------------- 1 files changed, 26 insertions(+), 22 deletions(-) diff --git a/dbus/dbus-sysdeps.c b/dbus/dbus-sysdeps.c index 1daba92..99bb9c6 100644 --- a/dbus/dbus-sysdeps.c +++ b/dbus/dbus-sysdeps.c @@ -940,8 +940,8 @@ _dbus_generate_random_ascii (DBusString *str, } /** - * Converts a UNIX or Windows errno - * into a #DBusError name. + * Converts a UNIX errno, or Windows errno or WinSock error value into + * a #DBusError name. * * @todo should cover more errnos, specifically those * from open(). @@ -961,10 +961,18 @@ _dbus_error_from_errno (int error_number) case EPROTONOSUPPORT: return DBUS_ERROR_NOT_SUPPORTED; #endif +#ifdef WSAEPROTONOSUPPORT + case WSAEPROTONOSUPPORT: + return DBUS_ERROR_NOT_SUPPORTED; +#endif #ifdef EAFNOSUPPORT case EAFNOSUPPORT: return DBUS_ERROR_NOT_SUPPORTED; #endif +#ifdef WSAEAFNOSUPPORT + case WSAEAFNOSUPPORT: + return DBUS_ERROR_NOT_SUPPORTED; +#endif #ifdef ENFILE case ENFILE: return DBUS_ERROR_LIMITS_EXCEEDED; /* kernel out of memory */ @@ -989,42 +997,38 @@ _dbus_error_from_errno (int error_number) case ENOMEM: return DBUS_ERROR_NO_MEMORY; #endif -#ifdef EINVAL - case EINVAL: - return DBUS_ERROR_FAILED; -#endif -#ifdef EBADF - case EBADF: - return DBUS_ERROR_FAILED; -#endif -#ifdef EFAULT - case EFAULT: - return DBUS_ERROR_FAILED; -#endif -#ifdef ENOTSOCK - case ENOTSOCK: - return DBUS_ERROR_FAILED; -#endif -#ifdef EISCONN - case EISCONN: - return DBUS_ERROR_FAILED; -#endif #ifdef ECONNREFUSED case ECONNREFUSED: return DBUS_ERROR_NO_SERVER; #endif +#ifdef WSAECONNREFUSED + case WSAECONNREFUSED: + return DBUS_ERROR_NO_SERVER; +#endif #ifdef ETIMEDOUT case ETIMEDOUT: return DBUS_ERROR_TIMEOUT; #endif +#ifdef WSAETIMEDOUT + case WSAETIMEDOUT: + return DBUS_ERROR_TIMEOUT; +#endif #ifdef ENETUNREACH case ENETUNREACH: return DBUS_ERROR_NO_NETWORK; #endif +#ifdef WSAENETUNREACH + case WSAENETUNREACH: + return DBUS_ERROR_NO_NETWORK; +#endif #ifdef EADDRINUSE case EADDRINUSE: return DBUS_ERROR_ADDRESS_IN_USE; #endif +#ifdef WSAEADDRINUSE + case WSAEADDRINUSE: + return DBUS_ERROR_ADDRESS_IN_USE; +#endif #ifdef EEXIST case EEXIST: return DBUS_ERROR_FILE_EXISTS; -- 1.6.4.msysgit.0 From 400dfb67c6e2715df0410e3d9984f348c480cbe1 Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Thu, 22 Oct 2009 13:24:22 +0300 Subject: [PATCH 112/114] Don't fake network errno values on Windows Don't pretend there exists errno values for some network errors in the Microsoft C library. Just use the WinSock error values. --- dbus/dbus-sockets-win.h | 4 ---- dbus/dbus-sysdeps-win.c | 6 +++--- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/dbus/dbus-sockets-win.h b/dbus/dbus-sockets-win.h index 881a127..0af5e7b 100644 --- a/dbus/dbus-sockets-win.h +++ b/dbus/dbus-sockets-win.h @@ -49,10 +49,6 @@ #error This does not look like Win32 and the Microsoft C library #endif -#define EPROTONOSUPPORT WSAEPROTONOSUPPORT -#define EAFNOSUPPORT WSAEAFNOSUPPORT -#define EWOULDBLOCK WSAEWOULDBLOCK - #define DBUS_SOCKET_IS_INVALID(s) ((SOCKET)(s) == INVALID_SOCKET) #define DBUS_SOCKET_API_RETURNS_ERROR(n) ((n) == SOCKET_ERROR) #define DBUS_SOCKET_SET_ERRNO() errno = WSAGetLastError() diff --git a/dbus/dbus-sysdeps-win.c b/dbus/dbus-sysdeps-win.c index b720de4..376b5f5 100644 --- a/dbus/dbus-sysdeps-win.c +++ b/dbus/dbus-sysdeps-win.c @@ -1070,7 +1070,7 @@ _dbus_poll (DBusPollFD *fds, if (DBUS_SOCKET_API_RETURNS_ERROR (ready)) { DBUS_SOCKET_SET_ERRNO (); - if (errno != EWOULDBLOCK) + if (errno != WSAEWOULDBLOCK) _dbus_verbose ("WSAWaitForMultipleEvents: failed: %s\n", strerror (errno)); ret = -1; } @@ -1208,7 +1208,7 @@ _dbus_poll (DBusPollFD *fds, if (DBUS_SOCKET_API_RETURNS_ERROR (ready)) { DBUS_SOCKET_SET_ERRNO (); - if (errno != EWOULDBLOCK) + if (errno != WSAEWOULDBLOCK) _dbus_verbose ("select: failed: %s\n", _dbus_strerror (errno)); } else if (ready == 0) @@ -3224,7 +3224,7 @@ _dbus_flush_caches (void) dbus_bool_t _dbus_get_is_errno_eagain_or_ewouldblock (void) { - return errno == EAGAIN || errno == EWOULDBLOCK; + return errno == WSAEWOULDBLOCK; } /** -- 1.6.4.msysgit.0 From c26a0beff6173532fd1937c1c3edc05f156c8305 Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Tue, 27 Oct 2009 14:13:37 +0200 Subject: [PATCH 113/114] Set the DBusError Put the correct error code and a relevant message into the DBusError in _dbus_unix_user_is_at_console(). --- dbus/dbus-sysdeps-util-win.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/dbus/dbus-sysdeps-util-win.c b/dbus/dbus-sysdeps-util-win.c index 81ce82d..8b9fe7a 100644 --- a/dbus/dbus-sysdeps-util-win.c +++ b/dbus/dbus-sysdeps-util-win.c @@ -837,6 +837,8 @@ dbus_bool_t _dbus_unix_user_is_at_console (dbus_uid_t uid, DBusError *error) { + dbus_set_error (error, DBUS_ERROR_NOT_SUPPORTED, + "UNIX user IDs not supported on Windows\n"); return FALSE; } -- 1.6.4.msysgit.0 From f11d42044bb6dceecaf1a5d68ac08efd0314b297 Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Tue, 27 Oct 2009 14:18:17 +0200 Subject: [PATCH 114/114] Drop unused complex function Drop _dbus_user_at_console() from dbus-sysdeps-util-win.c. It is called only from dbus-userdb-util.c which isn't compiled on Windows. --- dbus/dbus-sysdeps-util-win.c | 86 ------------------------------------------ 1 files changed, 0 insertions(+), 86 deletions(-) diff --git a/dbus/dbus-sysdeps-util-win.c b/dbus/dbus-sysdeps-util-win.c index 8b9fe7a..b9ebc82 100644 --- a/dbus/dbus-sysdeps-util-win.c +++ b/dbus/dbus-sysdeps-util-win.c @@ -224,92 +224,6 @@ _dbus_change_to_daemon_user (const char *user, return TRUE; } -/** Checks if user is at the console -* -* @param username user to check -* @param error return location for errors -* @returns #TRUE is the user is at the consolei and there are no errors -*/ -dbus_bool_t -_dbus_user_at_console(const char *username, - DBusError *error) -{ -#ifdef DBUS_WINCE - return TRUE; -#else - dbus_bool_t retval = FALSE; - wchar_t *wusername; - DWORD sid_length; - PSID user_sid, console_user_sid; - HWINSTA winsta; - - wusername = _dbus_win_utf8_to_utf16 (username, error); - if (!wusername) - return FALSE; - - // TODO remove - if (!_dbus_win_account_to_sid (wusername, &user_sid, error)) - goto out0; - - /* Now we have the SID for username. Get the SID of the - * user at the "console" (window station WinSta0) - */ - if (!(winsta = OpenWindowStation ("WinSta0", FALSE, READ_CONTROL))) - { - _dbus_win_set_error_from_win_error (error, GetLastError ()); - goto out2; - } - - sid_length = 0; - GetUserObjectInformation (winsta, UOI_USER_SID, - NULL, 0, &sid_length); - if (sid_length == 0) - { - /* Nobody is logged on */ - goto out2; - } - - if (sid_length < 0 || sid_length > 1000) - { - dbus_set_error_const (error, DBUS_ERROR_FAILED, "Invalid SID length"); - goto out3; - } - - console_user_sid = dbus_malloc (sid_length); - if (!console_user_sid) - { - _DBUS_SET_OOM (error); - goto out3; - } - - if (!GetUserObjectInformation (winsta, UOI_USER_SID, - console_user_sid, sid_length, &sid_length)) - { - _dbus_win_set_error_from_win_error (error, GetLastError ()); - goto out4; - } - - if (!IsValidSid (console_user_sid)) - { - dbus_set_error_const (error, DBUS_ERROR_FAILED, "Invalid SID"); - goto out4; - } - - retval = EqualSid (user_sid, console_user_sid); - -out4: - dbus_free (console_user_sid); -out3: - CloseWindowStation (winsta); -out2: - dbus_free (user_sid); -out0: - dbus_free (wusername); - - return retval; -#endif //DBUS_WINCE -} - void _dbus_init_system_log (void) { -- 1.6.4.msysgit.0