Subject: Re: mkstemp(3)
To: Aymeric Vincent <xmimic@free.fr>
From: Greywolf <greywolf@starwolf.com>
List: tech-userlevel
Date: 06/20/2001 11:52:03
#         Hi,
# 
# mkstemp(3) creates temporary files with permissions 0600. That's what
# the manual page says.
# 
# However, a user with a 777 umask (or 600) will get his temp files
# created with permissions 000.

Yes, that's what a umask does.

# Vi (the editor) is having trouble with that as it expects the file to
# be read/writable. OpenBSD have ``fixed'' vi to fchmod 0600 the file.

s/``fixed''/broken/

# The question for this list is:
# 
# - is it acceptable to have mkstemp(3) ensure that the created file is
#   0600 (as the manual page claims somehow)?

No.  All creat()/open(path, mode, O_CREAT|O_TRUNC|O_EXCL) and mkdir() calls
are affected by the user's umask [O_EXCL included because CREAT semantics
do not happen on an already existing file].

# - otherwise, could we point users to the fact that mkstemp, using
#   open(2), is subject to umask(2) behaviour?

This would be a good idea.

# As for vi, I intend to fail properly if the temp file is not
# read/writable. People with such umask's wouldn't want to run vi. ;-)

Most likely.

#  Aymeric



				--*greywolf;
--
NetBSD: A drinking group with a serious computing problem.