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

Add test process user #2978

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open

Conversation

sat0ken
Copy link
Contributor

@sat0ken sat0ken commented Nov 4, 2024

This implements the process_user validation in #361

Signed-off-by: sat0ken <15720506+sat0ken@users.noreply.github.com>
Signed-off-by: sat0ken <15720506+sat0ken@users.noreply.github.com>
Signed-off-by: sat0ken <15720506+sat0ken@users.noreply.github.com>
Signed-off-by: sat0ken <15720506+sat0ken@users.noreply.github.com>
Signed-off-by: sat0ken <15720506+sat0ken@users.noreply.github.com>
Signed-off-by: sat0ken <15720506+sat0ken@users.noreply.github.com>
Signed-off-by: sat0ken <15720506+sat0ken@users.noreply.github.com>
let current_umask = unsafe { libc::umask(0) };
unsafe { libc::umask(current_umask) };

if process.user().uid().ne(&uid) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think you should be able to directly use != operator. Same for below.

@@ -471,3 +472,37 @@ pub fn test_mount_rsuid_option(path: &str) -> Result<(), std::io::Error> {
format!("rsuid error {path:?}"),
))
}

pub fn test_additional_gids(gids: &Vec<u32>) -> Result<(), std::io::Error> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we can move this to the test file itself, I don't think we will be using this anywhere else.
Also please use safe alternatives from nix instead of unsafe from libc.
Can you add comments explaining what this is trying to do? The original go does not have comments, so it would be good to have explanation here.

Comment on lines +17 to +20
ProcessBuilder::default()
.user(user)
.build()
.expect("error in creating process config"),
Copy link
Collaborator

Choose a reason for hiding this comment

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

You need to set the process cmd to the runtimetest to actually run the internal test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants