#include "includes.h"
#include "smbd/globals.h"
+#include "librpc/gen_ndr/messaging.h"
+#include "../librpc/gen_ndr/ndr_security.h"
extern const struct generic_mapping file_generic_mapping;
struct deferred_open_record {
- bool delayed_for_oplocks;
- struct file_id id;
+ bool delayed_for_oplocks;
+ struct file_id id;
};
static NTSTATUS create_file_unixpath(connection_struct *conn,
{
*access_granted = 0;
- if (conn->server_info->utok.uid == 0 || conn->admin_user) {
+ if (get_current_uid(conn) == (uid_t)0) {
/* I'm sorry sir, I didn't know you were root... */
*access_granted = access_desired;
if (access_desired & SEC_FLAG_MAXIMUM_ALLOWED) {
struct security_descriptor *sd = NULL;
status = SMB_VFS_GET_NT_ACL(conn, smb_fname->base_name,
- (OWNER_SECURITY_INFORMATION |
- GROUP_SECURITY_INFORMATION |
- DACL_SECURITY_INFORMATION),&sd);
+ (SECINFO_OWNER |
+ SECINFO_GROUP |
+ SECINFO_DACL),&sd);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(10, ("smbd_check_open_rights: Could not get acl "
fsp->can_write = (access_mask & (FILE_WRITE_DATA | FILE_APPEND_DATA)) ?
True : False;
}
- fsp->print_file = False;
+ fsp->print_file = NULL;
fsp->modified = False;
fsp->sent_oplock_break = NO_BREAK_SENT;
fsp->is_directory = False;
static NTSTATUS send_break_message(files_struct *fsp,
struct share_mode_entry *exclusive,
- uint16 mid,
+ uint64_t mid,
int oplock_request)
{
NTSTATUS status;
don't want this set in the share mode struct pointed to by lck. */
if (oplock_request & FORCE_OPLOCK_BREAK_TO_NONE) {
- SSVAL(msg,6,exclusive->op_type | FORCE_OPLOCK_BREAK_TO_NONE);
+ SSVAL(msg,OP_BREAK_MSG_OP_TYPE_OFFSET,
+ exclusive->op_type | FORCE_OPLOCK_BREAK_TO_NONE);
}
status = messaging_send_buf(smbd_messaging_context(), exclusive->pid,
static bool delay_for_oplocks(struct share_mode_lock *lck,
files_struct *fsp,
- uint16 mid,
+ uint64_t mid,
int pass_number,
int oplock_request)
{
if (procid_is_me(&e->pid) && (e->op_mid == req->mid)) {
DEBUG(0, ("Trying to defer an already deferred "
- "request: mid=%d, exiting\n", req->mid));
+ "request: mid=%llu, exiting\n",
+ (unsigned long long)req->mid));
exit_server("attempt to defer a deferred request");
}
}
/* End paranoia check */
DEBUG(10,("defer_open_sharing_error: time [%u.%06u] adding deferred "
- "open entry for mid %u\n",
+ "open entry for mid %llu\n",
(unsigned int)request_time.tv_sec,
(unsigned int)request_time.tv_usec,
- (unsigned int)req->mid));
+ (unsigned long long)req->mid));
- if (!push_deferred_smb_message(req, request_time, timeout,
- (char *)state, sizeof(*state))) {
- exit_server("push_deferred_smb_message failed");
+ if (!push_deferred_open_message_smb(req, request_time, timeout,
+ state->id, (char *)state, sizeof(*state))) {
+ exit_server("push_deferred_open_message_smb failed");
}
add_deferred_open(lck, req->mid, request_time, state->id);
}
uint32_t access_granted = 0;
status = SMB_VFS_GET_NT_ACL(conn, smb_fname->base_name,
- (OWNER_SECURITY_INFORMATION |
- GROUP_SECURITY_INFORMATION |
- DACL_SECURITY_INFORMATION),&sd);
+ (SECINFO_OWNER |
+ SECINFO_GROUP |
+ SECINFO_DACL),&sd);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(10, ("calculate_access_mask: Could not get acl "
return NT_STATUS_OK;
}
+/****************************************************************************
+ Remove the deferred open entry under lock.
+****************************************************************************/
+
+void remove_deferred_open_entry(struct file_id id, uint64_t mid)
+{
+ struct share_mode_lock *lck = get_share_mode_lock(talloc_tos(), id,
+ NULL, NULL, NULL);
+ if (lck == NULL) {
+ DEBUG(0, ("could not get share mode lock\n"));
+ } else {
+ del_deferred_open_entry(lck, mid);
+ TALLOC_FREE(lck);
+ }
+}
+
/****************************************************************************
Open a file with a share mode. Passed in an already created files_struct *.
****************************************************************************/
mode_t unx_mode = (mode_t)0;
int info;
uint32 existing_dos_attributes = 0;
- struct pending_message_list *pml = NULL;
struct timeval request_time = timeval_zero();
struct share_mode_lock *lck = NULL;
uint32 open_access_mask = access_mask;
* Only non-internal opens can be deferred at all
*/
- if ((req != NULL)
- && ((pml = get_open_deferred_message(req->mid)) != NULL)) {
- struct deferred_open_record *state =
- (struct deferred_open_record *)pml->private_data.data;
+ if (req) {
+ void *ptr;
+ if (get_deferred_open_message_state(req,
+ &request_time,
+ &ptr)) {
- /* Remember the absolute time of the original
- request with this mid. We'll use it later to
- see if this has timed out. */
+ struct deferred_open_record *state = (struct deferred_open_record *)ptr;
+ /* Remember the absolute time of the original
+ request with this mid. We'll use it later to
+ see if this has timed out. */
- request_time = pml->request_time;
+ /* Remove the deferred open entry under lock. */
+ remove_deferred_open_entry(state->id, req->mid);
- /* Remove the deferred open entry under lock. */
- lck = get_share_mode_lock(talloc_tos(), state->id, NULL, NULL,
- NULL);
- if (lck == NULL) {
- DEBUG(0, ("could not get share mode lock\n"));
- } else {
- del_deferred_open_entry(lck, req->mid);
- TALLOC_FREE(lck);
+ /* Ensure we don't reprocess this message. */
+ remove_deferred_open_message_smb(req->mid);
}
-
- /* Ensure we don't reprocess this message. */
- remove_deferred_open_smb_message(req->mid);
}
status = check_name(conn, smb_fname->base_name);
}
/* ignore any oplock requests if oplocks are disabled */
- if (!lp_oplocks(SNUM(conn)) || global_client_failed_oplock_break ||
+ if (!lp_oplocks(SNUM(conn)) ||
IS_VETO_OPLOCK_PATH(conn, smb_fname->base_name)) {
/* Mask off everything except the private Samba bits. */
oplock_request &= SAMBA_PRIVATE_OPLOCK_MASK;
new_file_created = True;
}
- set_share_mode(lck, fsp, conn->server_info->utok.uid, 0,
+ set_share_mode(lck, fsp, get_current_uid(conn), 0,
fsp->oplock_type);
/* Handle strange delete on close create semantics. */
* According to Samba4, SEC_FILE_READ_ATTRIBUTE is always granted,
*/
fsp->access_mask = access_mask | FILE_READ_ATTRIBUTES;
- fsp->print_file = False;
+ fsp->print_file = NULL;
fsp->modified = False;
fsp->oplock_type = NO_OPLOCK;
fsp->sent_oplock_break = NO_BREAK_SENT;
return status;
}
- set_share_mode(lck, fsp, conn->server_info->utok.uid, 0, NO_OPLOCK);
+ set_share_mode(lck, fsp, get_current_uid(conn), 0, NO_OPLOCK);
/* For directories the delete on close bit at open time seems
always to be honored on close... See test 19 in Samba4 BASE-DELETE. */
security_acl_map_generic(sd->dacl, &file_generic_mapping);
security_acl_map_generic(sd->sacl, &file_generic_mapping);
- if (sec_info_sent & (OWNER_SECURITY_INFORMATION|
- GROUP_SECURITY_INFORMATION|
- DACL_SECURITY_INFORMATION|
- SACL_SECURITY_INFORMATION)) {
+ if (sec_info_sent & (SECINFO_OWNER|
+ SECINFO_GROUP|
+ SECINFO_DACL|
+ SECINFO_SACL)) {
status = SMB_VFS_FSET_NT_ACL(fsp, sec_info_sent, sd);
}
int info = FILE_WAS_OPENED;
files_struct *fsp = NULL;
NTSTATUS status;
+ bool stream_name = false;
DEBUG(10,("create_file: access_mask = 0x%x "
"file_attributes = 0x%x, share_access = 0x%x, "
* Check to see if this is a mac fork of some kind.
*/
- if (is_ntfs_stream_smb_fname(smb_fname)) {
+ stream_name = is_ntfs_stream_smb_fname(smb_fname);
+ if (stream_name) {
enum FAKE_FILE_TYPE fake_file_type;
fake_file_type = is_fake_file(smb_fname);
goto fail;
}
+ if (stream_name && is_ntfs_default_stream_smb_fname(smb_fname)) {
+ int ret;
+ smb_fname->stream_name = NULL;
+ /* We have to handle this error here. */
+ if (create_options & FILE_DIRECTORY_FILE) {
+ status = NT_STATUS_NOT_A_DIRECTORY;
+ goto fail;
+ }
+ if (lp_posix_pathnames()) {
+ ret = SMB_VFS_LSTAT(conn, smb_fname);
+ } else {
+ ret = SMB_VFS_STAT(conn, smb_fname);
+ }
+
+ if (ret == 0 && VALID_STAT_OF_DIR(smb_fname->st)) {
+ status = NT_STATUS_FILE_IS_A_DIRECTORY;
+ goto fail;
+ }
+ }
+
status = create_file_unixpath(
conn, req, smb_fname, access_mask, share_access,
create_disposition, create_options, file_attributes,