diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2002-09-04 13:59:02 +0000 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2002-09-04 13:59:02 +0000 |
commit | c8928081a5a9cbfaf16b14d4db57476bda8e1189 (patch) | |
tree | 2d7b495cd4352fd5facdeaeb500a394ba17b7714 | |
parent | e588fb0f217d4ab7d1bfe8a1d292b8f556cefcb8 (diff) | |
download | fetchmail-c8928081a5a9cbfaf16b14d4db57476bda8e1189.tar.gz fetchmail-c8928081a5a9cbfaf16b14d4db57476bda8e1189.tar.bz2 fetchmail-c8928081a5a9cbfaf16b14d4db57476bda8e1189.zip |
Cygwin port fix.
svn path=/trunk/; revision=3692
-rw-r--r-- | fetchmail.c | 6 | ||||
-rw-r--r-- | fetchmail.h | 6 | ||||
-rw-r--r-- | idle.c | 6 | ||||
-rw-r--r-- | lock.c | 2 | ||||
-rw-r--r-- | sink.c | 6 |
5 files changed, 19 insertions, 7 deletions
diff --git a/fetchmail.c b/fetchmail.c index 93f4754a..78f3993f 100644 --- a/fetchmail.c +++ b/fetchmail.c @@ -492,7 +492,7 @@ int main(int argc, char **argv) * but ignore them otherwise so as not to interrupt a poll. */ signal(SIGUSR1, SIG_IGN); - if (run.poll_interval && !getuid()) + if (run.poll_interval && getuid() == ROOT_UID) signal(SIGHUP, SIG_IGN); } else @@ -732,7 +732,7 @@ int main(int argc, char **argv) * for people who think all system daemons wake up on SIGHUP. */ signal(SIGUSR1, donothing); - if (!getuid()) + if (getuid() != ROOT_UID) signal(SIGHUP, donothing); /* @@ -1187,7 +1187,7 @@ static int load_params(int argc, char **argv, int optind) */ if (!run.postmaster) { - if (getuid()) /* ordinary user */ + if (getuid() != ROOT_UID) /* ordinary user */ run.postmaster = user; else /* root */ run.postmaster = "postmaster"; diff --git a/fetchmail.h b/fetchmail.h index bf67a280..7b2f0436 100644 --- a/fetchmail.h +++ b/fetchmail.h @@ -647,4 +647,10 @@ char *strerror (); } while(0) #endif /* FETCHMAIL_DEBUG */ +#ifdef __CYGWIN__ +#define ROOT_UID 18 +#else /* !__CYGWIN__ */ +#define ROOT_UID 0 +#endif /* __CYGWIN__ */ + /* fetchmail.h ends here */ @@ -22,6 +22,7 @@ MIT license. Compile with -DMAIN to build the demonstrator. #include <signal.h> #include <errno.h> #include <sys/time.h> +#include <fetchmail.h> /* for ROOT_UID */ #ifndef TRUE #define TRUE 1 @@ -154,12 +155,13 @@ int interruptible_idle(int seconds) pause(); signal(SIGALRM, SIG_IGN); #endif /* ! EMX */ - if (lastsig == SIGUSR1 || ((seconds && !getuid()) && lastsig == SIGHUP)) + if (lastsig == SIGUSR1 || ((seconds && getuid() == ROOT_UID) + && lastsig == SIGHUP)) awoken = TRUE; /* now lock out interrupts again */ signal(SIGUSR1, SIG_IGN); - if (!getuid()) + if (getuid() == ROOT_UID) signal(SIGHUP, SIG_IGN); return(awoken ? lastsig : 0); @@ -29,7 +29,7 @@ void lock_setup(void) { /* set up to do lock protocol */ #define FETCHMAIL_PIDFILE "fetchmail.pid" - if (!getuid()) { + if (getuid() == ROOT_UID) { lockfile = (char *)xmalloc( sizeof(PID_DIR) + sizeof(FETCHMAIL_PIDFILE) + 1); sprintf(lockfile, "%s/%s", PID_DIR, FETCHMAIL_PIDFILE); @@ -937,6 +937,9 @@ static int open_mda_sink(struct query *ctl, struct msgblk *msg, #ifdef HAVE_SIGACTION struct sigaction sa_new; #endif /* HAVE_SIGACTION */ +#ifdef HAVE_SETEUID + uid_t orig_uid; +#endif /* HAVE_SETEUID */ struct idlist *idp; int length = 0, fromlen = 0, nameslen = 0; char *names = NULL, *before, *after, *from = NULL; @@ -1062,6 +1065,7 @@ static int open_mda_sink(struct query *ctl, struct msgblk *msg, * MDA creates properly. (The seteuid call is available * under all BSDs and Linux) */ + orig_uid = getuid(); seteuid(ctl->uid); #endif /* HAVE_SETEUID */ @@ -1071,7 +1075,7 @@ static int open_mda_sink(struct query *ctl, struct msgblk *msg, #ifdef HAVE_SETEUID /* this will fail quietly if we didn't start as root */ - seteuid(0); + seteuid(orig_uid); #endif /* HAVE_SETEUID */ if (!sinkfp) |