diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 11 | ||||
| -rw-r--r-- | src/unexaix.c | 27 | ||||
| -rw-r--r-- | src/unexcoff.c | 27 | ||||
| -rw-r--r-- | src/unexelf.c | 12 | ||||
| -rw-r--r-- | src/unexmacosx.c | 2 |
5 files changed, 15 insertions, 64 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 819c88bc3a0..e21d9ee05e1 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,14 @@ | |||
| 1 | 2014-12-20 Paul Eggert <eggert@cs.ucla.edu> | ||
| 2 | |||
| 3 | Simplify unexec file mode setting | ||
| 4 | * unexaix.c, unexcoff.c, unexelf.c, unexmacosx.c: | ||
| 5 | Don't include <sys/stat.h> when no longer needed. | ||
| 6 | (unexec): Create file with correct mode in the first place, | ||
| 7 | rather than overwriting the mode later and fiddling with the | ||
| 8 | global umask in the mean time. Avoid bogus usage like | ||
| 9 | 'umask (777)', which should have been 'umask (0777)'. | ||
| 10 | (mark_x): Remove. All callers removed. | ||
| 11 | |||
| 1 | 2014-12-19 Paul Eggert <eggert@cs.ucla.edu> | 12 | 2014-12-19 Paul Eggert <eggert@cs.ucla.edu> |
| 2 | 13 | ||
| 3 | Minor cleanups for Lisp objects and symbols | 14 | Minor cleanups for Lisp objects and symbols |
diff --git a/src/unexaix.c b/src/unexaix.c index c97d5cae2a8..fd36e4a73a6 100644 --- a/src/unexaix.c +++ b/src/unexaix.c | |||
| @@ -55,7 +55,6 @@ what you give them. Help stamp out software-hoarding! */ | |||
| 55 | #include <inttypes.h> | 55 | #include <inttypes.h> |
| 56 | #include <stdarg.h> | 56 | #include <stdarg.h> |
| 57 | #include <stdio.h> | 57 | #include <stdio.h> |
| 58 | #include <sys/stat.h> | ||
| 59 | #include <errno.h> | 58 | #include <errno.h> |
| 60 | #include <unistd.h> | 59 | #include <unistd.h> |
| 61 | #include <fcntl.h> | 60 | #include <fcntl.h> |
| @@ -134,7 +133,7 @@ unexec (const char *new_name, const char *a_name) | |||
| 134 | { | 133 | { |
| 135 | PERROR (a_name); | 134 | PERROR (a_name); |
| 136 | } | 135 | } |
| 137 | if ((new = emacs_open (new_name, O_WRONLY | O_CREAT | O_TRUNC, 0666)) < 0) | 136 | if ((new = emacs_open (new_name, O_WRONLY | O_CREAT | O_TRUNC, 0777)) < 0) |
| 138 | { | 137 | { |
| 139 | PERROR (new_name); | 138 | PERROR (new_name); |
| 140 | } | 139 | } |
| @@ -152,7 +151,6 @@ unexec (const char *new_name, const char *a_name) | |||
| 152 | emacs_close (new); | 151 | emacs_close (new); |
| 153 | if (a_out >= 0) | 152 | if (a_out >= 0) |
| 154 | emacs_close (a_out); | 153 | emacs_close (a_out); |
| 155 | mark_x (new_name); | ||
| 156 | } | 154 | } |
| 157 | 155 | ||
| 158 | /* **************************************************************** | 156 | /* **************************************************************** |
| @@ -466,29 +464,6 @@ copy_sym (int new, int a_out, const char *a_name, const char *new_name) | |||
| 466 | return 0; | 464 | return 0; |
| 467 | } | 465 | } |
| 468 | 466 | ||
| 469 | /* **************************************************************** | ||
| 470 | * mark_x | ||
| 471 | * | ||
| 472 | * After successfully building the new a.out, mark it executable | ||
| 473 | */ | ||
| 474 | static void | ||
| 475 | mark_x (const char *name) | ||
| 476 | { | ||
| 477 | struct stat sbuf; | ||
| 478 | int um; | ||
| 479 | int new = 0; /* for PERROR */ | ||
| 480 | |||
| 481 | um = umask (777); | ||
| 482 | umask (um); | ||
| 483 | if (stat (name, &sbuf) == -1) | ||
| 484 | { | ||
| 485 | PERROR (name); | ||
| 486 | } | ||
| 487 | sbuf.st_mode |= 0111 & ~um; | ||
| 488 | if (chmod (name, sbuf.st_mode) == -1) | ||
| 489 | PERROR (name); | ||
| 490 | } | ||
| 491 | |||
| 492 | static int | 467 | static int |
| 493 | adjust_lnnoptrs (int writedesc, int readdesc, const char *new_name) | 468 | adjust_lnnoptrs (int writedesc, int readdesc, const char *new_name) |
| 494 | { | 469 | { |
diff --git a/src/unexcoff.c b/src/unexcoff.c index 0e47bdd8656..292c38f7ff7 100644 --- a/src/unexcoff.c +++ b/src/unexcoff.c | |||
| @@ -97,7 +97,6 @@ struct aouthdr | |||
| 97 | #include <sys/types.h> | 97 | #include <sys/types.h> |
| 98 | #endif /* makedev */ | 98 | #endif /* makedev */ |
| 99 | #include <stdio.h> | 99 | #include <stdio.h> |
| 100 | #include <sys/stat.h> | ||
| 101 | #include <errno.h> | 100 | #include <errno.h> |
| 102 | 101 | ||
| 103 | #include <sys/file.h> | 102 | #include <sys/file.h> |
| @@ -439,29 +438,6 @@ copy_sym (int new, int a_out, const char *a_name, const char *new_name) | |||
| 439 | return 0; | 438 | return 0; |
| 440 | } | 439 | } |
| 441 | 440 | ||
| 442 | /* **************************************************************** | ||
| 443 | * mark_x | ||
| 444 | * | ||
| 445 | * After successfully building the new a.out, mark it executable | ||
| 446 | */ | ||
| 447 | static void | ||
| 448 | mark_x (const char *name) | ||
| 449 | { | ||
| 450 | struct stat sbuf; | ||
| 451 | int um; | ||
| 452 | int new = 0; /* for PERROR */ | ||
| 453 | |||
| 454 | um = umask (777); | ||
| 455 | umask (um); | ||
| 456 | if (stat (name, &sbuf) == -1) | ||
| 457 | { | ||
| 458 | PERROR (name); | ||
| 459 | } | ||
| 460 | sbuf.st_mode |= 0111 & ~um; | ||
| 461 | if (chmod (name, sbuf.st_mode) == -1) | ||
| 462 | PERROR (name); | ||
| 463 | } | ||
| 464 | |||
| 465 | 441 | ||
| 466 | /* | 442 | /* |
| 467 | * If the COFF file contains a symbol table and a line number section, | 443 | * If the COFF file contains a symbol table and a line number section, |
| @@ -542,7 +518,7 @@ unexec (const char *new_name, const char *a_name) | |||
| 542 | { | 518 | { |
| 543 | PERROR (a_name); | 519 | PERROR (a_name); |
| 544 | } | 520 | } |
| 545 | if ((new = emacs_open (new_name, O_WRONLY | O_CREAT | O_TRUNC, 0666)) < 0) | 521 | if ((new = emacs_open (new_name, O_WRONLY | O_CREAT | O_TRUNC, 0777)) < 0) |
| 546 | { | 522 | { |
| 547 | PERROR (new_name); | 523 | PERROR (new_name); |
| 548 | } | 524 | } |
| @@ -560,7 +536,6 @@ unexec (const char *new_name, const char *a_name) | |||
| 560 | emacs_close (new); | 536 | emacs_close (new); |
| 561 | if (a_out >= 0) | 537 | if (a_out >= 0) |
| 562 | emacs_close (a_out); | 538 | emacs_close (a_out); |
| 563 | mark_x (new_name); | ||
| 564 | } | 539 | } |
| 565 | 540 | ||
| 566 | #endif /* not CANNOT_DUMP */ | 541 | #endif /* not CANNOT_DUMP */ |
diff --git a/src/unexelf.c b/src/unexelf.c index 0983f8f23ab..34478e0edb7 100644 --- a/src/unexelf.c +++ b/src/unexelf.c | |||
| @@ -665,7 +665,6 @@ unexec (const char *new_name, const char *old_name) | |||
| 665 | #endif | 665 | #endif |
| 666 | struct stat stat_buf; | 666 | struct stat stat_buf; |
| 667 | off_t old_file_size; | 667 | off_t old_file_size; |
| 668 | int mask; | ||
| 669 | 668 | ||
| 670 | /* Open the old file, allocate a buffer of the right size, and read | 669 | /* Open the old file, allocate a buffer of the right size, and read |
| 671 | in the file contents. */ | 670 | in the file contents. */ |
| @@ -799,7 +798,7 @@ unexec (const char *new_name, const char *old_name) | |||
| 799 | the image of the new file. Set pointers to various interesting | 798 | the image of the new file. Set pointers to various interesting |
| 800 | objects. */ | 799 | objects. */ |
| 801 | 800 | ||
| 802 | new_file = emacs_open (new_name, O_RDWR | O_CREAT, 0666); | 801 | new_file = emacs_open (new_name, O_RDWR | O_CREAT, 0777); |
| 803 | if (new_file < 0) | 802 | if (new_file < 0) |
| 804 | fatal ("Can't creat (%s): %s", new_name, strerror (errno)); | 803 | fatal ("Can't creat (%s): %s", new_name, strerror (errno)); |
| 805 | 804 | ||
| @@ -1319,13 +1318,4 @@ temacs: | |||
| 1319 | 1318 | ||
| 1320 | if (emacs_close (new_file) != 0) | 1319 | if (emacs_close (new_file) != 0) |
| 1321 | fatal ("Can't close (%s): %s", new_name, strerror (errno)); | 1320 | fatal ("Can't close (%s): %s", new_name, strerror (errno)); |
| 1322 | |||
| 1323 | if (stat (new_name, &stat_buf) != 0) | ||
| 1324 | fatal ("Can't stat (%s): %s", new_name, strerror (errno)); | ||
| 1325 | |||
| 1326 | mask = umask (777); | ||
| 1327 | umask (mask); | ||
| 1328 | stat_buf.st_mode |= 0111 & ~mask; | ||
| 1329 | if (chmod (new_name, stat_buf.st_mode) != 0) | ||
| 1330 | fatal ("Can't chmod (%s): %s", new_name, strerror (errno)); | ||
| 1331 | } | 1321 | } |
diff --git a/src/unexmacosx.c b/src/unexmacosx.c index 2e1ac880d2a..89971bb8a77 100644 --- a/src/unexmacosx.c +++ b/src/unexmacosx.c | |||
| @@ -1267,7 +1267,7 @@ unexec (const char *outfile, const char *infile) | |||
| 1267 | unexec_error ("cannot open input file `%s'", infile); | 1267 | unexec_error ("cannot open input file `%s'", infile); |
| 1268 | } | 1268 | } |
| 1269 | 1269 | ||
| 1270 | outfd = emacs_open (outfile, O_WRONLY | O_TRUNC | O_CREAT, 0755); | 1270 | outfd = emacs_open (outfile, O_WRONLY | O_TRUNC | O_CREAT, 0777); |
| 1271 | if (outfd < 0) | 1271 | if (outfd < 0) |
| 1272 | { | 1272 | { |
| 1273 | emacs_close (infd); | 1273 | emacs_close (infd); |