Skip to content

Commit

Permalink
Remove unnecessary umask change in text_save_begin_inplace
Browse files Browse the repository at this point in the history
POSIX says that

  The mkstemp() function shall use the resulting pathname to create the
  file, and obtain a file descriptor for it, as if by a call to:

    open(pathname, O_RDWR|O_CREAT|O_EXCL, S_IRUSR|S_IWUSR)

So this umask change didn't do anything in practice, unless the original
umask was more restrictive than 0177.
  • Loading branch information
michaelforney committed Feb 27, 2017
1 parent e4380da commit 80605f5
Showing 1 changed file with 0 additions and 2 deletions.
2 changes: 0 additions & 2 deletions text.c
Original file line number Diff line number Diff line change
Expand Up @@ -937,9 +937,7 @@ static bool text_save_begin_inplace(TextSave *ctx) {
*/
size_t size = txt->block->size;
char tmpname[32] = "/tmp/vis-XXXXXX";
mode_t mask = umask(S_IXUSR | S_IRWXG | S_IRWXO);
newfd = mkstemp(tmpname);
umask(mask);
if (newfd == -1)
goto err;
if (unlink(tmpname) == -1)
Expand Down

0 comments on commit 80605f5

Please sign in to comment.