summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHavoc Pennington <hp@redhat.com>2003-06-09 22:09:34 +0000
committerHavoc Pennington <hp@redhat.com>2003-06-09 22:09:34 +0000
commit6a109938f7a4fc726997985b6de66cf573961986 (patch)
tree63a1b9b17cfdc2748f4e9edcbc2a03304a16c06a
parenta70b042f0dcebb10689975c65a2c45b52b7a4437 (diff)
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.
-rw-r--r--ChangeLog8
-rw-r--r--dbus/dbus-internals.c14
-rw-r--r--dbus/dbus-sysdeps.c26
3 files changed, 38 insertions, 10 deletions
diff --git a/ChangeLog b/ChangeLog
index 7874185a..75a82351 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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
diff --git a/dbus/dbus-internals.c b/dbus/dbus-internals.c
index 6a091e62..6e7f9e16 100644
--- a/dbus/dbus-internals.c
+++ b/dbus/dbus-internals.c
@@ -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);
diff --git a/dbus/dbus-sysdeps.c b/dbus/dbus-sysdeps.c
index 35900d70..be867a9d 100644
--- a/dbus/dbus-sysdeps.c
+++ b/dbus/dbus-sysdeps.c
@@ -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.
*/