On linux generated makefile wants to delete root with wrong CONFIG specified


#1
$ make CONFIG=xxx clean
Cleaning MyOwnPlugin
rm: cannot remove ‘/’: Is a directory
Makefile:192: recipe for target 'clean' failed
make: [clean] Error 1 (ignored)
rm: cannot remove ‘/bin/echo’: Permission denied
rm: cannot remove ‘/bin/dir’: Permission denied
rm: cannot remove ‘/bin/env’: Permission denied
rm: cannot remove ‘/bin/lsmod’: Permission denied
rm: cannot remove ‘/bin/ping6’: Permission denied
rm: cannot remove ‘/bin/rc-status’: Permission denied
rm: cannot remove ‘/bin/dd’: Permission denied
rm: cannot remove ‘/bin/ifconfig’: Permission denied
rm: cannot remove ‘/bin/setfacl’: Permission denied
rm: cannot remove ‘/bin/chacl’: Permission denied
rm: cannot remove ‘/bin/cp’: Permission denied
rm: cannot remove ‘/bin/run-parts’: Permission denied
rm: cannot remove ‘/bin/df’: Permission denied
rm: cannot remove ‘/bin/umount’: Permission denied
rm: cannot remove ‘/bin/lsblk’: Permission denied
rm: cannot remove ‘/bin/nisdomainname’: Permission denied
rm: cannot remove ‘/bin/more’: Permission denied
rm: cannot remove ‘/bin/false’: Permission denied
rm: cannot remove ‘/bin/head’: Permission denied
rm: cannot remove ‘/bin/cut’: Permission denied
rm: cannot remove ‘/bin/tail’: Permission denied
rm: cannot remove ‘/bin/mount’: Permission denied
rm: cannot remove ‘/bin/groups’: Permission denied
rm: cannot remove ‘/bin/tempfile’: Permission denied
rm: cannot remove ‘/bin/mkdir’: Permission denied
rm: cannot remove ‘/bin/ypdomainname’: Permission denied
rm: cannot remove ‘/bin/keyctl’: Permission denied
rm: cannot remove ‘/bin/mountpoint’: Permission denied
rm: cannot remove ‘/bin/uname’: Permission denied
rm: cannot remove ‘/bin/chgrp’: Permission denied

If you specify a wrong CONFIG= option that is not present in the Makefile, you can easily ends up in running rm -rf /

Please don't allow such things, one can erase everything in its own home !


#2

Yikes! Thanks, I've fixed that to be safer now.


#3

something related, if you specify a wrong CONFIG= option when building some obscure error is raised


kraken@roxxorx ~/Projects/xxx/Builds/Linux $ make CONFIG=DebugXXX
mkdir: missing operand
Try 'mkdir --help' for more information.
Makefile:206: recipe for target '/MyClass_29b8474a.o' failed
make: [/MyClass_29b8474a.o] Error 1 (ignored)
Compiling MyClass.cpp
Assembler messages:
Fatal error: can't create /MyClass_29b8474a.o: Permission denied
Makefile:206: recipe for target '/MyClass_29b8474a.o' failed
make: *** [/MyClass_29b8474a.o] Error 1

is possible (and safer) to bail out when a wrong config is specified instead of running the commands and wait for an error ?


#4

Yeah, that'd be a good idea. I'm a bit scared of makefiles though, the syntax has always seemed a bit bizarre to me. I'll have a go next time I'm doing some work on them..