samba.git
5 years agosmbd: call chdir_current_service() in change_to_user_internal() and pop_conn_ctx()
Stefan Metzmacher [Wed, 13 Jun 2018 11:30:33 +0000 (13:30 +0200)]
smbd: call chdir_current_service() in change_to_user_internal() and pop_conn_ctx()

change_to_user() should be the one and only function for the whole
impersonation processing. So we also need to stack the
chdir_current_service() behaviour for become_user/unbecome_user,
so we may need to call vfs_ChDir(ctx_p->conn, ctx_p->conn->cwd_fname);
in pop_conn_ctx().

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 years agosmbd: remove set_current_service() from smbd_smb2_request_check_tcon()
Stefan Metzmacher [Thu, 14 Jun 2018 06:29:45 +0000 (08:29 +0200)]
smbd: remove set_current_service() from smbd_smb2_request_check_tcon()

The change_to_user() above already called chdir_current_service().
And for smb2 we don't have per packet conn->case_sensitive anyway.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 years agosmbd: remove set_current_service() from defer_rename_done()
Stefan Metzmacher [Thu, 14 Jun 2018 06:29:45 +0000 (08:29 +0200)]
smbd: remove set_current_service() from defer_rename_done()

The change_to_user() above already called chdir_current_service().
And for smb2 we don't have per packet conn->case_sensitive anyway.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 years agosmbd: call chdir_current_service() directly in smbXsrv_tcon_disconnect()
Stefan Metzmacher [Thu, 14 Jun 2018 06:27:50 +0000 (08:27 +0200)]
smbd: call chdir_current_service() directly in smbXsrv_tcon_disconnect()

There's no need to worry about conn->case_sensitive here.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 years agosmbd: remove useless set_current_service(NULL,0,True) from reload_services()
Stefan Metzmacher [Thu, 14 Jun 2018 06:23:56 +0000 (08:23 +0200)]
smbd: remove useless set_current_service(NULL,0,True) from reload_services()

All this does is 'return false' as conn is NULL...

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 years agosmbd: use conn->lastused_count++ directly in process_blocking_lock_queue()
Stefan Metzmacher [Thu, 14 Jun 2018 06:21:21 +0000 (08:21 +0200)]
smbd: use conn->lastused_count++ directly in process_blocking_lock_queue()

This avoids using set_current_service(), which will be removed shortly.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 years agosmbd: let create_conn_struct_as_root() fill in conn->origpath
Stefan Metzmacher [Fri, 15 Jun 2018 16:40:11 +0000 (18:40 +0200)]
smbd: let create_conn_struct_as_root() fill in conn->origpath

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 years agosmbd: make it possible to call vfs_ChDir(conn, conn->cwd_fname);
Stefan Metzmacher [Fri, 15 Jun 2018 09:49:57 +0000 (11:49 +0200)]
smbd: make it possible to call vfs_ChDir(conn, conn->cwd_fname);

We should only TALLOC_FREE(old_cwd) at the successful end.
This also avoids calling cp_smb_filename() on the old value.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 years agosmbd: call set_current_case_sensitive() before change_to_user() in switch_message()
Stefan Metzmacher [Thu, 14 Jun 2018 09:15:10 +0000 (11:15 +0200)]
smbd: call set_current_case_sensitive() before change_to_user() in switch_message()

change_to_user() will soon call chdir_current_service() and we should
make sure conn->case_sensitive is prepared before calling vfs_ChDir().

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 years agosmbd: remember that the tcon completely setup connection_struct
Stefan Metzmacher [Thu, 14 Jun 2018 05:27:43 +0000 (07:27 +0200)]
smbd: remember that the tcon completely setup connection_struct

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 years agosmbd: make it explicit that make_connection_snum() returns NT_STATUS_OK on success
Stefan Metzmacher [Thu, 14 Jun 2018 05:26:14 +0000 (07:26 +0200)]
smbd: make it explicit that make_connection_snum() returns NT_STATUS_OK on success

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 years agosmbd: call set_current_user_info() in change_to_user_internal() and pop_conn_ctx()
Stefan Metzmacher [Fri, 25 May 2018 12:22:43 +0000 (14:22 +0200)]
smbd: call set_current_user_info() in change_to_user_internal() and pop_conn_ctx()

