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

compose: Add --check-passwd/group options, to fail if uids/gids change #56

Closed
wants to merge 11 commits into from

Conversation

james-antill
Copy link
Contributor

No description provided.

@james-antill
Copy link
Contributor Author

Just looked at changing to fmemopen+fgetpwent ... the main problem is that we can't sort the entries if we do it that way, and it only gives us an entry for one file. So we have to read all the entries for each file, duplicate them, sort them, and then compare resulting lists. Then we end up with more code than just parsing the files by hand (because split into lines, and sort are two lines atm).

If you still want to do it, let me tomorrow, otherwise I'll look at merging the code for both files for monday.

@cgwalters
Copy link
Member

Agree the lack of comments in JSON is extremely painful.

If we end up with a lot of code, split into a separate file?

@cgwalters
Copy link
Member

@james-antill Can you rebase against master and squash the two together?

@james-antill
Copy link
Contributor Author

Ok, done.

@james-antill
Copy link
Contributor Author

Is there a use case for checking user/group against an arbitrary branch/commit versus reading the previous commit?

The two main reasons I did it that way are:

  1. Allowing a commit on a new branch to check vs. another branch, so we know it's compatible.
  2. We can keep the policy of what to check out of rpm-ostree and have it in rpm-ostree-toolbox.

...1 could eaisly be sovled by cherry-pick if that ever gets in ;) ... and I guess you are happier with the policy at rpm-ostree level? I can certainly fix that if you want, although I did think about the file overrides checksum thing but it seemed like something where a normal user couldn't attack the builder user easily (you'd need access to the dir. where the builder is building, which would be restricted).

james-antill and others added 3 commits December 8, 2014 13:04
- rename internal functions like _string_in_ptr_array0 to the
  more common OBJECT_VERB_NOUN style, like:
  "ptrarray_contains_str"

- Fix GError handling - we need a distinct output boolean, it's
  not allowed by convention to check *error

- Also verify uid/gid on directories and symlinks; I can see
  security sensitivity here

- Use gs_file_enumerator_iterate() as it's more convenient

- Some control flow tweaks to clarify things
@cgwalters
Copy link
Member

I made a branch which squashes your commits to one, then adds two on top: https://github.com/cgwalters/rpm-ostree/tree/wip/uid-gid-checking

Can we use this as a basis for further iteration?

@cgwalters
Copy link
Member

With respect to the policy discussion (maybe let's call it "reference source"?), I can see some value if we defaulted to inspecting the previous commit. But yeah, anything more than that would probably be -toolbox territory.

@james-antill
Copy link
Contributor Author

ok, push --force ping. Seems to work for me, and have a new -toolbox push as well that doesn't try to pass refs.

@cgwalters
Copy link
Member

If we go the treefile path for the last comment, I wonder if it'd make sense then to do it fully instead of commandline options? Something like:

"check-passwd": { type: "previous" }     // the default
"check-passwd": { type: "static", data: { "polkitd": 999, "chrony": 994 } }
"check-passwd": { type: "none" }

?

@james-antill
Copy link
Contributor Author

You seem really desperate to have people convert their passwd files into JSON dict data ... is there something I should know ;)
I esp. love the example with a comment :) :)

But more seriously, having a simple previous/none type entry should be trivial to add.

@cgwalters
Copy link
Member

I'm also OK with reading the passwd data from an external file, but it seems like it would go along more with the rest of the tooling if we took input from the treefile instead of commandline arguments. This would require changing the -toolbox code to generate it in the json.

The way I think of this is that given a treefile, I should be able to reproduce use it on another system to regenerate the tree. So anything that affects the output in a functional way should be there. On the other hand, things like --workdir-tmps are operational concerns. Whether or not I use a tmpfs shouldn't change the output, and that should be driven by build-side tools.

WRT the format, I'm certainly not saying JSON is awesome, but it does the job. I guess we could support YAML too. I originally thought YAML was crazy, but experience with Ansible, cloud-init, and Kubernetes pods has warmed me to it a bit.

@james-antill
Copy link
Contributor Author

JSON code push ping, note that this doesn't need any changes to -toolbox now as everything is only specified in the JSON.

@cgwalters
Copy link
Member

👍 to squash and push from me. After we have #75 let's see how hard doing unit testing for some of this is.

@james-antill
Copy link
Contributor Author

Ok, cool. Squashed rebased and merged.

cgwalters referenced this pull request in cgwalters/rpm-ostree Dec 23, 2014
The checking code from #56 landed, and started triggering for me on
the `dockerroot` user. It's nice to know it works. Then the issue
is... "what now"?

It turns out in the case of `dockerroot` it's actually unused, so we
could fix this by deleting it. But in general we need to support
dynamic uids/gids/. And we can't yet take a hard dep on #49.

So this patch changes things so we take a copy of the passwd/group
data from the previous commit.  Any users subsequently added in the
*new* commit will be additive.

Closes: coreos#78
cgwalters added a commit to cgwalters/ostree that referenced this pull request Jan 6, 2015
rpm-ostree had code to check for this, which didn't actually work.
See coreos/rpm-ostree#56

I don't see a no backwards compatibility concern in changing this, as
it's unlikely a caller would try to sensibly disambiguate FAILED.
@cgwalters
Copy link
Member

The check for G_IO_ERROR_NOT_FOUND didn't actually work due to ostreedev/ostree#37

@james-antill
Copy link
Contributor Author

Not sure that I explicitly tested this, but this is basically the code that ostree log uses, and I'm 100% sure that used to work.

@james-antill
Copy link
Contributor Author

Nevermind, somewhere along the way it changed from ostree_repo_load_variant to ostree_repo_read_commit but only the former returns NOT_FOUND.

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.

None yet

2 participants