ddiss/samba.git
11 years agosmb2_ioctl: copychunk request max output validation
David Disseldorp [Tue, 15 Jan 2013 16:23:12 +0000 (17:23 +0100)]
smb2_ioctl: copychunk request max output validation

Check that the copychunk ioctl request maximum output specified by the
client is large enough to hold copychunk response data.

Reviewed by: Jeremy Allison <jra@samba.org>

Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Thu Jan 17 00:59:44 CET 2013 on sn-devel-104

(cherry picked from commit 8e63a72ec1e9ea9efcbcdf156274afaed9a4b2ea)

11 years agosmb2_ioctl: track copychunk response output state
David Disseldorp [Tue, 15 Jan 2013 16:23:11 +0000 (17:23 +0100)]
smb2_ioctl: track copychunk response output state

Treat the response data independent to the status.

Reviewed by: Jeremy Allison <jra@samba.org>

(cherry picked from commit bf07c33dac37442b8f5b49e68653f8ef629ff679)

11 years agosmb2_ioctl: copychunk CHECK_READ and CHECK_WRITE
David Disseldorp [Tue, 15 Jan 2013 16:23:10 +0000 (17:23 +0100)]
smb2_ioctl: copychunk CHECK_READ and CHECK_WRITE

[MS-SMB2] 3.3.5.15.6 Handling a Server-Side Data Copy Request, specifies
that the copychunk destination file handle be granted FILE_WRITE_DATA
and FILE_READ_DATA access.

FILE_READ_DATA access must also be granted on the copychunk source file,
which may be done implicitly with execute permission.

Reviewed by: Jeremy Allison <jra@samba.org>

(cherry picked from commit cb323281c1f2b66f2b42527cda722e57ca1f1f23)

11 years agotorture: copychunk test suite improvements
David Disseldorp [Tue, 15 Jan 2013 16:23:09 +0000 (17:23 +0100)]
torture: copychunk test suite improvements

Allow for large files in test_setup_copy_chunk():
  Write test data in 1M IOs, rather than attempting to do the whole
  thing in one go.

Add copychunk bad resume key test:
  Send a copy chunk request with an intentionally bogus resume key
  (source key handle).

Add copychunk src=dest test:
  Test copychunk requests where the source and destination handles refer
  to the same file.

Add copychunk src=dest overlap test.

Add desired access args to test_setup_copy_chunk().

Add copychunk_bad_access test:
  Open the copychunk source and destination files with differing
  desired_access values. Confirm copychunk response matches 2k8 and 2k12
  behaviour.

Add copy_chunk_src_exceed test:
  Attempts to copy more data than is present in the copychunk source
  file.

Add copy_chunk_src_exceed_multi test:
  Test whether the first chunk in a multi-chunk copychunk request is
  written to disk, where the second chunk is invalid due to src file
  overrun.

Add copy_chunk_sparse_dest test:
  Issue a request where the target offset exceeds the file size, resulting
  in a sparse region.

Add copy_chunk_max_output_sz test.

(cherry picked from commit 456724f05d79733fe805a3209231c565d69d2be3)

11 years agosmb2_ioctl: only pass through to VFS on a valid fsp
David Disseldorp [Tue, 15 Jan 2013 16:23:08 +0000 (17:23 +0100)]
smb2_ioctl: only pass through to VFS on a valid fsp

A null fsp is dereferenced on VFS call.

Reviewed by: Jeremy Allison <jra@samba.org>

(cherry picked from commit c3cc51e8a2f31565c3bac219ea3a78ab4287bcd5)

11 years agotorture: replace ioctl failure returns with helper calls
David Disseldorp [Tue, 15 Jan 2013 16:23:07 +0000 (17:23 +0100)]
torture: replace ioctl failure returns with helper calls

Also change test_ioctl_get_shadow_copy() to use torture_skip(), and
clean up test output.

Reviewed by: Jeremy Allison <jra@samba.org>

(cherry picked from commit bfe765367e1425fc3ae98e6b8183e6ac5476e97b)

11 years agotorture: add locking tests for copychunk
David Disseldorp [Tue, 15 Jan 2013 16:23:06 +0000 (17:23 +0100)]
torture: add locking tests for copychunk

Reviewed by: Jeremy Allison <jra@samba.org>

(cherry picked from commit 42a5a6c0f61f0c863bac1bf65e7045f1ce086409)

11 years agosmb2_ioctl: perform locking around copychunk requests
David Disseldorp [Tue, 15 Jan 2013 16:23:05 +0000 (17:23 +0100)]
smb2_ioctl: perform locking around copychunk requests

For each chunk in a copychunk request, take a read and write lock on
the source and destination files respectively.

Also change the resume key format to use a combination of the persistent
and volatile handles. Thanks to Metze for his help on this.

Reviewed by: Jeremy Allison <jra@samba.org>

(cherry picked from commit a7c2f13d7a5646f2a63ce33e8155ce79d10ef696)

11 years agosmbd: split out file_fsp_get from file_fsp_smb2
David Disseldorp [Tue, 15 Jan 2013 16:23:04 +0000 (17:23 +0100)]
smbd: split out file_fsp_get from file_fsp_smb2

Obtain the files_struct from smb2req, persistent_id and
volatile_id.

Reviewed by: Jeremy Allison <jra@samba.org>

(cherry picked from commit 7ca8663e313a55fd6157cf20eb02c2ac8be94a00)

11 years agotorture: skip FSCTL_SRV_ENUM_SNAPS test when not supported
David Disseldorp [Tue, 15 Jan 2013 16:23:03 +0000 (17:23 +0100)]
torture: skip FSCTL_SRV_ENUM_SNAPS test when not supported

If FSCTL_SRV_ENUM_SNAPS fails with NT_STATUS_NOT_SUPPORTED then skip the
test, this means we can run the full ioctl test suite as part of
autobuild.

Reviewed by: Jeremy Allison <jra@samba.org>

(cherry picked from commit 3619b1a7b2b5a2bfe6fdb13ecb4650ae575ab3e8)

11 years agoselftest: enable samba3.smb2.ioctl tests against s3fs
David Disseldorp [Tue, 15 Jan 2013 16:23:02 +0000 (17:23 +0100)]
selftest: enable samba3.smb2.ioctl tests against s3fs

These tests are now expected to pass with copy-chunk support now
implemented.

This effectively reverts 632b1042aed94a71d810613fcdbbfecf615a25fa.

(cherry picked from commit bc59ebf5231b44220598dfdf44c9a2cfcc538711)

