|
From: | Ilkka Virta |
Subject: | Re: [minor] umask 400 causes here-{doc,string} failure |
Date: | Sun, 11 Mar 2018 19:31:15 +0200 |
User-agent: | Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 |
On 11.3. 17:17, Stephane Chazelas wrote:
$ bash -c 'umask 400; cat <<< test' bash: cannot create temp file for here-document: Permission denied
Those shells use temporary files to store the content of the here-documents as the Bourne shell initially did, and open them in read-only mode to make it cat's stdin. When umask contains the 0400 bit, the file is created without read permission to the user, hence the error upon that second open(). I can think of several ways to address it: 1- do nothing and blame the user 2- open the file only once for both writing the content and making it the command's stdin 3. use a pipe instead of a temp file 4. Reset the umask temporarily to 077
One more came to mind:5. manually chmod() the tempfile to 0400 or 0600 if the open() for reading fails with EACCES, and then retry. Should be doable with a localized change to that particular error condition, without changing the overall behaviour.
2 would have my preference.
-- Ilkka Virta / itvirta@iki.fi
[Prev in Thread] | Current Thread | [Next in Thread] |