1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-27 03:21:53 +03:00
Commit Graph

771 Commits

Author SHA1 Message Date
Andreas Schneider
92afa1b165 smbd: Simplify chroot option in smbd
rpmlint has a check for this and prefers to call chdir() before
chroot(). If not it will complain with
missing-call-to-chdir-with-chroot. The old code equivalent secure. See

    http://unixwiz.net/techtips/chroot-practices.html

This removes several unneeded talloc_tos() calls.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>

Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Sat Feb 13 03:50:54 CET 2016 on sn-devel-144
2016-02-13 03:50:54 +01:00
Michael Adam
476672b647 dlist: remove unneeded type argument from DLIST_ADD_END()
Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2016-02-06 21:48:17 +01:00
Michael Adam
a446966e71 smbd:process: use smbXsrv_client_create.
Signed-off-by: Michael Adam <obnox@samba.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
2016-01-26 15:58:11 +01:00
Michael Adam
0010dc81be smbd:process: treat initialized table in smbXsrv_connection_init_tables
Pair-Programmed-With: Stefan Metzmacher <metze@samba.org>

Signed-off-by: Michael Adam <obnox@samba.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
2016-01-26 15:58:11 +01:00
Ralph Boehme
b74bef8f7d smbstatus: add support for SMB1 signing and CIFS UNIX extensions encryption
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>

Autobuild-User(master): Ralph Böhme <slow@samba.org>
Autobuild-Date(master): Fri Jan 22 11:06:05 CET 2016 on sn-devel-144
2016-01-22 11:06:05 +01:00
Jeremy Allison
4587d83f07 s3: smbd: VFS change. Add new field bool posix_pathnames into struct smb_request.
Initialize from lp_posix_pathnames() global.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <Volker.Lendecke@SerNet.DE>
2015-12-23 18:23:17 +01:00
Volker Lendecke
258ce91f31 lib: Move sys_rw* to lib/util
genrand.c will require it soon

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2015-10-13 01:23:07 +02:00
Volker Lendecke
a039463d82 lib: Make ctdbd_register_ips return 0/errno
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2015-10-07 23:54:06 +02:00
Ralph Boehme
1bb46dae82 s3:smb3: rename smbd_smb2_first_negprot and pass expected seq_low
This is in preperation of connection passing where we have to set
seq_low to the mid from the negprot we've handed over.

Pair-Programmed-With: Stefan Metzmacher <metze@samba.org>

Signed-off-by: Ralph Boehme <slow@samba.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>

Autobuild-User(master): Michael Adam <obnox@samba.org>
Autobuild-Date(master): Wed Oct  7 00:54:34 CEST 2015 on sn-devel-104
2015-10-07 00:54:34 +02:00
Christof Schmitt
0b455a5c2d smbd: Set process name for async echo handler
Signed-off-by: Christof Schmitt <cs@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2015-09-24 08:00:16 +02:00
Christof Schmitt
96c48b3c06 s3: Move call to prctl_set_comment to reinit_after_fork
This save a few lines of code.

Signed-off-by: Christof Schmitt <cs@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2015-09-24 08:00:16 +02:00
Uri Simchoni
0c6dc1ecf9 async_req: check for errors when monitoring socket for readability
Add an option to wait_for_read_send(), so that the request, upon
calling back, report whether the socket actually contains data
or is in EOF/error state. EOF is signalled via the EPIPE error.

