uint32_t wire_mode_bits = 0;
mode_t mode_bits = 0;
SMB_STRUCT_STAT sbuf = { 0 };
- enum perm_type ptype =
- (create_options & FILE_DIRECTORY_FILE) ?
- PERM_NEW_DIR : PERM_NEW_FILE;
if (posx->data.length != 4) {
status = NT_STATUS_INVALID_PARAMETER;
}
wire_mode_bits = IVAL(posx->data.data, 0);
- status = unix_perms_from_wire(
- conn, &sbuf, wire_mode_bits, ptype, &mode_bits);
+ status = unix_perms_from_wire(conn,
+ &sbuf,
+ wire_mode_bits,
+ &mode_bits);
if (!NT_STATUS_IS_OK(status)) {
goto fail;
}
+ if (create_options & FILE_DIRECTORY_FILE) {
+ mode_bits = apply_conf_dir_mask(conn, mode_bits);
+ } else {
+ mode_bits = apply_conf_file_mask(conn, mode_bits);
+ }
/*
* Remove type info from mode, leaving only the
* permissions and setuid/gid bits.
raw_unixmode = IVAL(pdata,8);
/* Next 4 bytes are not yet defined. */
- status = unix_perms_from_wire(conn, &smb_fname->st, raw_unixmode,
- PERM_NEW_DIR, &unixmode);
+ status = unix_perms_from_wire(conn,
+ &smb_fname->st,
+ raw_unixmode,
+ &unixmode);
if (!NT_STATUS_IS_OK(status)) {
return status;
}
+ unixmode = apply_conf_dir_mask(conn, unixmode);
status = make_smb2_posix_create_ctx(talloc_tos(), &posx, unixmode);
if (!NT_STATUS_IS_OK(status)) {
raw_unixmode = IVAL(pdata,8);
/* Next 4 bytes are not yet defined. */
- status = unix_perms_from_wire(conn, &smb_fname->st, raw_unixmode,
- (VALID_STAT(smb_fname->st) ?
- PERM_EXISTING_FILE : PERM_NEW_FILE),
+ status = unix_perms_from_wire(conn,
+ &smb_fname->st,
+ raw_unixmode,
&unixmode);
if (!NT_STATUS_IS_OK(status)) {
return status;
}
+ if (!VALID_STAT(smb_fname->st)) {
+ unixmode = apply_conf_dir_mask(conn, unixmode);
+ }
status = make_smb2_posix_create_ctx(talloc_tos(), &posx, unixmode);
if (!NT_STATUS_IS_OK(status)) {
return NT_STATUS_INVALID_PARAMETER;
}
- status = unix_perms_from_wire(conn, &smb_fname->st, raw_unixmode,
- PERM_NEW_FILE, &unixmode);
+ status = unix_perms_from_wire(conn,
+ &smb_fname->st,
+ raw_unixmode,
+ &unixmode);
if (!NT_STATUS_IS_OK(status)) {
return status;
}
+ unixmode = apply_conf_file_mask(conn, unixmode);
#if defined(HAVE_MAKEDEV)
dev = makedev(dev_major, dev_minor);
uid_t set_owner = (uid_t)SMB_UID_NO_CHANGE;
gid_t set_grp = (uid_t)SMB_GID_NO_CHANGE;
NTSTATUS status = NT_STATUS_OK;
- enum perm_type ptype;
files_struct *all_fsps = NULL;
bool modify_mtime = true;
struct file_id id;
set_grp = (gid_t)IVAL(pdata,48);
raw_unixmode = IVAL(pdata,84);
- if (VALID_STAT(smb_fname->st)) {
- if (S_ISDIR(smb_fname->st.st_ex_mode)) {
- ptype = PERM_EXISTING_DIR;
- } else {
- ptype = PERM_EXISTING_FILE;
- }
- } else {
- ptype = PERM_NEW_FILE;
- }
-
- status = unix_perms_from_wire(conn, &smb_fname->st, raw_unixmode,
- ptype, &unixmode);
+ status = unix_perms_from_wire(conn,
+ &smb_fname->st,
+ raw_unixmode,
+ &unixmode);
if (!NT_STATUS_IS_OK(status)) {
return status;
}
+ if (!VALID_STAT(smb_fname->st)) {
+ unixmode = apply_conf_file_mask(conn, unixmode);
+ }
DBG_DEBUG("SMB_SET_FILE_UNIX_BASIC: name = "
"%s size = %.0f, uid = %u, gid = %u, raw perms = 0%o\n",
NTSTATUS unix_perms_from_wire(connection_struct *conn,
const SMB_STRUCT_STAT *psbuf,
uint32_t perms,
- enum perm_type ptype,
mode_t *ret_perms)
{
mode_t ret = 0;
ret = wire_perms_to_unix(perms);
- if (ptype == PERM_NEW_FILE) {
- /*
- * "create mask"/"force create mode" are
- * only applied to new files, not existing ones.
- */
- ret = apply_conf_file_mask(conn, ret);
- } else if (ptype == PERM_NEW_DIR) {
- /*
- * "directory mask"/"force directory mode" are
- * only applied to new directories, not existing ones.
- */
- ret = apply_conf_dir_mask(conn, ret);
- }
-
*ret_perms = ret;
return NT_STATUS_OK;
}