files: remove two superfluous calls for shielding temp files from others
If there are still systems where mkstemp() creates world-readable temporary files, then please holler. On current BSDs and on GNU, I've verified that mkstemp() creates files with 0600 permissions.master
parent
f8366cd5c9
commit
b48dfde3b2
|
@ -1398,7 +1398,6 @@ char *safe_tempfile(FILE **stream)
|
||||||
{
|
{
|
||||||
const char *env_dir = getenv("TMPDIR");
|
const char *env_dir = getenv("TMPDIR");
|
||||||
char *tempdir = NULL, *tempfile_name = NULL;
|
char *tempdir = NULL, *tempfile_name = NULL;
|
||||||
mode_t was_mask;
|
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
/* Get the absolute path for the first directory among $TMPDIR
|
/* Get the absolute path for the first directory among $TMPDIR
|
||||||
|
@ -1415,12 +1414,8 @@ char *safe_tempfile(FILE **stream)
|
||||||
tempfile_name = charealloc(tempdir, strlen(tempdir) + 12);
|
tempfile_name = charealloc(tempdir, strlen(tempdir) + 12);
|
||||||
strcat(tempfile_name, "nano.XXXXXX");
|
strcat(tempfile_name, "nano.XXXXXX");
|
||||||
|
|
||||||
was_mask = umask(S_IRWXG | S_IRWXO);
|
|
||||||
|
|
||||||
fd = mkstemp(tempfile_name);
|
fd = mkstemp(tempfile_name);
|
||||||
|
|
||||||
umask(was_mask);
|
|
||||||
|
|
||||||
if (fd == -1) {
|
if (fd == -1) {
|
||||||
free(tempfile_name);
|
free(tempfile_name);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
Loading…
Reference in New Issue