Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 92152 Details for
Bug 140570
dbus doesn't work on x86-fbsd
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
dbus-fbsd.patch
dbus-fbsd.patch (text/plain), 9.19 KB, created by
Diego Elio Pettenò (RETIRED)
on 2006-07-18 12:36:25 UTC
(
hide
)
Description:
dbus-fbsd.patch
Filename:
MIME Type:
Creator:
Diego Elio Pettenò (RETIRED)
Created:
2006-07-18 12:36:25 UTC
Size:
9.19 KB
patch
obsolete
>--- bus/bus.c.orig Thu Jun 30 23:55:41 2005 >+++ bus/bus.c Thu Jun 30 23:56:04 2005 >@@ -486,7 +486,7 @@ process_config_every_time (BusContext > > _dbus_list_foreach (bus_config_parser_get_conf_dirs (parser), > (DBusForeachFunction) bus_watch_directory, >- NULL); >+ bus_context_get_loop (context)); > > _DBUS_ASSERT_ERROR_IS_CLEAR (error); > retval = TRUE; >--- bus/dir-watch.c.orig Tue Jun 14 22:31:38 2005 >+++ bus/dir-watch.c Tue May 2 12:52:08 2006 >@@ -28,17 +28,25 @@ > #include <stdlib.h> > #include <unistd.h> > #include <fcntl.h> >+#elif defined(DBUS_BUS_ENABLE_KQUEUE_ON_FREEBSD) >+#include <sys/types.h> >+#include <sys/event.h> >+#include <sys/time.h> >+#include <signal.h> >+#include <fcntl.h> >+#include <unistd.h> >+#include "bus.h" >+#include <dbus/dbus-watch.h> > #endif /* DBUS_BUS_ENABLE_DNOTIFY_ON_LINUX */ > > #include <dbus/dbus-internals.h> > #include "dir-watch.h" > >+#define MAX_DIRS_TO_WATCH 128 > > /* D_NOTIFY is available on Linux 2.4 or greater - the actual SIGIO signal is handled in main.c:signal_handler() */ > #ifdef DBUS_BUS_ENABLE_DNOTIFY_ON_LINUX > >-#define MAX_DIRS_TO_WATCH 128 >- > /* use a static array to avoid handling OOM */ > static int fds[MAX_DIRS_TO_WATCH]; > static int num_fds = 0; >@@ -92,6 +100,147 @@ bus_drop_all_directory_watches (void) > } > } > >+ num_fds = 0; >+} >+ >+#elif defined(DBUS_BUS_ENABLE_KQUEUE_ON_FREEBSD) >+ >+static int kq = -1; >+static int fds[MAX_DIRS_TO_WATCH]; >+static int num_fds = 0; >+static DBusWatch *watch = NULL; >+static DBusLoop *loop = NULL; >+ >+static dbus_bool_t >+_kqueue_watch_callback (DBusWatch *watch, unsigned int condition, void *data) >+{ >+ return dbus_watch_handle (watch, condition); >+} >+ >+static dbus_bool_t >+_handle_kqueue_watch (DBusWatch *watch, unsigned int flags, void *data) >+{ >+ struct kevent ev; >+ struct timespec nullts = { 0, 0 }; >+ int res; >+ pid_t pid; >+ >+ res = kevent (kq, NULL, 0, &ev, 1, &nullts); >+ >+ /* Sleep for half a second to avoid a race when files are install(1)'d >+ * to system.d. */ >+ usleep(500000); >+ >+ if (res > 0) >+ { >+ pid = getpid (); >+ _dbus_verbose ("Sending SIGHUP signal on reception of a kevent\n"); >+ (void) kill (pid, SIGHUP); >+ } >+ else if (res < 0 && errno == EBADF) >+ { >+ kq = -1; >+ if (watch != NULL) >+ { >+ _dbus_loop_remove_watch (loop, watch, _kqueue_watch_callback, NULL); >+ _dbus_watch_unref (watch); >+ watch = NULL; >+ } >+ pid = getpid (); >+ _dbus_verbose ("Sending SIGHUP signal since kqueue has been closed\n"); >+ (void) kill (pid, SIGHUP); >+ } >+ >+ return TRUE; >+} >+ >+void >+bus_watch_directory (const char *dir, void *userdata) >+{ >+ int fd; >+ struct kevent ev; >+ >+ _dbus_assert (dir != NULL); >+ >+ if (kq < 0) >+ { >+ >+ kq = kqueue (); >+ if (kq < 0) >+ { >+ _dbus_warn ("Cannot create kqueue; error '%s'\n", _dbus_strerror (errno)); >+ goto out; >+ } >+ >+ loop = userdata; >+ >+ watch = _dbus_watch_new (kq, DBUS_WATCH_READABLE, TRUE, >+ _handle_kqueue_watch, NULL, NULL); >+ >+ if (watch == NULL) >+ { >+ _dbus_warn ("Unable to create kqueue watch\n"); >+ close (kq); >+ kq = -1; >+ goto out; >+ } >+ >+ if (!_dbus_loop_add_watch (loop, watch, _kqueue_watch_callback, >+ NULL, NULL)) >+ { >+ _dbus_warn ("Unable to add reload watch to main loop"); >+ close (kq); >+ kq = -1; >+ _dbus_watch_unref (watch); >+ watch = NULL; >+ goto out; >+ } >+ } >+ >+ if (num_fds >= MAX_DIRS_TO_WATCH ) >+ { >+ _dbus_warn ("Cannot watch config directory '%s'. Already watching %d directories\n", dir, MAX_DIRS_TO_WATCH); >+ goto out; >+ } >+ >+ fd = open (dir, O_RDONLY); >+ if (fd < 0) >+ { >+ _dbus_warn ("Cannot open directory '%s'; error '%s'\n", dir, _dbus_strerror (errno)); >+ goto out; >+ } >+ >+ EV_SET (&ev, fd, EVFILT_VNODE, EV_ADD | EV_ENABLE | EV_CLEAR, >+ NOTE_DELETE | NOTE_EXTEND | NOTE_WRITE | NOTE_RENAME, 0, 0); >+ if (kevent (kq, &ev, 1, NULL, 0, NULL) == -1) >+ { >+ _dbus_warn ("Cannot setup a kevent for '%s'; error '%s'\n", dir, _dbus_strerror (errno)); >+ close (fd); >+ goto out; >+ } >+ >+ fds[num_fds++] = fd; >+ _dbus_verbose ("Added kqueue watch on config directory '%s'\n", dir); >+ >+ out: >+ ; >+} >+ >+void >+bus_drop_all_directory_watches (void) >+{ >+ int i; >+ >+ _dbus_verbose ("Dropping all watches on config directories\n"); >+ >+ for (i = 0; i < num_fds; i++) >+ { >+ if (close (fds[i]) != 0) >+ { >+ _dbus_verbose ("Error closing fd %d for config directory watch\n", fds[i]); >+ } >+ } >+ > num_fds = 0; > } > >--- configure.in.old Fri Jun 9 23:42:41 2006 >+++ configure.in Sat Jul 15 22:04:35 2006 >@@ -68,6 +68,7 @@ > AC_ARG_ENABLE(python, AS_HELP_STRING([--enable-python],[build python bindings]),enable_python=$enableval,enable_python=auto) > AC_ARG_ENABLE(selinux, AS_HELP_STRING([--enable-selinux],[build with SELinux support]),enable_selinux=$enableval,enable_selinux=auto) > AC_ARG_ENABLE(dnotify, AS_HELP_STRING([--enable-dnotify],[build with dnotify support (linux only)]),enable_dnotify=$enableval,enable_dnotify=auto) >+AC_ARG_ENABLE(kqueue, AS_HELP_STRING([--enable-kqueue],[build with kqueue support (FreeBSD only)]),enable_kqueue=$enableval,enable_kqueue=auto) > AC_ARG_ENABLE(console-owner-file, AS_HELP_STRING([--enable-console-owner-file],[enable console owner file]),enable_console_owner_file=$enableval,enable_console_owner_file=auto) > > AC_ARG_WITH(xml, AS_HELP_STRING([--with-xml=[libxml/expat]],[XML library to use])) >@@ -851,6 +852,25 @@ > dnl check if dnotify backend is enabled > if test x$have_dnotify = xyes; then > AC_DEFINE(DBUS_BUS_ENABLE_DNOTIFY_ON_LINUX,1,[Use dnotify on Linux]) >+fi >+ >+# kqueue checks >+if test x$enable_kqueue = xno ; then >+ have_kqueue=no; >+else >+ case "${target_os}" in >+ freebsd*) >+ have_kqueue=yes; >+ ;; >+ *) >+ have_kqueue=no; >+ ;; >+ esac >+fi >+ >+dnl check if kqueue backend is enabled >+if test x$have_kqueue = xyes; then >+ AC_DEFINE(DBUS_BUS_ENABLE_KQUEUE_ON_FREEBSD,1,[Use kqueue on FreeBSD]) > fi > > dnl console owner file >--- dbus/dbus-sysdeps.c.orig Tue Nov 22 15:37:00 2005 >+++ dbus/dbus-sysdeps.c Sat Dec 31 13:08:04 2005 >@@ -781,16 +781,16 @@ write_credentials_byte (int > { > int bytes_written; > char buf[1] = { '\0' }; >-#if defined(HAVE_CMSGCRED) && !defined(LOCAL_CREDS) >- struct { >+#if defined(HAVE_CMSGCRED) >+ union { > struct cmsghdr hdr; >- struct cmsgcred cred; >+ char cred[CMSG_SPACE (sizeof (struct cmsgcred))]; > } cmsg; > struct iovec iov; > struct msghdr msg; > #endif > >-#if defined(HAVE_CMSGCRED) && !defined(LOCAL_CREDS) >+#if defined(HAVE_CMSGCRED) > iov.iov_base = buf; > iov.iov_len = 1; > >@@ -798,10 +798,10 @@ write_credentials_byte (int > msg.msg_iov = &iov; > msg.msg_iovlen = 1; > >- msg.msg_control = &cmsg; >- msg.msg_controllen = sizeof (cmsg); >+ msg.msg_control = (caddr_t) &cmsg; >+ msg.msg_controllen = CMSG_SPACE (sizeof (struct cmsgcred)); > memset (&cmsg, 0, sizeof (cmsg)); >- cmsg.hdr.cmsg_len = sizeof (cmsg); >+ cmsg.hdr.cmsg_len = CMSG_LEN (sizeof (struct cmsgcred)); > cmsg.hdr.cmsg_level = SOL_SOCKET; > cmsg.hdr.cmsg_type = SCM_CREDS; > #endif >@@ -810,7 +810,7 @@ write_credentials_byte (int > > again: > >-#if defined(HAVE_CMSGCRED) && !defined(LOCAL_CREDS) >+#if defined(HAVE_CMSGCRED) > bytes_written = sendmsg (server_fd, &msg, 0); > #else > bytes_written = write (server_fd, buf, 1); >@@ -868,9 +868,10 @@ _dbus_read_credentials_unix_socket (int > char buf; > > #ifdef HAVE_CMSGCRED >- struct { >+ struct cmsgcred *cred; >+ union { > struct cmsghdr hdr; >- struct cmsgcred cred; >+ char cred[CMSG_SPACE (sizeof (struct cmsgcred))]; > } cmsg; > #endif > >@@ -886,7 +887,7 @@ _dbus_read_credentials_unix_socket (int > > _dbus_credentials_clear (credentials); > >-#if defined(LOCAL_CREDS) && defined(HAVE_CMSGCRED) >+#if defined(LOCAL_CREDS) && !defined(HAVE_CMSGCRED) > /* Set the socket to receive credentials on the next message */ > { > int on = 1; >@@ -907,8 +908,8 @@ _dbus_read_credentials_unix_socket (int > > #ifdef HAVE_CMSGCRED > memset (&cmsg, 0, sizeof (cmsg)); >- msg.msg_control = &cmsg; >- msg.msg_controllen = sizeof (cmsg); >+ msg.msg_control = (caddr_t) &cmsg; >+ msg.msg_controllen = CMSG_SPACE (sizeof (struct cmsgcred)); > #endif > > again: >@@ -931,7 +932,8 @@ _dbus_read_credentials_unix_socket (int > } > > #ifdef HAVE_CMSGCRED >- if (cmsg.hdr.cmsg_len < sizeof (cmsg) || cmsg.hdr.cmsg_type != SCM_CREDS) >+ if (cmsg.hdr.cmsg_len < CMSG_LEN (sizeof (struct cmsgcred)) >+ || cmsg.hdr.cmsg_type != SCM_CREDS) > { > dbus_set_error (error, DBUS_ERROR_FAILED, > "Message from recvmsg() was not SCM_CREDS"); >@@ -959,9 +961,10 @@ _dbus_read_credentials_unix_socket (int > cr_len, (int) sizeof (cr), _dbus_strerror (errno)); > } > #elif defined(HAVE_CMSGCRED) >- credentials->pid = cmsg.cred.cmcred_pid; >- credentials->uid = cmsg.cred.cmcred_euid; >- credentials->gid = cmsg.cred.cmcred_groups[0]; >+ cred = (struct cmsgcred *) CMSG_DATA (&cmsg); >+ credentials->pid = cred->cmcred_pid; >+ credentials->uid = cred->cmcred_euid; >+ credentials->gid = cred->cmcred_groups[0]; > #elif defined(HAVE_GETPEEREID) > uid_t euid; > gid_t egid; >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 140570
:
91833
| 92152 |
93220
|
93221
|
93222