r23697: use the file perm options in the posix backend
authorAndrew Tridgell <tridge@samba.org>
Wed, 4 Jul 2007 04:16:16 +0000 (04:16 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 19:59:03 +0000 (14:59 -0500)
source/ntvfs/posix/pvfs_fileinfo.c
source/ntvfs/posix/vfs_posix.c
source/ntvfs/posix/vfs_posix.h

index 8226b66d1f28b0b2ed67cd539eb536419b5f0446..b244019d5611564c9417e24d4d993d3e643e8b42 100644 (file)
@@ -88,15 +88,11 @@ NTSTATUS pvfs_fill_dos_info(struct pvfs_state *pvfs, struct pvfs_filename *name,
 */
 mode_t pvfs_fileperms(struct pvfs_state *pvfs, uint32_t attrib)
 {
-       mode_t mode = S_IRUSR;
+       mode_t mode = (S_IRUSR | S_IRGRP | S_IROTH | S_IWUSR | S_IWGRP | S_IWOTH);
 
-       if (attrib & FILE_ATTRIBUTE_DIRECTORY) {
-               mode |= S_IXUSR;
-       }
-
-       if (!(attrib & FILE_ATTRIBUTE_READONLY) ||
-           (pvfs->flags & PVFS_FLAG_XATTR_ENABLE)) {
-               mode |= S_IWUSR;
+       if (!(pvfs->flags & PVFS_FLAG_XATTR_ENABLE) &&
+           (attrib & FILE_ATTRIBUTE_READONLY)) {
+               mode &= ~(S_IWUSR | S_IWGRP | S_IWOTH);
        }
 
        if (!(pvfs->flags & PVFS_FLAG_XATTR_ENABLE)) {
@@ -104,18 +100,27 @@ mode_t pvfs_fileperms(struct pvfs_state *pvfs, uint32_t attrib)
                    (pvfs->flags & PVFS_FLAG_MAP_ARCHIVE)) {
                        mode |= S_IXUSR;
                }
-               
                if ((attrib & FILE_ATTRIBUTE_SYSTEM) &&
                    (pvfs->flags & PVFS_FLAG_MAP_SYSTEM)) {
                        mode |= S_IXGRP;
                }
-               
                if ((attrib & FILE_ATTRIBUTE_HIDDEN) &&
                    (pvfs->flags & PVFS_FLAG_MAP_HIDDEN)) {
                        mode |= S_IXOTH;
                }
        }
 
+       if (attrib & FILE_ATTRIBUTE_DIRECTORY) {
+               mode |= (S_IFDIR | S_IWUSR);
+               mode |= (S_IXUSR | S_IXGRP | S_IXOTH);                 
+               mode &= pvfs->options.dir_mask;
+               mode |= pvfs->options.force_dir_mode;
+       } else {
+               mode &= pvfs->options.create_mask;
+               mode |= pvfs->options.force_create_mode;
+       }
+
        return mode;
 }
 
+
index c8d85b557c00634812368925d1c03a82cae55e5c..2508496fac218dff85cabf1243fe20458fd6bc73 100644 (file)
@@ -60,6 +60,19 @@ static void pvfs_setup_options(struct pvfs_state *pvfs)
        if (share_bool_option(scfg, PVFS_AIO, False))
                pvfs->flags |= PVFS_FLAG_LINUX_AIO;
 
+       /* file perm options */
+       pvfs->options.create_mask       = share_int_option(scfg,
+                                                          SHARE_CREATE_MASK,
+                                                          SHARE_CREATE_MASK_DEFAULT);
+       pvfs->options.dir_mask          = share_int_option(scfg,
+                                                          SHARE_DIR_MASK,
+                                                          SHARE_DIR_MASK_DEFAULT);
+       pvfs->options.force_dir_mode    = share_int_option(scfg,
+                                                          SHARE_FORCE_DIR_MODE,
+                                                          SHARE_FORCE_DIR_MODE_DEFAULT);
+       pvfs->options.force_create_mode = share_int_option(scfg,
+                                                          SHARE_FORCE_CREATE_MODE,
+                                                          SHARE_FORCE_CREATE_MODE_DEFAULT);
        /* this must be a power of 2 */
        pvfs->alloc_size_rounding = share_int_option(scfg,
                                                        PVFS_ALLOCATION_ROUNDING,
index cff0206f61e6cd765f2b31c3ddefee7946347228..78b63612da4adb8361baeeea0af9ab5afe800b8a 100644 (file)
@@ -86,6 +86,14 @@ struct pvfs_state {
 
        /* the acl backend */
        const struct pvfs_acl_ops *acl_ops;
+
+       /* non-flag share options */
+       struct {
+               mode_t dir_mask;
+               mode_t force_dir_mode;
+               mode_t create_mask;
+               mode_t force_create_mode;
+       } options;
 };
 
 /* this is the basic information needed about a file from the filesystem */