notifyd: Use messaging_register for MSG_SMB_NOTIFY_GET_DB
[vlendec/samba-autobuild/.git] / source3 / smbd / dosmode.c
index ef880e5100571ff280006437205de46915a3efd9..0ee6894785169a8ba72dca77eb475a36066ae0ad 100644 (file)
@@ -278,7 +278,7 @@ NTSTATUS get_ea_dos_attribute(connection_struct *conn,
        /* Don't reset pattr to zero as we may already have filename-based attributes we
           need to preserve. */
 
-       sizeret = SMB_VFS_GETXATTR(conn, smb_fname->base_name,
+       sizeret = SMB_VFS_GETXATTR(conn, smb_fname,
                                   SAMBA_XATTR_DOS_ATTRIB, attrstr,
                                   sizeof(attrstr));
        if (sizeret == -1) {
@@ -384,6 +384,12 @@ NTSTATUS set_ea_dos_attribute(connection_struct *conn,
                return NT_STATUS_NOT_IMPLEMENTED;
        }
 
+       /*
+        * Don't store FILE_ATTRIBUTE_OFFLINE, it's dealt with in
+        * vfs_default via DMAPI if that is enabled.
+        */
+       dosmode &= ~FILE_ATTRIBUTE_OFFLINE;
+
        ZERO_STRUCT(dosattrib);
        ZERO_STRUCT(blob);
 
@@ -414,7 +420,7 @@ NTSTATUS set_ea_dos_attribute(connection_struct *conn,
                return NT_STATUS_INVALID_PARAMETER;
        }
 
-       if (SMB_VFS_SETXATTR(conn, smb_fname->base_name,
+       if (SMB_VFS_SETXATTR(conn, smb_fname,
                             SAMBA_XATTR_DOS_ATTRIB, blob.data, blob.length,
                             0) == -1) {
                NTSTATUS status = NT_STATUS_OK;
@@ -605,7 +611,6 @@ static uint32_t dos_mode_from_name(connection_struct *conn,
 uint32_t dos_mode(connection_struct *conn, struct smb_filename *smb_fname)
 {
        uint32_t result = 0;
-       bool offline;
        NTSTATUS status = NT_STATUS_OK;
 
        DEBUG(8,("dos_mode: %s\n", smb_fname_str_dbg(smb_fname)));
@@ -620,11 +625,6 @@ uint32_t dos_mode(connection_struct *conn, struct smb_filename *smb_fname)
                result |= dos_mode_from_sbuf(conn, smb_fname);
        }
 
-       offline = SMB_VFS_IS_OFFLINE(conn, smb_fname, &smb_fname->st);
-       if (S_ISREG(smb_fname->st.st_ex_mode) && offline) {
-               result |= FILE_ATTRIBUTE_OFFLINE;
-       }
-
        if (conn->fs_capabilities & FILE_FILE_COMPRESSION) {
                bool compressed = false;
                status = dos_mode_check_compressed(conn, smb_fname,
@@ -636,7 +636,9 @@ uint32_t dos_mode(connection_struct *conn, struct smb_filename *smb_fname)
 
        result |= dos_mode_from_name(conn, smb_fname, result);
 
-       if (result == 0) {
+       if (S_ISDIR(smb_fname->st.st_ex_mode)) {
+               result |= FILE_ATTRIBUTE_DIRECTORY;
+       } else if (result == 0) {
                result = FILE_ATTRIBUTE_NORMAL;
        }
 
@@ -661,8 +663,6 @@ int file_set_dosmode(connection_struct *conn, struct smb_filename *smb_fname,
        mode_t tmp;
        mode_t unixmode;
        int ret = -1, lret = -1;
-       uint32_t old_mode;
-       struct timespec new_create_timespec;
        files_struct *fsp = NULL;
        bool need_close = false;
        NTSTATUS status;
@@ -672,50 +672,21 @@ int file_set_dosmode(connection_struct *conn, struct smb_filename *smb_fname,
                return -1;
        }
 
-       /* We only allow READONLY|HIDDEN|SYSTEM|DIRECTORY|ARCHIVE here. */
-       dosmode &= (SAMBA_ATTRIBUTES_MASK | FILE_ATTRIBUTE_OFFLINE);
+       dosmode &= SAMBA_ATTRIBUTES_MASK;
 
        DEBUG(10,("file_set_dosmode: setting dos mode 0x%x on file %s\n",
                  dosmode, smb_fname_str_dbg(smb_fname)));
 
        unixmode = smb_fname->st.st_ex_mode;
 
-       get_acl_group_bits(conn, smb_fname->base_name,
-                          &smb_fname->st.st_ex_mode);
+       get_acl_group_bits(conn, smb_fname,
+                       &smb_fname->st.st_ex_mode);
 
        if (S_ISDIR(smb_fname->st.st_ex_mode))
                dosmode |= FILE_ATTRIBUTE_DIRECTORY;
        else
                dosmode &= ~FILE_ATTRIBUTE_DIRECTORY;
 
-       new_create_timespec = smb_fname->st.st_ex_btime;
-
-       old_mode = dos_mode(conn, smb_fname);
-
-       if ((dosmode & FILE_ATTRIBUTE_OFFLINE) &&
-           !(old_mode & FILE_ATTRIBUTE_OFFLINE)) {
-               lret = SMB_VFS_SET_OFFLINE(conn, smb_fname);
-               if (lret == -1) {
-                       if (errno == ENOTSUP) {
-                               DEBUG(10, ("Setting FILE_ATTRIBUTE_OFFLINE for "
-                                          "%s/%s is not supported.\n",
-                                          parent_dir,
-                                          smb_fname_str_dbg(smb_fname)));
-                       } else {
-                               DEBUG(0, ("An error occurred while setting "
-                                         "FILE_ATTRIBUTE_OFFLINE for "
-                                         "%s/%s: %s", parent_dir,
-                                         smb_fname_str_dbg(smb_fname),
-                                         strerror(errno)));
-                       }
-               }
-       }
-
-       dosmode  &= ~FILE_ATTRIBUTE_OFFLINE;
-       old_mode &= ~FILE_ATTRIBUTE_OFFLINE;
-
-       smb_fname->st.st_ex_btime = new_create_timespec;
-
        /* Store the DOS attributes in an EA by preference. */
        status = SMB_VFS_SET_DOS_ATTRIBUTES(conn, smb_fname, dosmode);
        if (NT_STATUS_IS_OK(status)) {