11 years agosmb2_ioctl: remove ioctl error response assumptions
David Disseldorp [Tue, 15 Jan 2013 16:23:01 +0000 (17:23 +0100)]
smb2_ioctl: remove ioctl error response assumptions

MS-SMB2 3.3.4.4 documents cases where a ntstatus indicating an error
should not be considered a failure. In such a case the output data
buffer should be sent to the client rather than an error response
packet.

Add a new fsctl copy_chunk test to confirm field limits are sent back
in response to an oversize chunk request.

Reviewed by: Jeremy Allison <jra@samba.org>

(cherry picked from commit 65983aac12e5ecb12157b39c7bec464388716f27)

11 years agosmb2_ioctl: add support for FSCTL_SRV_COPYCHUNK
David Disseldorp [Tue, 15 Jan 2013 16:23:00 +0000 (17:23 +0100)]
smb2_ioctl: add support for FSCTL_SRV_COPYCHUNK

SMB2 clients can issue FSCTL_SRV_COPYCHUNK requests in order to copy
data between files on the server side only, rather than reading data
then writing back from the client. FSCTL_SRV_COPYCHUNK is used by
default for Explorer SMB2 file copies on Windows Server 2012.

2.2.32.1 SRV_COPYCHUNK_RESPONSE in [MS-SMB2] describes the requirement
for the server to provide maximum copychunk request size limits in ioctl
responses carrying STATUS_INVALID_PARAMETER.

Reviewed by: Jeremy Allison <jra@samba.org>

(cherry picked from commit e38d9f71d90e6b20a027d91d4768d91378728621)

11 years agos3-vfs: add copy_chunk vfs hooks
David Disseldorp [Tue, 15 Jan 2013 16:22:59 +0000 (17:22 +0100)]
s3-vfs: add copy_chunk vfs hooks

copy_chunk copies n bytes from a source file at a specific offset to a
destination file at a given offset. This interface will be used in
handling smb2 FSCTL_SRV_COPYCHUNK ioctl requests.

Use a pread/pwrite loop in vfs_default, so that requests referring to
the same src and dest file are possible.

Provide send and receive hooks for copy chunk VFS interface, allowing
asynchronous behaviour.

Check whether the request source offset + length exceeds the current
size. Return STATUS_INVALID_VIEW_SIZE under such a condition, matching
Windows server behaviour.

(cherry picked from commit ef00eb90e56dfac2d823582cec92abf1fa9905f1)

11 years agosmb2_ioctl: add FSCTL_SRV_REQUEST_RESUME_KEY support
David Disseldorp [Tue, 15 Jan 2013 16:22:58 +0000 (17:22 +0100)]
smb2_ioctl: add FSCTL_SRV_REQUEST_RESUME_KEY support

Use existing ioctl IDL infrastructure for marshalling. Support for this
ioctl is a prerequisite for FSCTL_SRV_COPYCHUNK handling.
The client-opaque resume key is constructed using the server side
dev/inode file identifier.

Reviewed by: Jeremy Allison <jra@samba.org>

(cherry picked from commit 2bde9636888067210dc38523b6fafaa0b179ec3b)

11 years agosmb2_ioctl: split ioctl handler code on device type
David Disseldorp [Tue, 15 Jan 2013 16:22:57 +0000 (17:22 +0100)]
smb2_ioctl: split ioctl handler code on device type

Add per device type ioctl handler source files for FSCTL_DFS,
FSCTL_FILESYSTEM, FSCTL_NAMED_PIPE and FSCTL_NETWORK_FILESYSTEM.

Reviewed by: Jeremy Allison <jra@samba.org>

(cherry picked from commit 14bd6c8b0954ad58ac4e3e157835594c26bfa97a)

11 years agosmb2_ioctl: split ioctl handlers into separate funtions
David Disseldorp [Tue, 15 Jan 2013 16:22:56 +0000 (17:22 +0100)]
smb2_ioctl: split ioctl handlers into separate funtions

Reviewed by: Jeremy Allison <jra@samba.org>

(cherry picked from commit 958b21c28dacad38cd64e79ca7d77cd8acc20dd0)

11 years agotorture: Fix copy and paste error.
Andreas Schneider [Fri, 30 Nov 2012 09:57:39 +0000 (10:57 +0100)]
torture: Fix copy and paste error.

Found by Coverity.

(cherry picked from commit 1b170c29bc9239e2077e70c929e7426f5b19104d)

11 years agoMake sure that we only propogate the INHERITED flag when we are allowed to.
Richard Sharpe [Thu, 28 Mar 2013 02:36:43 +0000 (19:36 -0700)]
Make sure that we only propogate the INHERITED flag when we are allowed to.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Richard Sharpe <realrichardsharpe@gmail.com>
Fix bug #9747 - When creating a directory Samba allows inherited bit to slip
through.

Autobuild-User(v4-0-test): Karolin Seeger <kseeger@samba.org>
Autobuild-Date(v4-0-test): Tue Apr  2 23:07:34 CEST 2013 on sn-devel-104

11 years agobuild: Do not pass CPP="" to pidl, skip the env variable entirely
Andrew Bartlett [Fri, 22 Mar 2013 02:47:46 +0000 (13:47 +1100)]
build: Do not pass CPP="" to pidl, skip the env variable entirely

This will cause pidl to use $CC -E instead.

Andrew Bartlett

Reviewed-by: Stefan Metzmacher <metze@samba.org>
(cherry picked from commit afe9343880ee27cf9fe937c6379c469435ef20d6)

The last 2 patches address bug #9739 - [PATCH] PIDL build fixes for hosts
without CPP (Solaris 11).

11 years agobuild: Remove the forced use of only the first part of the compiler string
Andrew Bartlett [Fri, 22 Mar 2013 02:06:43 +0000 (13:06 +1100)]
build: Remove the forced use of only the first part of the compiler string

This corrects parts of 378295c3fe813c70815a14c7de608e4a859bd6cc and
301d59caf2ee6f49e108b748b0e38221dec9bb96.  This is seen if CC="ccache
gcc" and CPP isn't used for some reason.

Andrew Bartlett

Reviewed-by: Stefan Metzmacher <metze@samba.org>
(cherry picked from commit 7dc6dfd90c5182ed85042b22d4864d3e9b007531)

11 years agoscripting: No longer install samba_upgradeprovision
Andrew Bartlett [Wed, 27 Feb 2013 13:03:19 +0000 (00:03 +1100)]
scripting: No longer install samba_upgradeprovision

