Commit 021a1e78 authored by Lennart Poettering's avatar Lennart Poettering

bus: make optional whether unix socket passing is negotiated and whether hello is sent

This alos gets rid of explicit sd_open_fd() and sd_open_address()
constructors in favour of sd_new() + sd_new_start() where the
negotiation parameters may be set it in between.
parent 66f931b4
......@@ -57,6 +57,7 @@ struct object_callback {
};
enum bus_state {
BUS_UNSET,
BUS_OPENING,
BUS_AUTHENTICATING,
BUS_HELLO,
......@@ -68,8 +69,10 @@ struct sd_bus {
enum bus_state state;
int fd;
int message_version;
bool negotiate_fds:1;
bool can_fds:1;
bool sent_hello:1;
bool send_hello:1;
bool ucred_valid:1;
void *rbuffer;
......
......@@ -331,7 +331,7 @@ static sd_bus_message *message_new(sd_bus *bus, uint8_t type) {
m->header->endian = SD_BUS_NATIVE_ENDIAN;
m->header->type = type;
m->header->version = bus ? bus->message_version : 1;
m->allow_fds = !bus || bus->can_fds;
m->allow_fds = !bus || bus->can_fds || (bus->state != BUS_HELLO && bus->state != BUS_RUNNING);
return m;
}
......@@ -354,6 +354,8 @@ int sd_bus_message_new_signal(
return -EINVAL;
if (!m)
return -EINVAL;
if (bus && bus->state == BUS_UNSET)
return -ENOTCONN;
t = message_new(bus, SD_BUS_MESSAGE_TYPE_SIGNAL);
if (!t)
......@@ -396,6 +398,8 @@ int sd_bus_message_new_method_call(
return -EINVAL;
if (!m)
return -EINVAL;
if (bus && bus->state == BUS_UNSET)
return -ENOTCONN;
t = message_new(bus, SD_BUS_MESSAGE_TYPE_METHOD_CALL);
if (!t)
......@@ -445,6 +449,8 @@ static int message_new_reply(
return -EINVAL;
if (!m)
return -EINVAL;
if (bus && bus->state == BUS_UNSET)
return -ENOTCONN;
t = message_new(bus, type);
if (!t)
......
This diff is collapsed.
......@@ -53,8 +53,14 @@ typedef int (*sd_message_handler_t)(sd_bus *bus, int ret, sd_bus_message *m, voi
int sd_bus_open_system(sd_bus **ret);
int sd_bus_open_user(sd_bus **ret);
int sd_bus_open_address(const char *address, sd_bus **ret);
int sd_bus_open_fd(int fd, sd_bus **ret);
int sd_bus_new(sd_bus **ret);
int sd_bus_set_address(sd_bus *bus, const char *address);
int sd_bus_set_fd(sd_bus *bus, int fd);
int sd_bus_set_hello(sd_bus *bus, int b);
int sd_bus_set_negotiate_fds(sd_bus *bus, int b);
int sd_bus_start(sd_bus *ret);
void sd_bus_close(sd_bus *bus);
sd_bus *sd_bus_ref(sd_bus *bus);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment