r3154: pvfs now passes all of BASE-DELETE
authorAndrew Tridgell <tridge@samba.org>
Sun, 24 Oct 2004 12:53:13 +0000 (12:53 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:02:26 +0000 (13:02 -0500)
(This used to be commit abbfca1401818edd896493ab9c875224e3b7e0e7)

source4/ntvfs/posix/pvfs_open.c

index 7c1e1645759745d8844f4f09f990eba7aaccaa6d..95990f63323beadc06b936b5ba5cfc2eace56341 100644 (file)
@@ -266,6 +266,12 @@ static NTSTATUS pvfs_create_file(struct pvfs_state *pvfs,
        uint32_t create_options = io->generic.in.create_options;
        uint32_t share_access = io->generic.in.share_access;
        uint32_t access_mask = io->generic.in.access_mask;
+       mode_t mode;
+
+       if ((io->ntcreatex.in.file_attr & FILE_ATTRIBUTE_READONLY) &&
+           (create_options & NTCREATEX_OPTIONS_DELETE_ON_CLOSE)) {
+               return NT_STATUS_CANNOT_DELETE;
+       }
        
        flags = O_RDWR;
 
@@ -279,8 +285,14 @@ static NTSTATUS pvfs_create_file(struct pvfs_state *pvfs,
                return NT_STATUS_TOO_MANY_OPENED_FILES;
        }
 
+       if (io->ntcreatex.in.file_attr & FILE_ATTRIBUTE_READONLY) {
+               mode = 0444;
+       } else {
+               mode = 0644;
+       }
+
        /* create the file */
-       fd = open(name->full_name, flags | O_CREAT | O_EXCL, 0644);
+       fd = open(name->full_name, flags | O_CREAT | O_EXCL, mode);
        if (fd == -1) {
                idr_remove(pvfs->idtree_fnum, fnum);
                return pvfs_map_errno(pvfs, errno);
@@ -407,7 +419,7 @@ NTSTATUS pvfs_open(struct ntvfs_module_context *ntvfs,
 
        /* certain create options are not allowed */
        if ((create_options & NTCREATEX_OPTIONS_DELETE_ON_CLOSE) &&
-           !(share_access & NTCREATEX_SHARE_ACCESS_DELETE)) {
+           !(access_mask & STD_RIGHT_DELETE_ACCESS)) {
                return NT_STATUS_INVALID_PARAMETER;
        }
 
@@ -475,6 +487,11 @@ NTSTATUS pvfs_open(struct ntvfs_module_context *ntvfs,
                /* fall through to a normal open */
        }
 
+       if ((name->dos.attrib & FILE_ATTRIBUTE_READONLY) &&
+           (create_options & NTCREATEX_OPTIONS_DELETE_ON_CLOSE)) {
+               return NT_STATUS_CANNOT_DELETE;
+       }
+
        f = talloc_p(req, struct pvfs_file);
        if (f == NULL) {
                return NT_STATUS_NO_MEMORY;
@@ -655,6 +672,11 @@ NTSTATUS pvfs_change_create_options(struct pvfs_state *pvfs,
                return NT_STATUS_OK;
        }
 
+       if ((f->name->dos.attrib & FILE_ATTRIBUTE_READONLY) &&
+           (create_options & NTCREATEX_OPTIONS_DELETE_ON_CLOSE)) {
+               return NT_STATUS_CANNOT_DELETE;
+       }
+
        lck = odb_lock(req, pvfs->odb_context, &f->locking_key);
        if (lck == NULL) {
                return NT_STATUS_INTERNAL_DB_CORRUPTION;