I have a script which opens terminal windows and sends commands to them. Some of these had to run as root so I would send them this command
sudo sh -c 'do_stuff && bash'
This would run some initial commands and then drop into an interactive shell.
In my environment, the terminal programs themselves cannot be started by the root user (yes, really) and it actually makes sense to store the root password in a file (yes, really) and launch several such terminals without asking for a password each time.
This is a silly situation, but roll with it. Please don't tell me I'm doing the wrong thing, I don't have any other choice in this environment.
If I send them this command
sudo sh -S -c 'do_stuff && bash' <passwordfile
then the terminals do not drop into an interactive shell, sudo
exits immediately after do_stuff
.
How do I drop into an interactive shell from sudo -S
?