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

passwd: Use check-* file json config. entries to migrate data across commits #101

Merged
merged 1 commit into from
Jan 22, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
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
15 changes: 10 additions & 5 deletions doc/treefile.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,18 +66,21 @@ Treefile
Note this does not alter the RPM database, so `rpm -V` will complain.

* `preserve-passwd`: boolean, optional: Defaults to `true`. If enabled,
copy the `/etc/passwd` (and `/usr/lib/passwd`) files from the previous commit
if they exist. This helps ensure consistent uid/gid allocations across
builds. However, it does mean that removed users will exist in the `passwd`
database forever. It also does not help clients switch between unrelated
trees.
and `check-passwd` has a type other than file, copy the `/etc/passwd` (and
`/usr/lib/passwd`) files from the previous commit if they exist. If
check-passwd has the file type, then the data is preserved from that file to
`/usr/lib/passwd`.
This helps ensure consistent uid/gid allocations across builds. However, it
does mean that removed users will exist in the `passwd` database forever.

* `check-passwd`: Object, optional: Checks to run against the new passwd file
before accepting the tree. All the entries specified should exist (unless
ignored) and have the same values or the compose will fail. There are four
types: none (for no checking), previous (to check against the passwd file in
the previous commit), file (to check against another passwd file), and data
to specify the relevant passwd data in the json itself.
Note that if you choose file, and preserve-passwd is true then the data will
be copied from the referenced file and not the previous commit.

Example: `check-passwd: { "type": "none" }`
Example: `check-passwd: { "type": "previous" }`
Expand All @@ -91,6 +94,8 @@ Treefile
types: none (for no checking), previous (to check against the group file in
the previous commit), file (to check against another group file), and data
to specify the relevant group data in the json itself.
Note that if you choose file, and preserve-passwd is true then the data will
be copied from the referenced file and not the previous commit.

Example: `check-groups: { "type": "none" }`
Example: `check-groups: { "type": "previous" }`
Expand Down
12 changes: 8 additions & 4 deletions src/rpmostree-compose-builtin-tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -786,6 +786,7 @@ rpmostree_compose_builtin_tree (int argc,
gs_unref_ptrarray GPtrArray *bootstrap_packages = NULL;
gs_unref_ptrarray GPtrArray *packages = NULL;
gs_unref_object GFile *treefile_path = NULL;
gs_unref_object GFile *treefile_dirpath = NULL;
gs_unref_object GFile *repo_path = NULL;
gs_unref_object JsonParser *treefile_parser = NULL;
gs_unref_variant_builder GVariantBuilder *metadata_builder =
Expand Down Expand Up @@ -1022,7 +1023,8 @@ rpmostree_compose_builtin_tree (int argc,
self->serialized_treefile = g_bytes_new_take (treefile_buf, len);
}

if (previous_root != NULL)
treefile_dirpath = g_file_get_parent (treefile_path);
if (TRUE)
{
gboolean generate_from_previous = TRUE;

Expand All @@ -1034,7 +1036,9 @@ rpmostree_compose_builtin_tree (int argc,

if (generate_from_previous)
{
if (!rpmostree_generate_passwd_from_previous (repo, yumroot, previous_root,
if (!rpmostree_generate_passwd_from_previous (repo, yumroot,
treefile_dirpath,
previous_root, treefile,
cancellable, error))
goto out;
}
Expand Down Expand Up @@ -1076,11 +1080,11 @@ rpmostree_compose_builtin_tree (int argc,
if (!rpmostree_prepare_rootfs_for_commit (yumroot, treefile, cancellable, error))
goto out;

if (!rpmostree_check_passwd (repo, yumroot, treefile_path, treefile,
if (!rpmostree_check_passwd (repo, yumroot, treefile_dirpath, treefile,
cancellable, error))
goto out;

if (!rpmostree_check_groups (repo, yumroot, treefile_path, treefile,
if (!rpmostree_check_groups (repo, yumroot, treefile_dirpath, treefile,
cancellable, error))
goto out;

Expand Down
Loading