change_to_user() should be the one and only function for the whole
impersonation processing. So we also need to stack the
set_current_user_info() information for become_user/unbecome_user.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 years agosmbd: move current_user caching to change_to_user_internal()
Stefan Metzmacher [Tue, 12 Jun 2018 13:39:51 +0000 (15:39 +0200)]
smbd: move current_user caching to change_to_user_internal()

Note that (current_user.vuid == vuid) also works with
UID_FIELD_INVALID.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 years agosmbd: simplify the logic in change_to_user()
Stefan Metzmacher [Tue, 12 Jun 2018 13:39:51 +0000 (15:39 +0200)]
smbd: simplify the logic in change_to_user()

We can return early if (vuser == NULL).

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 years agosmbd: let check_user_ok() construct ent->session_info in one coherent block
Stefan Metzmacher [Thu, 3 May 2018 13:04:30 +0000 (15:04 +0200)]
smbd: let check_user_ok() construct ent->session_info in one coherent block

We should finish manipulating ent->session_info before filling
conn->session_info. And conn->session_info should be not be changed.

Use git show -U15.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 years agosmbd: call set_current_case_sensitive() before chdir_current_service()
Stefan Metzmacher [Wed, 13 Jun 2018 09:23:42 +0000 (11:23 +0200)]
smbd: call set_current_case_sensitive() before chdir_current_service()

I guess we better setup conn->case_sensitive before doing the
vfs_ChDir() calls, so we have a consistent result everytime.
Otherwise vfs_Chdir() would get conn->case_sensitive from
last request.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 years agosmbd: split out set_current_case_sensitive() and chdir_current_service() functions
Stefan Metzmacher [Wed, 13 Jun 2018 09:03:01 +0000 (11:03 +0200)]
smbd: split out set_current_case_sensitive() and chdir_current_service() functions

We'll soon use them independend from set_current_service().

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 years agosmbd: remove xconn->client->last_session_id based set_current_user_info() caching
Stefan Metzmacher [Fri, 25 May 2018 11:58:04 +0000 (13:58 +0200)]
smbd: remove xconn->client->last_session_id based set_current_user_info() caching

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 years agos3:lib: add caching to set_current_user_info()
Stefan Metzmacher [Fri, 25 May 2018 11:40:12 +0000 (13:40 +0200)]
s3:lib: add caching to set_current_user_info()

Currently we do that in the caller, but we use global
cache anyway, so we can simplify the callers.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 years agos4-dsdb: fix the build of audit_util.c
Günther Deschner [Tue, 12 Jun 2018 10:54:15 +0000 (12:54 +0200)]
s4-dsdb: fix the build of audit_util.c

Guenther

Signed-off-by: Guenther Deschner <gd@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Sat Jun 16 11:56:53 CEST 2018 on sn-devel-144

5 years agoaddns: Fix a typo
Volker Lendecke [Fri, 15 Jun 2018 12:56:57 +0000 (14:56 +0200)]
addns: Fix a typo

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): Sat Jun 16 04:21:18 CEST 2018 on sn-devel-144

5 years agodsdb: Fix a typo
Volker Lendecke [Thu, 14 Jun 2018 14:47:26 +0000 (16:47 +0200)]
dsdb: Fix a typo

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
5 years agowinbindd: Fix winbindd_ping_dc_recv
Volker Lendecke [Sat, 19 May 2018 16:40:44 +0000 (18:40 +0200)]
winbindd: Fix winbindd_ping_dc_recv

tevent_req_simple_recv_ntstatus is only for the one-liner without any
additional functionality.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
5 years agowinbindd: Add a missing NULL check
Volker Lendecke [Sat, 19 May 2018 16:39:36 +0000 (18:39 +0200)]
winbindd: Add a missing NULL check

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
5 years agowinbindd: Do an early TALLOC_FREE
Volker Lendecke [Sat, 19 May 2018 16:31:17 +0000 (18:31 +0200)]
winbindd: Do an early TALLOC_FREE

