waf:lib/replace correct detection of libiconv

add -liconv as a complete command line argument,
not all characters on their own

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

Signed-off-by: Christian Ambach <ambi@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
(cherry picked from commit 1a42ff7d8db63b26e2beb43268a1c4664723358e)
waf:lib/replace fix up libintl related checks

on a default installation of AIX, libintl.a exists but
libintl.h does not
So check for the declarations of those functions as well
to make sure that the build works.

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

Signed-off-by: Christian Ambach <ambi@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
(cherry picked from commit df6ddcfbfcd33274c1b768ce26829b0ad9278cd0)
waf:lib/replace change detection of gettext

convert this to an automatic check: if no option is given, try to find gettext
and if found, use it
if user has specified --with-gettext, then bail out if it could not be found
in case of --without-gettext, skip all gettext related configure checks

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

Signed-off-by: Christian Ambach <ambi@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
(cherry picked from commit a83f491810d34cc8b6eb4b0f40bbbb1440e0f84d)
waf:lib/replace fix gettext detection

if the user has specified a path for gettext, add it to CFLAGS and LDFLAGS
so we can find it during configure and build

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

Signed-off-by: Christian Ambach <ambi@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
(cherry picked from commit 31db0c8acdd68f396417e1f6504a91a40295bc89)
waf:lib/replace gettext configure checks

Make sure we only try to work with gettext if we found
the prototypes and were able to link

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

Signed-off-by: Christian Ambach <ambi@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>

Autobuild-User(master): Christian Ambach <ambi@samba.org>
Autobuild-Date(master): Fri Jan 17 19:30:33 CET 2014 on sn-devel-104

(cherry picked from commit da891e2101c568d2f0b9a2bda78702826ea68f3c)
waf:lib/replace fix iconv checks on HP/UX

we need to copy away the list of LDFLAGS
to be tried before modifying it instead of
just creating a new reference and then continuing
with a modified list while it should have been
reset back to the original value

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

Signed-off-by: Christian Ambach <ambi@samba.org>

Reviewed-by: Andrew Bartlett <abartlet@samba.org>

Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Thu Feb 13 02:01:03 CET 2014 on sn-devel-104

(cherry picked from commit 6a7c420a79cc1258528f152f4de9a0608767729f)
heimdal_build: only enable libintl functions if everything was found

do not rely on intl.h being available but also on the functions being usable
This should fix the build on HP-UX

Bug: https://bugzilla.samba.org/show_bug.cgi?id=9911
Signed-off-by: Christian Ambach <ambi@samba.org>

Change-Id: I5dd88d2d5216b778624778455cca99b32d0be58f
Reviewed-by: Andrew Bartlett <abartlet@samba.org>

Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Thu Feb 20 01:28:24 CET 2014 on sn-devel-104

(cherry picked from commit 8f0d06fa5e654f647664727db6f12901579ec2c7)
waf: improve iconv checks

there are broken iconv implementations around (e.g. on AIX) that you
can compile against but that refuse any mapping requests

make sure we do the same as the autoconf-based build did and
fall back to our own code

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

Signed-off-by: Christian Ambach <ambi@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
(cherry picked from commit 15b2d1a658b3fc428c20a7a461168f464951f40f)
(cherry picked from commit f5cbfd6ce5e5a0977e5c1a53046ee883b3431246)
s3: ldap client can return NT_STATUS_OK when an error occurs in a paged search.

"Inside ads_do_search_all_args(), if the first call to ads_do_paged_search_args()
fails, the proper error status is returned.

But, if the execution is already inside the loop to get all the accounts doing
several calls to ads_do_paged_search_args(), and one of these calls times out,
the status returned is from the *first* call, so success. This causes
net_ads_search() to interpret the return from ads_do_search_retry() as
success and print all the accounts returned, but it’s only a subset."

Also ensure we free previously returned results on error
in subsequent fetches.

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

Signed-off-by: Daniel Liberman <danielvl@gmail.com>
Reviewed-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Richard Sharpe <realrichardsharpe@gmail.com>

Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Thu Jan 23 01:40:54 CET 2014 on sn-devel-104

(cherry picked from commit b04e8b7557b82a4b96cf74db04742fb017edb3ba)
rpc_client: retry open on STATUS_PIPE_NOT_AVAILABLE

Windows Server starts some named pipe services on demand, and responds
to initial open requests with STATUS_PIPE_NOT_AVAILABLE. The FssagentRpc
named pipe on Windows Server 2012 exhibits this behaviour.