This tool is an important part of the toolkit a Samba Team member can
use to assist a user with the upgrade of a very old Samba 4.0 AD DC
installation.

However, like all powerful tools, it has sharp edges, and these need
to have more protection added before we recommend the tool be used.

The WHATSNEW already indicated that this tool should not be used but a
large number of users have run it, and due to lack of testing in the
past, some have run into bugs.

While this tool can be run in debug modes, by default it simply fixes
the database following a series of internal rule.  This does a good
job much of the time, but does not request permission in the way that
dbcheck does, and will create extra objects for things like the DNS
partitions.

By removing this from the installed binaries, we provide another
signal that it should not be used right now, until these matters are
fixed and some clear documentation on how to safely use the tool can
be written.

Andrew Bartlett

Reviewed-by: Michael Adam <obnox@samba.org>
Autobuild-User(master): Michael Adam <obnox@samba.org>
Autobuild-Date(master): Tue Mar 12 02:51:23 CET 2013 on sn-devel-104
(cherry picked from commit 389197e7c31e8d6616e6503181c088940ddb5986)

Fix bug #9728 - DO NOT install samba_upgradeprovision in 4.0.x.

11 years agoscripting/samba_upgradedns: Only look for IPv4/IPv6 addresses if we actually them
Andrew Bartlett [Thu, 27 Dec 2012 23:05:40 +0000 (10:05 +1100)]
scripting/samba_upgradedns: Only look for IPv4/IPv6 addresses if we actually them

This allows the script to be used to create/remove the samba-specific dns-SERVER account
when we do not need to create the in-directory partition.

Andrew Bartlett

Reviewed-by: Stefan Metzmacher <metze@samba.org>
Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Thu Jan 10 20:56:50 CET 2013 on sn-devel-104
(cherry picked from commit edbc26bca84ee77b5a9571ba8dc9416c0db25906)

Fix bug #9721 - samba_upgradedns patch for robustness (do not guess addresses
when just changing roles).

11 years agosamba-tool classicupgrade: Do not print the admin password during upgrade
Andrew Bartlett [Fri, 21 Dec 2012 22:28:05 +0000 (09:28 +1100)]
samba-tool classicupgrade: Do not print the admin password during upgrade

This changes the code to only set and show a new password if no admin
user is found during the upgrade.

Andrew Bartlett

Reviewed-by: Stefan Metzmacher <metze@samba.org>
Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Thu Jan 10 16:55:23 CET 2013 on sn-devel-104
(cherry picked from commit 051a1a9c6417c2cbffa7d091ae477a6c7922d363)

Fix bug #samba-tool classicupgrade patch to not print incorrect admin passwords.

11 years agos4-dbcheck: Allow forcing an override of an old @MODULES record
Andrew Bartlett [Thu, 23 Aug 2012 05:18:13 +0000 (15:18 +1000)]
s4-dbcheck: Allow forcing an override of an old @MODULES record

Reviewed-by: Stefan Metzmacher <metze@samba.org>
(cherry picked from commit 99d872ee9261a299add4718c38234dfe9f7658fc)

Fix bug #9719 - dbcheck patch from master needed in 4.0.

11 years agoselftest: Add test for rfc2307 mapping handling
Andrew Bartlett [Fri, 28 Dec 2012 01:36:06 +0000 (12:36 +1100)]
selftest: Add test for rfc2307 mapping handling

Reviewed-by: Stefan Metzmacher <metze@samba.org>
(cherry picked from commit c9d2ca585e198b1006bbf7f1a3c988c1188b66cb)

The last 2 patches address bug #9718 - rfc2307 patches not yet in 4.0.

11 years agos4-idmap: Remove requirement that posixAccount or posixGroup be set for rfc2307
Andrew Bartlett [Wed, 26 Dec 2012 09:48:12 +0000 (20:48 +1100)]
s4-idmap: Remove requirement that posixAccount or posixGroup be set for rfc2307

This change matches the source3/idmap/idmap_ad.c code, and allows this
feature to work with only the setting of the UID/GID in Active
Directory Users and Computers.

Andrew Bartlett

Reviewed-by: Stefan Metzmacher <metze@samba.org>
(cherry picked from commit 5e0fcb04a48d96669ed4376bfa17f679e3582236)

11 years agobuild: Set LD_LIBRARY_PATH in install_with_python.sh
Andrew Bartlett [Thu, 10 Jan 2013 01:00:03 +0000 (12:00 +1100)]
build: Set LD_LIBRARY_PATH in install_with_python.sh

This ensures that the python install finishes correctly.

Andrew Bartlett

Reviewed-by: Stefan Metzmacher <metze@samba.org>
Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Thu Jan 10 14:00:13 CET 2013 on sn-devel-104
(cherry picked from commit 213e7260a83d4349132e8c159798b476cec3f814)

Fix bug #9717 - install_with_python fix not yet in 4.0.x.

11 years agoFix bug #9724 - is_encrypted_packet() function incorrectly used inside server.
Jeremy Allison [Fri, 15 Mar 2013 22:05:31 +0000 (15:05 -0700)]
Fix bug #9724 - is_encrypted_packet() function incorrectly used inside server.

The is_encrypted_packet() function should only be used on the raw received data
to determine if a packet came in encrypted. Once we're inside the SMB1
processing code in smbd/reply.c we should be looking at the
smb1request->encrypted field to determine if a packet was really encrypted or
not.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Sat Mar 16 12:44:44 CET 2013 on sn-devel-104
(cherry picked from commit 1d15fc75a33b7368049876368f4b70c188bbd55e)

Autobuild-User(v4-0-test): Karolin Seeger <kseeger@samba.org>
Autobuild-Date(v4-0-test): Thu Mar 21 11:15:16 CET 2013 on sn-devel-104

11 years agotorture: Add ntprinting latin1 test.
Andreas Schneider [Thu, 14 Mar 2013 06:29:20 +0000 (07:29 +0100)]
torture: Add ntprinting latin1 test.

Reviewed-by: Günther Deschner <gd@samba.org>
The last 7 patches address bug #9723 - Add a tool to migrate latin1 printing
tdb's to registry.

11 years agos3-net: Add encoding=<CP> to 'net printing dump'.
Andreas Schneider [Tue, 12 Mar 2013 17:42:02 +0000 (18:42 +0100)]
s3-net: Add encoding=<CP> to 'net printing dump'.

