Actually, since there is no need to be running this script as root if user
mixmaster has permission to write to /home/mixmaster/Mix, and since this script does internet access, it would be more secure to run the main script as
mixmaster rather than
root (in case there is an exploitable bug in
wget).
This can be done in three ways. One is to remove the script from cron.daily and create a new /etc/crontab entry with the user field set to
mixmaster. Another is to remove the script from cron.daily and use
mixmaster's own crontab (using the program
crontab -- see
man pages). Or you can leave the script in cron.daily and change the user by having the script call itself, something like:
Code:
#!/bin/sh
if [ $(id -u) -eq 0 ]; then
su -c "$0" mixmaster
else
{ Insert main body of script here }
fi
(While programs have setuid() available to directly change the user, I am not aware of any such direct capability in bash, which is why I have the script call itself.)
In all of these cases, since the main body of the script is executed as
mixmaster, there is no need to change ownership of the files.