Patch to run as "nullmail"

Clint Pachl <[email protected]> Sun, 29 May 2005 07:19:45 -0700
Newsgroups gmane.mail.nullmailer
Message-ID <[email protected]>
Hey guys,
Because the install script (make install-root) requires the user
"nullmail", I thought it might be convenient to have nullmailer-send
set its own uid at startup. I'm not using any daemonizing/supervising
tools to manage nullmailer. Could also make this a switch on the cmdl.
Are there any problems with this configuration?

Anyway, I love nullmailer and have removed sendmail from all my
servers. Much easier!

--- send.cc=09Sun May 29 04:44:47 2005
+++ send-patch.cc=09Sun May 29 05:23:21 2005
@@ -30,6 +30,7 @@
 #include <sys/types.h>
 #include <sys/wait.h>
 #include <unistd.h>
+#include <pwd.h>
 #include "ac/systime.h"
 #include "configio.h"
 #include "defines.h"
@@ -303,6 +304,17 @@
 int main(int, char*[])
 {
   mystring hh;
+  struct passwd *pw_nullmail =3D NULL;
+
+  if(!(pw_nullmail =3D getpwnam("nullmail"))){
+    fout << "Unable to locate user 'nullmail' in database." << endl;
+    return 1; =20
+  }
+
+  if(setuid(pw_nullmail->pw_uid) =3D=3D -1){
+    fout << "Unable to run as user 'nullmail'." << endl;
+    return 1;
+  }
=20
   read_hostnames();
   if (!config_read("helohost", hh)) hh =3D me;


Regards,
Clint