Skip to content

Commit

Permalink
app: Only call RegisterClient() if we're root
Browse files Browse the repository at this point in the history
Otherwise we can't do e.g. `rpm-ostree status`.

Closes: #738

Closes: #739
Approved by: dustymabe
  • Loading branch information
cgwalters authored and rh-atomic-bot committed Apr 14, 2017
1 parent 67c9b38 commit b21b08c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/app/rpmostree-dbus-helpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,16 @@ rpmostree_load_sysroot (gchar *sysroot,
if (sysroot_proxy == NULL)
return FALSE;

/* This tells the daemon not to auto-exit as long as we are alive */
if (!rpmostree_sysroot_call_register_client_sync (sysroot_proxy,
g_variant_builder_end (options_builder),
cancellable, error))
return FALSE;
/* This tells the daemon not to auto-exit as long as we are alive; but we can
* only do this as root.
*/
if (getuid () == 0)
{
if (!rpmostree_sysroot_call_register_client_sync (sysroot_proxy,
g_variant_builder_end (options_builder),
cancellable, error))
return FALSE;
}

*out_sysroot_proxy = g_steal_pointer (&sysroot_proxy);
*out_peer_pid = peer_pid; peer_pid = 0;
Expand Down
3 changes: 3 additions & 0 deletions tests/vmcheck/test-layering-basic.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ if vm_cmd "runuser -u bin rpm-ostree pkg-add foo-1.0"; then
assert_not_reached "Was able to install a package as non-root!"
fi

# Assert that we can do status as non-root
vm_cmd "runuser -u bin rpm-ostree status" >/dev/null

# Be sure an unprivileged user exists
if vm_rpmostree install test-opt-1.0 2>err.txt; then
assert_not_reached "Was able to install a package in /opt"
Expand Down

0 comments on commit b21b08c

Please sign in to comment.