Skip to content

Commit 38f75a6

Browse files
authored
Suppress stdout from env loading script to avoid python exec pollution (#54)
Without this suppression environment loading scripts that give verbose information (e.g. intel setvars.sh) will have these lines executed by the Python `exec()` function. Best case, it is total nonsense and throws an error, worst case it executes some catastrophic code. Note that the loader still executes perceived differences in the env, so users should be cautious about loading scripts and be aware of code injection.
2 parents 50092ce + abaf539 commit 38f75a6

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

sane/env_from_script.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ import json
4545
json.dump( env, open( "$save_env", "w" ), indent=2 )
4646
EOF
4747

48-
. $script
48+
# Ensure that any rogue stdout from script does not pollute ingestion of
49+
# generated python commands. Perhaps later we can wrap and output this as stdout/log
50+
. $script &> /dev/null
4951

5052
output=$( env )
5153
python3 << EOF

0 commit comments

Comments
 (0)