1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2024-10-30 23:21:08 +03:00

bus: rename sd_bus_get_peer() to sd_bus_get_server_id()

This function always returns the server side ID. The name suggested it
was actually always the peer's ID, but that's not correct if the call is
called on a server bus context. Hence, let's correct the name a bit.
This commit is contained in:
Lennart Poettering 2013-03-31 16:46:21 +02:00
parent 52f3ba915b
commit 98178d3947
5 changed files with 17 additions and 17 deletions

View File

@ -112,7 +112,7 @@ struct sd_bus {
} sockaddr;
socklen_t sockaddr_size;
sd_id128_t peer;
sd_id128_t server_id;
char *address;
unsigned address_index;

View File

@ -146,11 +146,11 @@ static int bus_socket_auth_verify_client(sd_bus *b) {
peer.bytes[i/2] = ((uint8_t) x << 4 | (uint8_t) y);
}
if (!sd_id128_equal(b->peer, SD_ID128_NULL) &&
!sd_id128_equal(b->peer, peer))
if (!sd_id128_equal(b->server_id, SD_ID128_NULL) &&
!sd_id128_equal(b->server_id, peer))
return -EPERM;
b->peer = peer;
b->server_id = peer;
/* And possibly check the second line, too */
@ -286,7 +286,7 @@ static int bus_socket_auth_write_ok(sd_bus *b) {
assert(b);
snprintf(t, sizeof(t), "OK " SD_ID128_FORMAT_STR "\r\n", SD_ID128_FORMAT_VAL(b->peer));
snprintf(t, sizeof(t), "OK " SD_ID128_FORMAT_STR "\r\n", SD_ID128_FORMAT_VAL(b->server_id));
char_array_0(t);
return bus_socket_auth_write(b, t);

View File

@ -200,16 +200,16 @@ int sd_bus_set_negotiate_fds(sd_bus *bus, int b) {
return 0;
}
int sd_bus_set_server(sd_bus *bus, int b, sd_id128_t server) {
int sd_bus_set_server(sd_bus *bus, int b, sd_id128_t server_id) {
if (!bus)
return -EINVAL;
if (!b && !sd_id128_equal(server, SD_ID128_NULL))
if (!b && !sd_id128_equal(server_id, SD_ID128_NULL))
return -EINVAL;
if (bus->state != BUS_UNSET)
return -EPERM;
bus->is_server = !!b;
bus->peer = server;
bus->server_id = server_id;
return 0;
}
@ -604,7 +604,7 @@ static void bus_reset_parsed_address(sd_bus *b) {
free(b->exec_path);
b->exec_path = NULL;
b->exec_argv = NULL;
b->peer = SD_ID128_NULL;
b->server_id = SD_ID128_NULL;
}
static int bus_parse_next_address(sd_bus *b) {
@ -664,7 +664,7 @@ static int bus_parse_next_address(sd_bus *b) {
}
if (guid) {
r = sd_id128_from_string(guid, &b->peer);
r = sd_id128_from_string(guid, &b->server_id);
if (r < 0)
return r;
}
@ -907,19 +907,19 @@ int sd_bus_can_send(sd_bus *bus, char type) {
return bus_type_is_valid(type);
}
int sd_bus_get_peer(sd_bus *bus, sd_id128_t *peer) {
int sd_bus_get_server_id(sd_bus *bus, sd_id128_t *server_id) {
int r;
if (!bus)
return -EINVAL;
if (!peer)
if (!server_id)
return -EINVAL;
r = bus_ensure_running(bus);
if (r < 0)
return r;
*peer = bus->peer;
*server_id = bus->server_id;
return 0;
}

View File

@ -60,9 +60,9 @@ 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_exec(sd_bus *bus, const char *path, char *const argv[]);
int sd_bus_set_bus_client(sd_bus *bus, int b);
int sd_bus_set_negotiate_fds(sd_bus *bus, int b);
int sd_bus_set_server(sd_bus *bus, int b, sd_id128_t server_id);
int sd_bus_set_anonymous(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);
@ -72,7 +72,7 @@ sd_bus *sd_bus_unref(sd_bus *bus);
int sd_bus_is_open(sd_bus *bus);
int sd_bus_can_send(sd_bus *bus, char type);
int sd_bus_get_peer(sd_bus *bus, sd_id128_t *peer);
int sd_bus_get_server_id(sd_bus *bus, sd_id128_t *peer);
int sd_bus_send(sd_bus *bus, sd_bus_message *m, uint64_t *serial);
int sd_bus_send_with_reply(sd_bus *bus, sd_bus_message *m, sd_bus_message_handler_t callback, void *userdata, uint64_t usec, uint64_t *serial);

View File

@ -85,9 +85,9 @@ static int server_init(sd_bus **_bus) {
goto fail;
}
r = sd_bus_get_peer(bus, &id);
r = sd_bus_get_server_id(bus, &id);
if (r < 0) {
log_error("Failed to get peer ID: %s", strerror(-r));
log_error("Failed to get server ID: %s", strerror(-r));
goto fail;
}