summaryrefslogtreecommitdiff
path: root/source3/lib
Commit message (Collapse)AuthorAgeFilesLines
* s3:lib: factor out talloc_sub_advanced() from talloc_sub_full()Ralph Boehme2019-11-071-5/+23
| | | | | | | BUG: https://bugzilla.samba.org/show_bug.cgi?id=13745 Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* s3: rename talloc_sub_advanced() to talloc_sub_full()Ralph Boehme2019-11-071-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We currently have the following substitution functions: talloc_sub_basic() talloc_sub_advanced() talloc_sub_basic() currently substitutes a subset of talloc_sub_advanced(). We'll need a function X that only substitutes what talloc_sub_advanced() substitutes *without* what talloc_sub_basic() does. To get there rename talloc_sub_advanced() to talloc_sub_full(). A subsequent commit will then bring back talloc_sub_advanced() as described above. Examples with fictional replacement letters A and B. Currently: talloc_sub_basic: A talloc_sub_advanced: AB New: talloc_sub_basic: A talloc_sub_advanced: B talloc_sub_full: AB BUG: https://bugzilla.samba.org/show_bug.cgi?id=13745 Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* s3: remove unused function standard_sub_advanced()Ralph Boehme2019-11-071-16/+0
| | | | | | | BUG: https://bugzilla.samba.org/show_bug.cgi?id=13745 Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* lib: Avoid includes.h in g_lock.cVolker Lendecke2019-11-061-1/+5
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* lib: Remove g_lock_do()Volker Lendecke2019-11-061-64/+0
| | | | | | | | This puts too much logic into this lowlevel infrastructure module, given the two minor external users. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* g_lock: Avoid sys_random(), use generate_random()Volker Lendecke2019-11-061-2/+2
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* lib: Remove #define serverid_equal server_id_equalVolker Lendecke2019-11-061-3/+3
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* lib/adouble: pass filesize to ad_unpack()Ralph Boehme2019-10-301-1/+3
| | | | | | | | | | | | | | | | | ad_unpack() needs the filesize, not the capped IO size we're using in the caller to read up to "size" bystem from the ._ AppleDouble file. This fixes a regression introduced by bdc257a1cbac7e8c73a084b618ba642476807483 for bug 13968. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14171 RN: vfs_fruit returns capped resource fork length Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org> Autobuild-User(master): Ralph Böhme <slow@samba.org> Autobuild-Date(master): Wed Oct 30 14:52:34 UTC 2019 on sn-devel-184
* lib/adouble: drop ad_data reallocate logicRalph Boehme2019-10-301-23/+23
| | | | | | | | | | Simply set the buffer size to AD_XATTR_MAX_HDR_SIZE. When reading the AppleDouble file, read up to AD_XATTR_MAX_HDR_SIZE from the file. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14171 Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* lib/adouble: README.Coding fix: multi-line if expressionRalph Boehme2019-10-301-1/+2
| | | | | | | | | Also remove a TAB. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14171 Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* lib/adouble: fix a long lineRalph Boehme2019-10-301-1/+5
| | | | | | | BUG: https://bugzilla.samba.org/show_bug.cgi?id=14171 Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* s3: remove now unneeded call to cmdline_messaging_context()Ralph Boehme2019-10-241-7/+0
| | | | | | | | | | | | | | | This was only needed as dbwrap_open() had a bug where it asked for the ctdb connection before initializing messaging. The previous commit fixed that so we can now safely remove the calls to cmdline_messaging_context() from all tools that don't use messaging. Bug: https://bugzilla.samba.org/show_bug.cgi?id=13925 Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Thu Oct 24 09:33:47 UTC 2019 on sn-devel-184
* s3:dbwrap: initialize messaging before getting the ctdb connectionRalph Boehme2019-10-241-1/+7
| | | | | | | | | This is a better fix for bug #13465. Bug: https://bugzilla.samba.org/show_bug.cgi?id=13925 Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* s3:lib:wins fix a compile warning on Ubuntu 18.04Christian Ambach2019-10-231-1/+1
| | | | | | | | | | | | | | | | gcc version 7.4.0 (Ubuntu 7.4.0-1ubuntu1~18.04.1) with -O2 puts up a warning here: ../../source3/lib/wins_srv.c: In function ‘wins_srv_tags’: ../../source3/lib/wins_srv.c:235:3: error: assuming signed overflow does not occur when simplifying conditional to constant [-Werror=strict-overflow] for (j=0;j<count;j++) { ^~~ cc1: all warnings being treated as errors Signed-off-by: Christian Ambach <ambi@samba.org> Reviewed-by: Uri Simchoni <uri@samba.org> Autobuild-User(master): Uri Simchoni <uri@samba.org> Autobuild-Date(master): Wed Oct 23 04:57:09 UTC 2019 on sn-devel-184
* dbwrap_watch: Fix cleaning up dead watchersVolker Lendecke2019-10-181-0/+1
| | | | | | | | | | | "wrec->num_watchers" changes in dbwrap_watch_rec_del_watcher(). In 32d6cc84c I forgot to update the copy of that variable. 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): Fri Oct 18 22:28:07 UTC 2019 on sn-devel-184
* lib: Explicitly refuse to truncate unix domain socket pathsAndrew Bartlett2019-10-181-1/+12
| | | | | | | | | | | | | This avoids creating a socket like: .../winbindd_privileged/p instead of .../winbindd_privileged/pipe Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* s3/dump_core: Have a newline towards the end of log messageAnoop C S2019-10-181-1/+1
| | | | | | | | | Signed-off-by: Anoop C S <anoopcs@redhat.com> Reviewed-by: Andreas Schneider <asn@samba.org> Reviewed-by: Uri Simchoni <uri@samba.org> Autobuild-User(master): Uri Simchoni <uri@samba.org> Autobuild-Date(master): Fri Oct 18 08:54:04 UTC 2019 on sn-devel-184
* s3:libnet: Require sealed LDAP SASL connections for joiningAndreas Schneider2019-10-091-1/+4
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Alexander Bokovoy <ab@samba.org>
* s3: VFS: Add SMB_VFS_FCNTLAnoop C S2019-10-081-0/+14
| | | | | | Signed-off-by: Anoop C S <anoopcs@redhat.com> Reviewed-by: Ralph Boehme <slow@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* dbwrap_watch: Don't alert ourselves, fix raw.oplock.batch26 raceVolker Lendecke2019-10-021-2/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This fixes the following flaky test: UNEXPECTED(failure): samba3.raw.oplock.batch26(nt4_dc) REASON: Exception: Exception: (../../source4/torture/raw/oplock.c:3718): wrong value for break_info.count got 0x2 - should be 0x1 You can reproduce it with two small msleeps, which means it's a race condition: diff --git a/source3/smbd/open.c b/source3/smbd/open.c index 20b5a3e294c..126c7fc021d 100644 --- a/source3/smbd/open.c +++ b/source3/smbd/open.c @@ -1917,6 +1917,14 @@ NTSTATUS send_break_message(struct messaging_context *msg_ctx, DATA_BLOB blob; NTSTATUS status; + { + static bool sent = false; + if (sent) { + smb_msleep(500); + } + sent = true; + } + if (DEBUGLVL(10)) { struct server_id_buf buf; DBG_DEBUG("Sending break message to %s\n", diff --git a/source3/smbd/oplock.c b/source3/smbd/oplock.c index b3da84b1269..d9c4dbb9487 100644 --- a/source3/smbd/oplock.c +++ b/source3/smbd/oplock.c @@ -858,6 +858,8 @@ static void process_oplock_break_message(struct messaging_context *msg_ctx, uint16_t break_to; bool break_needed = true; + smb_msleep(100); + msg = talloc(talloc_tos(), struct oplock_break_message); if (msg == NULL) { DBG_WARNING("talloc failed\n"); 15a8af075a2 introduced a bug where we immediately wake up ourselves after doing a watch_send, leading to two inter-smbd oplock break messages for this case. In theory, this should not matter, as in the oplock break handler in the destination smbd we check (fsp->sent_oplock_break != NO_BREAK_SENT) so that the break does not get sent twice. However, with the above two sleeps the oplock holding client could send out its oplock downgrade while the second inter-smbd break messages was on its way. The real fix would be to note in the share mode array that the inter-smbd message has already been sent, but as other users of dbwrap_watched_watch_send might also be affected by this bug, this fix should be sufficient to get rid of this flaky test. Unfortunately, dbwrap_watch.c is now pretty complex and needs some serious refactoring to become understandable again. But that's something for another day, sorry. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* dbwrap_watch: Remove "addwatch" handling from dbwrap_watched_save()Volker Lendecke2019-10-021-28/+10
| | | | | | | This has been moved to dbwrap_watched_watch_send() Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* dbwrap_watch: Move reallocating watchers to dbwrap_watched_watch_send()Volker Lendecke2019-10-021-2/+19
| | | | | | | | | | | Before 15a8af075a2 we did not have a separately allocated watchers array and dbwrap_watched_save() could play (too) smart tricks with dbwrap_record_storev(). Now that we always have watchers talloc'ed, we can remove those smart tricks from dbwrap_watched_save() in the next commit. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* dbwrap_watch: Slightly simplify dbwrap_watched_fetch_locked()Volker Lendecke2019-10-021-4/+1
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* lib: Fix CID 1453985: Null pointer dereferences (FORWARD_NULL)Volker Lendecke2019-10-021-0/+1
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* s3:lib: add is_named_stream()Ralph Boehme2019-10-021-0/+26
| | | | | | | | | | | | | | | Add a new utility functions that checks whether a struct smb_filename points to a real named stream, excluding the default stream "::$DATA". foo -> false foo::$DATA -> false foo:bar -> true foo:bar:$DATA -> true BUG: https://bugzilla.samba.org/show_bug.cgi?id=14137 Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* s3:lib: use strequal_m() in is_ntfs_default_stream_smb_fname()Ralph Boehme2019-10-021-1/+1
| | | | | | | BUG: https://bugzilla.samba.org/show_bug.cgi?id=14137 Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* s3:lib: implement logic directly in is_ntfs_default_stream_smb_fname()Ralph Boehme2019-10-021-1/+3
| | | | | | | | | | This allows changing the semantics of is_ntfs_stream_smb_fname() in the next commit. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14137 Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* s3:lib: expand a comment with the function doc for is_ntfs_stream_smb_fnameRalph Boehme2019-10-021-1/+2
| | | | | Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* s3:lib: factor out stream name asserts to helper functionRalph Boehme2019-10-021-4/+10
| | | | | | | BUG: https://bugzilla.samba.org/show_bug.cgi?id=14137 Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* s3:lib: assert stream_name is NULL for POSIX pathsRalph Boehme2019-10-021-1/+1
| | | | | | | BUG: https://bugzilla.samba.org/show_bug.cgi?id=14137 Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* s3:lib: rework a return expression into an if blockRalph Boehme2019-10-021-1/+5
| | | | | | | | | Needed to add additional stuff after the if block in the next commit. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14137 Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* s3/lib/netapi: clang: Fix 'Value stored during initialization is never read'Noel Power2019-09-261-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | Fixes: source3/lib/netapi/user.c:1290:11: warning: Value stored to 'status' during its initialization is never read <--[clang] NTSTATUS status = NT_STATUS_OK; ^~~~~~ ~~~~~~~~~~~~ source3/lib/netapi/user.c:1610:11: warning: Value stored to 'status' during its initialization is never read <--[clang] NTSTATUS status = NT_STATUS_OK; ^~~~~~ ~~~~~~~~~~~~ source3/lib/netapi/user.c:2990:11: warning: Value stored to 'status' during its initialization is never read <--[clang] NTSTATUS status = NT_STATUS_OK; ^~~~~~ ~~~~~~~~~~~~ source3/lib/netapi/user.c:3184:11: warning: Value stored to 'status' during its initialization is never read <--[clang] NTSTATUS status = NT_STATUS_OK; ^~~~~~ ~~~~~~~~~~~~ source3/lib/netapi/user.c:3522:11: warning: Value stored to 'status' during its initialization is never read <--[clang] NTSTATUS status = NT_STATUS_OK; ^~~~~~ ~~~~~~~~~~~~ Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Jeremy Allison <jra@samba.org>
* s3/lib/netapi: clang: Fix 'Value stored during initialization is never read'Noel Power2019-09-261-1/+1
| | | | | | | | | | | | Fixes: source3/lib/netapi/getdc.c:173:11: warning: Value stored to 'status' during its initialization is never read <--[clang] NTSTATUS status = NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND; ^~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1 warning generated. Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Jeremy Allison <jra@samba.org>
* s3/lib/netapi: clang: Fix 'Value stored during initialization is never read'Noel Power2019-09-261-3/+3
| | | | | | | | | | | | | | | | | | | | | Fixes: source3/lib/netapi/group.c:1383:11: warning: Value stored to ' status' during its initialization is never read <--[clang] NTSTATUS status = NT_STATUS_OK; ^~~~~~ ~~~~~~~~~~~~ samba/source3/lib/netapi/group.c:1521:11: warning: Value stored to ' status' during its initialization is never read <--[clang] NTSTATUS status = NT_STATUS_OK; ^~~~~~ ~~~~~~~~~~~~ samba/source3/lib/netapi/group.c:1718:11: warning: Value stored to ' status' during its initialization is never read <--[clang] NTSTATUS status = NT_STATUS_OK; ^~~~~~ ~~~~~~~~~~~~ 3 warnings generated. Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Jeremy Allison <jra@samba.org>
* s3: lib: adouble: Add dirfsp to ad_convert_delete_adfile(). Use UNLINKAT ↵Jeremy Allison2019-09-261-5/+13
| | | | | | | instead of UNLINK. Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* s3: lib: adouble: Add struct files_struct *dirfsp parameter to ad_convert().Jeremy Allison2019-09-262-6/+8
| | | | | Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* messaging: Do POOL_USAGE via a socketVolker Lendecke2019-09-181-73/+62
| | | | | | | | | | | | | This makes debugging run-away processes much more efficient and even possible at all: If the pool-usage output is more than 256MB, the previous code could not realloc it and threw it away. Also, it is not helpful for an already huge process to allocate even more. 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): Wed Sep 18 21:27:30 UTC 2019 on sn-devel-184
* lib: Enable watching and storing dbwrap_watch records.Volker Lendecke2019-09-171-14/+55
| | | | | | | | | | | | Samba so far on a dbwrap_watch record either watches or stores a record, but never both from the same db_record instance acquired from a dbwrap_fetch_locked(). In one of the next commits this will change, we will watch a record and at the same time store data into it. This patch enables a watch_send() followed by a storev() by properly keeping the watchers around. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* util_sec.c: Move __thread variable to global scopeKhem Raj2019-09-171-8/+11
| | | | | | | | | | | | | | Make clang happy otherwise it complains about variable scope fixes source3/./lib/util_sec.c:470:4: error: '__thread' variables must have global storage } __thread cache; ^ Signed-off-by: Khem Raj <raj.khem@gmail.com> Reviewed-by: Matthias Dieter Wallnöfer <mdw@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* lib: Add "utok_string"Volker Lendecke2019-09-111-0/+29
| | | | | | | A terse, one-line unix token representation for debugging purposes Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* vfs: Use file_id_str_buf() in xattr_tdb_setattr()Volker Lendecke2019-09-101-2/+3
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* vfs: Use file_id_str_buf() in xattr_tdb_getattr()Volker Lendecke2019-09-101-2/+3
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* lib: Use file_id_str_buf() in file_id_string()Volker Lendecke2019-09-101-4/+2
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* lib: Add file_id_str_buf()Volker Lendecke2019-09-102-0/+18
| | | | | | | file_id_string() without talloc Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* lib: Properly #ifdef __LIB_FILE_ID_H__Volker Lendecke2019-09-101-0/+5
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* s3:lib: add update_stat_ex_from_saved_stat()Ralph Boehme2019-09-101-0/+20
| | | | | | | BUG: https://bugzilla.samba.org/show_bug.cgi?id=14121 Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* s3:lib: round itime to NTTIME resolution in make_file_id_from_itime()Ralph Boehme2019-09-101-0/+2
| | | | | | | | | | | | | | | | | | The rounding is needed because when a file is created via eg an SMB2 CREATE request, we need to calculate the correct File-ID for the QFID Create-Context or for a subsequent GETINFO SMB request on the same file-handle. Any later metadata request that received the File-ID will do so by going through dos_mode() -> ... -> parse_dos_attribute_blob(), where the File-ID will be calculated from the on-disk itime which has NTTIME resolution. As long as that is the only available itime backend, I'm rounding itime inside make_file_id_from_itime(), not in the callers. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14121 Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* s3/lib/ctdbd_conn: assert hdr following read/recvDavid Disseldorp2019-09-041-2/+6
| | | | | | | | | | | | | | | | ctdb_pkt_recv_recv() and ctdb_read_packet() give us a non-null hdr on success, so drop the error path check in favour of an assert. This fixes a regression in 3913b9a4088b83d6ed7f94d136a26ecfa7e16b35, where tevent_req_error() may be skipped in the ctdbd_parse_done() ctdb_pkt_recv_recv() error path. Reported-by: Stefan Metzmacher <metze@samba.org> Signed-off-by: David Disseldorp <ddiss@samba.org> Reviewed-by: Noel Power <npower@samba.org> Autobuild-User(master): Noel Power <npower@samba.org> Autobuild-Date(master): Wed Sep 4 14:20:16 UTC 2019 on sn-devel-184
* s3: smbd: Add sys_mknodat() wrapper call.Jeremy Allison2019-08-221-0/+15
| | | | | Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Ralph Böhme <slow@samba.org>
* tldap: Paged searches fail when they get to the endGarming Sam2019-08-011-1/+2
| | | | | | | | The normal case hit the goto label, and should have just returned. Signed-off-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> BUG: https://bugzilla.samba.org/show_bug.cgi?id=14029