Reviewed-by: Günther Deschner <gd@samba.org>
11 years agos3-net: Add encoding=<CP> to 'net printing migrate'.
Andreas Schneider [Tue, 12 Mar 2013 10:39:08 +0000 (11:39 +0100)]
s3-net: Add encoding=<CP> to 'net printing migrate'.

This allows you to convert printing tdb's which are in e.g. in latin1 to
convert to UTF-8 and import them into the registry.

Reviewed-by: Günther Deschner <gd@samba.org>
11 years agondr: Pass down string_flags in ndr_pull_ntprinting_printer().
Andreas Schneider [Tue, 12 Mar 2013 14:17:54 +0000 (15:17 +0100)]
ndr: Pass down string_flags in ndr_pull_ntprinting_printer().

Reviewed-by: Günther Deschner <gd@samba.org>
11 years agoidl: Add flags for strings in ntprinting idl.
Andreas Schneider [Mon, 11 Mar 2013 14:47:00 +0000 (15:47 +0100)]
idl: Add flags for strings in ntprinting idl.

Reviewed-by: Günther Deschner <gd@samba.org>
11 years agondr: Add ndr_ntprinting_string_flags() function.
Andreas Schneider [Mon, 11 Mar 2013 14:45:15 +0000 (15:45 +0100)]
ndr: Add ndr_ntprinting_string_flags() function.

It defaults to utf8string.

Reviewed-by: Günther Deschner <gd@samba.org>
11 years agopidl: Add skip option to elements.
Andreas Schneider [Tue, 12 Mar 2013 10:36:38 +0000 (11:36 +0100)]
pidl: Add skip option to elements.

This option allows to skip struct elements in pull and push function.
This can be used to pass flags to the structure e.g. for string values.

Reviewed-by: Günther Deschner <gd@samba.org>
11 years agos4:torture: let raw.read accept larger reads than 0x10000
Stefan Metzmacher [Wed, 20 Mar 2013 07:49:20 +0000 (08:49 +0100)]
s4:torture: let raw.read accept larger reads than 0x10000

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
The last 16 patches address bug #9706 - Parameter is incorrect on Android.

11 years agos4:torture: raw.read fix large reads against windows
Stefan Metzmacher [Tue, 19 Mar 2013 16:11:03 +0000 (17:11 +0100)]
s4:torture: raw.read fix large reads against windows

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
11 years agos3:selftest: Add LARGE_READX test into our make test infrastructure.
Jeremy Allison [Wed, 13 Mar 2013 22:45:12 +0000 (15:45 -0700)]
s3:selftest: Add LARGE_READX test into our make test infrastructure.

Tested against non-encrypted and encrypted connections.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
11 years agos3:torture: Add new LARGE_READX test to investigate large SMBreadX behavior.
Jeremy Allison [Wed, 13 Mar 2013 22:43:21 +0000 (15:43 -0700)]
s3:torture: Add new LARGE_READX test to investigate large SMBreadX behavior.

Signed-off-by: Jeremy Allison <jra@samba.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
11 years agos4:smb_server: fix large read_andx requests
Stefan Metzmacher [Mon, 18 Mar 2013 18:50:38 +0000 (19:50 +0100)]
s4:smb_server: fix large read_andx requests

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
11 years agos3:smbd: Add functions calc_max_read_pdu()/calc_read_size() to work out the length...
Jeremy Allison [Fri, 15 Mar 2013 18:57:48 +0000 (11:57 -0700)]
s3:smbd: Add functions calc_max_read_pdu()/calc_read_size() to work out the length we should return.

LARGE_READX test shows it's always safe to return a short read.
Windows does so. Do the calculations to return what will fit
in a read depending on what the client negotiated.

Signed-off-by: Jeremy Allison <jra@samba.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
11 years agos3:smbd: Remove server_will_accept_large_read() and erroneous comment.
Jeremy Allison [Fri, 15 Mar 2013 18:53:04 +0000 (11:53 -0700)]
s3:smbd: Remove server_will_accept_large_read() and erroneous comment.

We're going to replace this with a function that calculates
the max PDU to return on a read and supports short reads.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
11 years agos3:smbd: Fix off-by 4 error in wrap protection code in create_outbuf()
Jeremy Allison [Mon, 18 Mar 2013 22:05:24 +0000 (15:05 -0700)]
s3:smbd: Fix off-by 4 error in wrap protection code in create_outbuf()

Subtract 4 from smb_size (39) here as the length
of the SMB reply following the 4 byte type+length
field can be up to 0xFFFFFF bytes.

Signed-off-by: Jeremy Allison <jra@samba.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
11 years agos3:smbd: add some const to req_is_in_chain()
Stefan Metzmacher [Mon, 18 Mar 2013 11:36:30 +0000 (12:36 +0100)]
s3:smbd: add some const to req_is_in_chain()

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
11 years agos3:smbd: remove silly (SMB_OFF_T_BITS == 64) checks
Stefan Metzmacher [Tue, 19 Mar 2013 12:24:46 +0000 (13:24 +0100)]
s3:smbd: remove silly (SMB_OFF_T_BITS == 64) checks

configure will abort if sizeof(off_t) is not 8.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
11 years agos3:smbd: keep global_client_caps and max_send from the first successful session setup
Stefan Metzmacher [Mon, 18 Mar 2013 09:10:25 +0000 (10:10 +0100)]
s3:smbd: keep global_client_caps and max_send from the first successful session setup

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
11 years agos3:libsmb: let cli_read_andx_create() accept any length
Stefan Metzmacher [Mon, 18 Mar 2013 08:33:00 +0000 (09:33 +0100)]
s3:libsmb: let cli_read_andx_create() accept any length

It's up to the server to decide the allowed length.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
11 years agolibcli/smb: smb1cli_inbuf_parse_chain() and smb1cli_conn_dispatch_incoming() should...
Jeremy Allison [Wed, 13 Mar 2013 22:23:52 +0000 (15:23 -0700)]
libcli/smb: smb1cli_inbuf_parse_chain() and smb1cli_conn_dispatch_incoming() should use smb_len_tcp.

They have to cope with large READX call replies that have
a length greater than smb_len_nbt() can handle.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
11 years agolibcli/smb: defer failing for missing NEGOTIATE_SECURITY_SIGNATURES_ENABLED
Stefan Metzmacher [Mon, 18 Mar 2013 14:02:55 +0000 (15:02 +0100)]
libcli/smb: defer failing for missing NEGOTIATE_SECURITY_SIGNATURES_ENABLED

