FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » FUDforum Development » Plugins and Code Hacks » run_maillist.c : Run Mailling List As A Particular User (NOBODY)
Show: Today's Messages :: Unread Messages :: Show Polls :: Message Navigator
| Subscribe to topic | Bookmark topic 
Switch to threaded view of this topic Create a new topic Submit Reply
run_maillist.c : Run Mailling List As A Particular User (NOBODY) [message #33233] Sun, 20 August 2006 16:48
jeffrey is currently offline  jeffrey   United States
Messages: 36
Registered: June 2006
Location: Atlanta, GA
Karma: 0
Member
add to buddy list
ignore all messages by this user
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"

Quick Reply
Formatting Tools:   
  Switch to threaded view of this topic Create a new topic
Previous Topic: Viewing the same message from different threads
Next Topic: Pre-Filter Your Email List
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Tue Oct 24 02:05:50 EDT 2017

Total time taken to generate the page: 0.00641 seconds