static const char * const prohibited_ea_names[] = {
SAMBA_POSIX_INHERITANCE_EA_NAME,
SAMBA_XATTR_DOS_ATTRIB,
- SAMBA_XATTR_DOSTIMESTAMPS,
SAMBA_XATTR_MARKER,
+ XATTR_NTACL_NAME,
NULL
};
pname = ¶ms[28];
if (IS_IPC(conn)) {
- reply_doserror(req, ERRSRV, ERRaccess);
+ reply_nterror(req, NT_STATUS_NETWORK_ACCESS_DENIED);
goto out;
}
&access_mask, &share_mode,
&create_disposition,
&create_options)) {
- reply_doserror(req, ERRDOS, ERRbadaccess);
+ reply_nterror(req, NT_STATUS_ACCESS_DENIED);
goto out;
}
inode = smb_fname->st.st_ex_ino;
if (fattr & aDIR) {
close_file(req, fsp, ERROR_CLOSE);
- reply_doserror(req, ERRDOS,ERRnoaccess);
+ reply_nterror(req, NT_STATUS_ACCESS_DENIED);
goto out;
}
char *nameptr;
char *last_entry_ptr;
bool was_8_3;
- uint32_t nt_extmode; /* Used for NT connections instead of mode */
off_t off;
off_t pad = 0;
pad = 0;
off = 0;
- nt_extmode = mode ? mode : FILE_ATTRIBUTE_NORMAL;
-
switch (info_level) {
case SMB_FIND_INFO_STANDARD:
DEBUG(10,("smbd_marshall_dir_entry: SMB_FIND_INFO_STANDARD\n"));
put_long_date_timespec(conn->ts_res,p,cdate_ts); p += 8;
SOFF_T(p,0,file_size); p += 8;
SOFF_T(p,0,allocation_size); p += 8;
- SIVAL(p,0,nt_extmode); p += 4;
+ SIVAL(p,0,mode); p += 4;
q = p; p += 4; /* q is placeholder for name length. */
{
unsigned int ea_size = estimate_ea_size(conn, NULL,
put_long_date_timespec(conn->ts_res,p,cdate_ts); p += 8;
SOFF_T(p,0,file_size); p += 8;
SOFF_T(p,0,allocation_size); p += 8;
- SIVAL(p,0,nt_extmode); p += 4;
+ SIVAL(p,0,mode); p += 4;
len = srvstr_push(base_data, flags2,
p + 4, fname, PTR_DIFF(end_data, p+4),
STR_TERMINATE_ASCII);
put_long_date_timespec(conn->ts_res,p,cdate_ts); p += 8;
SOFF_T(p,0,file_size); p += 8;
SOFF_T(p,0,allocation_size); p += 8;
- SIVAL(p,0,nt_extmode); p += 4;
+ SIVAL(p,0,mode); p += 4;
q = p; p += 4; /* q is placeholder for name length. */
{
unsigned int ea_size = estimate_ea_size(conn, NULL,
put_long_date_timespec(conn->ts_res,p,cdate_ts); p += 8;
SOFF_T(p,0,file_size); p += 8;
SOFF_T(p,0,allocation_size); p += 8;
- SIVAL(p,0,nt_extmode); p += 4;
+ SIVAL(p,0,mode); p += 4;
q = p; p += 4; /* q is placeholder for name length. */
{
unsigned int ea_size = estimate_ea_size(conn, NULL,
put_long_date_timespec(conn->ts_res,p,cdate_ts); p += 8;
SOFF_T(p,0,file_size); p += 8;
SOFF_T(p,0,allocation_size); p += 8;
- SIVAL(p,0,nt_extmode); p += 4;
+ SIVAL(p,0,mode); p += 4;
q = p; p += 4; /* q is placeholder for name length */
{
unsigned int ea_size = estimate_ea_size(conn, NULL,
}
if (!lp_ea_support(SNUM(conn))) {
- reply_doserror(req, ERRDOS, ERReasnotsupported);
+ reply_nterror(req, NT_STATUS_EAS_NOT_SUPPORTED);
goto out;
}
if(numentries == 0) {
dptr_close(sconn, &dptr_num);
if (get_Protocol() < PROTOCOL_NT1) {
- reply_doserror(req, ERRDOS, ERRnofiles);
+ reply_force_doserror(req, ERRDOS, ERRnofiles);
goto out;
} else {
reply_botherror(req, NT_STATUS_NO_SUCH_FILE,
}
if (!lp_ea_support(SNUM(conn))) {
- reply_doserror(req, ERRDOS, ERReasnotsupported);
+ reply_nterror(req, NT_STATUS_EAS_NOT_SUPPORTED);
return;
}
/* Check that the dptr is valid */
if(!(dirptr = dptr_fetch_lanman2(sconn, dptr_num))) {
- reply_doserror(req, ERRDOS, ERRnofiles);
+ reply_nterror(req, STATUS_NO_MORE_FILES);
return;
}
/* Get the wildcard mask from the dptr */
if((p = dptr_wcard(sconn, dptr_num))== NULL) {
DEBUG(2,("dptr_num %d has no wildcard\n", dptr_num));
- reply_doserror(req, ERRDOS, ERRnofiles);
+ reply_nterror(req, STATUS_NO_MORE_FILES);
return;
}
} else {
mode = dos_mode(conn, smb_fname);
}
- if (!mode)
- mode = FILE_ATTRIBUTE_NORMAL;
nlink = psbuf->st_ex_nlink;
}
if (!lp_ea_support(SNUM(conn))) {
- reply_doserror(req, ERRDOS,
- ERReasnotsupported);
+ reply_nterror(req, NT_STATUS_EAS_NOT_SUPPORTED);
return;
}
files_struct *fsp,
const struct smb_filename *smb_fname,
const SMB_STRUCT_STAT *psbuf,
- SMB_OFF_T size)
+ SMB_OFF_T size,
+ bool fail_after_createfile)
{
NTSTATUS status = NT_STATUS_OK;
struct smb_filename *smb_fname_tmp = NULL;
req, /* req */
0, /* root_dir_fid */
smb_fname_tmp, /* fname */
- FILE_WRITE_ATTRIBUTES, /* access_mask */
+ FILE_WRITE_DATA, /* access_mask */
(FILE_SHARE_READ | FILE_SHARE_WRITE | /* share_access */
FILE_SHARE_DELETE),
FILE_OPEN, /* create_disposition*/
return status;
}
+ /* See RAW-SFILEINFO-END-OF-FILE */
+ if (fail_after_createfile) {
+ close_file(req, new_fsp,NORMAL_CLOSE);
+ return NT_STATUS_INVALID_LEVEL;
+ }
+
if (vfs_set_filelen(new_fsp, size) == -1) {
status = map_nt_error_from_unix(errno);
close_file(req, new_fsp,NORMAL_CLOSE);
(unsigned int)dosmode,
(unsigned int)delete_on_close ));
- status = can_set_delete_on_close(fsp, delete_on_close, dosmode);
-
- if (!NT_STATUS_IS_OK(status)) {
- return status;
+ if (delete_on_close) {
+ status = can_set_delete_on_close(fsp, dosmode);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
+ }
}
/* The set is across all open files on this dev/inode pair. */
return NT_STATUS_INVALID_PARAMETER;
}
- /* !widelinks forces the target path to be within the share. */
- /* This means we can interpret the target as a pathname. */
- if (!lp_widelinks(SNUM(conn))) {
- char *rel_name = NULL;
- char *last_dirp = NULL;
-
- if (*link_target == '/') {
- /* No absolute paths allowed. */
- return NT_STATUS_ACCESS_DENIED;
- }
- rel_name = talloc_strdup(ctx,newname);
- if (!rel_name) {
- return NT_STATUS_NO_MEMORY;
- }
- last_dirp = strrchr_m(rel_name, '/');
- if (last_dirp) {
- last_dirp[1] = '\0';
- } else {
- rel_name = talloc_strdup(ctx,"./");
- if (!rel_name) {
- return NT_STATUS_NO_MEMORY;
- }
- }
- rel_name = talloc_asprintf_append(rel_name,
- "%s",
- link_target);
- if (!rel_name) {
- return NT_STATUS_NO_MEMORY;
- }
-
- status = check_name(conn, rel_name);
- if (!NT_STATUS_IS_OK(status)) {
- return status;
- }
- }
-
DEBUG(10,("smb_set_file_unix_link: SMB_SET_FILE_UNIX_LINK doing symlink %s -> %s\n",
newname, link_target ));
const char *pdata,
int total_data,
files_struct *fsp,
- const struct smb_filename *smb_fname)
+ const struct smb_filename *smb_fname,
+ bool fail_after_createfile)
{
SMB_OFF_T size;
fsp,
smb_fname,
&smb_fname->st,
- size);
+ size,
+ fail_after_createfile);
}
/****************************************************************************
fsp,
smb_fname,
&sbuf,
- size);
+ size,
+ false);
if (!NT_STATUS_IS_OK(status)) {
return status;
}
case SMB_FILE_END_OF_FILE_INFORMATION:
case SMB_SET_FILE_END_OF_FILE_INFO:
{
+ /*
+ * XP/Win7 both fail after the createfile with
+ * SMB_SET_FILE_END_OF_FILE_INFO but not
+ * SMB_FILE_END_OF_FILE_INFORMATION (pass-through).
+ * The level is known here, so pass it down
+ * appropriately.
+ */
+ bool should_fail =
+ (info_level == SMB_SET_FILE_END_OF_FILE_INFO);
+
status = smb_set_file_end_of_file_info(conn, req,
pdata,
total_data,
fsp,
- smb_fname);
+ smb_fname,
+ should_fail);
break;
}
max_data_bytes);
return;
} else {
- reply_doserror(req, ERRDOS, ERRbadpath);
+ reply_nterror(req,
+ NT_STATUS_OBJECT_PATH_NOT_FOUND);
return;
}
} else {
TALLOC_CTX *ctx = talloc_tos();
if (!CAN_WRITE(conn)) {
- reply_doserror(req, ERRSRV, ERRaccess);
+ reply_nterror(req, NT_STATUS_ACCESS_DENIED);
return;
}
max_referral_level = SVAL(params,0);
if(!lp_host_msdfs()) {
- reply_doserror(req, ERRDOS, ERRbadfunc);
+ reply_nterror(req, NT_STATUS_NOT_IMPLEMENTED);
return;
}
/* check for an invalid fid before proceeding */
if (!fsp) {
- reply_doserror(req, ERRDOS, ERRbadfid);
+ reply_nterror(req, NT_STATUS_INVALID_HANDLE);
return;
}
}
DEBUG(2,("Unknown TRANS2_IOCTL\n"));
- reply_doserror(req, ERRSRV, ERRerror);
+ reply_nterror(req, NT_STATUS_NOT_IMPLEMENTED);
}
/****************************************************************************
default:
/* Error in request */
DEBUG(2,("Unknown request %d in trans2 call\n", state->call));
- reply_doserror(req, ERRSRV,ERRerror);
+ reply_nterror(req, NT_STATUS_NOT_IMPLEMENTED);
}
}
case TRANSACT2_SETFSINFO:
break;
default:
- reply_doserror(req, ERRSRV, ERRaccess);
+ reply_nterror(req, NT_STATUS_ACCESS_DENIED);
END_PROFILE(SMBtrans2);
return;
}