X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fbus-proxyd%2Fproxy.c;h=3dea908f5bd44cef79d2c81e2c0fa5c565e0b8ec;hp=a34c43109653b7bba03b9d92dacdfc5c13f27623;hb=e28569311f5385cde76e4b84adbec6609b451cf9;hpb=557b5d4a94967198b3181fcb83879d4569cbf456 diff --git a/src/bus-proxyd/proxy.c b/src/bus-proxyd/proxy.c index a34c43109..3dea908f5 100644 --- a/src/bus-proxyd/proxy.c +++ b/src/bus-proxyd/proxy.c @@ -81,14 +81,14 @@ static int proxy_create_destination(Proxy *p, const char *destination, const cha b->fake_pids.pid = p->local_creds.pid; b->fake_pids_valid = true; - b->fake_creds.uid = p->local_creds.uid; + b->fake_creds.uid = UID_INVALID; b->fake_creds.euid = p->local_creds.uid; - b->fake_creds.suid = p->local_creds.uid; - b->fake_creds.fsuid = p->local_creds.uid; - b->fake_creds.gid = p->local_creds.gid; + b->fake_creds.suid = UID_INVALID; + b->fake_creds.fsuid = UID_INVALID; + b->fake_creds.gid = GID_INVALID; b->fake_creds.egid = p->local_creds.gid; - b->fake_creds.sgid = p->local_creds.gid; - b->fake_creds.fsgid = p->local_creds.gid; + b->fake_creds.sgid = GID_INVALID; + b->fake_creds.fsgid = GID_INVALID; b->fake_creds_valid = true; } @@ -376,7 +376,7 @@ static int proxy_wait(Proxy *p) { } pollfd = (struct pollfd[3]) { - { .fd = fd, .events = events_destination, }, + { .fd = fd, .events = events_destination, }, { .fd = p->local_in, .events = events_local & POLLIN, }, { .fd = p->local_out, .events = events_local & POLLOUT, }, }; @@ -689,6 +689,8 @@ static int proxy_process_destination_to_local(Proxy *p) { return -ECONNRESET; r = synthesize_name_acquired(p->destination_bus, p->local_bus, m); + if (r == -ECONNRESET || r == -ENOTCONN) + return r; if (r < 0) return log_error_errno(r, "Failed to synthesize message: %m"); @@ -696,6 +698,8 @@ static int proxy_process_destination_to_local(Proxy *p) { if (p->policy) { r = process_policy(p->destination_bus, p->local_bus, m, p->policy, &p->local_creds, p->owned_names); + if (r == -ECONNRESET || r == -ENOTCONN) + return r; if (r < 0) return log_error_errno(r, "Failed to process policy: %m"); if (r > 0) @@ -725,7 +729,10 @@ static int proxy_process_destination_to_local(Proxy *p) { /* Return the error to the client, if we can */ synthetic_reply_method_errnof(m, r, "Failed to forward message we got from destination: %m"); - log_error_errno(r, "Failed to send message to client, ignoring: %m"); + log_error_errno(r, + "Failed to forward message we got from destination: uid=" UID_FMT " gid=" GID_FMT" message=%s destination=%s path=%s interface=%s member=%s: %m", + p->local_creds.uid, p->local_creds.gid, bus_message_type_to_string(m->header->type), + strna(m->destination), strna(m->path), strna(m->interface), strna(m->member)); return 1; } @@ -755,12 +762,16 @@ static int proxy_process_local_to_destination(Proxy *p) { return -ECONNRESET; r = process_hello(p, m); + if (r == -ECONNRESET || r == -ENOTCONN) + return r; if (r < 0) return log_error_errno(r, "Failed to process HELLO: %m"); if (r > 0) return 1; r = bus_proxy_process_driver(p->destination_bus, p->local_bus, m, p->policy, &p->local_creds, p->owned_names); + if (r == -ECONNRESET || r == -ENOTCONN) + return r; if (r < 0) return log_error_errno(r, "Failed to process driver calls: %m"); if (r > 0) @@ -769,9 +780,11 @@ static int proxy_process_local_to_destination(Proxy *p) { for (;;) { if (p->policy) { r = process_policy(p->local_bus, p->destination_bus, m, p->policy, &p->local_creds, p->owned_names); + if (r == -ECONNRESET || r == -ENOTCONN) + return r; if (r < 0) return log_error_errno(r, "Failed to process policy: %m"); - else if (r > 0) + if (r > 0) return 1; } @@ -789,7 +802,10 @@ static int proxy_process_local_to_destination(Proxy *p) { return 1; synthetic_reply_method_errnof(m, r, "Failed to forward message we got from local: %m"); - log_error_errno(r, "Failed to send message to bus: %m"); + log_error_errno(r, + "Failed to forward message we got from local: uid=" UID_FMT " gid=" GID_FMT" message=%s destination=%s path=%s interface=%s member=%s: %m", + p->local_creds.uid, p->local_creds.gid, bus_message_type_to_string(m->header->type), + strna(m->destination), strna(m->path), strna(m->interface), strna(m->member)); return 1; } @@ -829,6 +845,8 @@ int proxy_run(Proxy *p) { if (!busy) { r = proxy_wait(p); + if (r == -ECONNRESET || r == -ENOTCONN) + return 0; if (r < 0) return r; }