1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-10-14 23:51:08 +02:00

42538: Temporarily set umask for here document.

Done while signals are queued.
This commit is contained in:
Martijn Dekker 2018-03-26 22:32:50 +02:00 committed by Peter Stephenson
parent 9bc391105f
commit fa0105f78c
3 changed files with 19 additions and 0 deletions

View file

@ -1,3 +1,9 @@
2018-03-27 Peter Stephenson <p.stephenson@samsung.com>
* Martijn: 42538: Src/utils.c, Test/A04redirect.ztst:
temporarily set umask (with signals queued) while reading
here document.
2018-03-25 Barton E. Schaefer <schaefer@zsh.org> 2018-03-25 Barton E. Schaefer <schaefer@zsh.org>
* 42480: Src/utils.c: optimize $#var for single-byte character sets * 42480: Src/utils.c: optimize $#var for single-byte character sets

View file

@ -2177,10 +2177,12 @@ gettempfile(const char *prefix, int use_heap, char **tempname)
{ {
char *fn; char *fn;
int fd; int fd;
mode_t old_umask;
#if HAVE_MKSTEMP #if HAVE_MKSTEMP
char *suffix = prefix ? ".XXXXXX" : "XXXXXX"; char *suffix = prefix ? ".XXXXXX" : "XXXXXX";
queue_signals(); queue_signals();
old_umask = umask(0177);
if (!prefix && !(prefix = getsparam("TMPPREFIX"))) if (!prefix && !(prefix = getsparam("TMPPREFIX")))
prefix = DEFAULT_TMPPREFIX; prefix = DEFAULT_TMPPREFIX;
if (use_heap) if (use_heap)
@ -2198,6 +2200,7 @@ gettempfile(const char *prefix, int use_heap, char **tempname)
int failures = 0; int failures = 0;
queue_signals(); queue_signals();
old_umask = umask(0177);
do { do {
if (!(fn = gettempname(prefix, use_heap))) { if (!(fn = gettempname(prefix, use_heap))) {
fd = -1; fd = -1;
@ -2212,6 +2215,7 @@ gettempfile(const char *prefix, int use_heap, char **tempname)
#endif #endif
*tempname = fn; *tempname = fn;
umask(old_umask);
unqueue_signals(); unqueue_signals();
return fd; return fd;
} }

View file

@ -667,3 +667,12 @@
0:Redirect in the middle of assignments 0:Redirect in the middle of assignments
>b >b
>d >d
umask 0777
cat <<' HERE'
look ma, no permissions
HERE
cat <<<"it's a miracle"
0:Here-{string,document}s succeed with restrictive umask
> look ma, no permissions
>it's a miracle