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

os/Chown #4213

Merged
merged 5 commits into from
Jul 21, 2024
Merged

os/Chown #4213

merged 5 commits into from
Jul 21, 2024

Conversation

leongross
Copy link
Contributor

Add os.Chown()

@leongross leongross force-pushed the os/chown branch 2 times, most recently from d1b89f1 to 724b52c Compare March 28, 2024 15:50
src/os/os_chmod_test.go Outdated Show resolved Hide resolved
src/os/os_chmod_test.go Outdated Show resolved Hide resolved
src/os/os_chmod_test.go Outdated Show resolved Hide resolved
src/os/os_chmod_test.go Show resolved Hide resolved
@leongross
Copy link
Contributor Author

leongross commented Apr 3, 2024

To design meaningful test cases for chown, I think you would need multiple users with different uids and gids and a user who has permission to change ownership of a file to this, a super user. In my opinion, there are 2 ways to integrate this:

  1. update the container image for the CI so that there are accounts with said properties
  2. mocking the file system and permissions

The problem I see with solution 2 is that the implementation of chown relies on the syscall chown, so I wouldn't know how to mock that.

I would appreciate your input on that @rminnich

EDIT: Maybe I am mistaken but as I see it, golang does not do any of the described tests but checks for an error of an invalid gid, maybe this is the way to go here as well?

@leongross
Copy link
Contributor Author

@deadprogram do you have an opinion on that?

@leongross
Copy link
Contributor Author

@deadprogram

@leongross
Copy link
Contributor Author

@rminnich

Copy link
Member

@aykevl aykevl left a comment

Choose a reason for hiding this comment

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

I think it's fine to keep this lightly tested, for example by checking that the syscall returns an expected permission error (or even just "file not found" - it also means the call works at least somewhat).

Yes it would be great to be able to test everything, but that's very hard to do for things like this and you'll end up putting a lot of effort into what's essentially just a wrapper for a libc function.

src/os/file_anyos.go Outdated Show resolved Hide resolved
@leongross leongross force-pushed the os/chown branch 5 times, most recently from 71d571e to 8c3e435 Compare May 3, 2024 10:53
@leongross leongross force-pushed the os/chown branch 4 times, most recently from dedff0a to b9a32dd Compare June 7, 2024 14:07
@leongross leongross force-pushed the os/chown branch 2 times, most recently from cebc95d to 38c58f8 Compare June 14, 2024 10:52
@deadprogram
Copy link
Member

@leongross can you please rebase this PR against the latest dev? Thanks!

@leongross
Copy link
Contributor Author

@deadprogram rebase done, but noq quite sure where the runtime panic originates. Do you know anything about this?

@leongross
Copy link
Contributor Author

@deadprogram @aykevl

@deadprogram
Copy link
Member

@leongross looks like some CI fails on this PR. You probably also need to rebase against latest dev.

@leongross leongross force-pushed the os/chown branch 2 times, most recently from 202e583 to c7e6851 Compare July 19, 2024 12:02
@leongross
Copy link
Contributor Author

The old errors should be fixed except for the ci (failing probably due to #4347). Could you review it? @deadprogram

@leongross leongross force-pushed the os/chown branch 2 times, most recently from e10a472 to 0494337 Compare July 20, 2024 20:55
@leongross
Copy link
Contributor Author

@deadprogram I think this was the last fix now, mind to review?

@deadprogram
Copy link
Member

Thanks for the additions @leongross and too @rminnich and @aykevl for review.

Now squash/merging.

@deadprogram deadprogram merged commit 3e2230e into tinygo-org:dev Jul 21, 2024
17 checks passed
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.

4 participants