summaryrefslogtreecommitdiffstats
path: root/bus
diff options
context:
space:
mode:
Diffstat (limited to 'bus')
-rw-r--r--bus/bus.c42
-rw-r--r--bus/bus.h4
-rw-r--r--bus/config-parser.c1
-rw-r--r--bus/main.c18
-rw-r--r--bus/test.c4
5 files changed, 37 insertions, 32 deletions
diff --git a/bus/bus.c b/bus/bus.c
index b54ea2d8..fb9322a9 100644
--- a/bus/bus.c
+++ b/bus/bus.c
@@ -527,8 +527,8 @@ process_config_postinit (BusContext *context,
BusContext*
bus_context_new (const DBusString *config_file,
ForceForkSetting force_fork,
- DBusPipe print_addr_fd,
- DBusPipe print_pid_fd,
+ DBusPipe *print_addr_pipe,
+ DBusPipe *print_pid_pipe,
DBusError *error)
{
BusContext *context;
@@ -598,12 +598,12 @@ bus_context_new (const DBusString *config_file,
if (!dbus_server_allocate_data_slot (&server_data_slot))
_dbus_assert_not_reached ("second ref of server data slot failed");
- /* Note that we don't know whether the print_addr_fd is
+ /* Note that we don't know whether the print_addr_pipe is
* one of the sockets we're using to listen on, or some
* other random thing. But I think the answer is "don't do
* that then"
*/
- if (_dbus_pipe_is_valid(print_addr_fd))
+ if (print_addr_pipe != NULL && _dbus_pipe_is_valid (print_addr_pipe))
{
DBusString addr;
const char *a = bus_context_get_address (context);
@@ -625,17 +625,20 @@ bus_context_new (const DBusString *config_file,
}
bytes = _dbus_string_get_length (&addr);
- if (_dbus_pipe_write(print_addr_fd, &addr, 0, bytes) != bytes)
+ if (_dbus_pipe_write (print_addr_pipe, &addr, 0, bytes, error) != bytes)
{
- dbus_set_error (error, DBUS_ERROR_FAILED,
- "Printing message bus address: %s\n",
- _dbus_strerror (errno));
+ /* pipe write returns an error on failure but not short write */
+ if (error != NULL && !dbus_error_is_set (error))
+ {
+ dbus_set_error (error, DBUS_ERROR_FAILED,
+ "Printing message bus address: did not write all bytes\n");
+ }
_dbus_string_free (&addr);
goto failed;
}
- if (_dbus_pipe_is_special(print_addr_fd))
- _dbus_pipe_close(print_addr_fd, NULL);
+ if (!_dbus_pipe_is_stdout_or_stderr (print_addr_pipe))
+ _dbus_pipe_close (print_addr_pipe, NULL);
_dbus_string_free (&addr);
}
@@ -681,7 +684,7 @@ bus_context_new (const DBusString *config_file,
_dbus_string_init_const (&u, context->pidfile);
if (!_dbus_become_daemon (context->pidfile ? &u : NULL,
- print_pid_fd,
+ print_pid_pipe,
error))
{
_DBUS_ASSERT_ERROR_IS_SET (error);
@@ -706,7 +709,7 @@ bus_context_new (const DBusString *config_file,
}
/* Write PID if requested */
- if (_dbus_pipe_is_valid(print_pid_fd))
+ if (print_pid_pipe != NULL && _dbus_pipe_is_valid (print_pid_pipe))
{
DBusString pid;
int bytes;
@@ -726,17 +729,20 @@ bus_context_new (const DBusString *config_file,
}
bytes = _dbus_string_get_length (&pid);
- if (_dbus_pipe_write (print_pid_fd, &pid, 0, bytes) != bytes)
+ if (_dbus_pipe_write (print_pid_pipe, &pid, 0, bytes, error) != bytes)
{
- dbus_set_error (error, DBUS_ERROR_FAILED,
- "Printing message bus PID: %s\n",
- _dbus_strerror (errno));
+ /* pipe_write sets error on failure but not short write */
+ if (error != NULL && !dbus_error_is_set (error))
+ {
+ dbus_set_error (error, DBUS_ERROR_FAILED,
+ "Printing message bus PID: did not write enough bytes\n");
+ }
_dbus_string_free (&pid);
goto failed;
}
- if (_dbus_pipe_is_special (print_pid_fd))
- _dbus_pipe_close (print_pid_fd, NULL);
+ if (!_dbus_pipe_is_stdout_or_stderr (print_pid_pipe))
+ _dbus_pipe_close (print_pid_pipe, NULL);
_dbus_string_free (&pid);
}
diff --git a/bus/bus.h b/bus/bus.h
index 0aea841a..bb51004b 100644
--- a/bus/bus.h
+++ b/bus/bus.h
@@ -70,8 +70,8 @@ typedef enum
BusContext* bus_context_new (const DBusString *config_file,
ForceForkSetting force_fork,
- DBusPipe print_addr_fd,
- DBusPipe print_pid_fd,
+ DBusPipe *print_addr_pipe,
+ DBusPipe *print_pid_pipe,
DBusError *error);
dbus_bool_t bus_context_reload_config (BusContext *context,
DBusError *error);
diff --git a/bus/config-parser.c b/bus/config-parser.c
index db46893a..ea12ce7f 100644
--- a/bus/config-parser.c
+++ b/bus/config-parser.c
@@ -27,6 +27,7 @@
#include "selinux.h"
#include <dbus/dbus-list.h>
#include <dbus/dbus-internals.h>
+#include <dbus/dbus-userdb.h>
#include <string.h>
typedef enum
diff --git a/bus/main.c b/bus/main.c
index b73c683f..bf471484 100644
--- a/bus/main.c
+++ b/bus/main.c
@@ -247,8 +247,8 @@ main (int argc, char **argv)
DBusString addr_fd;
DBusString pid_fd;
const char *prev_arg;
- DBusPipe print_addr_fd;
- DBusPipe print_pid_fd;
+ DBusPipe print_addr_pipe;
+ DBusPipe print_pid_pipe;
int i;
dbus_bool_t print_address;
dbus_bool_t print_pid;
@@ -387,10 +387,10 @@ main (int argc, char **argv)
usage ();
}
- print_addr_fd = _dbus_pipe_init(-1);
+ _dbus_pipe_invalidate (&print_addr_pipe);
if (print_address)
{
- print_addr_fd = _dbus_pipe_init(1); /* stdout */
+ _dbus_pipe_init_stdout (&print_addr_pipe);
if (_dbus_string_get_length (&addr_fd) > 0)
{
long val;
@@ -404,15 +404,15 @@ main (int argc, char **argv)
exit (1);
}
- print_addr_fd = _dbus_pipe_init(val);
+ _dbus_pipe_init (&print_addr_pipe, val);
}
}
_dbus_string_free (&addr_fd);
- print_pid_fd = _dbus_pipe_init(-1);
+ _dbus_pipe_invalidate (&print_pid_pipe);
if (print_pid)
{
- print_pid_fd = _dbus_pipe_init(1); /* stdout */
+ _dbus_pipe_init_stdout (&print_pid_pipe);
if (_dbus_string_get_length (&pid_fd) > 0)
{
long val;
@@ -426,7 +426,7 @@ main (int argc, char **argv)
exit (1);
}
- print_pid_fd = _dbus_pipe_init(val);
+ _dbus_pipe_init (&print_pid_pipe, val);
}
}
_dbus_string_free (&pid_fd);
@@ -439,7 +439,7 @@ main (int argc, char **argv)
dbus_error_init (&error);
context = bus_context_new (&config_file, force_fork,
- print_addr_fd, print_pid_fd,
+ &print_addr_pipe, &print_pid_pipe,
&error);
_dbus_string_free (&config_file);
if (context == NULL)
diff --git a/bus/test.c b/bus/test.c
index 3315a702..629d52d4 100644
--- a/bus/test.c
+++ b/bus/test.c
@@ -298,7 +298,6 @@ bus_context_new_test (const DBusString *test_data_dir,
DBusString config_file;
DBusString relative;
BusContext *context;
- DBusPipe pipe;
if (!_dbus_string_init (&config_file))
{
@@ -324,8 +323,7 @@ bus_context_new_test (const DBusString *test_data_dir,
}
dbus_error_init (&error);
- pipe = _dbus_pipe_init(-1);
- context = bus_context_new (&config_file, FALSE, pipe, pipe, &error);
+ context = bus_context_new (&config_file, FALSE, NULL, NULL, &error);
if (context == NULL)
{
_DBUS_ASSERT_ERROR_IS_SET (&error);