-
Notifications
You must be signed in to change notification settings - Fork 198
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
WIP: add sysusers to compose #1376
Open
peterbaouoft
wants to merge
2
commits into
coreos:main
Choose a base branch
from
peterbaouoft:pr/add_sysusers_to_compose
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -359,6 +359,7 @@ rpmostree_check_passwd_groups (gboolean passwd, | |
GFile *treefile_dirpath, | ||
JsonObject *treedata, | ||
const char *previous_commit, | ||
GPtrArray **out_sysuser_entries, | ||
GCancellable *cancellable, | ||
GError **error) | ||
{ | ||
|
@@ -386,7 +387,7 @@ rpmostree_check_passwd_groups (gboolean passwd, | |
return TRUE; /* Note early return */ | ||
else if (g_str_equal (chk_type, "previous")) | ||
; /* Handled below */ | ||
else if (g_str_equal (chk_type, "file")) | ||
else if (g_str_equal (chk_type, "file") || g_str_equal (chk_type, "sysusers")) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For sysusers option, I think it might be good if we also check passwd/group as b4, which is why I added those lines. But let me know what you think about this. =) |
||
{ | ||
direct = _rpmostree_jsonutil_object_require_string_member (chk, | ||
"filename", | ||
|
@@ -491,7 +492,7 @@ rpmostree_check_passwd_groups (gboolean passwd, | |
return TRUE; | ||
} | ||
} | ||
else if (g_str_equal (chk_type, "file")) | ||
else if (g_str_equal (chk_type, "file") || g_str_equal (chk_type, "sysusers")) | ||
{ | ||
old_path = g_file_resolve_relative_path (treefile_dirpath, direct); | ||
old_contents = glnx_file_get_contents_utf8_at (AT_FDCWD, gs_file_get_path_cached (old_path), NULL, | ||
|
@@ -500,7 +501,7 @@ rpmostree_check_passwd_groups (gboolean passwd, | |
return FALSE; | ||
} | ||
|
||
if (g_str_equal (chk_type, "previous") || g_str_equal (chk_type, "file")) | ||
if (g_str_equal (chk_type, "previous") || g_str_equal (chk_type, "file") || g_str_equal (chk_type, "sysusers")) | ||
{ | ||
if (passwd) | ||
old_ents = rpmostree_passwd_data2passwdents (old_contents); | ||
|
@@ -681,6 +682,16 @@ rpmostree_check_passwd_groups (gboolean passwd, | |
} | ||
} | ||
|
||
/* Now, at the end of checking, if all goes correctly, we put entries into | ||
* the array of sysusers */ | ||
if (g_str_equal (chk_type, "sysusers")) | ||
{ | ||
if (passwd) | ||
return rpmostree_passwdents2sysusers (new_ents, out_sysuser_entries, error); | ||
else | ||
return rpmostree_groupents2sysusers (new_ents, out_sysuser_entries, error); | ||
} | ||
|
||
return TRUE; | ||
} | ||
|
||
|
@@ -693,11 +704,12 @@ rpmostree_check_passwd (OstreeRepo *repo, | |
GFile *treefile_dirpath, | ||
JsonObject *treedata, | ||
const char *previous_commit, | ||
GPtrArray **out_sysuser_entries, | ||
GCancellable *cancellable, | ||
GError **error) | ||
{ | ||
return rpmostree_check_passwd_groups (TRUE, repo, rootfs_fd, treefile_dirpath, | ||
treedata, previous_commit, | ||
treedata, previous_commit, out_sysuser_entries, | ||
cancellable, error); | ||
} | ||
|
||
|
@@ -710,11 +722,12 @@ rpmostree_check_groups (OstreeRepo *repo, | |
GFile *treefile_dirpath, | ||
JsonObject *treedata, | ||
const char *previous_commit, | ||
GPtrArray **out_sysuser_entries, | ||
GCancellable *cancellable, | ||
GError **error) | ||
{ | ||
return rpmostree_check_passwd_groups (FALSE, repo, rootfs_fd, treefile_dirpath, | ||
treedata, previous_commit, | ||
treedata, previous_commit, out_sysuser_entries, | ||
cancellable, error); | ||
} | ||
|
||
|
@@ -1032,7 +1045,7 @@ _data_from_json (int rootfs_dfd, | |
if (!chk_type) | ||
return FALSE; | ||
|
||
if (!g_str_equal (chk_type, "file")) | ||
if (!g_str_equal (chk_type, "file") && !g_str_equal (chk_type, "sysusers")) | ||
return TRUE; | ||
|
||
const char *filename = | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems to me that if we're using sysusers - there's really no reason to go into any of the
rpmostree_check_passwd()
code. With sysusers, the uids are assigned on the client side, unlike every other approach here. The code here was mostly concerned with comparing from the "previous" values, but conceptually we don't have any previous values.It seems the main thing we're lifting there is the current values of the passwd/group database.
One thing it's tempting to do here too is add a new
systemd-sysusers: true
boolean, and then that overrides all of the other legacy stuff. Then here incompose-builtin-tree.c
we'd do:or so?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ha, I was thinking to propose this approach, but then I figured some packages seem to own their specific uid/gid (Can't seem to find a source, so may be I was wrong). One example i believe is
daemon
sometimes own uid 2? So, I thoughtcheck_passwd
andcheck_group
was mainly used for that case (the exact mapping of package assignment).But if not, then I agree, we don't necessarily need to check sysusers for "previous" values.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea, this implementation makes sense, and if we are skipping that, may be we can also skip the sections here too?
https://github.com/projectatomic/rpm-ostree/blob/master/src/libpriv/rpmostree-postprocess.c#L971-L991.
I was thinking earlier if we could work around the sysuser logic a bit so that the migration of passwd needs not to happen (or skipped) in postprocess.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A bunch of uid/gid values are fixed; see https://fedoraproject.org/wiki/Packaging:UsersAndGroups and note https://pagure.io/setup/blob/master/f/uidgid
Is that what you're thinking of?
But that...oh wait, argh, I think this calls into question our entire approach here 😦 - I'll comment below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup. :D