aboutsummaryrefslogtreecommitdiffstats
path: root/sink.c
diff options
context:
space:
mode:
authorMatthias Andree <matthias.andree@gmx.de>2010-02-26 03:44:21 +0100
committerMatthias Andree <matthias.andree@gmx.de>2010-02-26 03:44:21 +0100
commitd628b9c96acfcfddf89abe091c40cc18785d8b63 (patch)
tree686dfeb607ffbf20cb22264e5196f05a47e698fa /sink.c
parent85f4bdcc0c77f97d3d6987be662c350249359a5d (diff)
downloadfetchmail-d628b9c96acfcfddf89abe091c40cc18785d8b63.tar.gz
fetchmail-d628b9c96acfcfddf89abe091c40cc18785d8b63.tar.bz2
fetchmail-d628b9c96acfcfddf89abe091c40cc18785d8b63.zip
Check seteuid() return value.
Diffstat (limited to 'sink.c')
-rw-r--r--sink.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/sink.c b/sink.c
index e1f008c9..675c2b95 100644
--- 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)