From 9127e555ab043000adc516a9177e43812e52fd4b Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 23 Apr 2011 10:30:59 +0200 Subject: s3:smbd/trans2: make use of BVAL() and remove ugly LARGE_SMB_OFF_T ifdef's We rely on uint64_t for a long time now... metze --- source3/smbd/trans2.c | 30 ++---------------------------- 1 file changed, 2 insertions(+), 28 deletions(-) (limited to 'source3/smbd/trans2.c') diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c index 507ae9ba93..830504c657 100644 --- a/source3/smbd/trans2.c +++ b/source3/smbd/trans2.c @@ -3733,36 +3733,10 @@ cap_low = 0x%x, cap_high = 0x%x\n", /* unknown_1 24 NULL bytes in pdata*/ /* the soft quotas 8 bytes (uint64_t)*/ - quotas.softlim = (uint64_t)IVAL(pdata,24); -#ifdef LARGE_SMB_OFF_T - quotas.softlim |= (((uint64_t)IVAL(pdata,28)) << 32); -#else /* LARGE_SMB_OFF_T */ - if ((IVAL(pdata,28) != 0)&& - ((quotas.softlim != 0xFFFFFFFF)|| - (IVAL(pdata,28)!=0xFFFFFFFF))) { - /* more than 32 bits? */ - reply_nterror( - req, - NT_STATUS_INVALID_PARAMETER); - return; - } -#endif /* LARGE_SMB_OFF_T */ + quotas.softlim = BVAL(pdata,24); /* the hard quotas 8 bytes (uint64_t)*/ - quotas.hardlim = (uint64_t)IVAL(pdata,32); -#ifdef LARGE_SMB_OFF_T - quotas.hardlim |= (((uint64_t)IVAL(pdata,36)) << 32); -#else /* LARGE_SMB_OFF_T */ - if ((IVAL(pdata,36) != 0)&& - ((quotas.hardlim != 0xFFFFFFFF)|| - (IVAL(pdata,36)!=0xFFFFFFFF))) { - /* more than 32 bits? */ - reply_nterror( - req, - NT_STATUS_INVALID_PARAMETER); - return; - } -#endif /* LARGE_SMB_OFF_T */ + quotas.hardlim = BVAL(pdata,32); /* quota_flags 2 bytes **/ quotas.qflags = SVAL(pdata,40); -- cgit From 0eca33bbf620678759bbe39efaa74f33f96efb74 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Fri, 29 Apr 2011 11:57:02 +1000 Subject: s3-smb Use FILE_ATTRIBUTE_DIRECTORY intead of aDIR This means we use just one constant for this file attribute. Andrew Bartlett --- source3/smbd/trans2.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'source3/smbd/trans2.c') diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c index 830504c657..abab3879f6 100644 --- a/source3/smbd/trans2.c +++ b/source3/smbd/trans2.c @@ -1148,7 +1148,7 @@ static void call_trans2open(connection_struct *conn, fattr = dos_mode(conn, smb_fname); mtime = convert_timespec_to_time_t(smb_fname->st.st_ex_mtime); inode = smb_fname->st.st_ex_ino; - if (fattr & aDIR) { + if (fattr & FILE_ATTRIBUTE_DIRECTORY) { close_file(req, fsp, ERROR_CLOSE); reply_nterror(req, NT_STATUS_ACCESS_DENIED); goto out; @@ -1524,7 +1524,7 @@ static bool smbd_marshall_dir_entry(TALLOC_CTX *ctx, ZERO_STRUCT(create_date_ts); ZERO_STRUCT(cdate_ts); - if (!(mode & aDIR)) { + if (!(mode & FILE_ATTRIBUTE_DIRECTORY)) { file_size = get_file_size_stat(&smb_fname->st); } allocation_size = SMB_VFS_GET_ALLOC_SIZE(conn, NULL, &smb_fname->st); @@ -4227,7 +4227,7 @@ NTSTATUS smbd_do_qfilepathinfo(connection_struct *conn, mode = dos_mode(conn, smb_fname); nlink = psbuf->st_ex_nlink; - if (nlink && (mode&aDIR)) { + if (nlink && (mode&FILE_ATTRIBUTE_DIRECTORY)) { nlink = 1; } @@ -4308,7 +4308,7 @@ NTSTATUS smbd_do_qfilepathinfo(connection_struct *conn, } } - if (!(mode & aDIR)) { + if (!(mode & FILE_ATTRIBUTE_DIRECTORY)) { file_size = get_file_size_stat(psbuf); } @@ -4478,7 +4478,7 @@ NTSTATUS smbd_do_qfilepathinfo(connection_struct *conn, SOFF_T(pdata,8,file_size); SIVAL(pdata,16,nlink); SCVAL(pdata,20,delete_pending?1:0); - SCVAL(pdata,21,(mode&aDIR)?1:0); + SCVAL(pdata,21,(mode&FILE_ATTRIBUTE_DIRECTORY)?1:0); SSVAL(pdata,22,0); /* Padding. */ break; @@ -4561,7 +4561,7 @@ NTSTATUS smbd_do_qfilepathinfo(connection_struct *conn, SOFF_T(pdata,8,file_size); SIVAL(pdata,16,nlink); SCVAL(pdata,20,delete_pending); - SCVAL(pdata,21,(mode&aDIR)?1:0); + SCVAL(pdata,21,(mode&FILE_ATTRIBUTE_DIRECTORY)?1:0); SSVAL(pdata,22,0); pdata += 24; SIVAL(pdata,0,ea_size); @@ -4592,7 +4592,7 @@ NTSTATUS smbd_do_qfilepathinfo(connection_struct *conn, SBVAL(pdata, 0x30, file_size); SIVAL(pdata, 0x38, nlink); SCVAL(pdata, 0x3C, delete_pending); - SCVAL(pdata, 0x3D, (mode&aDIR)?1:0); + SCVAL(pdata, 0x3D, (mode&FILE_ATTRIBUTE_DIRECTORY)?1:0); SSVAL(pdata, 0x3E, 0); /* padding */ SBVAL(pdata, 0x40, file_index); SIVAL(pdata, 0x48, ea_size); @@ -5554,9 +5554,9 @@ static NTSTATUS smb_set_file_dosmode(connection_struct *conn, if (dosmode) { if (S_ISDIR(smb_fname_base->st.st_ex_mode)) { - dosmode |= aDIR; + dosmode |= FILE_ATTRIBUTE_DIRECTORY; } else { - dosmode &= ~aDIR; + dosmode &= ~FILE_ATTRIBUTE_DIRECTORY; } } -- cgit From 76739435fc8abf1f47193ec4db35a567b564c785 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 29 Apr 2011 14:27:32 -0700 Subject: Fix bug 8111 - CIFS VFS: unexpected error on SMB posix open We are conflating the O_CREAT|O_EXCL with the O_TRUNC processing, they need to be separate. We need to chose using (O_CREAT|O_EXCL) first, then modify if O_TRUNC is set. This needs two separate switch statements. Jeremy --- source3/smbd/trans2.c | 61 +++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 49 insertions(+), 12 deletions(-) (limited to 'source3/smbd/trans2.c') diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c index abab3879f6..028d3182a7 100644 --- a/source3/smbd/trans2.c +++ b/source3/smbd/trans2.c @@ -7286,18 +7286,55 @@ static NTSTATUS smb_posix_open(connection_struct *conn, wire_open_mode &= ~SMB_ACCMODE; - if((wire_open_mode & (SMB_O_CREAT | SMB_O_EXCL)) == (SMB_O_CREAT | SMB_O_EXCL)) { - create_disp = FILE_CREATE; - } else if((wire_open_mode & (SMB_O_CREAT | SMB_O_TRUNC)) == (SMB_O_CREAT | SMB_O_TRUNC)) { - create_disp = FILE_OVERWRITE_IF; - } else if((wire_open_mode & SMB_O_CREAT) == SMB_O_CREAT) { - create_disp = FILE_OPEN_IF; - } else if ((wire_open_mode & (SMB_O_CREAT | SMB_O_EXCL | SMB_O_TRUNC)) == 0) { - create_disp = FILE_OPEN; - } else { - DEBUG(5,("smb_posix_open: invalid create mode 0x%x\n", - (unsigned int)wire_open_mode )); - return NT_STATUS_INVALID_PARAMETER; + /* First take care of O_CREAT|O_EXCL interactions. */ + switch (wire_open_mode & (SMB_O_CREAT | SMB_O_EXCL)) { + case (SMB_O_CREAT | SMB_O_EXCL): + /* File exists fail. File not exist create. */ + create_disp = FILE_CREATE; + break; + case SMB_O_CREAT: + /* File exists open. File not exist create. */ + create_disp = FILE_OPEN_IF; + break; + case 0: + /* File exists open. File not exist fail. */ + create_disp = FILE_OPEN; + break; + case SMB_O_EXCL: + /* O_EXCL on its own without O_CREAT is undefined. */ + default: + DEBUG(5,("smb_posix_open: invalid create mode 0x%x\n", + (unsigned int)wire_open_mode )); + return NT_STATUS_INVALID_PARAMETER; + } + + /* Next factor in the effects of O_TRUNC. */ + wire_open_mode &= ~(SMB_O_CREAT | SMB_O_EXCL); + + if (wire_open_mode & SMB_O_TRUNC) { + switch (create_disp) { + case FILE_CREATE: + /* (SMB_O_CREAT | SMB_O_EXCL | O_TRUNC) */ + /* Leave create_disp alone as + (O_CREAT|O_EXCL|O_TRUNC) == (O_CREAT|O_EXCL) + */ + /* File exists fail. File not exist create. */ + break; + case FILE_OPEN_IF: + /* SMB_O_CREAT | SMB_O_TRUNC */ + /* File exists overwrite. File not exist create. */ + create_disp = FILE_OVERWRITE_IF; + break; + case FILE_OPEN: + /* SMB_O_TRUNC */ + /* File exists overwrite. File not exist fail. */ + create_disp = FILE_OVERWRITE; + break; + default: + /* Cannot get here. */ + smb_panic("smb_posix_open: logic error"); + return NT_STATUS_INVALID_PARAMETER; + } } raw_unixmode = IVAL(pdata,8); -- cgit From 2cb53f066e0e42d923be89dd3a7e18ea7a1b7340 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 29 Apr 2011 16:15:55 -0700 Subject: Fix bug #8112 - POSIX extension opens of a directory are denied with EISDIR. Ensure create_options are passed down to SMB_VFS_CREATE_FILE(). Correctly set create_options is SMB_O_DIRECTORY is set or pathname is known to be a directory. Jeremy. --- source3/smbd/trans2.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'source3/smbd/trans2.c') diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c index 028d3182a7..46f2aa0368 100644 --- a/source3/smbd/trans2.c +++ b/source3/smbd/trans2.c @@ -7240,7 +7240,7 @@ static NTSTATUS smb_posix_open(connection_struct *conn, uint32 mod_unixmode = 0; uint32 create_disp = 0; uint32 access_mask = 0; - uint32 create_options = 0; + uint32 create_options = FILE_NON_DIRECTORY_FILE; NTSTATUS status = NT_STATUS_OK; mode_t unixmode = (mode_t)0; files_struct *fsp = NULL; @@ -7354,6 +7354,14 @@ static NTSTATUS smb_posix_open(connection_struct *conn, if (wire_open_mode & SMB_O_SYNC) { create_options |= FILE_WRITE_THROUGH; } + if ((wire_open_mode & SMB_O_DIRECTORY) || + VALID_STAT_OF_DIR(smb_fname->st)) { + if (access_mask != FILE_READ_DATA) { + return NT_STATUS_FILE_IS_A_DIRECTORY; + } + create_options &= ~FILE_NON_DIRECTORY_FILE; + create_options |= FILE_DIRECTORY_FILE; + } if (wire_open_mode & SMB_O_APPEND) { access_mask |= FILE_APPEND_DATA; } @@ -7375,7 +7383,7 @@ static NTSTATUS smb_posix_open(connection_struct *conn, (FILE_SHARE_READ | FILE_SHARE_WRITE | /* share_access */ FILE_SHARE_DELETE), create_disp, /* create_disposition*/ - FILE_NON_DIRECTORY_FILE, /* create_options */ + create_options, /* create_options */ mod_unixmode, /* file_attributes */ oplock_request, /* oplock_request */ 0, /* allocation_size */ -- cgit From 047d8c073b57bc12648a251deaceedb65f4f59cf Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 29 Apr 2011 23:32:28 +0200 Subject: s3-proto: move more rpc_server prototypes out of proto.h Guenther --- source3/smbd/trans2.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source3/smbd/trans2.c') diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c index 46f2aa0368..aee4e8865c 100644 --- a/source3/smbd/trans2.c +++ b/source3/smbd/trans2.c @@ -35,6 +35,7 @@ #include "trans2.h" #include "auth.h" #include "smbprofile.h" +#include "rpc_server/srv_pipe_hnd.h" #define DIR_ENTRY_SAFETY_MARGIN 4096 -- cgit From cabd9e70e2f3ce3f617975a4d005d79121313b5f Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 3 May 2011 13:52:06 -0700 Subject: Simple +1 changes in hardcoded lengths when changing from safe_strcpy to strlcpy. --- source3/smbd/trans2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/smbd/trans2.c') diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c index aee4e8865c..39e653afae 100644 --- a/source3/smbd/trans2.c +++ b/source3/smbd/trans2.c @@ -491,7 +491,7 @@ static void canonicalize_ea_name(connection_struct *conn, files_struct *fsp, con if (strequal(&unix_ea_name[5], ea_list->ea.name)) { DEBUG(10,("canonicalize_ea_name: %s -> %s\n", &unix_ea_name[5], ea_list->ea.name)); - safe_strcpy(&unix_ea_name[5], ea_list->ea.name, sizeof(fstring)-6); + strlcpy(&unix_ea_name[5], ea_list->ea.name, sizeof(fstring)-5); break; } } -- cgit From 8380835fc6de38706d9af29dc7f0fa4cec4f9c90 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 4 May 2011 11:38:26 -0700 Subject: Fix warning messages caused by addition of null check in fstrcpy macro. --- source3/smbd/trans2.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/smbd/trans2.c') diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c index 39e653afae..7c8b43c10c 100644 --- a/source3/smbd/trans2.c +++ b/source3/smbd/trans2.c @@ -388,7 +388,7 @@ static unsigned int fill_ea_buffer(TALLOC_CTX *mem_ctx, char *pdata, unsigned in SCVAL(p,0,ea_list->ea.flags); SCVAL(p,1,dos_namelen); SSVAL(p,2,ea_list->ea.value.length); - fstrcpy(p+4, dos_ea_name); + strlcpy(p+4, dos_ea_name, dos_namelen+1); memcpy( p + 4 + dos_namelen + 1, ea_list->ea.value.data, ea_list->ea.value.length); total_data_size -= 4 + dos_namelen + 1 + ea_list->ea.value.length; @@ -452,7 +452,7 @@ static NTSTATUS fill_ea_chained_buffer(TALLOC_CTX *mem_ctx, SCVAL(p, 0x04, ea_list->ea.flags); SCVAL(p, 0x05, dos_namelen); SSVAL(p, 0x06, ea_list->ea.value.length); - fstrcpy((char *)(p+0x08), dos_ea_name); + strlcpy((char *)(p+0x08), dos_ea_name, dos_namelen+1); memcpy(p + 0x08 + dos_namelen + 1, ea_list->ea.value.data, ea_list->ea.value.length); total_data_size -= this_size; -- cgit From 4f41be356a4e6b311d30de3b2e36e4c33aa72ca3 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 5 May 2011 10:41:59 -0700 Subject: Fix many const compiler warnings. --- source3/smbd/trans2.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/smbd/trans2.c') diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c index 7c8b43c10c..733f1bc2a8 100644 --- a/source3/smbd/trans2.c +++ b/source3/smbd/trans2.c @@ -8322,7 +8322,7 @@ static void call_trans2getdfsreferral(connection_struct *conn, return; } - SSVAL(req->inbuf, smb_flg2, + SSVAL((discard_const_p(uint8_t, req->inbuf)), smb_flg2, SVAL(req->inbuf,smb_flg2) | FLAGS2_DFS_PATHNAMES); send_trans2_replies(conn, req,0,0,*ppdata,reply_size, max_data_bytes); @@ -8453,7 +8453,7 @@ static void handle_trans2(connection_struct *conn, struct smb_request *req, { if (get_Protocol() >= PROTOCOL_NT1) { req->flags2 |= 0x40; /* IS_LONG_NAME */ - SSVAL(req->inbuf,smb_flg2,req->flags2); + SSVAL((discard_const_p(uint8_t, req->inbuf)),smb_flg2,req->flags2); } if (conn->encrypt_level == Required && !req->encrypted) { @@ -8812,7 +8812,7 @@ void reply_transs2(struct smb_request *req) START_PROFILE(SMBtranss2); - show_msg((char *)req->inbuf); + show_msg((const char *)req->inbuf); if (req->wct < 8) { reply_nterror(req, NT_STATUS_INVALID_PARAMETER); -- cgit From 28734295557620c36ffe8f51dcef7158c46d78a0 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 17 May 2011 16:18:51 -0700 Subject: Fix bug #8144 - touch /mnt/newfile fails to set timestamp with CIFS client. The extra checks added for Windows correctness in our metadata changing paths to ensure the file handle has been opened with the correct access mask to allow FILE_WRITE_ATTRIBUTES etc. caused problems with the POSIX open code. The old POSIX open code maped O_RDONLY into FILE_READ, O_WRONLY into FILE_WRITE, and O_RDWR into FILE_READ|FILE_WRITE. This patch extends the mapping to add FILE_WRITE_ATTRIBUTES, FILE_READ_ATTRIBUTES and FILE_WRITE_EA, FILE_READ_EA to allow POSIX opens to set these values. Autobuild-User: Jeremy Allison Autobuild-Date: Wed May 18 02:22:32 CEST 2011 on sn-devel-104 --- source3/smbd/trans2.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) (limited to 'source3/smbd/trans2.c') diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c index 733f1bc2a8..75d0a41e6b 100644 --- a/source3/smbd/trans2.c +++ b/source3/smbd/trans2.c @@ -7226,6 +7226,9 @@ static NTSTATUS smb_posix_mkdir(connection_struct *conn, Open/Create a file with POSIX semantics. ****************************************************************************/ +#define SMB_O_RDONLY_MAPPING (FILE_READ_DATA|FILE_READ_ATTRIBUTES|FILE_READ_EA) +#define SMB_O_WRONLY_MAPPING (FILE_WRITE_DATA|FILE_WRITE_ATTRIBUTES|FILE_WRITE_EA) + static NTSTATUS smb_posix_open(connection_struct *conn, struct smb_request *req, char **ppdata, @@ -7271,13 +7274,14 @@ static NTSTATUS smb_posix_open(connection_struct *conn, switch (wire_open_mode & SMB_ACCMODE) { case SMB_O_RDONLY: - access_mask = FILE_READ_DATA; + access_mask = SMB_O_RDONLY_MAPPING; break; case SMB_O_WRONLY: - access_mask = FILE_WRITE_DATA; + access_mask = SMB_O_WRONLY_MAPPING; break; case SMB_O_RDWR: - access_mask = FILE_READ_DATA|FILE_WRITE_DATA; + access_mask = (SMB_O_RDONLY_MAPPING| + SMB_O_WRONLY_MAPPING); break; default: DEBUG(5,("smb_posix_open: invalid open mode 0x%x\n", @@ -7355,20 +7359,21 @@ static NTSTATUS smb_posix_open(connection_struct *conn, if (wire_open_mode & SMB_O_SYNC) { create_options |= FILE_WRITE_THROUGH; } + if (wire_open_mode & SMB_O_APPEND) { + access_mask |= FILE_APPEND_DATA; + } + if (wire_open_mode & SMB_O_DIRECT) { + mod_unixmode |= FILE_FLAG_NO_BUFFERING; + } + if ((wire_open_mode & SMB_O_DIRECTORY) || VALID_STAT_OF_DIR(smb_fname->st)) { - if (access_mask != FILE_READ_DATA) { + if (access_mask != SMB_O_RDONLY_MAPPING) { return NT_STATUS_FILE_IS_A_DIRECTORY; } create_options &= ~FILE_NON_DIRECTORY_FILE; create_options |= FILE_DIRECTORY_FILE; } - if (wire_open_mode & SMB_O_APPEND) { - access_mask |= FILE_APPEND_DATA; - } - if (wire_open_mode & SMB_O_DIRECT) { - mod_unixmode |= FILE_FLAG_NO_BUFFERING; - } DEBUG(10,("smb_posix_open: file %s, smb_posix_flags = %u, mode 0%o\n", smb_fname_str_dbg(smb_fname), -- cgit From c615ebed6e3d273a682806b952d543e834e5630d Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Fri, 13 May 2011 20:21:30 +0200 Subject: s3-lib Replace StrCaseCmp() with strcasecmp_m() strcasecmp_m() never needs to call to talloc, and via next_codepoint() still has an ASCII fast-path bypassing iconv() calls. Andrew Bartlett --- source3/smbd/trans2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/smbd/trans2.c') diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c index 75d0a41e6b..6eae9a5764 100644 --- a/source3/smbd/trans2.c +++ b/source3/smbd/trans2.c @@ -1219,7 +1219,7 @@ static bool exact_match(bool has_wild, if (case_sensitive) { return strcmp(str,mask)==0; } else { - return StrCaseCmp(str,mask) == 0; + return strcasecmp_m(str,mask) == 0; } } -- cgit From da662b82b87cdbe07762974b1f9e825ef15951bd Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Fri, 13 May 2011 20:23:36 +0200 Subject: s3-lib Replace StrnCaseCmp() with strncasecmp_m() strncasecmp_m() never needs to call to talloc, and via next_codepoint() still has an ASCII fast-path bypassing iconv() calls. Andrew Bartlett --- source3/smbd/trans2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/smbd/trans2.c') diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c index 6eae9a5764..f5b87c77d3 100644 --- a/source3/smbd/trans2.c +++ b/source3/smbd/trans2.c @@ -107,7 +107,7 @@ static bool samba_private_attr_name(const char *unix_ea_name) if (strequal( prohibited_ea_names[i], unix_ea_name)) return true; } - if (StrnCaseCmp(unix_ea_name, SAMBA_XATTR_DOSSTREAM_PREFIX, + if (strncasecmp_m(unix_ea_name, SAMBA_XATTR_DOSSTREAM_PREFIX, strlen(SAMBA_XATTR_DOSSTREAM_PREFIX)) == 0) { return true; } -- cgit From 95a55e2feabfae3b0874ae9aa2ce716ca0a9ae39 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 19 May 2011 16:39:18 -0700 Subject: Fix bug 8133 - strange behavior for the file (whose filename first character is period ) in SMB2 case. When doing SMB2 renames, we need to match all filetypes (no attributes field in the SMB2 call). By default a file starting with a period is returned as FILE_ATTRIBUTE_HIDDEN in Samba. Autobuild-User: Jeremy Allison Autobuild-Date: Fri May 20 19:26:04 CEST 2011 on sn-devel-104 --- source3/smbd/trans2.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'source3/smbd/trans2.c') diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c index f5b87c77d3..cc21b32fe7 100644 --- a/source3/smbd/trans2.c +++ b/source3/smbd/trans2.c @@ -6050,8 +6050,9 @@ static NTSTATUS smb2_file_rename_information(connection_struct *conn, "SMB_FILE_RENAME_INFORMATION (fnum %d) %s -> %s\n", fsp->fnum, fsp_str_dbg(fsp), smb_fname_str_dbg(smb_fname_dst))); - status = rename_internals_fsp(conn, fsp, smb_fname_dst, 0, - overwrite); + status = rename_internals_fsp(conn, fsp, smb_fname_dst, + (FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_SYSTEM), + overwrite); out: TALLOC_FREE(smb_fname_dst); -- cgit From 73b377432c5efb8451f09f6d25d8aa1b28c239c9 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Tue, 7 Jun 2011 11:10:15 +1000 Subject: s3-talloc Change TALLOC_REALLOC_ARRAY() to talloc_realloc() Using the standard macro makes it easier to move code into common, as TALLOC_REALLOC_ARRAY isn't standard talloc. Andrew Bartlett --- source3/smbd/trans2.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/smbd/trans2.c') diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c index cc21b32fe7..72907c5d3a 100644 --- a/source3/smbd/trans2.c +++ b/source3/smbd/trans2.c @@ -129,7 +129,7 @@ NTSTATUS get_ea_value(TALLOC_CTX *mem_ctx, connection_struct *conn, again: - val = TALLOC_REALLOC_ARRAY(mem_ctx, val, char, attr_size); + val = talloc_realloc(mem_ctx, val, char, attr_size); if (!val) { return NT_STATUS_NO_MEMORY; } @@ -200,7 +200,7 @@ NTSTATUS get_ea_names_from_file(TALLOC_CTX *mem_ctx, connection_struct *conn, while (ea_namelist_size <= 65536) { - ea_namelist = TALLOC_REALLOC_ARRAY( + ea_namelist = talloc_realloc( names, ea_namelist, char, ea_namelist_size); if (ea_namelist == NULL) { DEBUG(0, ("talloc failed\n")); @@ -259,7 +259,7 @@ NTSTATUS get_ea_names_from_file(TALLOC_CTX *mem_ctx, connection_struct *conn, num_names += 1; } - tmp = TALLOC_REALLOC_ARRAY(mem_ctx, names, char *, num_names); + tmp = talloc_realloc(mem_ctx, names, char *, num_names); if (tmp == NULL) { DEBUG(0, ("talloc failed\n")); TALLOC_FREE(names); -- cgit From 3d15137653a7d1b593a9af2eef12f6e5b9a04c4f Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Tue, 7 Jun 2011 11:30:12 +1000 Subject: s3-talloc Change TALLOC_ARRAY() to talloc_array() Using the standard macro makes it easier to move code into common, as TALLOC_ARRAY isn't standard talloc. --- source3/smbd/trans2.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/smbd/trans2.c') diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c index 72907c5d3a..b9a4d4624b 100644 --- a/source3/smbd/trans2.c +++ b/source3/smbd/trans2.c @@ -192,7 +192,7 @@ NTSTATUS get_ea_names_from_file(TALLOC_CTX *mem_ctx, connection_struct *conn, * TALLOC the result early to get the talloc hierarchy right. */ - names = TALLOC_ARRAY(mem_ctx, char *, 1); + names = talloc_array(mem_ctx, char *, 1); if (names == NULL) { DEBUG(0, ("talloc failed\n")); return NT_STATUS_NO_MEMORY; @@ -4768,7 +4768,7 @@ NTSTATUS smbd_do_qfilepathinfo(connection_struct *conn, case SMB_QUERY_FILE_UNIX_LINK: { int len; - char *buffer = TALLOC_ARRAY(mem_ctx, char, PATH_MAX+1); + char *buffer = talloc_array(mem_ctx, char, PATH_MAX+1); if (!buffer) { return NT_STATUS_NO_MEMORY; -- cgit From d5e6a47f064a3923b1e257ab84fa7ccd7c4f89f4 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Tue, 7 Jun 2011 11:38:41 +1000 Subject: s3-talloc Change TALLOC_P() to talloc() Using the standard macro makes it easier to move code into common, as TALLOC_P isn't standard talloc. --- source3/smbd/trans2.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/smbd/trans2.c') diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c index b9a4d4624b..6d85edf9eb 100644 --- a/source3/smbd/trans2.c +++ b/source3/smbd/trans2.c @@ -316,7 +316,7 @@ static struct ea_list *get_ea_list_from_file(TALLOC_CTX *mem_ctx, connection_str || samba_private_attr_name(names[i])) continue; - listp = TALLOC_P(mem_ctx, struct ea_list); + listp = talloc(mem_ctx, struct ea_list); if (listp == NULL) { return NULL; } @@ -8672,7 +8672,7 @@ void reply_trans2(struct smb_request *req) } } - if ((state = TALLOC_P(conn, struct trans_state)) == NULL) { + if ((state = talloc(conn, struct trans_state)) == NULL) { DEBUG(0, ("talloc failed\n")); reply_nterror(req, NT_STATUS_NO_MEMORY); END_PROFILE(SMBtrans2); -- cgit From ad0a07c531fadd1639c5298951cfaf5cfe0cb10e Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Tue, 7 Jun 2011 11:44:43 +1000 Subject: s3-talloc Change TALLOC_ZERO_P() to talloc_zero() Using the standard macro makes it easier to move code into common, as TALLOC_ZERO_P isn't standard talloc. --- source3/smbd/trans2.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/smbd/trans2.c') diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c index 6d85edf9eb..92ac78c6e9 100644 --- a/source3/smbd/trans2.c +++ b/source3/smbd/trans2.c @@ -590,7 +590,7 @@ static struct ea_list *read_ea_name_list(TALLOC_CTX *ctx, const char *pdata, siz size_t converted_size, offset = 0; while (offset + 2 < data_size) { - struct ea_list *eal = TALLOC_ZERO_P(ctx, struct ea_list); + struct ea_list *eal = talloc_zero(ctx, struct ea_list); unsigned int namelen = CVAL(pdata,offset); offset++; /* Go past the namelen byte. */ @@ -628,7 +628,7 @@ static struct ea_list *read_ea_name_list(TALLOC_CTX *ctx, const char *pdata, siz struct ea_list *read_ea_list_entry(TALLOC_CTX *ctx, const char *pdata, size_t data_size, size_t *pbytes_used) { - struct ea_list *eal = TALLOC_ZERO_P(ctx, struct ea_list); + struct ea_list *eal = talloc_zero(ctx, struct ea_list); uint16 val_len; unsigned int namelen; size_t converted_size; -- cgit From 8d4a8389bb2df77ff8923dda8368aa2915652c1a Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Tue, 7 Jun 2011 12:13:26 +1000 Subject: s3-talloc Change TALLOC_MEMDUP() to talloc_memdup() Using the standard macro makes it easier to move code into common, as TALLOC_MEMDUP isn't standard talloc. --- source3/smbd/trans2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/smbd/trans2.c') diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c index 92ac78c6e9..ae6eb59451 100644 --- a/source3/smbd/trans2.c +++ b/source3/smbd/trans2.c @@ -5301,7 +5301,7 @@ total_data=%u (should be %u)\n", (unsigned int)total_data, (unsigned int)IVAL(pd } /* Copy the lock range data. */ - lock_data = (char *)TALLOC_MEMDUP( + lock_data = (char *)talloc_memdup( req, pdata, total_data); if (!lock_data) { reply_nterror(req, NT_STATUS_NO_MEMORY); -- cgit From 74eed8f3ed5c333728350df1d23a4318e9104909 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Thu, 9 Jun 2011 15:31:03 +1000 Subject: s3-param Remove special case for global_myname(), rename to lp_netbios_name() There is no reason this can't be a normal constant string in the loadparm system, now that we have lp_set_cmdline() to handle overrides correctly. Andrew Bartlett --- source3/smbd/trans2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/smbd/trans2.c') diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c index ae6eb59451..b853722eae 100644 --- a/source3/smbd/trans2.c +++ b/source3/smbd/trans2.c @@ -8377,7 +8377,7 @@ static void call_trans2ioctl(connection_struct *conn, SSVAL(pdata, 0, 0); } srvstr_push(pdata, req->flags2, pdata + 2, - global_myname(), 15, + lp_netbios_name(), 15, STR_ASCII|STR_TERMINATE); /* Our NetBIOS name */ srvstr_push(pdata, req->flags2, pdata+18, lp_servicename(SNUM(conn)), 13, -- cgit