summaryrefslogtreecommitdiff
path: root/source3/lib
Commit message (Collapse)AuthorAgeFilesLines
* lib: Fix a shutdown crash with "clustering = yes"Volker Lendecke2020-02-181-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | This is a bit confusing now, sorry for that: register_msg_pool_usage() in the ctdb case uses messaging_ctdb_register_tevent_context(), which talloc_reference()s the central struct messaging_ctdb_fde_ev of the messaging_ctdb_context. In messaging_reinit(), we talloc_free only one of those references and allocate a new messaging_ctdb_fde_ev. The remaining messaging_ctdb_fde_ev should have been deleted as well, but due to the second reference this does not happen. When doing the shutdown messaging_ctdb_fde_ev_destructor() is called twice, once on the properly reinitialized fde_ev, and once much later on the leftover one which references invalid data structures. By the way, this is not a problem with talloc_reference(), this would have happened with explicit refcounting too. Bug: https://bugzilla.samba.org/show_bug.cgi?id=14281 Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Stefan Metzmacher <metze@samba.org> Autobuild-User(master): Björn Baumbach <bb@sernet.de> Autobuild-Date(master): Tue Feb 18 13:05:53 UTC 2020 on sn-devel-184
* lib: Introduce messaging_context->per_process_talloc_ctxVolker Lendecke2020-02-181-29/+55
| | | | | | | | | | | | | Consolidate "msg_dgm_ref" and "msg_ctdb_ref": The only purpose of those pointers was to TALLOC_FREE() them in messaging_reinit(). We'll have a third entity to talloc_free() in the next commit, make that simpler. Bug: https://bugzilla.samba.org/show_bug.cgi?id=14281 Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* lib: Add a TALLOC_CTX to base register_msg_pool_usage() onVolker Lendecke2020-02-182-3/+4
| | | | | | | | | | Add a simple way to deactivate the registration Bug: https://bugzilla.samba.org/show_bug.cgi?id=14281 Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* lib: Simplify register_msg_pool_usage()Volker Lendecke2020-02-181-38/+19
| | | | | | | | | | | | We can do as much as we want in the filter. This gives us automatic retry, we don't have to do the messaging_filtered_read_send() over and over again Bug: https://bugzilla.samba.org/show_bug.cgi?id=14281 Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* dbwrap: Improve an error messageVolker Lendecke2020-02-101-2/+3
| | | | | | | Include the path where db_open() tried to find the ctdb socket Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* s3: lib: Now remote_machine is static, we can depend on it being non-NULL.Jeremy Allison2020-02-071-3/+1
| | | | | | | | Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Fri Feb 7 18:26:15 UTC 2020 on sn-devel-184
* s3:lib: Remove unneded call to set_local_machine_name()Andreas Schneider2020-02-071-2/+0
| | | | | | | We return the netbios name by default if not set. Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* s3:lib: Use a static buffer for (local|remote)_machineAndreas Schneider2020-02-072-44/+23
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* s3/lib: RIP smb_user_nameRalph Boehme2020-02-061-72/+0
| | | | | | | This has been replaced in previous commits by consistently using current_user_info.smb_name. Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* s3/lib: use talloc_alpha_strcpy() in sub_set_smb_name()Ralph Boehme2020-02-061-10/+5
| | | | Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* s3/lib: use talloc_alpha_strcpy() in set_remote_machine_name()Ralph Boehme2020-02-061-9/+4
| | | | Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* s3/lib: use talloc_alpha_strcpy() in set_local_machine_name()Ralph Boehme2020-02-061-8/+4
| | | | Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* lib: Align integer typesVolker Lendecke2020-01-301-2/+1
| | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* dbwrap: Do direct struct initalization in db_ctdb_store_db_seqnum()Volker Lendecke2020-01-231-8/+2
| | | | | | | Save a few lines Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* s3: lib: dbwrap_ctdb: Ensure value_valid is set when creating empty recordMartin Schwenke2020-01-201-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixes: PANIC: assert failed at ../../lib/dbwrap/dbwrap.c(82): rec->value_valid PANIC (pid 902392): assert failed: rec->value_valid BACKTRACE: 16 stack frames: #0 bin/shared/libsamba-util.so.0(log_stack_trace+0x30) [0x7fb161f69cb0] #1 bin/shared/libsmbconf.so.0(smb_panic_s3+0x23) [0x7fb1619f4863] #2 bin/shared/libsamba-util.so.0(smb_panic+0x2f) [0x7fb161f69daf] #3 bin/shared/private/libdbwrap-samba4.so(dbwrap_record_get_value+0x27) [0x7fb160a04c57] #4 bin/shared/libsamba-passdb.so.0(+0x2d27c) [0x7fb1618e627c] #5 bin/shared/libsamba-passdb.so.0(pdb_add_aliasmem+0x33) [0x7fb1618db663] #6 bin/shared/libsamba-passdb.so.0(+0x1edbb) [0x7fb1618d7dbb] #7 bin/shared/libsamba-passdb.so.0(create_builtin_administrators+0x167) [0x7fb1618d8217] #8 bin/shared/private/libauth-samba4.so(finalize_local_nt_token+0x39d) [0x7fb16194bd5d] #9 bin/shared/private/libauth-samba4.so(create_local_nt_token_from_info3+0x304) [0x7fb16194c3f4] #10 bin/shared/private/libauth-samba4.so(create_local_token+0x3d6) [0x7fb161945106] #11 bin/shared/private/libauth-samba4.so(+0x154b4) [0x7fb1619474b4] #12 bin/shared/private/libauth-samba4.so(init_guest_session_info+0x58) [0x7fb161947798] #13 ./bin/smbd(main+0x80f) [0x55944ef8f91f] #14 /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xeb) [0x7fb161076bbb] #15 ./bin/smbd(_start+0x2a) [0x55944ef90f8a] This is a similar, additional fix to commit 36ea1e188d5ea8d40c47ffc466a494c1160e471c. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Jeremy Allison <jra@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Mon Jan 20 04:25:57 UTC 2020 on sn-devel-184
* lib: Use closefrom() in smbrun.cVolker Lendecke2020-01-191-12/+2
| | | | | | | INSURE is never defined or used. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* lib: Align integer typesVolker Lendecke2020-01-191-2/+2
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* lib: Avoid an unnecessary includeVolker Lendecke2020-01-141-1/+0
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* lib: Remove "msg_ctx" from server_id_watch_send()Volker Lendecke2020-01-143-5/+1
| | | | | | | Not needed Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* lib: Use tevent version of timeval_current_ofs()Volker Lendecke2020-01-141-3/+4
| | | | | | | We have tevent available anyway, use that infrastructure Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* s3: lib: dbwrap. Cleanup. Add a couple of missing 'return NULL' statements ↵Jeremy Allison2020-01-131-0/+2
| | | | | | | on talloc fail. Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
* s3: lib: dbwrap_ctdb: Ensure value_valid is set true if we find the record ↵Jeremy Allison2020-01-131-0/+1
| | | | | | | | | in the marshall buffer. Found by "Christopher O Cowan - Christopher.O.Cowan@ibm.com" <Christopher.O.Cowan@ibm.com> Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
* s3: lib: dbwrap: Set rec->value_valid to avoid backtrace in `smbstatus`Anoop C S2020-01-081-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Following backtrace is observed on executing `smbstatus` with at least one SMB client connection established: PANIC: assert failed at ../../lib/dbwrap/dbwrap.c(82): rec->value_valid PANIC (pid 350270): assert failed: rec->value_valid BACKTRACE: 15 stack frames: #0 /usr/local/lib/libsamba-util.so.0(log_stack_trace+0x1f) [0x7fbbd9b32047] #1 /usr/local/lib/libsmbconf.so.0(smb_panic_s3+0x74) [0x7fbbd9c1e6ff] #2 /usr/local/lib/libsamba-util.so.0(smb_panic+0x28) [0x7fbbd9b32012] #3 /usr/local/lib/samba/libdbwrap- samba4.so(dbwrap_record_get_value+0x86) [0x7fbbd95800ac] #4 /usr/local/lib/samba/libsmbd-base-samba4.so(+0x28f563) [0x7fbbd999e563] #5 /usr/local/lib/samba/libsamba-cluster-support-samba4.so(+0x7851) [0x7fbbd92c7851] #6 /usr/local/lib/samba/libsamba-cluster-support- samba4.so(ctdbd_traverse+0x4ca) [0x7fbbd92cc641] #7 /usr/local/lib/samba/libsamba-cluster-support-samba4.so(+0x73eb) [0x7fbbd92c73eb] #8 /usr/local/lib/samba/libsamba-cluster-support-samba4.so(+0x7a52) [0x7fbbd92c7a52] #9 /usr/local/lib/samba/libdbwrap-samba4.so(dbwrap_traverse_read+0x35) [0x7fbbd9580de5] #10 /usr/local/lib/samba/libsmbd-base- samba4.so(smbXsrv_tcon_global_traverse+0xc5) [0x7fbbd999e7d9] #11 smbstatus(connections_forall_read+0x114) [0x55d17872b8ee] #12 smbstatus(main+0x7b2) [0x55d17872a2f3] #13 /lib64/libc.so.6(__libc_start_main+0xf3) [0x7fbbd93a21a3] #14 smbstatus(_start+0x2e) [0x55d17872894e] Can not dump core: corepath not set up Assertion on rec->value_valid fails as it is uninitialized in the following functions: traverse_read_callback traverse_persistent_callback_read Signed-off-by: Anoop C S <anoopcs@redhat.com> Reviewed-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 Jan 8 23:24:58 UTC 2020 on sn-devel-184
* system: Rename argument for kernel_flock functionChristof Schmitt2020-01-081-4/+4
| | | | | | | | MS-SMB2 and the smbd code refer to this field as share_access. Use the same name in the function argument. Signed-off-by: Christof Schmitt <cs@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* lib: Fix contending with a READ lockVolker Lendecke2019-12-221-0/+2
| | | | | | | | | | | | | | | When contending a WRITE with an existing READ, the contender puts himself into the exclusive slot, waiting for the READers to go away. If the async lock request is canceled before we got the lock, we need to remove ourselves again. This is done in the destructor of the g_lock_lock_state. In the successful case, the destructor needs to go away. 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): Sun Dec 22 18:57:17 UTC 2019 on sn-devel-184
* s3:lib: Move NULL check before messaging_dgm_out_rearm_idle_timer()Andreas Schneider2019-12-101-1/+1
| | | | | | | | | | We dereference out in messaging_dgm_out_rearm_idle_timer(). Found by covscan. Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Richard Sharpe <realrichardsharpe@gmail.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* s3:lib: use nt_time_to_full_timespec() in interpret_long_date()Ralph Boehme2019-12-061-1/+1
| | | | | | | | | | interpret_long_date() is now only used in the client. To enable correct processing of dates before the UNIX epoch, call nt_time_to_full_timespec(). BUG: https://bugzilla.samba.org/show_bug.cgi?id=7771 Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* s3:lib: add pull_long_date_full_timespec()Ralph Boehme2019-12-061-0/+7
| | | | | | | BUG: https://bugzilla.samba.org/show_bug.cgi?id=7771 Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* s3:lib: add put_long_date_full_timespec()Ralph Boehme2019-12-061-0/+12
| | | | | | | | | | | | put_long_date_full_timespec() will be used in the fileserver to marshall struct timespec timestamps that are sent to the client. By using full_timespec_to_nt_time() which supports tv_sec=0 and negative values, we can return timestamps to clients with a date before the UNIX epoch. BUG: https://bugzilla.samba.org/show_bug.cgi?id=7771 Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* s3:lib: let round_timespec() handle SAMBA_UTIME_OMITRalph Boehme2019-12-061-0/+4
| | | | | | | | | | This ensures callers are not required to do the check themselves and we don't clobber omit-timespecs in this function. BUG: https://bugzilla.samba.org/show_bug.cgi?id=7771 Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* s3:lib: remove unused uint64s_nt_time_to_unix_abs()Ralph Boehme2019-12-061-7/+0
| | | | | Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* lib: Remove unused smb_xvasprintf()Volker Lendecke2019-12-021-19/+0
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Martin Schwenke <martins@samba.org>
* smbdotconf: mark "ldap suffix" with constant="1"Ralph Boehme2019-11-271-1/+1
| | | | | | | | | Due to the use of append_ldap_suffix() where Globals.ldap_suffix was used directly in the dependent options like "ldap group suffix", we can just mark this option as const thereby removing substitution from "ldap suffix". Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* smbdotconf: mark "set quota command" with substitution="1"Ralph Boehme2019-11-271-1/+3
| | | | | Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* smbdotconf: mark "server string" with substitution="1"Ralph Boehme2019-11-271-2/+6
| | | | | Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* smbdotconf: mark "panic action" with substitution="1"Ralph Boehme2019-11-271-1/+3
| | | | | Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* smbdotconf: mark "logfile" with substitution="1"Ralph Boehme2019-11-271-1/+3
| | | | | Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* smbdotconf: mark "homedir map" with substitution="1"Ralph Boehme2019-11-271-2/+6
| | | | | Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* s3:lib: add missing TALLOC_CTX parameter in call to lp_homedir_map()Ralph Boehme2019-11-271-1/+1
| | | | | | | | This seems to be dead (at least dying) code, is WITH_NISPLUS_HOME ever defined? Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* smbdotconf: mark "get quota command" with substitution="1"Ralph Boehme2019-11-271-1/+3
| | | | | Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* param: add FN_{GLOBAL,LOCAL}_SUBSTITUTED_STRING supportStefan Metzmacher2019-11-271-0/+1
| | | | | | | Pair-Programmed-With: Ralph Boehme <slow@samba.org> Signed-off-by: Stefan Metzmacher <metze@samba.org> Signed-off-by: Ralph Boehme <slow@samba.org>
* s3:lib: remove unused str_list_substitute()Stefan Metzmacher2019-11-271-74/+0
| | | | | Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* s3:lib: remove unused str_list_sub_basic()Stefan Metzmacher2019-11-271-29/+0
| | | | | Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* sharesec: Return NTSTATUS from delete_share_securityChristof Schmitt2019-11-261-7/+7
| | | | | Signed-off-by: Christof Schmitt <cs@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* sharesec: Return NTSTATUS from set_share_securityChristof Schmitt2019-11-261-5/+7
| | | | | Signed-off-by: Christof Schmitt <cs@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* sharesec: Return NTSTATUS from share_info_db_initChristof Schmitt2019-11-261-14/+24
| | | | | Signed-off-by: Christof Schmitt <cs@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* g_lock: Speed up sync g_lock_lock()Volker Lendecke2019-11-261-2/+86
| | | | | | | | The comment "this is used in very hot code paths" is not true right now, but will get true soon.... Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* g_lock: Move a variable inside the block were it's usedVolker Lendecke2019-11-261-2/+1
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* g_lock: Factor out g_lock_cleanup_shared()Volker Lendecke2019-11-261-27/+29
| | | | | | | This function will find a second user soon Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* lib: Change the g_lock data modelVolker Lendecke2019-11-221-247/+398
| | | | | | | | | | | | | | | | | | | | Now we have one fixed field for the exclusive lock holder and an array of shared locks. This way we now prioritize writers over readers: If a pending write comes in while readers are active, it will put itself into the exclusive slot. Then it waits for the readers to vanish. Only when all readers are gone the exclusive lock request is granted. New readers will just look at the exclusive slot and see it's taken. They will then line up as watchers, retrying whenever things change. This also means that it will be cheaper to support many shared locks: Granting a shared lock just means to extend the array. We don't have to walk the array for possible conflicts. This also adds explicit UPGRADE and DOWNGRADE operations for better error checking. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>