|
Look at the ownership of any previous version of the created file,
look at the parent directory ownership, look for applicable access
control list entries on the parent directory or on previous file
versions, and look at the use of SYSPRV or BYPASS privileges --
there's a fairly involved discussion of ownership of created files
in the OpenVMS documentation set. (If you're not familiar with the
sequence, it's worth looking at it, as it's fairly involved.)
|
| You didn't mention the VMS version and whether you're linking against
DEC C or VAX C RTL.
> [...] If I create other files in the directory using an editor
> or the fopen routine, they get the owner of the directory,
> [SYSTEM], as owner.
With the DEC C RTL both open() and fopen() routines call the same auxiliary
internal CRTL routine, which does the real work.
Anyway, I cannot reproduce the problem on my OpenVMS Alpha V6.2.
Could you provide more info? A (small) reproducer would be greatly
appreciated.
From .-1:
> Look at the ownership of any previous version of the created file,
> look at the parent directory ownership, look for applicable access
The O_EXCL|O_CREAT|O_TRUNC flags must cause the open() to fail if the file
exists - see example below, but, actually, it looks like the file' ownership
was inherited from the previous version of the file (?).
Boris
$ say f$getsy("version")
V6.2-1H1
$ dir x.x
%DIRECT-W-NOFILES, no files found
$ run x
success
$ dir/owner x.x
Directory DISK:[DIRECTORY]
X.X;1 0/0 25-FEB-1997 20:17:21.66 [ALPHA,BORIS] (RWED,RWED,RWE,)
Total of 1 file, 0/0 blocks.
$ run x
open: file exists
$
X.C
===
#include <errno.h>
#include <fcntl.h>
#include <unixio.h>
#include <stdio.h>
main()
{
if (open("x.x",O_EXCL|O_CREAT|O_TRUNC|O_RDWR, 0, "shr=del,get,put,upd") == -1)
perror("open");
else puts("success");
}
|