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

Refactor to use xpasswd #149

Merged
merged 4 commits into from
May 15, 2024
Merged

Refactor to use xpasswd #149

merged 4 commits into from
May 15, 2024

Conversation

mauromorales
Copy link
Collaborator

passwd library is simple but also limited and includes no license, so I started working on my own version xpasswd. I'd like yip to be the first consumer. Please feel free to suggest any recommendations

@mauromorales
Copy link
Collaborator Author

ping @mudler

go.mod Outdated Show resolved Hide resolved
@mudler mudler linked an issue May 6, 2024 that may be closed by this pull request
Signed-off-by: Mauro Morales <contact@mauromorales.com>
Expect(foo).ToNot(BeNil())
Expect(foo.Gecos).To(Equal("Created by entities"))
Expect(foo.Pass).To(Equal("x"))
Copy link
Owner

Choose a reason for hiding this comment

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

aren't we testing Pass anymore? what's the default in this case?

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 is not a real pass test, there's always an x in /etc/passwd the real passwords are saved in the shadow file

Copy link
Owner

@mudler mudler May 6, 2024

Choose a reason for hiding this comment

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

right, but it is worth checking if we write/read x here by default - to check that we are still compliant and we do not break while generating the user in the /etc/passwd file

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ahh, sorry I misunderstood the question. Yeah, I decided it's not a good API to ask xpasswd for a .Pass() because it's not representative, the x is not the password so if I implement that I want it to return the value in the shadow file.

I would claim that for this test it is actually ok because when we Load() the passwd file, xpasswd validates that the list fulfills the 7 elements per item. But it indeed does not check that it specifically is an x but as far as i understand the value there should not break the functionality

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'll change to at least check that error, and will think of a better option

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@mudler I've updated it to also check the password

pkg/plugins/user_test.go Outdated Show resolved Hide resolved
Signed-off-by: Mauro Morales <contact@mauromorales.com>
Signed-off-by: Mauro Morales <contact@mauromorales.com>
Signed-off-by: Mauro Morales <contact@mauromorales.com>
@mudler
Copy link
Owner

mudler commented May 15, 2024

Looking good! Thanks @mauromorales , that's indeed a good add so we can also close #128

@mudler mudler merged commit 0446b4e into mudler:master May 15, 2024
3 checks passed
davidcassany pushed a commit to davidcassany/yip that referenced this pull request Jul 3, 2024
* Refactor to use xpasswd

Signed-off-by: Mauro Morales <contact@mauromorales.com>

* Change path in tests to reflect a real path

Signed-off-by: Mauro Morales <contact@mauromorales.com>

* Check for an error when loading the user lists

Signed-off-by: Mauro Morales <contact@mauromorales.com>

* Check password

Signed-off-by: Mauro Morales <contact@mauromorales.com>

---------

Signed-off-by: Mauro Morales <contact@mauromorales.com>
(cherry picked from commit 0446b4e)
davidcassany pushed a commit to rancher/yip that referenced this pull request Jul 8, 2024
* Refactor to use xpasswd

Signed-off-by: Mauro Morales <contact@mauromorales.com>

* Change path in tests to reflect a real path

Signed-off-by: Mauro Morales <contact@mauromorales.com>

* Check for an error when loading the user lists

Signed-off-by: Mauro Morales <contact@mauromorales.com>

* Check password

Signed-off-by: Mauro Morales <contact@mauromorales.com>

---------

Signed-off-by: Mauro Morales <contact@mauromorales.com>
(cherry picked from commit 0446b4e)
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.

go library passwd does not have a license
2 participants