From 5fbea18fbe6fb626dede3b7d8afd7592f0606e45 Mon Sep 17 00:00:00 2001 From: Joerg Wunsch Date: Wed, 14 Jun 1995 06:25:09 +0000 Subject: Make `ld' properly honoring the umask setting when chmod'ing the output file for the `x' bits. This is a Posix requirement. --- gnu/usr.bin/ld/ld.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'gnu') diff --git a/gnu/usr.bin/ld/ld.c b/gnu/usr.bin/ld/ld.c index a1f81ad0e2c8..5196ef0fc830 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); -- cgit v1.3