Open malensek opened 2 months ago
I will review this pull request!
I can review this.
This is a very useful addition to the operating system, and extremely useful for automation and testing. It's fairly easy to understand (once you wrap your head around inodes). I made some scripts to test and they seem mostly robust. Mostly.
I'm happy to announce that I found a serious bug allowing for the execution of commands in comments. Anything after 100 characters is treated like a new line. As such:
#!/sh /echo This is supposed to be commented
results in text being displayed.
Since the buffer to check for an interpreter is 128 bytes while the buffer for sh
lines is 100, running a script directly can yield different results than running it as an argument to sh
. For example:
#!/./././././././././././././././././././././././././././././././././././././././././././././././././rm /init
/echo You have been pwned
deletes the script if run directly but renders the OS unbootable if ran with sh.
For positive news, I tried making a fork bomb since scripting makes it easier, but it failed to fork and pipe after a few recursions, allowing init
to avoid an unfortunate death.
High Level Checks:
Code Checks:
This PR adds basic shell script support to FogOS.
Modifications:
exec.c
now looks for#!
, determines script interpreter, and runs the interpreter with the script name set toargv[1]
sh.c
will read commands from a script file passed in onargv[1]
and ignores#commented
commandsLimitations: