Xref: utzoo comp.unix.questions:6677 comp.unix.wizards:7975 comp.lang.c:9554 Path: utzoo!mnetor!uunet!lll-winken!lll-tis!ames!mailrus!tut.cis.ohio-state.edu!bloom-beacon!mcgill-vision!mouse From: mouse@mcgill-vision.UUCP (der Mouse) Newsgroups: comp.unix.questions,comp.unix.wizards,comp.lang.c Subject: Re: Writing to A NON-Existing File in "C" Message-ID: <1075@mcgill-vision.UUCP> Date: 23 Apr 88 08:08:34 GMT References: <9654@jplgodo.UUCP> <10285@steinmetz.steinmetz.ge.com> <147@obie.UUCP> Distribution: na Organization: McGill University, Montreal Lines: 16 Keywords: C program, NON-EXISTING File, flushed results In article <147@obie.UUCP>, wes@obie.UUCP (Barnacle Wes) writes: > I'd do it slightly different. Unless you need speed, try using > access(2) to determine if the file is available to you, and if not > open /dev/null for writing: [code which is supposed to do that - I didn't check it] This is wrong if the program might ever run setuid. access() does not exist to allow vanilla users to find out whether files are accessible; it's for setuid programs to determine whether the real user can access a file. (It's the wrong way to do even that, because of the resulting window, but that's another can of worms.) The right way to find out whether you can open a file for write is...try it! der Mouse uucp: mouse@mcgill-vision.uucp arpa: mouse@larry.mcrcim.mcgill.edu