Windows servers take a look at the FLAGS2_SMB_SECURITY_SIGNATURES_REQUIRED
flag during a session setup and turn on signing if the client requires it.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
11 years agos3:libsmb: make use of SMB_CAP_LEGACY_CLIENT_MASK instead of SMB_CAP_CLIENT_MASK
Stefan Metzmacher [Tue, 19 Mar 2013 08:03:38 +0000 (09:03 +0100)]
s3:libsmb: make use of SMB_CAP_LEGACY_CLIENT_MASK instead of SMB_CAP_CLIENT_MASK

This should allow smbclient to keep using large reads against older Samba versions
(<= 3.6.x) and other servers that may also require this.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
11 years agolibcli/smb: add SMB_CAP_LEGACY_CLIENT_MASK define
Stefan Metzmacher [Tue, 19 Mar 2013 08:02:52 +0000 (09:02 +0100)]
libcli/smb: add SMB_CAP_LEGACY_CLIENT_MASK define

Older Samba releases (<= 3.6.x)
expect the client to send CAP_LARGE_READX
in order to let the client use large reads.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
11 years agos4:winbindd: do not drop the workgroup name in the getgrgid call
Michael Adam [Wed, 27 Feb 2013 00:04:46 +0000 (01:04 +0100)]
s4:winbindd: do not drop the workgroup name in the getgrgid call

Second part of fix for bug #9711.

Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Wed Feb 27 05:44:39 CET 2013 on sn-devel-104
(cherry picked from commit bb0e4cbc3c30137245ca6b6cf9d74812ad17cee1)

11 years agos4:winbindd: do not drop the workgroup name in the getgrnam and getgrent calls.
Michael Adam [Tue, 26 Feb 2013 23:45:55 +0000 (00:45 +0100)]
s4:winbindd: do not drop the workgroup name in the getgrnam and getgrent calls.

First part of fix for bug #9711.

Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
(cherry picked from commit ecd0b10d2f1de986303f8aab2915c20c2f025244)

11 years agoWHATSNEW: clarify how being a domain member server is supported in Samba 4.0
Michael Adam [Mon, 18 Mar 2013 01:47:46 +0000 (02:47 +0100)]
WHATSNEW: clarify how being a domain member server is supported in Samba 4.0

Signed-off-by: Michael Adam <obnox@samba.org>
11 years agoVERSION: Bump version number up to 4.0.5.
Karolin Seeger [Wed, 20 Mar 2013 11:23:14 +0000 (12:23 +0100)]
VERSION: Bump version number up to 4.0.5.

Signed-off-by: Karolin Seeger <kseeger@samba.org>
11 years agoMerge tag 'samba-4.0.4' into v4-0-test
Karolin Seeger [Wed, 20 Mar 2013 11:19:35 +0000 (12:19 +0100)]
Merge tag 'samba-4.0.4' into v4-0-test

samba: tag release samba-4.0.4

11 years agoVERSION: Bump version number up to 4.0.4. samba-4.0.4
Karolin Seeger [Tue, 19 Mar 2013 08:28:48 +0000 (09:28 +0100)]
VERSION: Bump version number up to 4.0.4.

Bug 9709: CVE-2013-1863: Remove forced set of 'create mask' to 0777.

Signed-off-by: Karolin Seeger <kseeger@samba.org>
11 years agoWHATSNEW: Prepare release notes for Samba 4.0.4
Karolin Seeger [Tue, 19 Mar 2013 08:27:57 +0000 (09:27 +0100)]
WHATSNEW: Prepare release notes for Samba 4.0.4

Bug 9709: CVE-2013-1863: Remove forced set of 'create mask' to 0777.

Signed-off-by: Karolin Seeger <kseeger@samba.org>
11 years agoRevert "Ensure the masks don't conflict with the ACL checks."
Andrew Bartlett [Sun, 10 Mar 2013 09:25:53 +0000 (20:25 +1100)]
Revert "Ensure the masks don't conflict with the ACL checks."

This reverts commit 78594909b8b22bd07978922b1c85dfd6f6456963 which was
needed by 7622aa16adeb00bf161a6dd07664c37125391272.

This change masked bug #9462 which was fixed by
2013bb9b4dbed747921df2591068e2765428f57d.  The issue was that the
defaults for the substituted parameters did not match the old
parameter.  Changing the values in our test suite hid the issue, but
did not fix the issue.

(Additional change in the revert is to correct the expected ACL value
in posixacl.py due to changed implied inherited permissions).

Andrew Bartlett

Reviewed-by: Michael Adam <obnox@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Michael Adam <obnox@samba.org>
Autobuild-Date(master): Mon Mar 11 19:46:24 CET 2013 on sn-devel-104
(cherry picked from commit 58e385a5ac37c072a4eef3baa7926b799a732e94)

The last 3 patches address bug #Bug 9709 - CVE-2013-1863; Remove forced set of
'create mask' to 0777.

CVE-2013-1863: World-writeable files may be created in additional shares on a
Samba 4.0 AD DC.

11 years agosmbd:posix_acls Remove incorrectly added lp_create_mask() and lp_dir_mask() calls
Andrew Bartlett [Fri, 8 Mar 2013 05:15:37 +0000 (16:15 +1100)]
smbd:posix_acls Remove incorrectly added lp_create_mask() and lp_dir_mask() calls

When 6adc7dad96b8c7366da042f0d93b28c1ecb092eb removed the calls to
lp_security_mask/lp_force_security_mode/lp_dir_security_mask/lp_force_dir_security_mode
these calls were replaced with lp_create_mask() and lp_dir_mask()

The issue is that while lp_security_mask() and lp_dir_security_mask defaulted to
0777, the replacement calls did not.  This changes behaviour, and incorrectly
prevents a posix mode being specified by the client from being applied to
the disk in the non-ACL enabled case.

Andrew Bartlett
Reviewed-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
(cherry picked from commit fc496ef323c908a6b621198d9dc8076f6857385e)

11 years agoparam: Remove incorrectly added defaults in AD DC allowing WORLD WRITABLE files
Andrew Bartlett [Fri, 8 Mar 2013 05:49:21 +0000 (16:49 +1100)]
param: Remove incorrectly added defaults in AD DC allowing WORLD WRITABLE files

These defaults were incorrectly added in
fc5caffbc139d63cab1ec105884863f73772586f in what turns out to be an
incorrect fix for bug #9462, which was in turn introduced by the
swapping of security mask (default 0777) for create mask (0755) in
6adc7dad96b8c7366da042f0d93b28c1ecb092eb.

While the permissions on sysvol and netlogon (the default shares) were
fixed by provision, any additional shares that did not yet have an
explit ACL set would create world-writable files by default.

