3 ms·
I accidentally set executable permissions on the following Makefile: https://github.com/samalba/acdcontrol/blob/master/Makefile https://github.com/samalba/acdc
by aleden 10y ago
I accidentally set executable permissions on the following Makefile:
https://github.com/samalba/acdcontrol/blob/master/Makefile https://github.com/samalba/acdcontrol/blob/master/Makefile
While typing quickly I tab-completed to 'Makefile' and hit enter. Although it was a Makefile, it was executed as a bash script. bash ignored the incorrect syntax and executed line 10:
rm -rf $(DIRNAME)/*
If make parsed the file, $(DIRNAME) would have been nonempty. But it was empty under bash.
--no-preserve-root did not protect against this, because the target of the command was '/*'
- lazzlazzlazz 10y agoAnd here it is.
- scintill76 10y agoHow/why does this work without "#!" at the beginning of the file? I just tested with fish shell, and I get "Exec format error. The file './x' is marked as an executable but could not be run by the operating system." But, from bash or dash it does execute commands from the file.
- Tiksi 10y agoIt'll fall back to sh, the default shell (or whatever it's symlinked to): http://paste.click/QxWUMG http://paste.click/QxWUMG In my case that's bash, debian based systems use dash.
- cyphar 10y agoThat shouldn't happen if you look at fs/exec.c (search_binary_handler) there isn't a "fallback to shell" option. And fs/binfmt_script.c doesn't fall back to shell either. Are you sure you don't have some weird binfmt_misc hook enabled?
- JdeBP 10y agoThe "it" in what you are replying to is not the kernel; but the shell. * http://pubs.opengroup.org/onlinepubs/007908799/xcu/chap2.html#tag_001_009_001_001 http://pubs.opengroup.org/onlinepubs/007908799/xcu/chap2.htm... * http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_09_01_01 http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3...