This change sees rpcclient retry named pipe open requests when the
server responds with STATUS_PIPE_NOT_AVAILABLE. The retry logic is
contained in an asynchronous tevent_timer callback, to allow for
non-blocking callers.

Signed-off-by: David Disseldorp <ddiss@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
(cherry picked from commit ebe6627c1f0e6b488a0c456860a055fd5701e84d)
[ddiss@samba.org: rebasead for 4.1 without 46d29d46bc065d51e3f7ca6892]

Bug: https://bugzilla.samba.org/show_bug.cgi?id=10484
Initial FSRVP rpcclient requests fail with NT_STATUS_PIPE_NOT_AVAILABLE
s3-printing: Fix obvious memory leak in printer_list_get_printer().

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

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

Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Tue Feb 25 13:19:37 CET 2014 on sn-devel-104

(cherry picked from commit 148bbdd8d04400b5d873f636671dd443952ca04f)
s3: smbd: Ensure brl_get_locks_internal() always returns a valid struct byte_range_lock even if there are no locks.

brl_get_locks_internal() currently returns NULL when it can't
find any byte range locks on the file. This is an error - it
should return a valid struct byte_range_lock containing num_locks == 0
so it can be cached.

Returning NULL when there are no locks causes POSIX lock
tests to fail returning NT_STATUS_NO_MEMORY (as it thinks
it can't allocate the struct) instead of NT_STATUS_OK.

This is a back-port of git commit abf08ed544ce05ea5a6e6ea2e531b6a2d97e15cc
that went into master.

Fixes bug:

Bug 10431 - STATUS_NO_MEMORY response from Query File Posix Lock request

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

Signed-off-by: Jeremy Allison <jra@samba.org>
pidl:NDR/Client: fix dcerpc_function() with [out,ref] pointers

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
(cherry picked from commit f50b561336c7b6c08300e6e477859d1f9fab62c2)
s3:winbindd: fix _wbint_LookupSids() on error

We need to make sure that r->out.domains remains valid,
otherwise we're not able to marshall the response.

Note that wbint_LookupSids() has [out,ref] lsa_RefDomainList *domains,
while lsa_LookupSids() has [out,ref] lsa_RefDomainList **domains.

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

Bug: https://bugzilla.samba.org/show_bug.cgi?id=10458
Signed-off-by: Gregor Beck <gbeck@sernet.de>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
(cherry picked from commit 3413e64149702136429d7b5acaa7a52c49abf564)
s3:winbindd: avoid directly asking a trusted domain in wb_lookupsids*()

As a domain member we should always use a DC of our own domain.

It would be possible to pass all sids in one single dcerpc_wbint_LookupSids()
call. For now we just fix bug.

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

Bug: https://bugzilla.samba.org/show_bug.cgi?id=10458
Signed-off-by: Gregor Beck <gbeck@sernet.de>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
(cherry picked from commit 66fb0ce9557553a4c01607b517e65ac4c93841d0)
s3-spoolssd: Don't register spoolssd if epmd is not running.

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

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
(cherry picked from commit 562ade624a78a11a5af0f26b04df93d76d6166bd)

Autobuild-User(v4-0-test): Karolin Seeger <kseeger@samba.org>
Autobuild-Date(v4-0-test): Mon Mar 10 18:37:25 CET 2014 on sn-devel-104
VERSION: Bump version number up to 4.0.16...

and re-enable git snapshots.

Signed-off-by: Karolin Seeger <kseeger@samba.org>
(cherry picked from commit 20d7ec8a7b1d39f5a93e58d22720d0a333079254)
CVE-2013-4496:s3-samr: Block attempts to crack passwords via repeated password changes

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

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
CVE-2013-4496:s3:auth: fix memory leak in the ACCOUNT_LOCKED_OUT case.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
CVE-2013-4496:samr: Remove ChangePasswordUser

This old password change mechanism does not provide the plaintext to
validate against password complexity, and it is not used by modern
clients.

The missing features in both implementations (by design) were:

 - the password complexity checks (no plaintext)
 - the minimum password length (no plaintext)

Additionally, the source3 version did not check:

 - the minimum password age
 - pdb_get_pass_can_change() which checks the security
   descriptor for the 'user cannot change password' setting.
 - the password history
 - the output of the 'passwd program' if 'unix passwd sync = yes'.

Finally, the mechanism was almost useless, as it was incorrectly
only made available to administrative users with permission
to reset the password.  It is removed here so that it is not
mistakenly reinstated in the future.

Andrew Bartlett

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

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>