summaryrefslogtreecommitdiffstats
path: root/source3/smbd
Commit message (Collapse)AuthorAgeFilesLines
* s3/smbd: fix FSCTL_SET_SPARSE permission checksDavid Disseldorp2015-03-091-2/+7
| | | | | | | | | | | | On Windows servers (tested against Windows Server 2008 & 2012) the FSCTL_SET_SPARSE ioctl is processed if FILE_WRITE_DATA, FILE_WRITE_ATTRIBUTES _or_ SEC_FILE_APPEND_DATA permissions are granted on the open file-handle. Fix Samba such that it matches this behaviour, rather than only checking for FILE_WRITE_DATA or FILE_WRITE_ATTRIBUTES. Signed-off-by: David Disseldorp <ddiss@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* s3/statvfs: expose FILE_SUPPORTS_SPARSE_FILES capabilityDavid Disseldorp2015-03-091-0/+9
| | | | | | | | | | | | | | Samba now supports: - FSCTL_SET_SPARSE - FSCTL_SET_ZERO_DATA, via FALLOC_FL_PUNCH_HOLE - FSCTL_QUERY_ALLOCATED_RANGES, via SEEK_DATA/SEEK_HOLE As such, flag support for sparse files, via the FILE_SUPPORTS_SPARSE_FILES capability flag if FALLOC_FL_PUNCH_HOLE and SEEK_DATA/SEEK_HOLE are present at configure time. Signed-off-by: David Disseldorp <ddiss@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* smbd/ioctl: add FSCTL_QUERY_ALLOCATED_RANGES supportDavid Disseldorp2015-03-091-0/+216
| | | | | | | | | | | This change implements support for FSCTL_QUERY_ALLOCATED_RANGES using the SEEK_HOLE/SEEK_DATA functionality of lseek(). Files marked non-sparse are always reported by the ioctl as fully allocated, regardless of any potential "strict allocate = no" savings. Signed-off-by: David Disseldorp <ddiss@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* smbd/ioctl: add FSCTL_SET_ZERO_DATA supportDavid Disseldorp2015-03-091-1/+111
| | | | | | | | | | | | | | | | | | | | | | FSCTL_SET_ZERO_DATA can be used in two ways. - When requested against a file marked as sparse, it provides a mechanism for requesting that the server deallocate the underlying disk space for the corresponding zeroed range. - When requested against a non-sparse file, it indicates that the server should allocate and zero the corresponding range. Both use cases can be handled in Samba using fallocate(). The Linux specific FALLOC_FL_PUNCH_HOLE flag can be used to deallocate the underlying disk space. After doing so, a normal fallocate() call can be used to ensure that the zeroed range is allocated on non-sparse files. FSCTL_SET_ZERO_DATA requests must not result in a change to the file size. The FSCTL_SET_ZERO_DATA handler always calls fallocate() with the KEEP_SIZE flag set, ensuring that Samba meets this requirement. Signed-off-by: David Disseldorp <ddiss@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* s3/vfs: change fallocate mode flags from enum->uint32_tDavid Disseldorp2015-03-091-7/+7
| | | | | | | | | | | | | | | | | | | | The Linux fallocate syscall offers a mode parameter which can take the following flags: FALLOC_FL_KEEP_SIZE FALLOC_FL_PUNCH_HOLE (since 2.6.38) FALLOC_FL_COLLAPSE_RANGE (since 3.15) FALLOC_FL_ZERO_RANGE (since 3.14) The flags are not exclusive, e.g. FALLOC_FL_PUNCH_HOLE must be specified alongside FALLOC_FL_KEEP_SIZE. Samba currently takes a vfs_fallocate_mode enum parameter for the VFS fallocate hook, taking either an EXTEND_SIZE or KEEP_SIZE value. This commit changes the fallocate hook such that it accepts a uint32_t flags parameter, in preparation for PUNCH_HOLE and ZERO_RANGE support. Signed-off-by: David Disseldorp <ddiss@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* s3:smbprofile: Replace sysv shmem with tdbVolker Lendecke2015-03-064-2/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | What? This patch gets rid of the central shared memory segment referenced by "profile_p". Instead, every smbd gets a static profile_area where it collects profiling data. Once a second, every smbd writes this profiling data into a record of its own in a "smbprofile.tdb". smbstatus -P does a tdb_traverse on this database and sums up what it finds. Why? At least in my perception sysv IPC has not the best reputation on earth. The code before this patch uses shmat(). Samba ages ago has developed a good abstraction of shared memory: It's called tdb. The main reason why I started this is that I have a request to become more flexible with profiling data. Samba should be able to collect data per share or per user, something which is almost impossible to do with a fixed structure. My idea is to for example install a profile area per share and every second marshall this into one tdb record indexed by share name. smbstatus -P would then also collect the data and either aggregate them or put them into individual per-share statistics. This flexibility in the data model is not really possible with one fixed structure. But isn't it slow? Well, I don't think so. I can't really prove it, but I do believe that on large boxes atomically incrementing a shared memory value for every SMB does show up due to NUMA effects. With this patch the hot code path is completely process-local. Once a second every smbd writes into a central tdb, this of course does atomic operations. But it's once a second, not on every SMB2 read. There's two places where I would like to improve things: With the current code all smbds wake up once a second. With 10,000 potentially idle smbds this will become noticable. That's why the current only starts the timer when something has changed. The second place is the tdb traverse: Right now traverse is blocking in the sense that when it has to switch hash chains it will block. With mutexes, this means a syscall. I have a traverse light in mind that works as follows: It assumes a locked hash chain and then walks the complete chain in one run without unlocking in between. This way the caller can do nonblocking locks in the first round and only do blocking locks in a second round. Also, a lot of syscall overhead will vanish. This way smbstatus -P will have almost zero impact on normal operations. Pair-Programmed-With: Stefan Metzmacher <metze@samba.org> Signed-off-by: Volker Lendecke <vl@samba.org> Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* smbd: Fix CID 1273088 Resource leakVolker Lendecke2015-03-031-0/+1
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* smbd: Make SMB3 clients use encryption with "smb encrypt = auto"Volker Lendecke2015-03-032-0/+10
| | | | | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org> Autobuild-User(master): Volker Lendecke <vl@samba.org> Autobuild-Date(master): Tue Mar 3 10:40:42 CET 2015 on sn-devel-104
* MSDFS referral shufflingRobin McCorkell2015-02-271-3/+26
| | | | | | | | | | Shuffle MSDFS referral list in smbd in accordance with [MS-DFSC] 3.2.1.1 When parsing an MSDFS symlink, the names are shuffled with a Fisher-Yates algorithm. Signed-off-by: Robin McCorkell <rmccorkell@karoshi.org.uk> Reviewed-by: David Disseldorp <ddiss@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* smbd: Simplify ReadDirNameVolker Lendecke2015-02-261-4/+6
| | | | | | | In the if-branches we return, so no "else" necessary Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* smbd: ZERO_STRUCT -> struct initVolker Lendecke2015-02-261-6/+4
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* smbd: ZERO_STRUCT -> struct assignmentVolker Lendecke2015-02-261-3/+3
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* smbd: ZERO_STRUCT -> struct assignmentVolker Lendecke2015-02-261-2/+1
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* smbd: ZERO_STRUCTP -> talloc_zero()Volker Lendecke2015-02-261-3/+1
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* smbd: Fix a typoVolker Lendecke2015-02-261-1/+1
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* smbd: Fix a typoVolker Lendecke2015-02-241-1/+1
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* smb2_server: Use iov_advanceVolker Lendecke2015-02-241-24/+4
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* smb2_server: Add range checking to nbt_lengthVolker Lendecke2015-02-241-13/+48
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* lib: Move "iov_buf.[ch]" to lib/utilVolker Lendecke2015-02-241-1/+1
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* Revert "s3: smbd: signing. Ensure we respond correctly to an SMB2 negprot ↵Jeremy Allison2015-02-232-5/+2
| | | | | | | | | | | | with SMB2_NEGOTIATE_SIGNING_REQUIRED." Even though the MS-SMB2 spec says so, Windows doesn't behave like this. This reverts commit 1cea6e5b6f8c0e28d5ba2d296c831c4878fca304. Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: "Stefan (metze) Metzmacher" <metze@samba.org>
* s3: smbd: SMB2 close. If a file has delete on close, store the return info ↵Jeremy Allison2015-02-201-0/+20
| | | | | | | | | | | | | | | | | before deleting. If we delete the file on close, the stat after the close will fail so we fail to return the attributes requested. Bug 11104 - SMB2/SMB3 close response does not include attributes when requested. https://bugzilla.samba.org/show_bug.cgi?id=11104 Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Steve French <sfrench@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Fri Feb 20 20:54:18 CET 2015 on sn-devel-104
* s3: smbd: SMB2 close. Call utility function setup_close_full_information()Jeremy Allison2015-02-201-26/+11
| | | | | | | | | | | Replaces existing inline code. Bug 11104 - SMB2/SMB3 close response does not include attributes when requested. https://bugzilla.samba.org/show_bug.cgi?id=11104 Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Steve French <sfrench@samba.org>
* s3: smbd: SMB2 close. Add utility function setup_close_full_information()Jeremy Allison2015-02-201-0/+42
| | | | | | | | | | | Not yet used. Bug 11104 - SMB2/SMB3 close response does not include attributes when requested. https://bugzilla.samba.org/show_bug.cgi?id=11104 Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Steve French <sfrench@samba.org>
* s3: smbd: leases - losen paranoia check. Stat opens can grant leases.Jeremy Allison2015-02-191-1/+2
| | | | | | | https://bugzilla.samba.org/show_bug.cgi?id=11102 Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Ralph Böhme <slow@samba.org>
* s3: smbd: leases - new torture test shows stat opens can get leases.Jeremy Allison2015-02-191-7/+4
| | | | | | | | | Can also issue breaks on these leases. https://bugzilla.samba.org/show_bug.cgi?id=11102 Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Ralph Böhme <slow@samba.org>
* s3: smbd: signing. Ensure we respond correctly to an SMB2 negprot with ↵Jeremy Allison2015-02-192-2/+5
| | | | | | | | | | | SMB2_NEGOTIATE_SIGNING_REQUIRED. Bug 11103: - Samba does not set the required flags in the SMB2/SMB3 Negotiate Protocol Response when signing required by client https://bugzilla.samba.org/show_bug.cgi?id=11103 Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Steve French <smfrench@gmail.com>
* s3/vfs: remove unused SMB_VFS_DISK_FREE() small_query parameterDavid Disseldorp2015-02-175-41/+29
| | | | | | | | | | | | | | | The small_query parameter for SMB_VFS_DISK_FREE() was, prior to the previous commit, used to obtain 16-bit wide free-space information for the deprecated dskattr SMB_COM_QUERY_INFORMATION_DISK command. With the dskattr handler now performing the 16-bit collapse directly, the small_query parameter can be removed from the entire code path. Signed-off-by: David Disseldorp <ddiss@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Tue Feb 17 05:37:20 CET 2015 on sn-devel-104
* smbd/reply: convert free space to 16bit in dskattr handlerDavid Disseldorp2015-02-171-1/+20
| | | | | | | | | | | | | | | | | | The deprecated Core Protocol dskattr SMB_COM_QUERY_INFORMATION_DISK command provides free space information in the form of 16-bit words. Until now, this has been handled by passing the dskattr specific small_query boolean through to disk_norm() via the SMB_VFS_DISK_FREE VFS hook. disk_norm(small_query=true) then modifies the block size and free space values such that they fit in the 16-bit field. This change adds the command specific logic to the dskattr handler, so that it can be removed from the SMB_VFS_DISK_FREE()->disk_norm() code path. In doing so, it fixes dskattr request handling against opaque VFS backends that don't call disk_norm(), such as vfs_glusterfs. Signed-off-by: David Disseldorp <ddiss@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* smbd: Fix a typoVolker Lendecke2015-02-101-1/+1
| | | | | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: David Disseldorp <ddiss@samba.org> Autobuild-User(master): David Disseldorp <ddiss@samba.org> Autobuild-Date(master): Tue Feb 10 20:27:32 CET 2015 on sn-devel-104
* smbd: Fix a typoVolker Lendecke2015-02-101-1/+1
| | | | | | | | http://www.oxfordlearnersdictionaries.com/definition/english/veto_2 says it's vetoed, not vetod Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: David Disseldorp <ddiss@samba.org>
* smbd: Make "check_veto_path" staticVolker Lendecke2015-02-102-2/+1
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: David Disseldorp <ddiss@samba.org>
* s3:smb2_server: protect against integer wrap with "smb2 max credits = 65535"Stefan Metzmacher2015-01-291-0/+3
| | | | | | | | | | Bug: https://bugzilla.samba.org/show_bug.cgi?id=9702 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org> Autobuild-User(master): Stefan Metzmacher <metze@samba.org> Autobuild-Date(master): Thu Jan 29 14:58:40 CET 2015 on sn-devel-104
* s3:smb2_server: always try to grant the credits the client just consumedStefan Metzmacher2015-01-291-6/+2
| | | | | | | | | | | | | | | | | | | | | | | | | It turns out that the effective credits_requested is always at least 1, even if the client sends credits_requested == 0. This means the client is not able to reduce the amount of credits itself. Without this fix a client (e.g. Windows7) would reach the case where it has been granted all credits it asked for. When copying a large file with a lot of parallel requests, all these requests have credits_requested == 0. This means the amount of granted credits where reduced by each request and only when the granted credits reached 0, the server granted one credit to allow the client to go on. The client might require more than one credit ([MS-SMB2] says Windows clients require at least 4 credits) and freezes with just 1 credit. Bug: https://bugzilla.samba.org/show_bug.cgi?id=9702 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* smbd: Stop using vfs_Chdir after SMB_VFS_DISCONNECT.Ira Cooper2015-01-161-3/+3
| | | | | | | | | | | This sequencing is causing problems for vfs_ceph, and likely other vfs modules. Signed-off-by: Ira Cooper <ira@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Fri Jan 16 00:13:17 CET 2015 on sn-devel-104
* notify: Move path construction to notify_triggerVolker Lendecke2014-12-163-15/+20
| | | | | | | | | | | notify_msg won't need to construct the path anymore, it will be able to put the parts into iovecs Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Tue Dec 16 21:22:26 CET 2014 on sn-devel-104
* s3:smb2_server: allow reauthentication without signingStefan Metzmacher2014-12-122-5/+4
| | | | | | | | | | If signing is not required we should not require it for reauthentication. Windows clients would otherwise fail to reauthenticate. Bug: https://bugzilla.samba.org/show_bug.cgi?id=10958 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* notify_inotify: Simplify inotify_dispatchVolker Lendecke2014-12-091-15/+17
| | | | | | | | | | | | Normally, I'm trying to simplify things with early returns. But in this case I think the reverse makes the if-condition easier to understand Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Tue Dec 9 06:37:24 CET 2014 on sn-devel-104
* smbd: Compile notify_inotify only if availableVolker Lendecke2014-12-091-4/+0
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* notify_inotify: inotify_watch now takes a mem_ctxVolker Lendecke2014-12-092-3/+5
| | | | | | | This will make it easier to integrate into proper memory hierarchies. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* notify: Add "dir" to notify_eventVolker Lendecke2014-12-092-3/+9
| | | | | | | | | | | | | "notify_event" only reports names relative to some path that is only implicitly known via "private_data". Right now "private_data" is the fsp of the directory holding this notify. I want to use inotify_watch in a notify-daemon that does not have a fsp available and has more problems getting the path right out of "private_data". notify_inotify has the directory under which the event happened available, so make it known to the callback. Right now no caller uses it yet. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* notify_inotify: Make inotify_watch return 0/errnoVolker Lendecke2014-12-092-24/+24
| | | | | | | | More like a cleanup, but I want to use inotify_watch in notifyd that I would like to keep as light as possible Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* notify_inotify: Slightly simplify watch_destructorVolker Lendecke2014-12-091-8/+10
| | | | | | | Another case of an early return Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* notify_inotify: Slightly simplify inotify_watchVolker Lendecke2014-12-091-15/+13
| | | | | | | | | | tallocing first avoids having to call inotify_rm_watch This even fixes a real error: We share inotifies between different instances, so the rm_watch in the error paths destroys other legitimate watches Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* notify_inotify: Make inotify_setup return 0/errnoVolker Lendecke2014-12-091-10/+15
| | | | | | | This gets rid of one NT_STATUS_HAVE_NO_MEMORY with its implicit return; :-) Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* notify_inotify: Add a NULL checkVolker Lendecke2014-12-091-1/+8
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* notify_inotify: Simplify filter_matchVolker Lendecke2014-12-091-20/+19
| | | | | | | Early returns make code simpler Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* smbd: Move lp_parm_bool out of notify_inotify.cVolker Lendecke2014-12-091-4/+0
| | | | | | | | Notifyd should be as independent of Samba infrastructure as possible, and it will call notify_inotify Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* s3:locking: Change the data model for leases_db to cope with dynamic path ↵Jeremy Allison2014-12-092-38/+122
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | renames. interface leases_db { typedef [public] struct { GUID client_guid; smb2_lease_key lease_key; } leases_db_key; typedef [public] struct { file_id id; [string,charset(UTF8)] char *servicepath; [string,charset(UTF8)] char *base_name; [string,charset(UTF8)] char *stream_name; } leases_db_file; typedef [public] struct { uint32 num_files; [size_is(num_files)] leases_db_file files[]; } leases_db_value; } As designed by metze. Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Tue Dec 9 03:44:04 CET 2014 on sn-devel-104
* s3:locking: pass down servicepath to leases_db_add()Jeremy Allison2014-12-091-2/+5
| | | | | Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* smbd: Add missing include for iov_buflen().Andreas Schneider2014-12-081-0/+1
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>