Leave the if-block without leaking

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
5 years agowinbindd: Use is_domain_offline() where appropriate
Volker Lendecke [Fri, 18 May 2018 14:15:06 +0000 (16:15 +0200)]
winbindd: Use is_domain_offline() where appropriate

That if-condition is precisely covered by the helper routine

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
5 years agowinbindd: Align integer types in for loops
Volker Lendecke [Fri, 18 May 2018 12:47:24 +0000 (14:47 +0200)]
winbindd: Align integer types in for loops

Iterate over the same type as the loop limit

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
5 years agoPossible memory leak in map_info6_to_validation
Swen Schillig [Fri, 25 May 2018 08:06:21 +0000 (10:06 +0200)]
Possible memory leak in map_info6_to_validation

If the call to copy_netr_SamInfo6 returns an error status,
the allocated memory for "validation" needs to be free'd before returning.

Signed-off-by: Swen Schillig <swen@vnet.ibm.com>
Reviewed-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Christof Schmitt <cs@samba.org>
5 years agoFix several mem leaks in ldb_index ldb_search ldb_tdb
Andrej Gessel [Thu, 14 Jun 2018 10:19:29 +0000 (12:19 +0200)]
Fix several mem leaks in ldb_index ldb_search ldb_tdb

BUG: https://bugzilla.samba.org/show_bug.cgi?id=13475

Signed-off-by: Andrej Gessel <Andrej.Gessel@janztec.com>
Reviewed-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Fri Jun 15 23:07:25 CEST 2018 on sn-devel-144

5 years agoldb_tdb: Use mem_ctx and so avoid leak onto long-term memory on duplicated add.
Andrew Bartlett [Wed, 13 Jun 2018 09:20:00 +0000 (11:20 +0200)]
ldb_tdb: Use mem_ctx and so avoid leak onto long-term memory on duplicated add.

After a duplicated add a small amount of memory can be leaked onto a
long-term context.

Found by Andrej Gessel https://github.com/andiges

https://github.com/samba-team/samba/commit/e8fb45125e6a279b918694668e0d4fbddac10aee#commitcomment-29334102

BUG: https://bugzilla.samba.org/show_bug.cgi?id=13471
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Fri Jun 15 04:39:41 CEST 2018 on sn-devel-144

5 years agosmbd: don't call change_to_root_user() before change_to_guest()
Stefan Metzmacher [Wed, 23 May 2018 12:26:37 +0000 (14:26 +0200)]
smbd: don't call change_to_root_user() before change_to_guest()

This is just an optimization and it makes it clearer
that calling change_to_root_user() just before change_to_guest()
is useless and confusing.

We call change_to_guest() before set_current_service() now,
but that has no impact as we pass 'do_chdir=false'
as AS_GUEST is never mixed with AS_USER or DO_CHDIR.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Thu Jun 14 23:38:55 CEST 2018 on sn-devel-144

5 years agosmbd: remove useless allow_access() check for AS_GUEST
Stefan Metzmacher [Wed, 23 May 2018 12:23:17 +0000 (14:23 +0200)]
smbd: remove useless allow_access() check for AS_GUEST

We already call allow_access() when we accept the connection
in smbd_add_connection().

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
5 years agosmbd: split out a fsp_flush_write_time_update() function from update_write_time_handler()
Stefan Metzmacher [Wed, 23 May 2018 07:41:29 +0000 (09:41 +0200)]
smbd: split out a fsp_flush_write_time_update() function from update_write_time_handler()

It's confusing to call update_write_time_handler() from anywhere,
it should only be called from within the event loop when the
timer expires.

This makes it more obvious that fsp_flush_write_time_update()
doesn't really need an tevent context argument.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
5 years agosmbd: make smbd_setup_sig_{term,hup}_handler() static
Stefan Metzmacher [Thu, 24 May 2018 07:49:40 +0000 (09:49 +0200)]
smbd: make smbd_setup_sig_{term,hup}_handler() static

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
5 years agovfs_glusterfs: use tevent_req_defer_callback() in order to use the correct event...
Stefan Metzmacher [Wed, 23 May 2018 06:53:47 +0000 (08:53 +0200)]
vfs_glusterfs: use tevent_req_defer_callback() in order to use the correct event context

The callback and _recv() functions should be called from the same
event context that was passed to the _send() function.

In future the completion pipe should be replaced by
tevent_threaded_context_create()

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
5 years agosmbd: call samba_tevent_context_init() within create_conn_struct_as_root()
Stefan Metzmacher [Fri, 25 May 2018 06:49:29 +0000 (08:49 +0200)]
smbd: call samba_tevent_context_init() within create_conn_struct_as_root()

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
5 years agosmbd: use pconn = talloc_move(ctx, &conn) in create_conn_struct_as_root()
Stefan Metzmacher [Fri, 25 May 2018 06:49:29 +0000 (08:49 +0200)]
smbd: use pconn = talloc_move(ctx, &conn) in create_conn_struct_as_root()

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
5 years agosmbd: remove unused create_conn_struct() function
Stefan Metzmacher [Fri, 25 May 2018 06:49:29 +0000 (08:49 +0200)]
smbd: remove unused create_conn_struct() function

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
5 years agosmbd: let create_conn_struct_tos() use create_conn_struct_as_root() directly
Stefan Metzmacher [Fri, 25 May 2018 06:49:29 +0000 (08:49 +0200)]
smbd: let create_conn_struct_tos() use create_conn_struct_as_root() directly

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
5 years agovfstest: make use of create_conn_struct_tos()
Stefan Metzmacher [Fri, 25 May 2018 06:49:29 +0000 (08:49 +0200)]
vfstest: make use of create_conn_struct_tos()

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
5 years agosmbd: remove unused create_conn_struct_cwd() function
Stefan Metzmacher [Fri, 25 May 2018 06:49:29 +0000 (08:49 +0200)]
smbd: remove unused create_conn_struct_cwd() function

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
5 years agoprinting: convert delete_driver_files() to use create_conn_struct_tos_cwd()
Stefan Metzmacher [Thu, 24 May 2018 15:55:02 +0000 (17:55 +0200)]
printing: convert delete_driver_files() to use create_conn_struct_tos_cwd()

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
5 years agoprinting: convert move_driver_to_download_area() to use create_conn_struct_tos_cwd()
Stefan Metzmacher [Thu, 24 May 2018 15:55:02 +0000 (17:55 +0200)]
printing: convert move_driver_to_download_area() to use create_conn_struct_tos_cwd()

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
5 years agoprinting: convert get_correct_cversion() to use create_conn_struct_tos_cwd()
Stefan Metzmacher [Thu, 24 May 2018 15:55:02 +0000 (17:55 +0200)]
printing: convert get_correct_cversion() to use create_conn_struct_tos_cwd()

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
5 years agoprinting: add an explicit talloc_stackframe() to delete_driver_files()
Stefan Metzmacher [Thu, 24 May 2018 15:40:27 +0000 (17:40 +0200)]
printing: add an explicit talloc_stackframe() to delete_driver_files()

This makes further changes simpler.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
5 years agoprinting: add an explicit talloc_stackframe() to move_driver_to_download_area()
Stefan Metzmacher [Thu, 24 May 2018 15:40:27 +0000 (17:40 +0200)]
printing: add an explicit talloc_stackframe() to move_driver_to_download_area()

This makes further changes simpler.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
5 years agoprinting: add an explicit talloc_stackframe() to get_correct_cversion()
Stefan Metzmacher [Thu, 24 May 2018 15:40:27 +0000 (17:40 +0200)]
printing: add an explicit talloc_stackframe() to get_correct_cversion()

This makes further changes simpler.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
5 years agoprinting: add more 'const' to read only input pointers
Stefan Metzmacher [Thu, 24 May 2018 15:40:27 +0000 (17:40 +0200)]
printing: add more 'const' to read only input pointers

This makes it clearer that they won't be changed.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
5 years agos3:rpc_server/srvsvc: _srvsvc_NetSetFileSecurity form_junctions() to use create_conn_...
Stefan Metzmacher [Thu, 24 May 2018 15:55:02 +0000 (17:55 +0200)]
s3:rpc_server/srvsvc: _srvsvc_NetSetFileSecurity form_junctions() to use create_conn_struct_tos_cwd()

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
5 years agos3:rpc_server/srvsvc: _srvsvc_NetGetFileSecurity() to use create_conn_struct_tos_cwd()
Stefan Metzmacher [Thu, 24 May 2018 15:55:02 +0000 (17:55 +0200)]
s3:rpc_server/srvsvc: _srvsvc_NetGetFileSecurity() to use create_conn_struct_tos_cwd()

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
5 years agos3:rpc_server/srvsvc: add an explicit talloc_stackframe() to _srvsvc_NetSetFileSecurity()
Stefan Metzmacher [Thu, 24 May 2018 15:40:27 +0000 (17:40 +0200)]
s3:rpc_server/srvsvc: add an explicit talloc_stackframe() to _srvsvc_NetSetFileSecurity()

This makes further changes simpler.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
5 years agos3:rpc_server/srvsvc: add an explicit talloc_stackframe() to _srvsvc_NetGetFileSecurity()
Stefan Metzmacher [Thu, 24 May 2018 15:40:27 +0000 (17:40 +0200)]
s3:rpc_server/srvsvc: add an explicit talloc_stackframe() to _srvsvc_NetGetFileSecurity()

This makes further changes simpler.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
5 years agosmbd: convert form_junctions() to use create_conn_struct_tos_cwd()
Stefan Metzmacher [Thu, 24 May 2018 15:55:02 +0000 (17:55 +0200)]
smbd: convert form_junctions() to use create_conn_struct_tos_cwd()

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
5 years agosmbd: convert count_dfs_links() to use create_conn_struct_tos_cwd()
Stefan Metzmacher [Thu, 24 May 2018 15:55:02 +0000 (17:55 +0200)]
smbd: convert count_dfs_links() to use create_conn_struct_tos_cwd()

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
5 years agosmbd: convert get_referred_path() to use create_conn_struct_tos_cwd()
Stefan Metzmacher [Thu, 24 May 2018 15:55:02 +0000 (17:55 +0200)]
smbd: convert get_referred_path() to use create_conn_struct_tos_cwd()

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
5 years agosmbd: convert junction_to_local_path() to use create_conn_struct_tos_cwd()
Stefan Metzmacher [Thu, 24 May 2018 15:55:02 +0000 (17:55 +0200)]
smbd: convert junction_to_local_path() to use create_conn_struct_tos_cwd()

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
5 years agosmbd: add an explicit talloc_stackframe() to form_junctions()
Stefan Metzmacher [Thu, 24 May 2018 15:40:27 +0000 (17:40 +0200)]
smbd: add an explicit talloc_stackframe() to form_junctions()

This makes further changes simpler.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
5 years agosmbd: add an explicit talloc_stackframe() to count_dfs_links()
Stefan Metzmacher [Thu, 24 May 2018 15:40:27 +0000 (17:40 +0200)]
smbd: add an explicit talloc_stackframe() to count_dfs_links()

This makes further changes simpler.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
5 years agosmbd: add an explicit talloc_stackframe() to get_referred_path()
Stefan Metzmacher [Thu, 24 May 2018 15:40:27 +0000 (17:40 +0200)]
smbd: add an explicit talloc_stackframe() to get_referred_path()

This makes further changes simpler.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
5 years agosmbd: add an explicit talloc_stackframe() to {create,remove}_msdfs_link()
Stefan Metzmacher [Thu, 24 May 2018 15:40:27 +0000 (17:40 +0200)]
smbd: add an explicit talloc_stackframe() to {create,remove}_msdfs_link()

This makes further changes simpler.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
5 years agos3:rpc_server/fss: make use of create_conn_struct_tos()
Stefan Metzmacher [Thu, 24 May 2018 15:34:18 +0000 (17:34 +0200)]
s3:rpc_server/fss: make use of create_conn_struct_tos()

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
5 years agos3:rpc_server/fss: use talloc_stackframe() for temporary memory
Stefan Metzmacher [Thu, 24 May 2018 14:41:32 +0000 (16:41 +0200)]
s3:rpc_server/fss: use talloc_stackframe() for temporary memory

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
5 years agosmbd: make use of create_conn_struct_tos() in get_nt_acl_no_snum()
Stefan Metzmacher [Thu, 24 May 2018 14:34:04 +0000 (16:34 +0200)]
smbd: make use of create_conn_struct_tos() in get_nt_acl_no_snum()

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
5 years agopysmbd: make use of create_conn_struct_tos()
Stefan Metzmacher [Thu, 24 May 2018 14:16:19 +0000 (16:16 +0200)]
pysmbd: make use of create_conn_struct_tos()

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
5 years agopysmbd: remove explicit talloc_stackframe() from get_conn() and name it get_conn_tos()
Stefan Metzmacher [Thu, 24 May 2018 14:16:19 +0000 (16:16 +0200)]
pysmbd: remove explicit talloc_stackframe() from get_conn() and name it get_conn_tos()

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
5 years agopysmbd: fix some talloc_stackframe() memory leaks and clean up the frame hierarchy...
Stefan Metzmacher [Thu, 24 May 2018 14:16:19 +0000 (16:16 +0200)]
pysmbd: fix some talloc_stackframe() memory leaks and clean up the frame hierarchy in make_simple_acl().

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
5 years agopysmbd: consitently use talloc_stackframe() for temporary memory
Stefan Metzmacher [Thu, 24 May 2018 14:16:19 +0000 (16:16 +0200)]
pysmbd: consitently use talloc_stackframe() for temporary memory

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
5 years agopysmbd: remove useless explicit conn_free() from set_nt_acl_conn()
Stefan Metzmacher [Fri, 25 May 2018 05:38:24 +0000 (07:38 +0200)]
pysmbd: remove useless explicit conn_free() from set_nt_acl_conn()

The following TALLOC_FREE(frame); will do the same via
conn_free_wrapper().

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
5 years agosmbd: add create_conn_struct_tos[_cwd]() helper functions
Stefan Metzmacher [Thu, 24 May 2018 13:59:43 +0000 (15:59 +0200)]
smbd: add create_conn_struct_tos[_cwd]() helper functions

This makes it more obvious that the returned connection_struct
is only temporary (and allocated on talloc_tos()!)
It will never allow async requests on a long term
tevent context! So we create a short term event context.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
5 years agoprinting: remove unused arguments from delete_and_reload_printers()
Stefan Metzmacher [Wed, 23 May 2018 14:35:20 +0000 (16:35 +0200)]
printing: remove unused arguments from delete_and_reload_printers()

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
5 years agoprinting: remove unused arguments from load_printers()
Stefan Metzmacher [Wed, 23 May 2018 14:35:20 +0000 (16:35 +0200)]
printing: remove unused arguments from load_printers()

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
5 years agoCID 1416475: possibly dereferencing NULL in fruit_pread_meta
Swen Schillig [Fri, 25 May 2018 10:45:35 +0000 (12:45 +0200)]
CID 1416475: possibly dereferencing NULL in fruit_pread_meta

Signed-off-by: Swen Schillig <swen@vnet.ibm.com>
Reviewed-by: Christof Schmitt <cs@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Autobuild-User(master): Ralph Böhme <slow@samba.org>
Autobuild-Date(master): Wed Jun 13 16:29:48 CEST 2018 on sn-devel-144

5 years agoCID 1416476: possibly dereferencing NULL in fruit_ftruncate_rsrc
Swen Schillig [Fri, 25 May 2018 10:43:42 +0000 (12:43 +0200)]
CID 1416476: possibly dereferencing NULL in fruit_ftruncate_rsrc

Signed-off-by: Swen Schillig <swen@vnet.ibm.com>
Reviewed-by: Christof Schmitt <cs@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 years agoCID 1416477: possibly dereferencing NULL in fruit_pwrite_meta
Swen Schillig [Fri, 25 May 2018 09:39:50 +0000 (11:39 +0200)]
CID 1416477: possibly dereferencing NULL in fruit_pwrite_meta

Signed-off-by: Swen Schillig <swen@vnet.ibm.com>
Reviewed-by: Christof Schmitt <cs@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 years agoCID 1416478: de-ref NULL value in fruit_pwrite_rsrc
Swen Schillig [Fri, 25 May 2018 09:32:38 +0000 (11:32 +0200)]
CID 1416478: de-ref NULL value in fruit_pwrite_rsrc

Signed-off-by: Swen Schillig <swen@vnet.ibm.com>
Reviewed-by: Christof Schmitt <cs@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 years agodsdb: Fix CID 1435968 Dereference before null check
Volker Lendecke [Tue, 12 Jun 2018 19:31:15 +0000 (21:31 +0200)]
dsdb: Fix CID 1435968 Dereference before null check

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Wed Jun 13 13:40:56 CEST 2018 on sn-devel-144

5 years agodsdb: Fix CID 1435966 Unchecked return value
Volker Lendecke [Tue, 12 Jun 2018 19:22:10 +0000 (21:22 +0200)]
dsdb: Fix CID 1435966 Unchecked return value

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
5 years agodsdb: Fix typos
Volker Lendecke [Tue, 12 Jun 2018 19:18:18 +0000 (21:18 +0200)]
dsdb: Fix typos

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
5 years agodsdb: Fix CID 1436918 Unchecked return value
Volker Lendecke [Tue, 12 Jun 2018 19:15:55 +0000 (21:15 +0200)]
dsdb: Fix CID 1436918 Unchecked return value

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
5 years agodsdb: Fix CID 1436919 Unchecked return value
Volker Lendecke [Tue, 12 Jun 2018 19:12:47 +0000 (21:12 +0200)]
dsdb: Fix CID 1436919 Unchecked return value

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
5 years agodsdb: Fix CID 1436920 Unchecked return value
Volker Lendecke [Tue, 12 Jun 2018 19:09:40 +0000 (21:09 +0200)]
dsdb: Fix CID 1436920 Unchecked return value

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
5 years agoFix UDP DNS queries in addns
Timur I. Bakeyev [Mon, 11 Jun 2018 20:38:00 +0000 (04:38 +0800)]
Fix UDP DNS queries in addns

The addns code tries to use common approach for TCP and UDP queries,
calling connect() for both types of sockets. In case of UDP that
requires to use send() instead of sendto().

Signed-off-by: Timur I. Bakeyev <timur@iXsystems.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Wed Jun 13 03:51:04 CEST 2018 on sn-devel-144

5 years agopython: call fault_setup() if samba.getopt is used
Stefan Metzmacher [Fri, 25 May 2018 05:52:40 +0000 (07:52 +0200)]
python: call fault_setup() if samba.getopt is used

This means we have a samba command line tool written in python,
e.g. samba-tool

We should get the samba typicall backtraces instead of
just "Segmentation fault (core dumped)".

BUG: https://bugzilla.samba.org/show_bug.cgi?id=13469

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Tue Jun 12 11:04:55 CEST 2018 on sn-devel-144

5 years agopython: export fault_setup() to python bindings
Stefan Metzmacher [Fri, 25 May 2018 05:52:02 +0000 (07:52 +0200)]
python: export fault_setup() to python bindings

BUG: https://bugzilla.samba.org/show_bug.cgi?id=13469

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
5 years agopython/drs_utils: fix repeated typo
Douglas Bagnall [Fri, 8 Jun 2018 03:36:39 +0000 (15:36 +1200)]
python/drs_utils: fix repeated typo

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Sun Jun 10 21:41:33 CEST 2018 on sn-devel-144

5 years agopython/join: fix a typo
Douglas Bagnall [Thu, 7 Jun 2018 08:11:26 +0000 (20:11 +1200)]
python/join: fix a typo

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
5 years agosambatool visualize: add up-to-dateness visualization
Douglas Bagnall [Fri, 1 Jun 2018 05:20:56 +0000 (17:20 +1200)]
sambatool visualize: add up-to-dateness visualization

Or more accurately, out-of-dateness visualization, which shows how far
each DCs is from every other using the difference in the up-to-dateness
vectors.

An example usage is

samba-tool visualize uptodateness -r -S -H ldap://somewhere \
      -UAdministrator --color=auto --partition=DOMAIN

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
5 years agosamba-tool visualize ntdsconn: properly sort/group vertices
Douglas Bagnall [Fri, 1 Jun 2018 05:14:32 +0000 (17:14 +1200)]
samba-tool visualize ntdsconn: properly sort/group vertices

The vertex is now a tuple, with the RODC state added.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
5 years agosamba-tool visualize: fix wrong variable name in get_partition()
Douglas Bagnall [Tue, 6 Mar 2018 22:40:00 +0000 (11:40 +1300)]
samba-tool visualize: fix wrong variable name in get_partition()

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
5 years agopython/graph: don't crash colourer on bad link
Douglas Bagnall [Fri, 1 Jun 2018 04:55:37 +0000 (16:55 +1200)]
python/graph: don't crash colourer on bad link

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
5 years agopython/graph: use '>' for excessive numbers, not '+'
Douglas Bagnall [Fri, 1 Jun 2018 04:51:19 +0000 (16:51 +1200)]
python/graph: use '>' for excessive numbers, not '+'

'+' already has another meaning in these graphs.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
5 years agopython/graph: add full_matrix graph function
Douglas Bagnall [Fri, 1 Jun 2018 04:48:34 +0000 (16:48 +1200)]
python/graph: add full_matrix graph function

This makes an ASCII/ANSI art picture like distance_matrix(), but from
a full matrix, not a list of adjacencies as in the distance_matrix case.

This will be used to visualise up-to-dateness vectors.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
5 years agopython/graph: rework shorten_vertex_names to not need edges
Douglas Bagnall [Fri, 1 Jun 2018 04:39:19 +0000 (16:39 +1200)]
python/graph: rework shorten_vertex_names to not need edges

This will be necessary for the forthcoming full_matrix function.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
5 years agopython/samba/graph: use look up table for ascii-art charsets
Douglas Bagnall [Tue, 15 May 2018 10:26:43 +0000 (22:26 +1200)]
python/samba/graph: use look up table for ascii-art charsets

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
5 years agosamba-tool visualize: separate dot options from common options
Douglas Bagnall [Thu, 24 May 2018 03:22:47 +0000 (15:22 +1200)]
samba-tool visualize: separate dot options from common options

because not all sub-commands make dot format

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
5 years agosamba-tool visualise: helper for getting the partition
Douglas Bagnall [Thu, 29 Mar 2018 02:52:25 +0000 (15:52 +1300)]
samba-tool visualise: helper for getting the partition

Repeated code becomes a function.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
5 years agopython/graph: tweak colour schemes for distance charts
Douglas Bagnall [Thu, 24 May 2018 02:42:37 +0000 (14:42 +1200)]
python/graph: tweak colour schemes for distance charts

This works a bit better in terminals with white text.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
5 years agosamba-tool drs showrepl: add a --verbose flag
Douglas Bagnall [Thu, 7 Jun 2018 02:35:38 +0000 (14:35 +1200)]
samba-tool drs showrepl: add a --verbose flag

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
5 years agosamba-tool drs showrepl: generalise the way output mode is chosen
Douglas Bagnall [Fri, 9 Mar 2018 03:16:23 +0000 (16:16 +1300)]
samba-tool drs showrepl: generalise the way output mode is chosen

We have a couple more output modes coming along, so it makes senses to
untangle .run() into a number of independent sub-methods.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
5 years agosamba-tool drs showrepl tests: don't assert existence of DNS partitions
Douglas Bagnall [Sat, 9 Jun 2018 08:35:30 +0000 (20:35 +1200)]
samba-tool drs showrepl tests: don't assert existence of DNS partitions

Because their existence is uncertain immediately after provision,
when these tests will run under some circumstances.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>