Administrators will need to manually correct the file permissions on
any additional shares that were created after installation of the AD
DC.

Andrew Bartlett

Reviewed-by: Michael Adam <obnox@samba.org>
Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Sun Mar 10 12:00:31 CET 2013 on sn-devel-104
(cherry picked from commit 287b5f6c0f40d3e3d09bc2ce80f5fee02cbae40f)

11 years agoCorrect the name of the nss_winbind module for FreeBSD by creating a symlink from...
Richard Sharpe [Fri, 8 Mar 2013 01:36:37 +0000 (17:36 -0800)]
Correct the name of the nss_winbind module for FreeBSD by creating a symlink from the FreeBSD required name to the built module.

Signed-off-by: Timur Bakeyev <timur@FreeBSD.org>
Reviewed-by: Andrew Bartlett <abartlett@samba.org>
Reviewed-by: Richard Sharpe <realrichardsharpe@gmail.com>
Autobuild-User(master): Richard Sharpe <sharpe@samba.org>
Autobuild-Date(master): Fri Mar  8 05:04:04 CET 2013 on sn-devel-104
(cherry picked from commit 11d128632357c9ae89d67aaf23c429fae83a1b29)

Fix bug #9704 - Fix nss_winbind name on FreeBSD.

Autobuild-User(v4-0-test): Karolin Seeger <kseeger@samba.org>
Autobuild-Date(v4-0-test): Tue Mar 12 10:43:32 CET 2013 on sn-devel-104

11 years agobuild: Do not force a specific perl from ${PERL} when running pod2man
Andrew Bartlett [Thu, 7 Feb 2013 22:12:20 +0000 (09:12 +1100)]
build: Do not force a specific perl from ${PERL} when running pod2man

pod2man should have the right #!/usr/bin/perl line already, and forcing it may
cause us to use the wrong perl.

Essentially treat this like any other system binary, rather than forcing
it to use the first perl we found.

This essentially reverts e80f576db66ad04592ac436ed74ceb9b96452060.
Current SLES11 does not seem to have the issue this was added to
address.

Andrew Bartlett

Reviewed-by: Michael Adam <obnox@samba.org>
Autobuild-User(master): Michael Adam <obnox@samba.org>
Autobuild-Date(master): Thu Feb 28 02:14:25 CET 2013 on sn-devel-104
(cherry picked from commit 1da22ab994822acacf9a0378c68b15cd32535390)

Fix bug #9703 - Fix build on solaris8: Do not force a specific perl on pod2man.

11 years agoselftest: also skip raw.search as it also spins
Andrew Bartlett [Sun, 13 Jan 2013 02:03:13 +0000 (13:03 +1100)]
selftest: also skip raw.search as it also spins

Reviewed-by: Stefan Metzmacher <metze@samba.org>
(cherry picked from commit b40d134bc1866dd7e5b5e7dfc5bf01f6d55b1c1f)

The last 2 patches fix bug #9663 - make test hangs.

11 years agoselftest: skip base.dir2 tests as they just spin on modern ext4
Andrew Bartlett [Thu, 10 Jan 2013 21:26:07 +0000 (08:26 +1100)]
selftest: skip base.dir2 tests as they just spin on modern ext4

Reviewed-by: Stefan Metzmacher <metze@samba.org>
(cherry picked from commit a8c745a28c3278e9fbee6f802dc340fe660f27ca)

11 years agovfs_catia: add my copyright
Guenter Kukkukk [Thu, 28 Feb 2013 23:58:05 +0000 (00:58 +0100)]
vfs_catia: add my copyright

Signed-off-by: Guenter Kukkukk <kukks@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
The last 5 patches address bug #9701 - vfs_catia is not working anymore (due to
a former regression).

Autobuild-User(v4-0-test): Karolin Seeger <kseeger@samba.org>
Autobuild-Date(v4-0-test): Mon Mar 11 10:55:48 CET 2013 on sn-devel-104

11 years agovfs_catia: add a sample for filename mapping to the manual page
Guenter Kukkukk [Thu, 28 Feb 2013 23:36:08 +0000 (00:36 +0100)]
vfs_catia: add a sample for filename mapping to the manual page

Signed-off-by: Guenter Kukkukk <kukks@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
11 years agovfs_catia: fix the completely outdated manual page
Guenter Kukkukk [Thu, 28 Feb 2013 05:12:36 +0000 (06:12 +0100)]
vfs_catia: fix the completely outdated manual page

The complete rework around 3.5.0 was not even mentioned somewhere.
(i was not able to find any info about that major change)

Signed-off-by: Guenter Kukkukk <kukks@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
11 years agovfs_catia: fix the translation to "vfs_translate_to_windows"
Guenter Kukkukk [Wed, 27 Feb 2013 04:50:52 +0000 (05:50 +0100)]
vfs_catia: fix the translation to "vfs_translate_to_windows"

THANKS to an IRC user (Raimund ?) who asked for a char mapping possibility.
I suggested vfs_catia - but it did not work!
Hopefully now it will. :-)

Signed-off-by: Guenter Kukkukk <kukks@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
11 years agovfs_catia: add debug class for that module
Guenter Kukkukk [Wed, 27 Feb 2013 04:34:05 +0000 (05:34 +0100)]
vfs_catia: add debug class for that module

Signed-off-by: Guenter Kukkukk <kukks@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
11 years agotsocket_bsd: Attempt to increase the SO_SNDBUF if we get EMSGSIZE in sendto()
Andrew Bartlett [Mon, 4 Mar 2013 03:06:14 +0000 (14:06 +1100)]
tsocket_bsd: Attempt to increase the SO_SNDBUF if we get EMSGSIZE in sendto()

This matches what was done for lib/socket/socket_unix.c in
c692bb02b039ae8fef6ba968fd13b36ad7d62a72.

(and is based on that patch by Landon Fuller <landonf@bikemonkey.org>)

Andrew Bartlett

Reviewed-by: Stefan Metzmacher <metze@samba.org>
Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Mon Mar  4 11:15:35 CET 2013 on sn-devel-104
(cherry picked from commit 70e1b6185e3fb35fdc72eeb529ffb4b50122dc40)

The last 3 patches address bug #9697 - DsReplicaGetInfo fails due to sendto()
EMSGSIZE error on UNIX domain socket.

Autobuild-User(v4-0-test): Karolin Seeger <kseeger@samba.org>
Autobuild-Date(v4-0-test): Wed Mar  6 11:57:20 CET 2013 on sn-devel-104

