Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

repo: Add checksum to error message opening unreadable object #1564

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/libostree/ostree-repo.c
Original file line number Diff line number Diff line change
Expand Up @@ -3550,6 +3550,9 @@ _ostree_repo_load_file_bare (OstreeRepo *self,
return FALSE;
}

const char *errprefix = glnx_strjoina ("Opening content object ", checksum);
GLNX_AUTO_PREFIX_ERROR (errprefix, error);

struct stat stbuf;
glnx_autofd int fd = -1;
g_autofree char *ret_symlink = NULL;
Expand Down Expand Up @@ -3590,7 +3593,7 @@ _ostree_repo_load_file_bare (OstreeRepo *self,
}

if (!(S_ISREG (stbuf.st_mode) || S_ISLNK (stbuf.st_mode)))
return glnx_throw (error, "Not a regular file or symlink: %s", loose_path_buf);
return glnx_throw (error, "Not a regular file or symlink");

/* In the non-bare-user case, gather symlink info if requested */
if (self->mode != OSTREE_REPO_MODE_BARE_USER
Expand Down
21 changes: 21 additions & 0 deletions tests/installed/nondestructive/itest-bare-unit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,24 @@ trap _tmpdir_cleanup EXIT
/usr/libexec/installed-tests/libostree/test-basic.sh
/usr/libexec/installed-tests/libostree/test-basic-c
date

# Test error message when opening a non-world-readable object
# https://github.com/ostreedev/ostree/issues/1562
rm repo -rf
chmod a+rx .
ostree --repo=repo init --mode=bare
mkdir files
touch files/unreadable
chmod 0 files/unreadable
ostree --repo=repo commit -b testbranch --tree=dir=files
# We should be able to read as non-root due to CAP_DAC_OVERRIDE
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should say "read as root", right?

ostree --repo=repo ls testbranch >/dev/null
cat >upriv.sh <<EOF
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't look used anywhere?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, fixup for all of these ⬇️

#!/bin/bash
set -xeuo pipefail
ostree --repo=testclone
EOF
if setpriv --reuid bin --regid bin --clear-groups ostree --repo=repo cat testbranch /unreadable 2>err.txt; then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd be more convinced if we did the exact same cat testbranch /unreadable test also for root above. :)

fatal "Listed unreadable object as non-root"
fi
assert_file_has_content err.txt "Opening content object.*openat: Permission denied"