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

Various fixes to allow uid to be in a correct range #159

Merged
merged 2 commits into from
Jun 26, 2024
Merged

Conversation

jimmykarily
Copy link
Collaborator

otherwise the user always appears as if it doesn't exist

Signed-off-by: Dimitris Karakasilis <[email protected]>
jimmykarily added a commit to jimmykarily/entities that referenced this pull request Jun 25, 2024
otherwise we may end up with id 65535 (the "nobody" user)

Part of: mudler/yip#159

Signed-off-by: Dimitris Karakasilis <[email protected]>
mudler pushed a commit to mudler/entities that referenced this pull request Jun 25, 2024
* Generate a user id in the range of human users

otherwise we may end up with id 65535 (the "nobody" user)

Part of: mudler/yip#159

Signed-off-by: Dimitris Karakasilis <[email protected]>

* Update pkg/entities/user.go

Signed-off-by: Dimitris Karakasilis <[email protected]>

* Move magic number to constants

Signed-off-by: Dimitris Karakasilis <[email protected]>

---------

Signed-off-by: Dimitris Karakasilis <[email protected]>
@jimmykarily jimmykarily force-pushed the dk-fix-uid branch 3 times, most recently from 0199e94 to f95d64b Compare June 26, 2024 09:05
if u.PrimaryGroup != "" {
gr, err := osuser.LookupGroup(u.PrimaryGroup)
if err != nil {
return errors.Wrap(err, "could not resolve primary group of user")
}
gid, _ = strconv.Atoi(gr.Gid)
primaryGroup = u.PrimaryGroup
} else {
Copy link
Collaborator Author

@jimmykarily jimmykarily Jun 26, 2024

Choose a reason for hiding this comment

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

not need anymore. That's what the updateGroup.Apply will do if the gid is -1.


uid := 1000
// reload the group to get the generated GID
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This wouldn't be needed if the ParseGroup had a pointer receiver. I don't want to change that here though to avoid breaking other things. We can consider changing it in the future to avoid this second parsing of groups.

and let them automatically set the uid and gid inside the "human" users
range.

Relevant:
- mauromorales/xpasswd#3
- mudler/entities#15

Signed-off-by: Dimitris Karakasilis <[email protected]>
@@ -205,11 +210,11 @@ func User(l logger.Interface, s schema.Stage, fs vfs.FS, console Console) error
for _, k := range users {
r := s.Users[k]
r.Name = k
if !s.Users[k].Exists() {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Exists() was never true because the Name on the s.Users[k] wasn't set. It's set on r above though.

Copy link
Collaborator

Choose a reason for hiding this comment

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

nice catch

@jimmykarily jimmykarily marked this pull request as ready for review June 26, 2024 09:11
@jimmykarily jimmykarily self-assigned this Jun 26, 2024
@jimmykarily jimmykarily merged commit d76f75c into master Jun 26, 2024
5 checks passed
@jimmykarily jimmykarily deleted the dk-fix-uid branch June 26, 2024 09:45
jimmykarily added a commit to kairos-io/immucore that referenced this pull request Jun 26, 2024
to properly set kairos uid and gid in the range of human users

Relevant: mudler/yip#159

Signed-off-by: Dimitris Karakasilis <[email protected]>
jimmykarily added a commit to kairos-io/kairos-agent that referenced this pull request Jun 26, 2024
to properly set kairos uid and gid in the range of human users

Relevant: mudler/yip#159

Signed-off-by: Dimitris Karakasilis <[email protected]>
jimmykarily added a commit to kairos-io/immucore that referenced this pull request Jun 26, 2024
to properly set kairos uid and gid in the range of human users

Relevant: mudler/yip#159

Signed-off-by: Dimitris Karakasilis <[email protected]>
jimmykarily added a commit to kairos-io/packages that referenced this pull request Jun 26, 2024
to get the yip fix for the user id an gid

Relevant: mudler/yip#159

Signed-off-by: Dimitris Karakasilis <[email protected]>
jimmykarily added a commit to kairos-io/packages that referenced this pull request Jun 27, 2024
to get the yip fix for the user id an gid

Relevant: mudler/yip#159

Signed-off-by: Dimitris Karakasilis <[email protected]>
davidcassany pushed a commit to davidcassany/yip that referenced this pull request Jul 3, 2024
* Use variable that has "Name" assigned

otherwise the user always appears as if it doesn't exist

Signed-off-by: Dimitris Karakasilis <[email protected]>

* Bump entities and xpasswd

and let them automatically set the uid and gid inside the "human" users
range.

Relevant:
- mauromorales/xpasswd#3
- mudler/entities#15

Signed-off-by: Dimitris Karakasilis <[email protected]>

---------

Signed-off-by: Dimitris Karakasilis <[email protected]>
(cherry picked from commit d76f75c)
davidcassany pushed a commit to rancher/yip that referenced this pull request Jul 8, 2024
* Use variable that has "Name" assigned

otherwise the user always appears as if it doesn't exist

Signed-off-by: Dimitris Karakasilis <[email protected]>

* Bump entities and xpasswd

and let them automatically set the uid and gid inside the "human" users
range.

Relevant:
- mauromorales/xpasswd#3
- mudler/entities#15

Signed-off-by: Dimitris Karakasilis <[email protected]>

---------

Signed-off-by: Dimitris Karakasilis <[email protected]>
(cherry picked from commit d76f75c)
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