vmactions / freebsd-vm

Use FreeBSD in github actions
https://vmactions.org
MIT License
243 stars 20 forks source link

Script is always run as root #59

Open arp242 opened 2 years ago

arp242 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

but would you accept a patch to

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

Neilpang commented 2 years ago

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