diff options
Diffstat (limited to 'lib-src/movemail.c')
| -rw-r--r-- | lib-src/movemail.c | 27 |
1 files changed, 7 insertions, 20 deletions
diff --git a/lib-src/movemail.c b/lib-src/movemail.c index cf93fb78d98..81ac8aa187c 100644 --- a/lib-src/movemail.c +++ b/lib-src/movemail.c | |||
| @@ -380,13 +380,9 @@ main (int argc, char **argv) | |||
| 380 | if (indesc < 0) | 380 | if (indesc < 0) |
| 381 | pfatal_with_name (inname); | 381 | pfatal_with_name (inname); |
| 382 | 382 | ||
| 383 | #ifdef BSD_SYSTEM | 383 | /* Make sure the user can read the output file. */ |
| 384 | /* In case movemail is setuid to root, make sure the user can | 384 | umask (umask (0) & 0377); |
| 385 | read the output file. */ | 385 | |
| 386 | /* This is desirable for all systems | ||
| 387 | but I don't want to assume all have the umask system call */ | ||
| 388 | umask (umask (0) & 0333); | ||
| 389 | #endif /* BSD_SYSTEM */ | ||
| 390 | outdesc = open (outname, O_WRONLY | O_CREAT | O_EXCL, 0666); | 386 | outdesc = open (outname, O_WRONLY | O_CREAT | O_EXCL, 0666); |
| 391 | if (outdesc < 0) | 387 | if (outdesc < 0) |
| 392 | pfatal_with_name (outname); | 388 | pfatal_with_name (outname); |
| @@ -470,10 +466,8 @@ main (int argc, char **argv) | |||
| 470 | } | 466 | } |
| 471 | } | 467 | } |
| 472 | 468 | ||
| 473 | #ifdef BSD_SYSTEM | 469 | if (fsync (outdesc) != 0 && errno != EINVAL) |
| 474 | if (fsync (outdesc) < 0) | ||
| 475 | pfatal_and_delete (outname); | 470 | pfatal_and_delete (outname); |
| 476 | #endif | ||
| 477 | 471 | ||
| 478 | /* Prevent symlink attacks truncating other users' mailboxes */ | 472 | /* Prevent symlink attacks truncating other users' mailboxes */ |
| 479 | if (setregid (-1, real_gid) < 0) | 473 | if (setregid (-1, real_gid) < 0) |
| @@ -754,21 +748,14 @@ popmail (char *mailbox, char *outfile, int preserve, char *password, int reverse | |||
| 754 | } | 748 | } |
| 755 | } | 749 | } |
| 756 | 750 | ||
| 757 | /* On AFS, a call to write only modifies the file in the local | 751 | if (fsync (mbfi) != 0 && errno != EINVAL) |
| 758 | * workstation's AFS cache. The changes are not written to the server | ||
| 759 | * until a call to fsync or close is made. Users with AFS home | ||
| 760 | * directories have lost mail when over quota because these checks were | ||
| 761 | * not made in previous versions of movemail. */ | ||
| 762 | |||
| 763 | #ifdef BSD_SYSTEM | ||
| 764 | if (fsync (mbfi) < 0) | ||
| 765 | { | 752 | { |
| 766 | error ("Error in fsync: %s", strerror (errno), 0); | 753 | error ("Error in fsync: %s", strerror (errno), 0); |
| 754 | close (mbfi); | ||
| 767 | return EXIT_FAILURE; | 755 | return EXIT_FAILURE; |
| 768 | } | 756 | } |
| 769 | #endif | ||
| 770 | 757 | ||
| 771 | if (close (mbfi) == -1) | 758 | if (close (mbfi) != 0) |
| 772 | { | 759 | { |
| 773 | error ("Error in close: %s", strerror (errno), 0); | 760 | error ("Error in close: %s", strerror (errno), 0); |
| 774 | return EXIT_FAILURE; | 761 | return EXIT_FAILURE; |