diff options
| author | Kenichi Handa | 2010-04-07 15:08:27 +0900 |
|---|---|---|
| committer | Kenichi Handa | 2010-04-07 15:08:27 +0900 |
| commit | 64e692b56e84153d45b2c46d833dce14243f7c69 (patch) | |
| tree | db049db5995f5cfcba3db28dfeb305ef5e04157c /lib-src | |
| parent | 86a366f4015868f03bc8399b412ea767e9337072 (diff) | |
| parent | e59c4233e20bfb2b8b50c77a42023a2473405391 (diff) | |
| download | emacs-64e692b56e84153d45b2c46d833dce14243f7c69.tar.gz emacs-64e692b56e84153d45b2c46d833dce14243f7c69.zip | |
merge trunk
Diffstat (limited to 'lib-src')
| -rw-r--r-- | lib-src/ChangeLog | 28 | ||||
| -rw-r--r-- | lib-src/makefile.w32-in | 2 | ||||
| -rw-r--r-- | lib-src/movemail.c | 45 | ||||
| -rw-r--r-- | lib-src/ntlib.c | 18 | ||||
| -rw-r--r-- | lib-src/ntlib.h | 3 |
5 files changed, 61 insertions, 35 deletions
diff --git a/lib-src/ChangeLog b/lib-src/ChangeLog index caa7f3cfc80..a68629d2393 100644 --- a/lib-src/ChangeLog +++ b/lib-src/ChangeLog | |||
| @@ -1,3 +1,15 @@ | |||
| 1 | 2010-04-03 Juanma Barranquero <lekktu@gmail.com> | ||
| 2 | |||
| 3 | Add stubs for Windows, required after CVE-2010-0825 change. | ||
| 4 | * ntlib.c (getgid, getegid, setegid): New stubs. | ||
| 5 | * ntlib.h (getgid, getegid, setegid): Declare them. | ||
| 6 | |||
| 7 | 2010-04-02 Dan Rosenberg <dan.j.rosenberg@gmail.com> (tiny change) | ||
| 8 | |||
| 9 | * movemail.c (main): Check return values of setuid. Avoid | ||
| 10 | possibility of symlink attack when movemail is setgid mail | ||
| 11 | (CVE-2010-0825). | ||
| 12 | |||
| 1 | 2010-03-19 Tetsurou Okazaki <okazaki@be.to> (tiny change) | 13 | 2010-03-19 Tetsurou Okazaki <okazaki@be.to> (tiny change) |
| 2 | 14 | ||
| 3 | * Makefile.in (uninstall): Handle the case where archlibdir does | 15 | * Makefile.in (uninstall): Handle the case where archlibdir does |
| @@ -3942,7 +3954,7 @@ | |||
| 3942 | (xmalloc, fatal, error): New functions. | 3954 | (xmalloc, fatal, error): New functions. |
| 3943 | (delete_socket, handle_signals): New functions. | 3955 | (delete_socket, handle_signals): New functions. |
| 3944 | (progname, socket_name): New variables. | 3956 | (progname, socket_name): New variables. |
| 3945 | [HAVE_SOCKETS] (main): Call handle_signals; set the new variables. | 3957 | [HAVE_SOCKETS] (main): Call handle_signals; set the new variables. |
| 3946 | 3958 | ||
| 3947 | 1996-09-01 Richard Stallman <rms@ethanol.gnu.ai.mit.edu> | 3959 | 1996-09-01 Richard Stallman <rms@ethanol.gnu.ai.mit.edu> |
| 3948 | 3960 | ||
| @@ -4715,9 +4727,9 @@ | |||
| 4715 | 1995-01-12 Francesco Potortì (pot@cnuce.cnr.it) | 4727 | 1995-01-12 Francesco Potortì (pot@cnuce.cnr.it) |
| 4716 | 4728 | ||
| 4717 | * etags.c (FILEPOS, GET_CHARNO, GET_FILEPOS, max, LINENO): Deleted. | 4729 | * etags.c (FILEPOS, GET_CHARNO, GET_FILEPOS, max, LINENO): Deleted. |
| 4718 | (append_to_tagfile, typedefs, typedefs_and_cplusplus, | 4730 | (append_to_tagfile, typedefs, typedefs_and_cplusplus) |
| 4719 | constantypedefs, update, vgrind_style, no_warnings, | 4731 | (constantypedefs, update, vgrind_style, no_warnings) |
| 4720 | cxref_style, cplusplus, noindentypedefs): Were int, now logical. | 4732 | (cxref_style, cplusplus, noindentypedefs): Were int, now logical. |
| 4721 | (permit_duplicates): Was a var, now a #define. | 4733 | (permit_duplicates): Was a var, now a #define. |
| 4722 | (filename_lb): Was global, now local to main. | 4734 | (filename_lb): Was global, now local to main. |
| 4723 | (main): Open the tag file when in cxref mode. | 4735 | (main): Open the tag file when in cxref mode. |
| @@ -4736,8 +4748,8 @@ | |||
| 4736 | (TOKEN_SAVED_P, SAVE_TOKEN, RESTORE_TOKEN): Deleted. | 4748 | (TOKEN_SAVED_P, SAVE_TOKEN, RESTORE_TOKEN): Deleted. |
| 4737 | (C_entries): nameb and savenameb deleted. Use dinamic allocation. | 4749 | (C_entries): nameb and savenameb deleted. Use dinamic allocation. |
| 4738 | (pfcnt): Deleted. Users updated. | 4750 | (pfcnt): Deleted. Users updated. |
| 4739 | (getit, Asm_labels, Pascal_functions, L_getit, get_scheme, | 4751 | (getit, Asm_labels, Pascal_functions, L_getit, get_scheme) |
| 4740 | TEX_getit, prolog_getit): Use dinamic allocation for storing | 4752 | (TEX_getit, prolog_getit): Use dinamic allocation for storing |
| 4741 | the tag instead of a fixed size buffer. | 4753 | the tag instead of a fixed size buffer. |
| 4742 | 4754 | ||
| 4743 | 1995-01-10 Richard Stallman <rms@mole.gnu.ai.mit.edu> | 4755 | 1995-01-10 Richard Stallman <rms@mole.gnu.ai.mit.edu> |
| @@ -6662,8 +6674,8 @@ | |||
| 6662 | 1990-01-19 David Lawrence (tale@cocoa-puffs) | 6674 | 1990-01-19 David Lawrence (tale@cocoa-puffs) |
| 6663 | 6675 | ||
| 6664 | * timer.c, getdate.y (new files) and Makefile: | 6676 | * timer.c, getdate.y (new files) and Makefile: |
| 6665 | Sub-process support for run-at-time in timer.el. | 6677 | Sub-process support for run-at-time in timer.el. |
| 6666 | Doesn't yet work correctly for USG. | 6678 | Doesn't yet work correctly for USG. |
| 6667 | 6679 | ||
| 6668 | 1990-01-10 Jim Kingdon (kingdon@pogo) | 6680 | 1990-01-10 Jim Kingdon (kingdon@pogo) |
| 6669 | 6681 | ||
diff --git a/lib-src/makefile.w32-in b/lib-src/makefile.w32-in index b59273ef33d..131cca7fdd7 100644 --- a/lib-src/makefile.w32-in +++ b/lib-src/makefile.w32-in | |||
| @@ -22,7 +22,7 @@ ALL = make-docfile hexl ctags etags movemail ebrowse sorted-doc digest-doc emacs | |||
| 22 | 22 | ||
| 23 | .PHONY: $(ALL) | 23 | .PHONY: $(ALL) |
| 24 | 24 | ||
| 25 | VERSION = 23.1.94 | 25 | VERSION = 23.1.95 |
| 26 | 26 | ||
| 27 | LOCAL_FLAGS = -DWINDOWSNT -DDOS_NT -DSTDC_HEADERS=1 -DNO_LDAV=1 \ | 27 | LOCAL_FLAGS = -DWINDOWSNT -DDOS_NT -DSTDC_HEADERS=1 -DNO_LDAV=1 \ |
| 28 | -DNO_ARCHIVES=1 -DHAVE_CONFIG_H=1 -I../nt/inc \ | 28 | -DNO_ARCHIVES=1 -DHAVE_CONFIG_H=1 -I../nt/inc \ |
diff --git a/lib-src/movemail.c b/lib-src/movemail.c index e0eb4d48b89..ae51df3d39c 100644 --- a/lib-src/movemail.c +++ b/lib-src/movemail.c | |||
| @@ -197,6 +197,9 @@ main (argc, argv) | |||
| 197 | # define ARGSTR "p" | 197 | # define ARGSTR "p" |
| 198 | #endif /* MAIL_USE_POP */ | 198 | #endif /* MAIL_USE_POP */ |
| 199 | 199 | ||
| 200 | uid_t real_gid = getgid(); | ||
| 201 | uid_t priv_gid = getegid(); | ||
| 202 | |||
| 200 | #ifdef WINDOWSNT | 203 | #ifdef WINDOWSNT |
| 201 | /* Ensure all file i/o is in binary mode. */ | 204 | /* Ensure all file i/o is in binary mode. */ |
| 202 | _fmode = _O_BINARY; | 205 | _fmode = _O_BINARY; |
| @@ -247,25 +250,6 @@ main (argc, argv) | |||
| 247 | if (*outname == 0) | 250 | if (*outname == 0) |
| 248 | fatal ("Destination file name is empty", 0, 0); | 251 | fatal ("Destination file name is empty", 0, 0); |
| 249 | 252 | ||
| 250 | /* Check access to output file. */ | ||
| 251 | if (access (outname, F_OK) == 0 && access (outname, W_OK) != 0) | ||
| 252 | pfatal_with_name (outname); | ||
| 253 | |||
| 254 | /* Also check that outname's directory is writable to the real uid. */ | ||
| 255 | { | ||
| 256 | char *buf = (char *) xmalloc (strlen (outname) + 1); | ||
| 257 | char *p; | ||
| 258 | strcpy (buf, outname); | ||
| 259 | p = buf + strlen (buf); | ||
| 260 | while (p > buf && !IS_DIRECTORY_SEP (p[-1])) | ||
| 261 | *--p = 0; | ||
| 262 | if (p == buf) | ||
| 263 | *p++ = '.'; | ||
| 264 | if (access (buf, W_OK) != 0) | ||
| 265 | pfatal_with_name (buf); | ||
| 266 | free (buf); | ||
| 267 | } | ||
| 268 | |||
| 269 | #ifdef MAIL_USE_POP | 253 | #ifdef MAIL_USE_POP |
| 270 | if (!strncmp (inname, "po:", 3)) | 254 | if (!strncmp (inname, "po:", 3)) |
| 271 | { | 255 | { |
| @@ -277,15 +261,12 @@ main (argc, argv) | |||
| 277 | exit (status); | 261 | exit (status); |
| 278 | } | 262 | } |
| 279 | 263 | ||
| 280 | setuid (getuid ()); | 264 | if (setuid (getuid ()) < 0) |
| 265 | fatal ("Failed to drop privileges", 0, 0); | ||
| 266 | |||
| 281 | #endif /* MAIL_USE_POP */ | 267 | #endif /* MAIL_USE_POP */ |
| 282 | 268 | ||
| 283 | #ifndef DISABLE_DIRECT_ACCESS | 269 | #ifndef DISABLE_DIRECT_ACCESS |
| 284 | |||
| 285 | /* Check access to input file. */ | ||
| 286 | if (access (inname, R_OK | W_OK) != 0) | ||
| 287 | pfatal_with_name (inname); | ||
| 288 | |||
| 289 | #ifndef MAIL_USE_MMDF | 270 | #ifndef MAIL_USE_MMDF |
| 290 | #ifndef MAIL_USE_SYSTEM_LOCK | 271 | #ifndef MAIL_USE_SYSTEM_LOCK |
| 291 | #ifdef MAIL_USE_MAILLOCK | 272 | #ifdef MAIL_USE_MAILLOCK |
| @@ -379,7 +360,8 @@ main (argc, argv) | |||
| 379 | time_t touched_lock, now; | 360 | time_t touched_lock, now; |
| 380 | #endif | 361 | #endif |
| 381 | 362 | ||
| 382 | setuid (getuid ()); | 363 | if (setuid (getuid ()) < 0 || setegid (real_gid) < 0) |
| 364 | fatal ("Failed to drop privileges", 0, 0); | ||
| 383 | 365 | ||
| 384 | #ifndef MAIL_USE_MMDF | 366 | #ifndef MAIL_USE_MMDF |
| 385 | #ifdef MAIL_USE_SYSTEM_LOCK | 367 | #ifdef MAIL_USE_SYSTEM_LOCK |
| @@ -405,6 +387,9 @@ main (argc, argv) | |||
| 405 | if (outdesc < 0) | 387 | if (outdesc < 0) |
| 406 | pfatal_with_name (outname); | 388 | pfatal_with_name (outname); |
| 407 | 389 | ||
| 390 | if (setegid (priv_gid) < 0) | ||
| 391 | fatal ("Failed to regain privileges", 0, 0); | ||
| 392 | |||
| 408 | /* This label exists so we can retry locking | 393 | /* This label exists so we can retry locking |
| 409 | after a delay, if it got EAGAIN or EBUSY. */ | 394 | after a delay, if it got EAGAIN or EBUSY. */ |
| 410 | retry_lock: | 395 | retry_lock: |
| @@ -498,6 +483,10 @@ main (argc, argv) | |||
| 498 | pfatal_and_delete (outname); | 483 | pfatal_and_delete (outname); |
| 499 | #endif | 484 | #endif |
| 500 | 485 | ||
| 486 | /* Prevent symlink attacks truncating other users' mailboxes */ | ||
| 487 | if (setegid (real_gid) < 0) | ||
| 488 | fatal ("Failed to drop privileges", 0, 0); | ||
| 489 | |||
| 501 | /* Check to make sure no errors before we zap the inbox. */ | 490 | /* Check to make sure no errors before we zap the inbox. */ |
| 502 | if (close (outdesc) != 0) | 491 | if (close (outdesc) != 0) |
| 503 | pfatal_and_delete (outname); | 492 | pfatal_and_delete (outname); |
| @@ -529,6 +518,10 @@ main (argc, argv) | |||
| 529 | } | 518 | } |
| 530 | #endif /* not MAIL_USE_SYSTEM_LOCK */ | 519 | #endif /* not MAIL_USE_SYSTEM_LOCK */ |
| 531 | 520 | ||
| 521 | /* End of mailbox truncation */ | ||
| 522 | if (setegid (priv_gid) < 0) | ||
| 523 | fatal ("Failed to regain privileges", 0, 0); | ||
| 524 | |||
| 532 | #ifdef MAIL_USE_MAILLOCK | 525 | #ifdef MAIL_USE_MAILLOCK |
| 533 | /* This has to occur in the child, i.e., in the process that | 526 | /* This has to occur in the child, i.e., in the process that |
| 534 | acquired the lock! */ | 527 | acquired the lock! */ |
diff --git a/lib-src/ntlib.c b/lib-src/ntlib.c index ae10caecd22..c815f32d51d 100644 --- a/lib-src/ntlib.c +++ b/lib-src/ntlib.c | |||
| @@ -125,12 +125,30 @@ getuid () | |||
| 125 | return 0; | 125 | return 0; |
| 126 | } | 126 | } |
| 127 | 127 | ||
| 128 | unsigned | ||
| 129 | getgid () | ||
| 130 | { | ||
| 131 | return 0; | ||
| 132 | } | ||
| 133 | |||
| 134 | unsigned | ||
| 135 | getegid () | ||
| 136 | { | ||
| 137 | return 0; | ||
| 138 | } | ||
| 139 | |||
| 128 | int | 140 | int |
| 129 | setuid (unsigned uid) | 141 | setuid (unsigned uid) |
| 130 | { | 142 | { |
| 131 | return 0; | 143 | return 0; |
| 132 | } | 144 | } |
| 133 | 145 | ||
| 146 | int | ||
| 147 | setegid (unsigned gid) | ||
| 148 | { | ||
| 149 | return 0; | ||
| 150 | } | ||
| 151 | |||
| 134 | struct passwd * | 152 | struct passwd * |
| 135 | getpwuid (unsigned uid) | 153 | getpwuid (unsigned uid) |
| 136 | { | 154 | { |
diff --git a/lib-src/ntlib.h b/lib-src/ntlib.h index 70b99d7a779..ab1e7ba2866 100644 --- a/lib-src/ntlib.h +++ b/lib-src/ntlib.h | |||
| @@ -36,7 +36,10 @@ int getppid(void); | |||
| 36 | char * getlogin (); | 36 | char * getlogin (); |
| 37 | char * cuserid (char * s); | 37 | char * cuserid (char * s); |
| 38 | unsigned getuid (); | 38 | unsigned getuid (); |
| 39 | unsigned getegid (); | ||
| 40 | unsigned getgid (); | ||
| 39 | int setuid (unsigned uid); | 41 | int setuid (unsigned uid); |
| 42 | int setegid (unsigned gid); | ||
| 40 | char * getpass (const char * prompt); | 43 | char * getpass (const char * prompt); |
| 41 | int fchown (int fd, unsigned uid, unsigned gid); | 44 | int fchown (int fd, unsigned uid, unsigned gid); |
| 42 | 45 | ||