orbital-transfer / p5-Orbital-Launch

0 stars 0 forks source link

Runnable: handle being run as root sensibly #45

Open zmughal opened 4 years ago

zmughal commented 4 years ago

If the script is run as root (as in a Docker environment), allow an optional user to run non-system wide commands. So if run in Docker as root, we need to have

root $ useradd -m notroot # create a user
root $ apt install dep0 dep1 dep2 # install system-wide dependencies

then as the user nonroot,

notroot $ cpanm -L /path/to/author # install deps
notroot $ # do the rest of the build
notroot $ prove -lvr t/

This means that we also need to chown nonroot /build so that the nonroot user can write in it.

This is necessary for code that we test that can not be run as root, (e.g., sandboxed Chrome which requires --no-sandbox to run under a root user). This split is a good idea in general.