Skip to content

Commit

Permalink
core: Don't try to apply non-root uid/gid when run as non-root
Browse files Browse the repository at this point in the history
In an unprivileged case, we can't do this on the real filesystem. For
`ex container`, we want to completely ignore uid/gid.  I added a test
installing `httpd` which failed previously.

TODO: For non-root `--ex-unified-core` we need to do it as a commit modifier.
  • Loading branch information
cgwalters committed Nov 16, 2017
1 parent b6bd2ab commit 6c9342a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/libpriv/rpmostree-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -2700,6 +2700,14 @@ apply_rpmfi_overrides (RpmOstreeContext *self,
GCancellable *cancellable,
GError **error)
{
/* In an unprivileged case, we can't do this on the real filesystem. For `ex
* container`, we want to completely ignore uid/gid.
*
* TODO: For non-root `--ex-unified-core` we need to do it as a commit modifier.
*/
if (getuid () != 0)
return TRUE; /* 🔚 Early return */

int i;
g_auto(rpmfi) fi = NULL;
gboolean emitted_nonusr_warning = FALSE;
Expand Down
19 changes: 19 additions & 0 deletions tests/ex-container-tests/test-httpd.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/bash
set -xeuo pipefail

cd ${test_tmpdir}

dn=$(cd $(dirname $0) && pwd)
. ${dn}/../common/libtest-core.sh

cat >httpd.conf <<EOF
[tree]
ref=httpd
packages=httpd;
repos=fedora;
EOF

# This one has non-root ownership in some of the dependencies, but we shouldn't
# try to apply them; see apply_rpmfi_overrides().
rpm-ostree ex container assemble httpd.conf
ostree --repo=repo ls httpd /usr/sbin/httpd

0 comments on commit 6c9342a

Please sign in to comment.