diff options
author | Joe Shaw <joeshaw@novell.com> | 2003-02-18 22:51:35 +0000 |
---|---|---|
committer | Joe Shaw <joeshaw@novell.com> | 2003-02-18 22:51:35 +0000 |
commit | 9ada6e2cad0d623fb578f349790a0c62297d2394 (patch) | |
tree | 2925acc28c0d15a6bb8bc78909502035847476b8 /dbus/dbus-sysdeps.c | |
parent | 9e1b2fe28e0f8ef49221113634d8d591d106820d (diff) |
2003-02-18 Joe Shaw <joe@assbarn.com>
* dbus/dbus-auth.c (handle_server_data_stupid_test_mech): Just get
credentials from our currently running process.
(get_word): Fix a buglet where we were copying the entire length
instead of relative to our position.
* dbus/dbus-hash.c (_dbus_hash_test): Don't try to allocate the
keys on the stack... it's 640k of data.
* dbus/dbus-sysdeps.c (_dbus_read_credentials_unix_socket): Always
read the credentials byte off the socket, even if we don't have
SO_PEERCRED.
(_dbus_poll): Implement poll() using select() for systems which
don't have it.
* glib/test-dbus-glib.c (main): Print out an error if no
parameters are given.
* test/data/auth/fallback.auth-script: Added. Tests that a client
can fallback to a secondary auth mechanism if the first fails.
Diffstat (limited to 'dbus/dbus-sysdeps.c')
-rw-r--r-- | dbus/dbus-sysdeps.c | 62 |
1 files changed, 55 insertions, 7 deletions
diff --git a/dbus/dbus-sysdeps.c b/dbus/dbus-sysdeps.c index 1308a6ba..f76c6bd0 100644 --- a/dbus/dbus-sysdeps.c +++ b/dbus/dbus-sysdeps.c @@ -503,9 +503,9 @@ _dbus_read_credentials_unix_socket (int client_fd, credentials->uid = -1; credentials->gid = -1; -#ifdef SO_PEERCRED if (read_credentials_byte (client_fd, result)) { +#ifdef SO_PEERCRED struct ucred cr; int cr_len = sizeof (cr); @@ -525,15 +525,14 @@ _dbus_read_credentials_unix_socket (int client_fd, _dbus_verbose ("Failed to getsockopt() credentials, returned len %d/%d: %s\n", cr_len, (int) sizeof (cr), _dbus_strerror (errno)); } +#else /* !SO_PEERCRED */ + _dbus_verbose ("Socket credentials not supported on this OS\n"); +#endif return TRUE; } else return FALSE; -#else /* !SO_PEERCRED */ - _dbus_verbose ("Socket credentials not supported on this OS\n"); - return TRUE; -#endif } /** @@ -1052,8 +1051,57 @@ _dbus_poll (DBusPollFD *fds, return -1; } #else /* ! HAVE_POLL */ - _dbus_warn ("need to implement select() fallback for systems with no poll()\n"); - return -1; + + fd_set read_set, write_set, err_set; + int max_fd; + int i; + struct timeval tv; + int ready; + + FD_ZERO (&read_set); + FD_ZERO (&write_set); + FD_ZERO (&err_set); + + for (i = 0; i < n_fds; i++) + { + DBusPollFD f = fds[i]; + + if (f.events & _DBUS_POLLIN) + FD_SET (f.fd, &read_set); + + if (f.events & _DBUS_POLLOUT) + FD_SET (f.fd, &write_set); + + FD_SET (f.fd, &err_set); + + max_fd = MAX (max_fd, f.fd); + } + + tv.tv_sec = timeout_milliseconds / 1000; + tv.tv_usec = (timeout_milliseconds % 1000) * 1000; + + ready = select (max_fd + 1, &read_set, &write_set, &err_set, &tv); + + if (ready > 0) + { + for (i = 0; i < n_fds; i++) + { + DBusPollFD f = fds[i]; + + f.revents = 0; + + if (FD_ISSET (f.fd, &read_set)) + f.revents |= _DBUS_POLLIN; + + if (FD_ISSET (f.fd, &write_set)) + f.revents |= _DBUS_POLLOUT; + + if (FD_ISSET (f.fd, &err_set)) + f.revents |= _DBUS_POLLERR; + } + } + + return ready; #endif } |