]> Pileus Git - ~andy/fetchmail/commitdiff
Check seteuid() return value.
authorMatthias Andree <matthias.andree@gmx.de>
Fri, 26 Feb 2010 02:44:21 +0000 (03:44 +0100)
committerMatthias Andree <matthias.andree@gmx.de>
Fri, 26 Feb 2010 02:44:21 +0000 (03:44 +0100)
NEWS
sink.c

diff --git a/NEWS b/NEWS
index 32807eef8f7537c18255be286019ca1165247ec8..4bff3c5238f9854ddaf4d44432a6945d98335a6b 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -63,6 +63,7 @@ fetchmail 6.3.15 (not yet released):
 * Log operating system errors when BSMTP writes fail.
 * Fix verbose mode progress formatting regression from 6.3.10; SMTP trace lines
   were no longer on a line of their own. Reported by Melchior Franz.
+* Check seteuid() return value and abort running MDA if switch fails.
 
 # CHANGES
 * The repository has been converted and moved from the Subversion (SVN) format
diff --git a/sink.c b/sink.c
index e1f008c91e562770e7a8df8151a967a7392f1718..675c2b9581f0d91dd590b38cba79ade5a58b2952 100644 (file)
--- a/sink.c
+++ b/sink.c
@@ -1235,7 +1235,10 @@ static int open_mda_sink(struct query *ctl, struct msgblk *msg,
      * under all BSDs and Linux)
      */
     orig_uid = getuid();
-    seteuid(ctl->uid);
+    if (seteuid(ctl->uid)) {
+       report(stderr, GT_("Cannot switch effective user id to %ld: %s\n"), (long)ctl->uid, strerror(errno));
+       return PS_IOERR;
+    }
 #endif /* HAVE_SETEUID */
 
     sinkfp = popen(before, "w");
@@ -1244,7 +1247,10 @@ 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(orig_uid);
+    if (seteuid(orig_uid)) {
+       report(stderr, GT_("Cannot switch effective user id back to original %ld: %s\n"), (long)orig_uid, strerror(errno));
+       return PS_IOERR;
+    }
 #endif /* HAVE_SETEUID */
 
     if (!sinkfp)