diff options
author | joerg <joerg@FreeBSD.org> | 1995-06-14 06:25:09 +0000 |
---|---|---|
committer | joerg <joerg@FreeBSD.org> | 1995-06-14 06:25:09 +0000 |
commit | dbe3013fc1d87ab5a3b99b98be81700a392b8343 (patch) | |
tree | 7cdd8a745aa2f844240ea30b62659f6fd91adfe0 /gnu/usr.bin | |
parent | 1c9ad9c342ecd2219194e63ddd075c61e82fcec9 (diff) | |
download | FreeBSD-src-dbe3013fc1d87ab5a3b99b98be81700a392b8343.zip FreeBSD-src-dbe3013fc1d87ab5a3b99b98be81700a392b8343.tar.gz |
Make `ld' properly honoring the umask setting when chmod'ing the
output file for the `x' bits.
This is a Posix requirement.
Diffstat (limited to 'gnu/usr.bin')
-rw-r--r-- | gnu/usr.bin/ld/ld.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/gnu/usr.bin/ld/ld.c b/gnu/usr.bin/ld/ld.c index a1f81ad..5196ef0 100644 --- a/gnu/usr.bin/ld/ld.c +++ b/gnu/usr.bin/ld/ld.c @@ -32,7 +32,7 @@ static char sccsid[] = "@(#)ld.c 6.10 (Berkeley) 5/22/91"; Set, indirect, and warning symbol features added by Randy Smith. */ /* - * $Id: ld.c,v 1.26 1995/03/10 19:41:50 davidg Exp $ + * $Id: ld.c,v 1.27 1995/05/30 05:01:44 rgrimes Exp $ */ /* Define how to initialize system-dependent header fields. */ @@ -2463,12 +2463,16 @@ write_output() { struct stat statbuf; int filemode; - + mode_t u_mask; + if (lstat(output_filename, &statbuf) == 0) { if (S_ISREG(statbuf.st_mode)) (void)unlink(output_filename); } + u_mask = umask(0); + (void)umask(u_mask); + outstream = fopen(output_filename, "w"); if (outstream == NULL) err(1, "open: %s", output_filename); @@ -2502,7 +2506,7 @@ write_output() /* Output the RSS section */ write_rrs(); - if (chmod (output_filename, filemode | 0111) == -1) + if (chmod (output_filename, filemode | (0111 & ~u_mask)) == -1) err(1, "chmod: %s", output_filename); fflush(outstream); |