Move #include from h/mh.h to source files
[mmh] / uip / inc.c
index 213cc5d..1cac19f 100644 (file)
--- a/uip/inc.c
+++ b/uip/inc.c
 #include <h/mh.h>
 #include <h/utils.h>
 #include <fcntl.h>
-
 #include <h/fmt_scan.h>
 #include <h/scansbr.h>
 #include <h/signals.h>
 #include <h/tws.h>
 #include <errno.h>
 #include <signal.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include <locale.h>
+
+#ifdef HAVE_SYS_PARAM_H
+# include <sys/param.h>
+#endif
 
 static struct swit switches[] = {
 #define AUDSW  0
@@ -97,8 +103,16 @@ static int return_gid;
 ** easy case; we're not setuid root, so can drop group privs immediately.
 */
 #define TRYDROPGROUPPRIVS() DROPGROUPPRIVS()
-#define DROPGROUPPRIVS() setgid(getgid())
-#define GETGROUPPRIVS() setgid(return_gid)
+#define DROPGROUPPRIVS() \
+    if (setegid(getgid()) != 0) { \
+        advise ("setegid", "unable to set group to %ld", (long) getgid()); \
+               _exit (-1); \
+    }
+#define GETGROUPPRIVS() \
+    if (setegid(return_gid) != 0) { \
+        advise ("setegid", "unable to set group to %ld", (long) return_gid); \
+               _exit (-1); \
+    }
 #define SAVEGROUPPRIVS() return_gid = getegid()
 #else
 /* define *GROUPPRIVS() as null; this avoids having lots of "#ifdef MAILGROUP"s */
@@ -119,7 +133,7 @@ static FILE *in;
 /*
 ** prototypes
 */
-static void inc_done();
+void inc_done();
 
 
 int
@@ -143,7 +157,9 @@ main(int argc, char **argv)
        /* copy of mail directory because the static gets overwritten */
        char *maildir_copy = NULL;
 
-       atexit(inc_done);
+       if (atexit(inc_done) != 0) {
+               adios(NULL, "atexit failed");
+       }
 
 /*
 ** absolutely the first thing we do is save our privileges,
@@ -484,7 +500,7 @@ main(int argc, char **argv)
        return 0;
 }
 
-static void
+void
 inc_done()
 {
        if (locked) {