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

lib/checkout: Ignore world-writable dirs for bare-user-only checkout #914

Closed

Conversation

cgwalters
Copy link
Member

See #909 for more information on the
rationale. Basically there's no reason for flatpak (which uses bare-user-only)
to have world-writable dirs. Particularly with the presence of the system
helper.

An approach I considered instead was to parse and validate directory metadata
objects at commit time. We still may do that in addition; for file objects we had
to do it that way because the actual files would be laid down suid. But directories
live only as inert .dirmeta objects until we do a checkout (i.e. mkdir()), so
we can solve the problem at checkout time.

@cgwalters
Copy link
Member Author

This depends on #913

@rh-atomic-bot
Copy link

☔ The latest upstream changes (presumably c81252c) made this pull request unmergeable. Please resolve the merge conflicts.

@alexlarsson
Copy link
Member

So, flatpak currently uses bare-user, although the long term plan when everything is working is to use bare-user-only.

Does it ever make sense to have writable directories when you do a checkout --user, independent of the repo format? I mean, I understand the system container case where you need 100% fidelity and check out as root. But once you're changing the uid/gid of the files you check out, then the permissions recorded in the repo does not mean the same thing as they do in the repo.

@cgwalters
Copy link
Member Author

cgwalters commented Jun 8, 2017

I was trying to be conservative initially; changing bare-user affects a lot more things (gcontinuous, buildstream, etc.), plus of course existing flatpak installs.

I was considering introducing a new flag for this (checkout ---user-safe or something?). But...there's definitely an argument we should just do the same for bare-user. If you're fine with that for flatpak, then I'd agree let's do it.

@alexlarsson
Copy link
Member

Its not just about bare-user though. I mean, if you have an archive-z2 repo, and you do a checkout --user from that, do you want a world-writable directory in your homedir? I mean, you might want to if you want 100% metadata fidelity, but then you would not use --user, which breaks that anyway.

I dunno. Maybe its too magic and should be a separate flag like --user-safe.

@cgwalters
Copy link
Member Author

I posted to the list: https://mail.gnome.org/archives/ostree-list/2017-June/msg00026.html

However, I realized there is a problem; when you want to do a commit based on content you checked out. And we'll definitely pick back up directory modes from there.

The only solution to this is to use a commit modifier (e.g. ostree commit --statoverride) for /tmp.

I think though most libostree users should start using 0700 directories and doing checkouts underneath there. See:

The special case here really is flatpak system wide installs, since there the directory obviously does need to be accessible by unprivileged users.

So...I think we should go with this patch as is for now.

cgwalters added 3 commits June 8, 2017 11:02
I noticed my previous patches incorrectly started doing `return glnx_throw*`
inside a `goto out;` function. Fix this by porting forward consistently to new
style. We just do the error prefixing in the caller.
Both callers of `commit_loose_object_trusted()` were passing
`OSTREE_OBJECT_TYPE_FILE`, so drop that parameter.  This in turn
allows us to drop lots of checking of that inside the function.

Add a doc comment, and rename to `commit_loose_content_object()` for clarity.
See ostreedev#909 for more information on the
rationale. Basically there's no reason for flatpak (which uses `bare-user-only`)
to have world-writable dirs. Particularly with the presence of the system
helper.

An approach I considered instead was to parse and validate directory metadata
objects at commit time. We still may do that in addition; for file objects we *had*
to do it that way because the actual files would be laid down suid.  But directories
live only as inert `.dirmeta` objects until we do a checkout (i.e. `mkdir()`), so
we can solve the problem at checkout time.
@cgwalters cgwalters force-pushed the bareuseronly-canonical-3 branch from bb277a5 to 7df9f40 Compare June 8, 2017 15:02
@cgwalters
Copy link
Member Author

Rebased 🏄‍♂️

@cgwalters
Copy link
Member Author

Or to elaborate, we could do this for bare-user behind a new flag, making the distinction between flatpak's use where we never want to have suid/worldwritable, and between "os buildroots" which need to keep around /tmp potentially.

But then again, given the impending migration to bare-user-only, is it worth it?

@alexlarsson
Copy link
Member

@rh-atomic-bot r+ 7df9f40

@rh-atomic-bot
Copy link

⌛ Testing commit 7df9f40 with merge 8edb516...

rh-atomic-bot pushed a commit that referenced this pull request Jun 12, 2017
Both callers of `commit_loose_object_trusted()` were passing
`OSTREE_OBJECT_TYPE_FILE`, so drop that parameter.  This in turn
allows us to drop lots of checking of that inside the function.

Add a doc comment, and rename to `commit_loose_content_object()` for clarity.

Closes: #914
Approved by: alexlarsson
rh-atomic-bot pushed a commit that referenced this pull request Jun 12, 2017
See #909 for more information on the
rationale. Basically there's no reason for flatpak (which uses `bare-user-only`)
to have world-writable dirs. Particularly with the presence of the system
helper.

An approach I considered instead was to parse and validate directory metadata
objects at commit time. We still may do that in addition; for file objects we *had*
to do it that way because the actual files would be laid down suid.  But directories
live only as inert `.dirmeta` objects until we do a checkout (i.e. `mkdir()`), so
we can solve the problem at checkout time.

Closes: #914
Approved by: alexlarsson
@rh-atomic-bot
Copy link

☀️ Test successful - status-atomicjenkins
Approved by: alexlarsson
Pushing 8edb516 to master...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants