Home »
FUDforum Development »
Plugins and Code Hacks »
run_maillist.c : Run Mailling List As A Particular User (NOBODY)
run_maillist.c : Run Mailling List As A Particular User (NOBODY) [message #33233] |
Sun, 20 August 2006 20:48 |
|
jeffrey
Messages: 36 Registered: June 2006 Location: Atlanta, GA
Karma: 0
|
Member |
|
|
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"
|
|
|
Goto Forum:
Current Time: Fri Nov 01 00:13:32 GMT 2024
Total time taken to generate the page: 0.02032 seconds