This is useful for clients which do not expect data to arrive but
wait for readability to detect a closed socket (i.e. they do not
intend to actually read the socket when it's readable). Actual data
arrival would indicate a bug in this case, so the check can
be used to print an error message.

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

Signed-off-by: Uri Simchoni <urisimchoni@gmail.com>
Reviewed-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
2015-07-15 22:41:13 +02:00
Volker Lendecke
539125c99d ctdbd_conn: Move release_ip handling into process.c
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>

Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Tue Jul 14 09:56:25 CEST 2015 on sn-devel-104
2015-07-14 09:56:25 +02:00
Günther Deschner
c638ce839b s3-smbd: reset protocol in smbXsrv_connection_init_tables failure paths.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=11373

Guenther

Pair-Programmed-With: Stefan Metzmacher <metze@samba.org>
Pair-Programmed-With: Michael Adam <obnox@samba.org>

Signed-off-by: Guenther Deschner <gd@samba.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2015-06-30 21:12:19 +02:00
Christof Schmitt
b51ad15618 smbd: Use new debug macros in kill-client-ip
Mainly to have the new macros actually used in the code.

Signed-off-by: Christof Schmitt <cs@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>

Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Thu Jun 11 04:34:50 CEST 2015 on sn-devel-104
2015-06-11 04:34:50 +02:00
Richard Sharpe
6abd986704 Convert all uses of uint8/16/32 to _t in source3/smbd.
Signed-off-by: Richard Sharpe <rsharpe@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2015-05-06 04:14:14 +02:00
Ralph Boehme
9e7cf87a30 s3:smbd: use smbd_reinit_after_fork
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2015-04-22 23:00:20 +02:00
Volker Lendecke
74a16a1094 s3:smbprofile: Replace sysv shmem with tdb
What?

This patch gets rid of the central shared memory segment referenced by
"profile_p". Instead, every smbd gets a static profile_area where it collects
profiling data. Once a second, every smbd writes this profiling data into a
record of its own in a "smbprofile.tdb". smbstatus -P does a tdb_traverse on this
database and sums up what it finds.

Why?

At least in my perception sysv IPC has not the best reputation on earth. The
code before this patch uses shmat(). Samba ages ago has developed a good
abstraction of shared memory: It's called tdb.

The main reason why I started this is that I have a request to become
more flexible with profiling data. Samba should be able to collect data
per share or per user, something which is almost impossible to do with
a fixed structure. My idea is to for example install a profile area per
share and every second marshall this into one tdb record indexed by share
name. smbstatus -P would then also collect the data and either aggregate
them or put them into individual per-share statistics. This flexibility
in the data model is not really possible with one fixed structure.

But isn't it slow?

Well, I don't think so. I can't really prove it, but I do believe that on large
boxes atomically incrementing a shared memory value for every SMB does show up
due to NUMA effects. With this patch the hot code path is completely
process-local. Once a second every smbd writes into a central tdb, this of
course does atomic operations. But it's once a second, not on every SMB2 read.

There's two places where I would like to improve things: With the current code
all smbds wake up once a second. With 10,000 potentially idle smbds this will
become noticable. That's why the current only starts the timer when something has
changed.

The second place is the tdb traverse: Right now traverse is blocking in the
sense that when it has to switch hash chains it will block. With mutexes, this
means a syscall. I have a traverse light in mind that works as follows: It
assumes a locked hash chain and then walks the complete chain in one run
without unlocking in between. This way the caller can do nonblocking locks in
the first round and only do blocking locks in a second round. Also, a lot of
syscall overhead will vanish. This way smbstatus -P will have almost zero
impact on normal operations.

Pair-Programmed-With: Stefan Metzmacher <metze@samba.org>

Signed-off-by: Volker Lendecke <vl@samba.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2015-03-06 12:31:10 +01:00
Volker Lendecke
0013001e70 lib: Split out write_data[_iov]
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2014-12-07 00:12:07 +01:00
Stefan Metzmacher
185c6feab7 s3:smbprofile: track connect_count and disconnect_count
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2014-11-19 20:51:37 +01:00
Stefan Metzmacher
487556e68e s3:smbprofile: report idle state of 'idle_count' and 'idle_time'
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2014-11-19 20:51:37 +01:00
Stefan Metzmacher
e007c60a4f s3:smbprofile: count all SMB1 and SMB2 requests as 'request_count'
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2014-11-19 20:51:37 +01:00
Christof Schmitt
5da31a9260 smbd: Always use uint8_t for inbuf pointer
This avoids some casts from char pointers.

Signed-off-by: Christof Schmitt <cs@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2014-10-04 00:11:21 +02:00
Christof Schmitt
6ab998f3fe smbd: Pass only cmd to construct_reply_common instead of complete req
construct_reply_common only needs the commands code and the inbuf field,
not the complete request.

Signed-off-by: Christof Schmitt <cs@samba.org>
2014-10-04 00:11:21 +02:00
Stefan Metzmacher
e773851c73 s3:smbd: split out a smbd_add_connection() helper function.
This attaches a smbXsrv_connection to a smbXsrv_client structure.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2014-09-19 09:15:13 +02:00
Stefan Metzmacher
7a45ddbaca s3:smbd: remove now unused smbd_server_connection->conn
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2014-09-19 09:15:13 +02:00
Stefan Metzmacher
a6ff17f978 s3:smb2_create: pass smbXsrv_connection to *deferred*_smb2
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2014-09-19 09:15:12 +02:00
Stefan Metzmacher
56d454b4ae s3:smbd: pass smbXsrv_connection to schedule_deferred_open_message_smb()
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2014-09-19 09:15:12 +02:00
Stefan Metzmacher
b05ae37da6 s3:smbd: pass smbXsrv_connection to remove_deferred_open_message_smb()
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2014-09-19 09:15:12 +02:00
Stefan Metzmacher
d8cffad8e0 s3:smbd: pass smbXsrv_connection to open_was_deferred()
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2014-09-19 09:15:12 +02:00
Stefan Metzmacher
333707fa37 s3:smbd: move smbXsrv_{session,tcon,open} tables to smbXsrv_client
These should be per client (based on the SMB >= 2.1 client_guid),
this is a preparation for multi-channel support.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2014-09-19 09:15:12 +02:00
Michael Adam
9afc37bef4 s3:smbd: use tevent_loop_wait() in the child process event loop
Pair-Programmed-With: Stefan Metzmacher <metze@samba.org>

Signed-off-by: Michael Adam <obnox@samba.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
2014-09-19 09:15:12 +02:00
Stefan Metzmacher
555b3d18d2 s3:smbd: use sconn->client->connections in keepalive_fn()
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2014-09-19 09:15:12 +02:00
Stefan Metzmacher
7012008eb6 s3:smbd: remove now unused smbXsrv_connection->sconn
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2014-09-19 09:15:12 +02:00
Stefan Metzmacher
981fb261c9 s3:smbd: use xconn->client->sconn in smb1_parse_chain()
xconn->sconn will go away soon.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2014-09-19 09:15:11 +02:00
Stefan Metzmacher
d83ecf5b1d s3:smbd: use xconn->client->sconn in construct_reply()
xconn->sconn will go away soon.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2014-09-19 09:15:11 +02:00
Stefan Metzmacher
78951fb099 s3:smbd: use xconn->client->sconn in process_smb()
xconn->sconn will go away soon.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2014-09-19 09:15:11 +02:00
Stefan Metzmacher
e23785ae37 s3:smbd: introduce 'struct smbXsrv_client' in order to prepare multi-channel support
This structure is supposed to hold the global state shared between
multiple connections from the same client.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2014-09-19 09:15:11 +02:00
Stefan Metzmacher
7408736d9d s3:smbd: pass smbXsrv_connection to construct_reply*()
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2014-09-19 09:15:11 +02:00
Stefan Metzmacher
3a26bd1a3d s3:smbd: pass smbXsrv_connection to smb1_parse_chain()
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2014-09-19 09:15:11 +02:00
Michael Adam
7c1553fe89 s3:smbd: support xconn=NULL in init_smb_request()
Pair-Programmed-With: Stefan Metzmacher <metze@samba.org>
Signed-off-by: Michael Adam <obnox@samba.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
2014-09-19 09:15:11 +02:00
Stefan Metzmacher
0b99a8ac45 s3:smbd: only pass smbXsrv_connection to fork_echo_handler()
We don't need smbd_server_connection there.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2014-09-19 09:15:11 +02:00
Stefan Metzmacher
4b9f17eca7 s3:smbd: pass smbXsrv_connection to srv_send_smb()
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2014-09-19 09:15:11 +02:00
Stefan Metzmacher
e3ab0a0569 s3:smbd: pass smbXsrv_connection to receive_smb*()
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2014-09-19 09:15:11 +02:00
Michael Adam
9fe6665968 s3:smbd: use smbXsrv_connection_dbg() in receive_smb_talloc()
instead of manually assembling the address string

Pair-Programmed-With: Stefan Metzmacher <metze@samba.org>
Signed-off-by: Michael Adam <obnox@samba.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
2014-09-19 09:15:11 +02:00
Michael Adam
93f7e6251b s3:smbd: use smbXsrv_connection_dbg() inreceive_smb_raw_talloc_partial_read()
instead of manually assembling the address string

Pair-Programmed-With: Stefan Metzmacher <metze@samba.org>
Signed-off-by: Michael Adam <obnox@samba.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
2014-09-19 09:15:11 +02:00
Stefan Metzmacher
dec0243c85 s3:smbd: close the connection if the client doesn't start with a SMB1 Negprot or old messaging call.
The case where the client starts with a SMB2 Negprot is already handled
in smbd_smb2_request_dispatch().

Bug: https://bugzilla.samba.org/show_bug.cgi?id=10766

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Signed-off-by: Jeremy Allison <jra@samba.org>

Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Tue Sep  9 13:02:21 CEST 2014 on sn-devel-104
2014-09-09 13:02:21 +02:00
Christof Schmitt
2132acb4d9 smbd: Add padding byte to readx response
MS-CIFS 2.2.4.42.2 states: "Pad (1 byte): This field is optional. When
using the NT LAN Manager dialect, this field can be used to align the
Data field to a 16-bit boundary relative to the start of the SMB Header.
If Unicode strings are being used, this field MUST be present. When
used, this field MUST be one padding byte long."

Always add the padding byte to all readx responses to avoid additional
complexity.

Signed-off-by: Christof Schmitt <cs@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2014-08-30 00:27:13 +02:00
Stefan Metzmacher
bb8e6d458a s3:smbd: pass smbXsrv_connection to smbd_[un]lock_socket()
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>

Autobuild-User(master): Michael Adam <obnox@samba.org>
Autobuild-Date(master): Wed Aug  6 12:15:57 CEST 2014 on sn-devel-104
2014-08-06 12:15:57 +02:00
Stefan Metzmacher
245e3959de s3:smbd: pass smbXsrv_connection to smb1 encryption functions
These parameters are not really used currently, but may be in future.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2014-08-06 09:51:14 +02:00