/[gentoo-alt]/trunk/overlay/sys-apps/dbus/files/dbus-freebsd.patch
Gentoo

Contents of /trunk/overlay/sys-apps/dbus/files/dbus-freebsd.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1309 - (show annotations) (download)
Thu Jul 20 01:47:34 2006 UTC (8 years, 4 months ago) by flameeyes
File size: 9627 byte(s)
Add dbus with patch from bug #140570 thanks to Timothy Redaelli.
1 --- bus/bus.c.orig Thu Jun 30 23:55:41 2005
2 +++ bus/bus.c Thu Jun 30 23:56:04 2005
3 @@ -486,7 +486,7 @@ process_config_every_time (BusContext
4
5 _dbus_list_foreach (bus_config_parser_get_conf_dirs (parser),
6 (DBusForeachFunction) bus_watch_directory,
7 - NULL);
8 + bus_context_get_loop (context));
9
10 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
11 retval = TRUE;
12 --- bus/dir-watch.c.orig Tue Jun 14 22:31:38 2005
13 +++ bus/dir-watch.c Tue May 2 12:52:08 2006
14 @@ -28,17 +28,25 @@
15 #include <stdlib.h>
16 #include <unistd.h>
17 #include <fcntl.h>
18 +#elif defined(DBUS_BUS_ENABLE_KQUEUE_ON_FREEBSD)
19 +#include <sys/types.h>
20 +#include <sys/event.h>
21 +#include <sys/time.h>
22 +#include <signal.h>
23 +#include <fcntl.h>
24 +#include <unistd.h>
25 +#include "bus.h"
26 +#include <dbus/dbus-watch.h>
27 #endif /* DBUS_BUS_ENABLE_DNOTIFY_ON_LINUX */
28
29 #include <dbus/dbus-internals.h>
30 #include "dir-watch.h"
31
32 +#define MAX_DIRS_TO_WATCH 128
33
34 /* D_NOTIFY is available on Linux 2.4 or greater - the actual SIGIO signal is handled in main.c:signal_handler() */
35 #ifdef DBUS_BUS_ENABLE_DNOTIFY_ON_LINUX
36
37 -#define MAX_DIRS_TO_WATCH 128
38 -
39 /* use a static array to avoid handling OOM */
40 static int fds[MAX_DIRS_TO_WATCH];
41 static int num_fds = 0;
42 @@ -92,6 +100,147 @@ bus_drop_all_directory_watches (void)
43 }
44 }
45
46 + num_fds = 0;
47 +}
48 +
49 +#elif defined(DBUS_BUS_ENABLE_KQUEUE_ON_FREEBSD)
50 +
51 +static int kq = -1;
52 +static int fds[MAX_DIRS_TO_WATCH];
53 +static int num_fds = 0;
54 +static DBusWatch *watch = NULL;
55 +static DBusLoop *loop = NULL;
56 +
57 +static dbus_bool_t
58 +_kqueue_watch_callback (DBusWatch *watch, unsigned int condition, void *data)
59 +{
60 + return dbus_watch_handle (watch, condition);
61 +}
62 +
63 +static dbus_bool_t
64 +_handle_kqueue_watch (DBusWatch *watch, unsigned int flags, void *data)
65 +{
66 + struct kevent ev;
67 + struct timespec nullts = { 0, 0 };
68 + int res;
69 + pid_t pid;
70 +
71 + res = kevent (kq, NULL, 0, &ev, 1, &nullts);
72 +
73 + /* Sleep for half a second to avoid a race when files are install(1)'d
74 + * to system.d. */
75 + usleep(500000);
76 +
77 + if (res > 0)
78 + {
79 + pid = getpid ();
80 + _dbus_verbose ("Sending SIGHUP signal on reception of a kevent\n");
81 + (void) kill (pid, SIGHUP);
82 + }
83 + else if (res < 0 && errno == EBADF)
84 + {
85 + kq = -1;
86 + if (watch != NULL)
87 + {
88 + _dbus_loop_remove_watch (loop, watch, _kqueue_watch_callback, NULL);
89 + _dbus_watch_unref (watch);
90 + watch = NULL;
91 + }
92 + pid = getpid ();
93 + _dbus_verbose ("Sending SIGHUP signal since kqueue has been closed\n");
94 + (void) kill (pid, SIGHUP);
95 + }
96 +
97 + return TRUE;
98 +}
99 +
100 +void
101 +bus_watch_directory (const char *dir, void *userdata)
102 +{
103 + int fd;
104 + struct kevent ev;
105 +
106 + _dbus_assert (dir != NULL);
107 +
108 + if (kq < 0)
109 + {
110 +
111 + kq = kqueue ();
112 + if (kq < 0)
113 + {
114 + _dbus_warn ("Cannot create kqueue; error '%s'\n", _dbus_strerror (errno));
115 + goto out;
116 + }
117 +
118 + loop = userdata;
119 +
120 + watch = _dbus_watch_new (kq, DBUS_WATCH_READABLE, TRUE,
121 + _handle_kqueue_watch, NULL, NULL);
122 +
123 + if (watch == NULL)
124 + {
125 + _dbus_warn ("Unable to create kqueue watch\n");
126 + close (kq);
127 + kq = -1;
128 + goto out;
129 + }
130 +
131 + if (!_dbus_loop_add_watch (loop, watch, _kqueue_watch_callback,
132 + NULL, NULL))
133 + {
134 + _dbus_warn ("Unable to add reload watch to main loop");
135 + close (kq);
136 + kq = -1;
137 + _dbus_watch_unref (watch);
138 + watch = NULL;
139 + goto out;
140 + }
141 + }
142 +
143 + if (num_fds >= MAX_DIRS_TO_WATCH )
144 + {
145 + _dbus_warn ("Cannot watch config directory '%s'. Already watching %d directories\n", dir, MAX_DIRS_TO_WATCH);
146 + goto out;
147 + }
148 +
149 + fd = open (dir, O_RDONLY);
150 + if (fd < 0)
151 + {
152 + _dbus_warn ("Cannot open directory '%s'; error '%s'\n", dir, _dbus_strerror (errno));
153 + goto out;
154 + }
155 +
156 + EV_SET (&ev, fd, EVFILT_VNODE, EV_ADD | EV_ENABLE | EV_CLEAR,
157 + NOTE_DELETE | NOTE_EXTEND | NOTE_WRITE | NOTE_RENAME, 0, 0);
158 + if (kevent (kq, &ev, 1, NULL, 0, NULL) == -1)
159 + {
160 + _dbus_warn ("Cannot setup a kevent for '%s'; error '%s'\n", dir, _dbus_strerror (errno));
161 + close (fd);
162 + goto out;
163 + }
164 +
165 + fds[num_fds++] = fd;
166 + _dbus_verbose ("Added kqueue watch on config directory '%s'\n", dir);
167 +
168 + out:
169 + ;
170 +}
171 +
172 +void
173 +bus_drop_all_directory_watches (void)
174 +{
175 + int i;
176 +
177 + _dbus_verbose ("Dropping all watches on config directories\n");
178 +
179 + for (i = 0; i < num_fds; i++)
180 + {
181 + if (close (fds[i]) != 0)
182 + {
183 + _dbus_verbose ("Error closing fd %d for config directory watch\n", fds[i]);
184 + }
185 + }
186 +
187 num_fds = 0;
188 }
189
190 --- configure.in.old Fri Jun 9 23:42:41 2006
191 +++ configure.in Sat Jul 15 22:04:35 2006
192 @@ -68,6 +68,7 @@
193 AC_ARG_ENABLE(python, AS_HELP_STRING([--enable-python],[build python bindings]),enable_python=$enableval,enable_python=auto)
194 AC_ARG_ENABLE(selinux, AS_HELP_STRING([--enable-selinux],[build with SELinux support]),enable_selinux=$enableval,enable_selinux=auto)
195 AC_ARG_ENABLE(dnotify, AS_HELP_STRING([--enable-dnotify],[build with dnotify support (linux only)]),enable_dnotify=$enableval,enable_dnotify=auto)
196 +AC_ARG_ENABLE(kqueue, AS_HELP_STRING([--enable-kqueue],[build with kqueue support (FreeBSD only)]),enable_kqueue=$enableval,enable_kqueue=auto)
197 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)
198
199 AC_ARG_WITH(xml, AS_HELP_STRING([--with-xml=[libxml/expat]],[XML library to use]))
200 @@ -851,6 +852,25 @@
201 dnl check if dnotify backend is enabled
202 if test x$have_dnotify = xyes; then
203 AC_DEFINE(DBUS_BUS_ENABLE_DNOTIFY_ON_LINUX,1,[Use dnotify on Linux])
204 +fi
205 +
206 +# kqueue checks
207 +if test x$enable_kqueue = xno ; then
208 + have_kqueue=no;
209 +else
210 + case "${target_os}" in
211 + freebsd*)
212 + have_kqueue=yes;
213 + ;;
214 + *)
215 + have_kqueue=no;
216 + ;;
217 + esac
218 +fi
219 +
220 +dnl check if kqueue backend is enabled
221 +if test x$have_kqueue = xyes; then
222 + AC_DEFINE(DBUS_BUS_ENABLE_KQUEUE_ON_FREEBSD,1,[Use kqueue on FreeBSD])
223 fi
224
225 dnl console owner file
226 --- dbus/dbus-sysdeps.c.orig Tue Nov 22 15:37:00 2005
227 +++ dbus/dbus-sysdeps.c Sat Dec 31 13:08:04 2005
228 @@ -781,16 +781,16 @@ write_credentials_byte (int
229 {
230 int bytes_written;
231 char buf[1] = { '\0' };
232 -#if defined(HAVE_CMSGCRED) && !defined(LOCAL_CREDS)
233 - struct {
234 +#if defined(HAVE_CMSGCRED)
235 + union {
236 struct cmsghdr hdr;
237 - struct cmsgcred cred;
238 + char cred[CMSG_SPACE (sizeof (struct cmsgcred))];
239 } cmsg;
240 struct iovec iov;
241 struct msghdr msg;
242 #endif
243
244 -#if defined(HAVE_CMSGCRED) && !defined(LOCAL_CREDS)
245 +#if defined(HAVE_CMSGCRED)
246 iov.iov_base = buf;
247 iov.iov_len = 1;
248
249 @@ -798,10 +798,10 @@ write_credentials_byte (int
250 msg.msg_iov = &iov;
251 msg.msg_iovlen = 1;
252
253 - msg.msg_control = &cmsg;
254 - msg.msg_controllen = sizeof (cmsg);
255 + msg.msg_control = (caddr_t) &cmsg;
256 + msg.msg_controllen = CMSG_SPACE (sizeof (struct cmsgcred));
257 memset (&cmsg, 0, sizeof (cmsg));
258 - cmsg.hdr.cmsg_len = sizeof (cmsg);
259 + cmsg.hdr.cmsg_len = CMSG_LEN (sizeof (struct cmsgcred));
260 cmsg.hdr.cmsg_level = SOL_SOCKET;
261 cmsg.hdr.cmsg_type = SCM_CREDS;
262 #endif
263 @@ -810,7 +810,7 @@ write_credentials_byte (int
264
265 again:
266
267 -#if defined(HAVE_CMSGCRED) && !defined(LOCAL_CREDS)
268 +#if defined(HAVE_CMSGCRED)
269 bytes_written = sendmsg (server_fd, &msg, 0);
270 #else
271 bytes_written = write (server_fd, buf, 1);
272 @@ -868,9 +868,10 @@ _dbus_read_credentials_unix_socket (int
273 char buf;
274
275 #ifdef HAVE_CMSGCRED
276 - struct {
277 + struct cmsgcred *cred;
278 + union {
279 struct cmsghdr hdr;
280 - struct cmsgcred cred;
281 + char cred[CMSG_SPACE (sizeof (struct cmsgcred))];
282 } cmsg;
283 #endif
284
285 @@ -886,7 +887,7 @@ _dbus_read_credentials_unix_socket (int
286
287 _dbus_credentials_clear (credentials);
288
289 -#if defined(LOCAL_CREDS) && defined(HAVE_CMSGCRED)
290 +#if defined(LOCAL_CREDS) && !defined(HAVE_CMSGCRED)
291 /* Set the socket to receive credentials on the next message */
292 {
293 int on = 1;
294 @@ -907,8 +908,8 @@ _dbus_read_credentials_unix_socket (int
295
296 #ifdef HAVE_CMSGCRED
297 memset (&cmsg, 0, sizeof (cmsg));
298 - msg.msg_control = &cmsg;
299 - msg.msg_controllen = sizeof (cmsg);
300 + msg.msg_control = (caddr_t) &cmsg;
301 + msg.msg_controllen = CMSG_SPACE (sizeof (struct cmsgcred));
302 #endif
303
304 again:
305 @@ -931,7 +932,8 @@ _dbus_read_credentials_unix_socket (int
306 }
307
308 #ifdef HAVE_CMSGCRED
309 - if (cmsg.hdr.cmsg_len < sizeof (cmsg) || cmsg.hdr.cmsg_type != SCM_CREDS)
310 + if (cmsg.hdr.cmsg_len < CMSG_LEN (sizeof (struct cmsgcred))
311 + || cmsg.hdr.cmsg_type != SCM_CREDS)
312 {
313 dbus_set_error (error, DBUS_ERROR_FAILED,
314 "Message from recvmsg() was not SCM_CREDS");
315 @@ -959,9 +961,10 @@ _dbus_read_credentials_unix_socket (int
316 cr_len, (int) sizeof (cr), _dbus_strerror (errno));
317 }
318 #elif defined(HAVE_CMSGCRED)
319 - credentials->pid = cmsg.cred.cmcred_pid;
320 - credentials->uid = cmsg.cred.cmcred_euid;
321 - credentials->gid = cmsg.cred.cmcred_groups[0];
322 + cred = (struct cmsgcred *) CMSG_DATA (&cmsg);
323 + credentials->pid = cred->cmcred_pid;
324 + credentials->uid = cred->cmcred_euid;
325 + credentials->gid = cred->cmcred_groups[0];
326 #elif defined(HAVE_GETPEEREID)
327 uid_t euid;
328 gid_t egid;
329
330 --- python/dbus_h_wrapper.h.orig Sat Jul 16 03:30:40 2005
331 +++ python/dbus_h_wrapper.h Sat Jul 16 03:28:47 2005
332 @@ -1,3 +1,4 @@
333 #define DBUS_API_SUBJECT_TO_CHANGE 1
334 +#define lint 1
335 #include <dbus/dbus.h>

  ViewVC Help
Powered by ViewVC 1.1.20