aboutsummaryrefslogtreecommitdiffstats
path: root/lib-src/movemail.c
diff options
context:
space:
mode:
authorJoakim Verona2011-02-05 11:23:09 +0100
committerJoakim Verona2011-02-05 11:23:09 +0100
commit4bd51ad5c3445b644dfb017d5b57b10a90aa325f (patch)
tree894801e7308ce4ecc34933f959e28f4b9cff9533 /lib-src/movemail.c
parent13cfe8df462ab8da9f0028e16cc84dcaceaca3d1 (diff)
parent9bcaafce5351d270ac514e23cb69ff1a5fd35229 (diff)
downloademacs-4bd51ad5c3445b644dfb017d5b57b10a90aa325f.tar.gz
emacs-4bd51ad5c3445b644dfb017d5b57b10a90aa325f.zip
merge from upstream. currently seems to have bitroted and i get segfaults
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 f300942427e..682aa10aa39 100644
--- a/lib-src/movemail.c
+++ b/lib-src/movemail.c
@@ -1,7 +1,8 @@
1/* movemail foo bar -- move file foo to file bar, 1/* movemail foo bar -- move file foo to file bar,
2 locking file foo the way /bin/mail respects. 2 locking file foo the way /bin/mail respects.
3 Copyright (C) 1986, 1992, 1993, 1994, 1996, 1999, 2001, 2002, 2003, 2004, 3
4 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. 4Copyright (C) 1986, 1992-1994, 1996, 1999, 2001-2011
5 Free Software Foundation, Inc.
5 6
6This file is part of GNU Emacs. 7This file is part of GNU Emacs.
7 8
@@ -63,9 +64,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
63#include <time.h> 64#include <time.h>
64 65
65#include <getopt.h> 66#include <getopt.h>
66#ifdef HAVE_UNISTD_H
67#include <unistd.h> 67#include <unistd.h>
68#endif
69#ifdef HAVE_FCNTL_H 68#ifdef HAVE_FCNTL_H
70#include <fcntl.h> 69#include <fcntl.h>
71#endif 70#endif
@@ -356,7 +355,7 @@ main (int argc, char **argv)
356 time_t touched_lock, now; 355 time_t touched_lock, now;
357#endif 356#endif
358 357
359 if (setuid (getuid ()) < 0 || setegid (real_gid) < 0) 358 if (setuid (getuid ()) < 0 || setregid (-1, real_gid) < 0)
360 fatal ("Failed to drop privileges", 0, 0); 359 fatal ("Failed to drop privileges", 0, 0);
361 360
362#ifndef MAIL_USE_MMDF 361#ifndef MAIL_USE_MMDF
@@ -383,7 +382,7 @@ main (int argc, char **argv)
383 if (outdesc < 0) 382 if (outdesc < 0)
384 pfatal_with_name (outname); 383 pfatal_with_name (outname);
385 384
386 if (setegid (priv_gid) < 0) 385 if (setregid (-1, priv_gid) < 0)
387 fatal ("Failed to regain privileges", 0, 0); 386 fatal ("Failed to regain privileges", 0, 0);
388 387
389 /* This label exists so we can retry locking 388 /* This label exists so we can retry locking
@@ -480,7 +479,7 @@ main (int argc, char **argv)
480#endif 479#endif
481 480
482 /* Prevent symlink attacks truncating other users' mailboxes */ 481 /* Prevent symlink attacks truncating other users' mailboxes */
483 if (setegid (real_gid) < 0) 482 if (setregid (-1, real_gid) < 0)
484 fatal ("Failed to drop privileges", 0, 0); 483 fatal ("Failed to drop privileges", 0, 0);
485 484
486 /* Check to make sure no errors before we zap the inbox. */ 485 /* Check to make sure no errors before we zap the inbox. */
@@ -490,7 +489,8 @@ main (int argc, char **argv)
490#ifdef MAIL_USE_SYSTEM_LOCK 489#ifdef MAIL_USE_SYSTEM_LOCK
491 if (! preserve_mail) 490 if (! preserve_mail)
492 { 491 {
493 ftruncate (indesc, 0L); 492 if (ftruncate (indesc, 0L) != 0)
493 pfatal_with_name (inname);
494 } 494 }
495#endif /* MAIL_USE_SYSTEM_LOCK */ 495#endif /* MAIL_USE_SYSTEM_LOCK */
496 496
@@ -515,7 +515,7 @@ main (int argc, char **argv)
515#endif /* not MAIL_USE_SYSTEM_LOCK */ 515#endif /* not MAIL_USE_SYSTEM_LOCK */
516 516
517 /* End of mailbox truncation */ 517 /* End of mailbox truncation */
518 if (setegid (priv_gid) < 0) 518 if (setregid (-1, priv_gid) < 0)
519 fatal ("Failed to regain privileges", 0, 0); 519 fatal ("Failed to regain privileges", 0, 0);
520 520
521#ifdef MAIL_USE_MAILLOCK 521#ifdef MAIL_USE_MAILLOCK
@@ -933,7 +933,5 @@ strerror (errnum)
933 933
934#endif /* ! HAVE_STRERROR */ 934#endif /* ! HAVE_STRERROR */
935 935
936/* arch-tag: 1c323112-41fe-4fe5-8de9-494de631f73f
937 (do not change this comment) */
938 936
939/* movemail.c ends here */ 937/* movemail.c ends here */