Skip to content

Commit

Permalink
ws: connect to cockpit-session via socket
Browse files Browse the repository at this point in the history
Unless it's otherwise specified in the configuration file, we now spawn
cockpit-session by connecting to /run/cockpit/session.

We leave the cockpit_ws_session_program variable in place to allow the
tests to override things.

Update the unit files for cockpit-ws to ensure that the socket is
available when cockpit-ws is running.
  • Loading branch information
allisonkarlitskaya committed Jan 11, 2022
1 parent 15ae6dc commit 4768a60
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
3 changes: 0 additions & 3 deletions selinux/cockpit.te
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@ can_exec(cockpit_ws_t,cockpit_ws_exec_t)
# systemd can execute cockpit-session
can_exec(init_t,cockpit_session_exec_t)

# cockpit-ws can execute cockpit-session
can_exec(cockpit_ws_t,cockpit_session_exec_t)

# cockpit-ws can read from /dev/urandom
dev_read_urand(cockpit_ws_t) # for authkey
dev_read_rand(cockpit_ws_t) # for libssh
Expand Down
2 changes: 2 additions & 0 deletions src/systemd/cockpit-wsinstance-http.service.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
Description=Cockpit Web Service http instance
BindsTo=cockpit.service
Documentation=man:cockpit-ws(8)
Requires=cockpit-session.socket
After=cockpit-session.socket

[Service]
ExecStart=@libexecdir@/cockpit-ws --no-tls --port=0
Expand Down
2 changes: 2 additions & 0 deletions src/systemd/[email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
Description=Cockpit Web Service https instance %I
BindsTo=cockpit.service
Documentation=man:cockpit-ws(8)
Requires=cockpit-session.socket
After=cockpit-session.socket

[Service]
Slice=system-cockpithttps.slice
Expand Down
9 changes: 7 additions & 2 deletions src/ws/cockpitauth.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
#define LOCAL_SESSION "local-session"

/* Some tunables that can be set from tests */
const gchar *cockpit_ws_session_program = LIBEXECDIR "/cockpit-session";
const gchar *cockpit_ws_session_program = NULL;
const gchar *cockpit_ws_ssh_program = LIBEXECDIR "/cockpit-ssh";

/* Timeout of authenticated session when no connections */
Expand Down Expand Up @@ -1137,7 +1137,12 @@ cockpit_session_launch (CockpitAuth *self,
g_str_equal (type, "tls-cert"))
{
if (command == NULL && connect_to == NULL)
command = cockpit_ws_session_program;
{
if (cockpit_ws_session_program)
command = cockpit_ws_session_program;
else
connect_to = "/run/cockpit/session";
}
}

g_autoptr(CockpitPipe) pipe = NULL;
Expand Down

0 comments on commit 4768a60

Please sign in to comment.