[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference turris::decc

Title:DECC
Notice:General DEC C discussions
Moderator:TLE::D_SMITHNTE
Created:Fri Nov 13 1992
Last Modified:Fri Jun 06 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:2212
Total number of notes:11045

2105.0. "Problem with 'open' and file's owner" by CPEEDY::OBRIEN () Tue Feb 25 1997 12:51

I'm having a problem with the "open" routine. The problem is
that the "open" routine is creating the file with an owner of
[0,0]. 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. Why isn't "open" getting the owner correct?


 open(filename, O_EXCL|O_CREAT|O_TRUNC|O_RDWR, 0, "shr=del,get,put,upd")

-Sean
T.RTitleUserPersonal
Name
DateLines
2105.1Things To Check...XDELTA::HOFFMANSteve, OpenVMS EngineeringTue Feb 25 1997 13:258
   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.)
2105.2cannot reproduce the problemTAVENG::BORISBoris Gubenko, ISETue Feb 25 1997 13:4056
  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");
}