aboutsummaryrefslogtreecommitdiffstats
path: root/lib-src/movemail.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib-src/movemail.c')
-rw-r--r--lib-src/movemail.c20
1 files changed, 9 insertions, 11 deletions
diff --git a/lib-src/movemail.c b/lib-src/movemail.c
index f300942427..682aa10aa3 100644
--- a/lib-src/movemail.c
+++ b/lib-src/movemail.c
@@ -1,7 +1,8 @@
/* movemail foo bar -- move file foo to file bar,
locking file foo the way /bin/mail respects.
- Copyright (C) 1986, 1992, 1993, 1994, 1996, 1999, 2001, 2002, 2003, 2004,
- 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+
+Copyright (C) 1986, 1992-1994, 1996, 1999, 2001-2011
+ Free Software Foundation, Inc.
This file is part of GNU Emacs.
@@ -63,9 +64,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include <time.h>
#include <getopt.h>
-#ifdef HAVE_UNISTD_H
#include <unistd.h>
-#endif
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#endif
@@ -356,7 +355,7 @@ main (int argc, char **argv)
time_t touched_lock, now;
#endif
- if (setuid (getuid ()) < 0 || setegid (real_gid) < 0)
+ if (setuid (getuid ()) < 0 || setregid (-1, real_gid) < 0)
fatal ("Failed to drop privileges", 0, 0);
#ifndef MAIL_USE_MMDF
@@ -383,7 +382,7 @@ main (int argc, char **argv)
if (outdesc < 0)
pfatal_with_name (outname);
- if (setegid (priv_gid) < 0)
+ if (setregid (-1, priv_gid) < 0)
fatal ("Failed to regain privileges", 0, 0);
/* This label exists so we can retry locking
@@ -480,7 +479,7 @@ main (int argc, char **argv)
#endif
/* Prevent symlink attacks truncating other users' mailboxes */
- if (setegid (real_gid) < 0)
+ if (setregid (-1, real_gid) < 0)
fatal ("Failed to drop privileges", 0, 0);
/* Check to make sure no errors before we zap the inbox. */
@@ -490,7 +489,8 @@ main (int argc, char **argv)
#ifdef MAIL_USE_SYSTEM_LOCK
if (! preserve_mail)
{
- ftruncate (indesc, 0L);
+ if (ftruncate (indesc, 0L) != 0)
+ pfatal_with_name (inname);
}
#endif /* MAIL_USE_SYSTEM_LOCK */
@@ -515,7 +515,7 @@ main (int argc, char **argv)
#endif /* not MAIL_USE_SYSTEM_LOCK */
/* End of mailbox truncation */
- if (setegid (priv_gid) < 0)
+ if (setregid (-1, priv_gid) < 0)
fatal ("Failed to regain privileges", 0, 0);
#ifdef MAIL_USE_MAILLOCK
@@ -933,7 +933,5 @@ strerror (errnum)
#endif /* ! HAVE_STRERROR */
-/* arch-tag: 1c323112-41fe-4fe5-8de9-494de631f73f
- (do not change this comment) */
/* movemail.c ends here */