11 years agos4-lib/socket: Return the original EMSGSIZE when sendto() and setsockopt() both fail
Andrew Bartlett [Mon, 4 Mar 2013 03:07:38 +0000 (14:07 +1100)]
s4-lib/socket: Return the original EMSGSIZE when sendto() and setsockopt() both fail

This ensures that should we be unable to increase the socket size, we return an
error that the application layer above might expect and be able to make
as reasonable response to (such as switching to a stream-based transport).

This fixes up c692bb02b039ae8fef6ba968fd13b36ad7d62a72.

As suggested by metze in https://bugzilla.samba.org/show_bug.cgi?id=9697#c4

Andrew Bartlett

Reviewed-by: Stefan Metzmacher <metze@samba.org>
(cherry picked from commit 50b42d1c5bb19e3a5050d7d23ac96e273d3974ee)

11 years agoHandle EMSGSIZE on UNIX domain sockets.
Landon Fuller [Sat, 2 Mar 2013 19:08:47 +0000 (14:08 -0500)]
Handle EMSGSIZE on UNIX domain sockets.

On some systems (eg, FreeBSD) the default SO_SNDBUF for UNIX
domain sockets is to small, and EMSGSIZE is returned. Other
systems provide a larger default send buffer, but there is
still no guarantee that the buffer will be sized appropriately.

This patch modifies the sendto() path to attempt to resize
the SO_SNDBUF dynamically upon an EMSGSIZE failure, and then
retry the send.

This fixes local DCE/RPC errors on FreeBSD, eg:

https://lists.samba.org/archive/samba-technical/2013-January/089881.html

Signed-Off-By: Landon Fuller <landonf@bikemonkey.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Sat Mar  2 23:34:03 CET 2013 on sn-devel-104
(cherry picked from commit c692bb02b039ae8fef6ba968fd13b36ad7d62a72)

11 years agos4-socket: Make sure unix socket addresses are null terminated.
Andreas Schneider [Mon, 10 Dec 2012 16:14:12 +0000 (17:14 +0100)]
s4-socket: Make sure unix socket addresses are null terminated.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Günther Deschner <gd@samba.org>
(cherry picked from commit 7dd13503c0919766ecf3c8f5f48cda72aae8ac73)

11 years agoRemove incomplete check for IPv6 link-local addresses.
Landon Fuller [Sun, 24 Feb 2013 03:32:25 +0000 (22:32 -0500)]
Remove incomplete check for IPv6 link-local addresses.

This has been superceded by a check for link-local
addresses in get_interfaces()

Signed-Off-By: Landon Fuller <landonf@bikemonkey.org>
Reviewed-By: Richard Sharpe <realrichardsharpe@gmail.com>
Fix bug #9696 - Remove incomplete samba_dnsupdate IPv6 link-local address
check.

11 years agos3:lib/events: add missing TEVENT_TRACE_BEFORE/AFTER_WAIT handling
Stefan Metzmacher [Thu, 28 Feb 2013 09:54:21 +0000 (10:54 +0100)]
s3:lib/events: add missing TEVENT_TRACE_BEFORE/AFTER_WAIT handling

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
(cherry picked from commit 2fb69f51c47c8859485011879afb11650835ecbe)

The last 77 patches address bug #9695 - Backport tevent changes to bring
library to version 0.9.18.

11 years agoFix typo to make master/lib/tevent identical to 4.0.x/lib/tevent
Jeremy Allison [Sat, 2 Mar 2013 00:10:47 +0000 (16:10 -0800)]
Fix typo to make master/lib/tevent identical to 4.0.x/lib/tevent

This was missed in the patch that was applied to fix bug 9550.

Signed-off-by: Jeremy Allison <jra@samba.org>
11 years agotevent: change version to 0.9.18
Stefan Metzmacher [Fri, 30 Nov 2012 08:43:23 +0000 (09:43 +0100)]
tevent: change version to 0.9.18

This release contains a lot of fixes:

- Adding new timer events is now faster, if there's
  a large number of timer events.

- sigprocmask does not work on FreeBSD to stop further signals in a signal
  handler.

- TEVENT_NUM_SIGNALS is calculated by configure in order
  to support realtime signals on freebsd.

- ./configure --disable-python was fixed for the standalone build.

- Several crash bugs in the poll backend are fixed.

- The poll backend removes deleted events from the
  cached pollfd array now.

- The poll doesn't pass pollfd.events == 0 to poll()
  and maintains a list of disabled events,
  instead of consuming 100% cpu and/or triggering
  the callers handler.

- The poll backend detects POLLNVAL and reports EBADF
  instead of consuming 100% cpu.

- The select backend supports separate handlers
  for TEVENT_FD_READ and TEVENT_FD_WRITE.

- The poll and select backends are now doing fair
  queuing of fd events.

- The epoll has better error checking
  and supports separate handlers
  for TEVENT_FD_READ and TEVENT_FD_WRITE.

- The standard backend was rewritten to be a tiny
  wrapper on top of epoll with a fallback to poll,
  which means that it doesn't use select directly anymore.

- TEVENT_TRACE_BEFORE_LOOP_ONCE and TEVENT_TRACE_AFTER_LOOP_ONCE
  are added in order to allow the application to hook in
  before and after the loop_once() backend function is called.
  The TEVENT_HAS_LOOP_ONCE_TRACE_POINTS define can be used to
  detect the new feature.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
11 years agotevent: optimize adding new zero timer events
Stefan Metzmacher [Fri, 22 Feb 2013 11:45:39 +0000 (12:45 +0100)]
tevent: optimize adding new zero timer events

Such events were used before we had immediate events.
It's likely that there're a lot of this events
and we need to add new ones in fifo order.

The tricky part is that tevent_common_add_timer()
should not use the optimization as it's used
by broken Samba versions, which don't use
tevent_common_loop_timer_delay() in source3/lib/events.c.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
11 years agotevent: optimize adding new timer events
Stefan Metzmacher [Fri, 22 Feb 2013 11:45:39 +0000 (12:45 +0100)]
tevent: optimize adding new timer events

As new timestamps typically get higher:-)
it's better to traverse the existing list from
the tail.

This is not completely optimal, but it should be better
than before.

