X-Git-Url: http://git.marmaro.de/?a=blobdiff_plain;f=uip%2Finc.c;h=1cac19fd822618e49a752e97ed18ebae030845ba;hb=d254c5e2ad008f26d5fda43c3f24f0a711c7e851;hp=159e0108d112d7bd3b1e0a1acb5fbcf51cb5af85;hpb=fede6e42d81ce34fd5c1bbe7fb2757b281c2573a;p=mmh diff --git a/uip/inc.c b/uip/inc.c index 159e010..1cac19f 100644 --- a/uip/inc.c +++ b/uip/inc.c @@ -29,13 +29,19 @@ #include #include #include - #include #include #include #include #include #include +#include +#include +#include + +#ifdef HAVE_SYS_PARAM_H +# include +#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, @@ -290,7 +306,7 @@ main(int argc, char **argv) if ((maildir_copy = strdup(maildir)) == NULL) adios(maildir, "error allocating memory to copy maildir"); - create_folder(maildir, noisy ? 0 : 1, done); + create_folder(maildir, noisy ? 0 : 1, exit); if (chdir(maildir) == NOTOK) adios(maildir, "unable to change directory to"); @@ -484,7 +500,7 @@ main(int argc, char **argv) return 0; } -static void +void inc_done() { if (locked) {