mirror of
https://github.com/troglobit/finit.git
synced 2026-10-14 10:19:36 +00:00
dbus: gate the bus socket like INIT_SOCKET
The D-Bus socket was bound world read/write, on the reasoning that SO_PEERCRED authorizes each method anyway. That leaves the read-only surface open to every local user, and it quietly ignores --with-group: a system that restricts initctl to the wheel group still handed the same service state to anyone who asked over the bus. Bind it 0660 and chown it to the configured group, the same gate the fallback socket has always had. libink takes the mode as an argument rather than assuming one, since who may connect is the embedder's policy, not the library's. The mode is applied at bind(), so there is no window where the socket is more permissive than intended. Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
1 parent
c71ccce742
commit
d710a23513
6 files changed
+33
-10
No files matched your search
+7
-1
@@ -1341,11 +1341,17 @@ int dbus_init(uev_ctx_t *ctx)
|
||||
{
|
||||
dbg("Setting up D-Bus listening socket at %s ...", FINIT_BUS_SOCKET);
|
||||
|
||||
if (link_server_new(&server, FINIT_BUS_SOCKET) < 0) {
|
||||
/* Same access policy as INIT_SOCKET: the bus reaches every
|
||||
* service operation initctl does, so --with-group has to gate
|
||||
* both or it gates neither. */
|
||||
if (link_server_new(&server, FINIT_BUS_SOCKET, 0660) < 0) {
|
||||
err(1, "Failed binding D-Bus socket %s", FINIT_BUS_SOCKET);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (chown(FINIT_BUS_SOCKET, geteuid(), getgroup(DEFGROUP)))
|
||||
err(1, "Failed setting group %s on %s", DEFGROUP, FINIT_BUS_SOCKET);
|
||||
|
||||
if (link_server_add_object(server, "/org/finit/manager",
|
||||
&manager_vtable, NULL) < 0) {
|
||||
err(1, "Failed registering Manager1 object");
|
||||
|
||||
Reference in new issue
Block a user