mirror of
https://gitlab.freedesktop.org/dbus/dbus.git
synced 2026-05-05 01:48:00 +02:00
2003-06-09 Havoc Pennington <hp@redhat.com>
* dbus/dbus-sysdeps.c (_dbus_listen_unix_socket): don't use SUN_LEN, it breaks abstract socket usage * dbus/dbus-internals.c (_dbus_verbose_real): only print PID at starts of lines.
This commit is contained in:
parent
a70b042f0d
commit
6a109938f7
3 changed files with 38 additions and 10 deletions
|
|
@ -1,3 +1,11 @@
|
|||
2003-06-09 Havoc Pennington <hp@redhat.com>
|
||||
|
||||
* dbus/dbus-sysdeps.c (_dbus_listen_unix_socket): don't use
|
||||
SUN_LEN, it breaks abstract socket usage
|
||||
|
||||
* dbus/dbus-internals.c (_dbus_verbose_real): only print PID at
|
||||
starts of lines.
|
||||
|
||||
2003-06-04 Havoc Pennington <hp@pobox.com>
|
||||
|
||||
* dbus/dbus-server.c (dbus_server_listen): allow abstract sockets
|
||||
|
|
|
|||
|
|
@ -190,6 +190,7 @@ _dbus_verbose_real (const char *format,
|
|||
{
|
||||
va_list args;
|
||||
static dbus_bool_t verbose = TRUE;
|
||||
static dbus_bool_t need_pid = TRUE;
|
||||
|
||||
/* things are written a bit oddly here so that
|
||||
* in the non-verbose case we just have the one
|
||||
|
|
@ -206,7 +207,18 @@ _dbus_verbose_real (const char *format,
|
|||
return;
|
||||
}
|
||||
|
||||
fprintf (stderr, "%lu: ", _dbus_getpid ());
|
||||
if (need_pid)
|
||||
{
|
||||
int len;
|
||||
|
||||
fprintf (stderr, "%lu: ", _dbus_getpid ());
|
||||
|
||||
len = strlen (format);
|
||||
if (format[len-1] == '\n')
|
||||
need_pid = TRUE;
|
||||
else
|
||||
need_pid = FALSE;
|
||||
}
|
||||
|
||||
va_start (args, format);
|
||||
vfprintf (stderr, format, args);
|
||||
|
|
|
|||
|
|
@ -62,12 +62,6 @@
|
|||
#define O_BINARY 0
|
||||
#endif
|
||||
|
||||
#ifndef SUN_LEN
|
||||
/* This system is not POSIX.1g. */
|
||||
#define SUN_LEN(ptr) ((size_t) (((struct sockaddr_un *) 0)->sun_path) \
|
||||
+ strlen ((ptr)->sun_path))
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @addtogroup DBusInternalsUtils
|
||||
* @{
|
||||
|
|
@ -392,6 +386,9 @@ _dbus_connect_unix_socket (const char *path,
|
|||
struct sockaddr_un addr;
|
||||
|
||||
_DBUS_ASSERT_ERROR_IS_CLEAR (error);
|
||||
|
||||
_dbus_verbose ("connecting to unix socket %s abstract=%d\n",
|
||||
path, abstract);
|
||||
|
||||
fd = socket (PF_UNIX, SOCK_STREAM, 0);
|
||||
|
||||
|
|
@ -411,14 +408,18 @@ _dbus_connect_unix_socket (const char *path,
|
|||
if (abstract)
|
||||
{
|
||||
#ifdef HAVE_ABSTRACT_SOCKETS
|
||||
/* remember that abstract names aren't nul-terminated so we rely
|
||||
* on sun_path being filled in with zeroes above.
|
||||
*/
|
||||
addr.sun_path[0] = '\0'; /* this is what says "use abstract" */
|
||||
strncpy (&addr.sun_path[1], path, _DBUS_MAX_SUN_PATH_LENGTH - 2);
|
||||
/* _dbus_verbose_bytes (addr.sun_path, sizeof (addr.sun_path)); */
|
||||
#else /* HAVE_ABSTRACT_SOCKETS */
|
||||
dbus_set_error (error, DBUS_ERROR_NOT_SUPPORTED,
|
||||
"Operating system does not support abstract socket namespace\n");
|
||||
close (fd);
|
||||
return -1;
|
||||
#endif /* ! HAVE_ABSTRACT_SOCKETS */
|
||||
#endif /* ! HAVE_ABSTRACT_SOCKETS */
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -475,6 +476,9 @@ _dbus_listen_unix_socket (const char *path,
|
|||
struct sockaddr_un addr;
|
||||
|
||||
_DBUS_ASSERT_ERROR_IS_CLEAR (error);
|
||||
|
||||
_dbus_verbose ("listening on unix socket %s abstract=%d\n",
|
||||
path, abstract);
|
||||
|
||||
listen_fd = socket (PF_UNIX, SOCK_STREAM, 0);
|
||||
|
||||
|
|
@ -492,8 +496,12 @@ _dbus_listen_unix_socket (const char *path,
|
|||
if (abstract)
|
||||
{
|
||||
#ifdef HAVE_ABSTRACT_SOCKETS
|
||||
/* remember that abstract names aren't nul-terminated so we rely
|
||||
* on sun_path being filled in with zeroes above.
|
||||
*/
|
||||
addr.sun_path[0] = '\0'; /* this is what says "use abstract" */
|
||||
strncpy (&addr.sun_path[1], path, _DBUS_MAX_SUN_PATH_LENGTH - 2);
|
||||
/* _dbus_verbose_bytes (addr.sun_path, sizeof (addr.sun_path)); */
|
||||
#else /* HAVE_ABSTRACT_SOCKETS */
|
||||
dbus_set_error (error, DBUS_ERROR_NOT_SUPPORTED,
|
||||
"Operating system does not support abstract socket namespace\n");
|
||||
|
|
@ -524,7 +532,7 @@ _dbus_listen_unix_socket (const char *path,
|
|||
strncpy (addr.sun_path, path, _DBUS_MAX_SUN_PATH_LENGTH - 1);
|
||||
}
|
||||
|
||||
if (bind (listen_fd, (struct sockaddr*) &addr, SUN_LEN (&addr)) < 0)
|
||||
if (bind (listen_fd, (struct sockaddr*) &addr, sizeof (addr)) < 0)
|
||||
{
|
||||
dbus_set_error (error, _dbus_error_from_errno (errno),
|
||||
"Failed to bind socket \"%s\": %s",
|
||||
|
|
@ -548,7 +556,7 @@ _dbus_listen_unix_socket (const char *path,
|
|||
close (listen_fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
/* Try opening up the permissions, but if we can't, just go ahead
|
||||
* and continue, maybe it will be good enough.
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue