samba.git
15 months agosmbd: explain that/why we use the raw tevent_context for update_write_time_handler()
Stefan Metzmacher [Thu, 22 Mar 2018 09:54:41 +0000 (10:54 +0100)]
smbd: explain that/why we use the raw tevent_context for update_write_time_handler()

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
15 months agovfs_glusterfs: explain that/why we use the raw tevent_context in init_gluster_aio()
Stefan Metzmacher [Thu, 22 Mar 2018 09:54:41 +0000 (10:54 +0100)]
vfs_glusterfs: explain that/why we use the raw tevent_context in init_gluster_aio()

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
15 months agosmbd: add smbd_server_connection->raw_ev_ctx pointer
Stefan Metzmacher [Thu, 22 Mar 2018 09:54:41 +0000 (10:54 +0100)]
smbd: add smbd_server_connection->raw_ev_ctx pointer

This will replace smbd_server_connection->ev_ctx in the next commits.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
15 months agosmbd: use req->xconn->client->raw_ev_ctx for schedule_deferred_open_message_smb()
Stefan Metzmacher [Thu, 22 Mar 2018 09:54:41 +0000 (10:54 +0100)]
smbd: use req->xconn->client->raw_ev_ctx for schedule_deferred_open_message_smb()

process_smb() will redo the impersonation anyway.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
15 months agos3:smb2_server: use req->xconn->client->raw_ev_ctx for smbd_smb2_request_dispatch_imm...
Stefan Metzmacher [Thu, 22 Mar 2018 09:54:41 +0000 (10:54 +0100)]
s3:smb2_server: use req->xconn->client->raw_ev_ctx for smbd_smb2_request_dispatch_immediate()

smbd_smb2_request_dispatch() will redo the impersonation anyway,
so we don't use req->ev_ctx.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
15 months agos3:smb2_server: use req->xconn->client->raw_ev_ctx for smbd_smb2_request_pending_timer()
Stefan Metzmacher [Thu, 22 Mar 2018 09:54:41 +0000 (10:54 +0100)]
s3:smb2_server: use req->xconn->client->raw_ev_ctx for smbd_smb2_request_pending_timer()

There's no need to use req->ev_ctx here just to do some network io.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
15 months agosmbd: remove unused tevent_context argument from notify_init
Stefan Metzmacher [Thu, 24 May 2018 05:18:10 +0000 (07:18 +0200)]
smbd: remove unused tevent_context argument from notify_init

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
15 months agosmbd: replace xconn->msg_ctx with xconn->client->msg_ctx
Stefan Metzmacher [Thu, 22 Mar 2018 09:54:41 +0000 (10:54 +0100)]
smbd: replace xconn->msg_ctx with xconn->client->msg_ctx

This is the same pointer and we don't have a lot of callers,
so we can just use one pointer.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
15 months agosmbd: replace xconn->ev_ctx with xconn->client->raw_ev_ctx
Stefan Metzmacher [Thu, 22 Mar 2018 09:54:41 +0000 (10:54 +0100)]
smbd: replace xconn->ev_ctx with xconn->client->raw_ev_ctx

This is the same pointer and we don't have a lot of callers,
so we can just use one pointer.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
15 months agosmbd: rename smbXsrv_client->ev_ctx into smbXsrv_client->raw_ev_ctx
Stefan Metzmacher [Thu, 22 Mar 2018 09:54:41 +0000 (10:54 +0100)]
smbd: rename smbXsrv_client->ev_ctx into smbXsrv_client->raw_ev_ctx

That makes it clearer that no tevent_context wrapper is used here
and the related code should really run without any (active) impersonation
as before.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
15 months agovfs_default: maintain vfswrap_offload_write_state->{src_ev,dst_ev}
Stefan Metzmacher [Thu, 22 Mar 2018 09:54:41 +0000 (10:54 +0100)]
vfs_default: maintain vfswrap_offload_write_state->{src_ev,dst_ev}

These get filled with impersonation wrappers in the following commits.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
15 months agovfs_default: make use of change_to_user_by_fsp() in order to switch between src and...
Stefan Metzmacher [Wed, 23 May 2018 10:03:02 +0000 (12:03 +0200)]
vfs_default: make use of change_to_user_by_fsp() in order to switch between src and dst fsp

This may matter if at least one share uses "force user".

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
15 months agovfs_btrfs: make use of become_user_by_fsp() in order to switch between src and dst fsp
Stefan Metzmacher [Wed, 23 May 2018 10:03:02 +0000 (12:03 +0200)]
vfs_btrfs: make use of become_user_by_fsp() in order to switch between src and dst fsp

We can use become_user_by_fsp()/unbecome_user() as it spans only parts of
the btrfs_offload_write_send() function and never goes async in between.

This may matter if at least one share uses "force user".

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
15 months agosmbd: add {become,change_to}_user_by_fsp() helper functions
Stefan Metzmacher [Wed, 23 May 2018 09:54:58 +0000 (11:54 +0200)]
smbd: add {become,change_to}_user_by_fsp() helper functions

This can be used if a request operates on two fsp's,
e.g. the offload_write_send/recv code.
This is important if (at least) one of
the shares uses "force user".

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
15 months agovfs_btrfs: don't keep state->subreq in btrfs_offload_write_send/recv()
Stefan Metzmacher [Wed, 23 May 2018 10:40:21 +0000 (12:40 +0200)]
vfs_btrfs: don't keep state->subreq in btrfs_offload_write_send/recv()

This can be a local variable as used in most of our tevent_req based
code.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
15 months agovfs_btrfs: update s/btrfs_cc_state/btrfs_offload_write_state/ s/cc_state/state/
Stefan Metzmacher [Wed, 23 May 2018 10:40:21 +0000 (12:40 +0200)]
vfs_btrfs: update s/btrfs_cc_state/btrfs_offload_write_state/ s/cc_state/state/

This matches our naming conventions used for tevent_req based functions.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
15 months agovfs_btrfs: remove unused checks which are already caught by vfs_offload_token_check_h...
Stefan Metzmacher [Wed, 23 May 2018 09:37:52 +0000 (11:37 +0200)]
vfs_btrfs: remove unused checks which are already caught by vfs_offload_token_check_handles()

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
15 months agovfs_default: remove unused checks which are already caught by vfs_offload_token_check...
Stefan Metzmacher [Wed, 23 May 2018 09:37:52 +0000 (11:37 +0200)]
vfs_default: remove unused checks which are already caught by vfs_offload_token_check_handles()

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
15 months agosmbd: avoid calling set_current_user_info() twice with .need_tcon (SMB2)
Stefan Metzmacher [Fri, 25 May 2018 14:30:13 +0000 (16:30 +0200)]
smbd: avoid calling set_current_user_info() twice with .need_tcon (SMB2)

It's already called via change_to_user().

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
15 months agosmbd: avoid calling set_current_user_info() twice with AS_USER (SMB1)
Stefan Metzmacher [Fri, 25 May 2018 14:30:13 +0000 (16:30 +0200)]
smbd: avoid calling set_current_user_info() twice with AS_USER (SMB1)

It will be called via change_to_user().

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
15 months agosmbd: remove unused set_current_service()
Stefan Metzmacher [Thu, 14 Jun 2018 09:22:31 +0000 (11:22 +0200)]
smbd: remove unused set_current_service()

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
15 months agosmbd: let switch_message() only call chdir_current_service() for SMBtdis/SMBexit
Stefan Metzmacher [Thu, 14 Jun 2018 09:18:13 +0000 (11:18 +0200)]
smbd: let switch_message() only call chdir_current_service() for SMBtdis/SMBexit

These are the two opcodes with DO_CHDIR, we don't want the
set_current_case_sensitive() logic for them,
so we don't need the full set_current_service() anymore.

The AS_USER case is already handled before, set_current_case_sensitive()
is called directly before change_to_user(), which already
calls chdir_current_service().

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
15 months 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>
15 months 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>
15 months 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>
15 months 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>
15 months 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>
15 months 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>
15 months 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>
15 months 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>
15 months 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>
15 months 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>
15 months 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>
15 months 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>
15 months 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>
15 months 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>
15 months 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>
15 months 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>
15 months 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>
15 months 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>
15 months 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>
15 months 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

15 months 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

15 months 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>
15 months 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>
15 months 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>
15 months 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>
15 months 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>
15 months 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>
15 months 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>
15 months 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

15 months 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

15 months 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

16 months 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>
16 months 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>
16 months 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>
16 months 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>
16 months 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>
16 months 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>
16 months 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>
16 months 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>
16 months 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>
16 months 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>
16 months 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>
16 months 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>
16 months 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>
16 months 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>
16 months 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>
16 months 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>
16 months 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>
16 months 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>
16 months 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>
16 months 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>
16 months 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>
16 months 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>
16 months 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>
16 months 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>
16 months 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>
16 months 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>
16 months 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>
16 months 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>
16 months 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>
16 months 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>
16 months 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>
16 months 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>
16 months 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>
16 months 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>
16 months 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>
16 months 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>
16 months 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>
16 months 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>
16 months 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>
16 months 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>
16 months 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

16 months 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>
16 months 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>
16 months 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>
16 months 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

16 months 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>
16 months 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>