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

Script is always run as root #59

Open
arp242 opened this issue Aug 1, 2022 · 4 comments
Open

Script is always run as root #59

arp242 opened this issue Aug 1, 2022 · 4 comments

Comments

@arp242
Copy link

arp242 commented Aug 1, 2022

Right now the "run" part is always run as the root user; this is an issue because I want to test a case where the user doesn't have permission to a file, but root always has access so it fails.

Other CI runners (e.g. the ubuntu and macos ones provided by GitHub) run as a regular unprivileged user; so it's a bit inconsistent.

I fixed it in my CI with:

run: |
  pw user add -n action -m
  su action -c 'go test -race ./...'

But it would probably be a good idea to do something like that by default; it took me quite a while to figure out why the tests were working locally but were failing on the CI 😅

This is also an issue with the NetBSD and OpenBSD VMs, but I didn't create an issue for those of them.

@Neilpang
Copy link
Member

Neilpang commented Aug 1, 2022

Sorry for the trouble. but I would like to keep the current behavior.
Running as a non-root user will cause more problems for normal users.
but I will add this note in the Readme.

thanks

@arp242
Copy link
Author

arp242 commented Aug 1, 2022

No worries.

I think changing the default would be a bad idea as it might break people's existing workflows, but would you accept a patch to add an option? with: {local-user: true} or something?

@Neilpang
Copy link
Member

Neilpang commented Aug 1, 2022

but would you accept a patch to

Yes, of course, as long as we don't change the default behavior.

@Neilpang
Copy link
Member

Neilpang commented Aug 1, 2022

You can create a new user or do any other initializations in the onStarted.sh hook:

https://github.com/vmactions/freebsd-vm/blob/main/hooks/onStarted.sh

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

No branches or pull requests

2 participants