One of my XigmaNAS machines had a curious issue. Upon boot, it wouldn’t display the console menu. After boot it would go directly to the bash prompt - no password asked. While practical, this was completely insecure as anyone capable of connecting monitor and keyboard would get a full access.
Upon checking configuration, culprit was obvious - I changed the default shell. As console menu execution is part of .cshrc
configuration file and bash ignores that file, the console menu was forever lost.
I definitely didn’t like that.
Since I really wanted bash prompt but also preferred to have the console menu (that can be disabled), I decided upon a slightly different shell selection approach without system-wide consequences . Simply adding exec bash
command at the end of .cshrc
works nicely without the nasty side-effects The following PostInit
script will do the trick:
printf '\\nif ($?prompt) then\\n\\texec bash\\nendif\\n' >> /root/.cshrc
And yes, check if we’re working with interactive shell ($?prompt
part) is necessary because commands executed without terminal (e.g. directly over SSH or cron jobs) will fail otherwise.