I was getting errors not running the maillist.php program as the correct user, so I wrote this little C program to enable the system to switch-user to NOBODY and run the program. The content of run_maillist.c:
#include <sys/types.h>
#include <stdlib.h>
#include <unistd.h>
#define NOBODY 99
main() {
setuid(NOBODY);
setgid(NOBODY);
if(fork() == 0) {
execl("/home/FUDforum/scripts/maillist.php","/home/FUDforum/scripts/maillist.php","1",(char *)NULL);
exit(0);
} else {
exit(0);
}
}
I use sendmail, and in order to get this to work you need to:
0. Login as root
1. Determine what your nobody userid is (from /etc/passwd) and set the NOBODY constant in run_maillist.c.
2. Complile above program into /usr/local/bin/run_maillist with:
gcc -o run_maillist run_maillist.c
3. chown root.root run_maillist
4. chmod 4755 run_maillist
5. cd /usr/adm/sm.bin
6. ln -s /usr/local/bin/run_maillist (enable sendmail to run it)
7. Put run_maillist in your email alias (/etc/aliases) for your mailling list: myforum: "|/usr/local/bin/run_maillist"