A second optimization could be done for zero timestamps,
we would just remember the last_zero_timer,
but that would change the internal ABI.
Normally thatshould not be a poblem, but the Samba's
source3/lib/events.c abuses tevent_internal.h
from the current source tree, even if an external tevent.h
is used. The other problem is that it makes use of
tevent_common_add_timer() without using
tevent_common_loop_timer_delay().

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
11 years agotevent: add a debug message in tevent_common_loop_timer_delay()
Stefan Metzmacher [Fri, 1 Mar 2013 08:25:32 +0000 (09:25 +0100)]
tevent: add a debug message in tevent_common_loop_timer_delay()

We should debug a message before and after running the handler.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
11 years agotevent: add test_event_fd2()
Stefan Metzmacher [Wed, 27 Feb 2013 15:43:44 +0000 (16:43 +0100)]
tevent: add test_event_fd2()

This test fills the socket kernel buffers
and verifies that we don't report TEVENT_FD_WRITE
if the buffer is full.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
11 years agotevent: add test_event_fd1()
Stefan Metzmacher [Fri, 22 Feb 2013 20:48:44 +0000 (21:48 +0100)]
tevent: add test_event_fd1()

This test verifies that TEVENT_FD_* flags are handled correctly.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
11 years agotevent: use better names for the subtests
Stefan Metzmacher [Thu, 28 Feb 2013 09:12:42 +0000 (10:12 +0100)]
tevent: use better names for the subtests

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
11 years agotevent: Regression test to ensure that a tevent backend can cope with separate read...
Jeremy Allison [Thu, 14 Feb 2013 22:16:31 +0000 (14:16 -0800)]
tevent: Regression test to ensure that a tevent backend can cope with separate read/write events on a single fd.

This tests the multiplex fd changes to the epoll backend to
ensure they work correctly.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
11 years agotevent: use DEBUG_ERROR for the fallback message in epoll_panic()
Stefan Metzmacher [Fri, 1 Mar 2013 13:30:54 +0000 (14:30 +0100)]
tevent: use DEBUG_ERROR for the fallback message in epoll_panic()

A Samba autobuild passed without a fallback, so this is
really an error.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
11 years agotevent: If epoll_ctl(..EPOLL_CTL_ADD,..) failes with EEXIST, merge the two fde's...
Jeremy Allison [Thu, 14 Feb 2013 21:52:41 +0000 (13:52 -0800)]
tevent: If epoll_ctl(..EPOLL_CTL_ADD,..) failes with EEXIST, merge the two fde's into one epoll event.

Signed-off-by: Jeremy Allison <jra@samba.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
11 years agotevent: preferr the write handler if there're two possible handlers registered with...
Stefan Metzmacher [Wed, 20 Feb 2013 10:50:56 +0000 (11:50 +0100)]
tevent: preferr the write handler if there're two possible handlers registered with epoll

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
11 years agotevent: In epoll_event_loop() ensure we trigger the right handler for a multiplexed...
Stefan Metzmacher [Wed, 20 Feb 2013 13:49:17 +0000 (14:49 +0100)]
tevent: In epoll_event_loop() ensure we trigger the right handler for a multiplexed fde event.

Signed-off-by: Jeremy Allison <jra@samba.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
11 years agotevent: Add utility function epoll_handle_hup_or_err()
Jeremy Allison [Thu, 14 Feb 2013 23:53:38 +0000 (15:53 -0800)]
tevent: Add utility function epoll_handle_hup_or_err()

We'll use this to handle the EPOLL_ADDITIONAL_FD_FLAG_GOT_ERROR
and EPOLL_ADDITIONAL_FD_FLAG_REPORT_ERROR flags with multiplexed
events in the event loop.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
11 years agotevent: handle EPOLL_ADDITIONAL_FD_FLAG_HAS_MPX in epoll_update_event()
Stefan Metzmacher [Wed, 20 Feb 2013 16:17:31 +0000 (17:17 +0100)]
tevent: handle EPOLL_ADDITIONAL_FD_FLAG_HAS_MPX in epoll_update_event()

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
11 years agotevent: handle multiplexed fde's in epoll_event_fd_destructor()
Stefan Metzmacher [Wed, 20 Feb 2013 17:01:57 +0000 (18:01 +0100)]
tevent: handle multiplexed fde's in epoll_event_fd_destructor()

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
11 years agotevent: Fix epoll_mod_event() to cope with modifying a multiplexed fde event.
Stefan Metzmacher [Fri, 1 Mar 2013 12:57:05 +0000 (13:57 +0100)]
tevent: Fix epoll_mod_event() to cope with modifying a multiplexed fde event.

Signed-off-by: Jeremy Allison <jra@samba.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
11 years agotevent: Fix up epoll_del_event to cope with deleting a multiplexed fde event.
Jeremy Allison [Fri, 15 Feb 2013 18:16:44 +0000 (10:16 -0800)]
tevent: Fix up epoll_del_event to cope with deleting a multiplexed fde event.

Signed-off-by: Jeremy Allison <jra@samba.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
11 years agotevent: handle multiplexed fde's in epoll_add_event()
Stefan Metzmacher [Wed, 20 Feb 2013 16:14:52 +0000 (17:14 +0100)]
tevent: handle multiplexed fde's in epoll_add_event()

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
11 years agotevent: Start to fix the epoll backend to support 2 fd events on the same fd correctly.
Jeremy Allison [Thu, 14 Feb 2013 21:50:56 +0000 (13:50 -0800)]
tevent: Start to fix the epoll backend to support 2 fd events on the same fd correctly.

Add a utility function epoll_add_multiplex_fd() and
a new flag EPOLL_ADDITIONAL_FD_FLAG_HAS_MPX.

This will be called by epoll_add_event() to merge two
fde events with the same file descriptor.

Signed-off-by: Jeremy Allison <jra@samba.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
11 years agotevent: ignore EBADF from epoll_ctl() and disable the event
Stefan Metzmacher [Wed, 20 Feb 2013 12:33:19 +0000 (13:33 +0100)]
tevent: ignore EBADF from epoll_ctl() and disable the event

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
11 years agotevent: unify handling of HAS_EVENT and REPORT_ERROR in epoll_{add,mod,del}_event()
Stefan Metzmacher [Wed, 20 Feb 2013 16:38:10 +0000 (17:38 +0100)]
tevent: unify handling of HAS_EVENT and REPORT_ERROR in epoll_{add,mod,del}_event()

epoll_{add,mod,del}_event() are only called via epoll_update_event()
and epoll_update_event() should not remove REPORT_ERROR itself.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
11 years agotevent: always go through epoll_update_event()
Stefan Metzmacher [Wed, 20 Feb 2013 10:26:00 +0000 (11:26 +0100)]
tevent: always go through epoll_update_event()

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