Translate WinSock errors to Posix counterparts

MSVC 2010 defines both Posix and WinSock error values so we can no longer
simply #define the Posix error values to be their WinSock counterpart.
This patch explicitly #includes <errno.h> in port-sockets.h and still
conditionally defines the Posix error values for compatibility with older
MSVC but also translates WinSock errors to Posix for MSVC 2010
compatibility.

The downside to this approach is that there are some Posix errors we
do not currently detect (e.g. EADDRINUSE) that are neither #defined nor
translated.  If we use one of those in the future but fail to update
TranslateWSAGetLastError() we'll once again be in the situation that the
windows build will compile but fail to work, possibly only when some rare
error condition occurs.

Signed-off-by: Kevin Wasserman <kevin.wasserman@painless-security.com>

(cherry picked from commit fc08c21ab33fcc0c8851a2a0fb0e55721ff975ea)

ticket: 7197
version_fixed: 1.10.3
status: resolved
Implement switch_to for ccapiv3

krb5_stdccv3_switch_to() calls cc_ccache_set_default().
krb5_stdccv3_resolve() checks for NULL or empty residual and calls
cc_context_get_default_ccache_name() in those cases.

Signed-off-by: Kevin Wasserman <kevin.wasserman@painless-security.com>

(cherry picked from commit 2648a94ea1cf3dec91186dfec59b75de9dac793d)

ticket: 7198
version_fixed: 1.10.3
status: resolved
Add krb5int_cc_user_set_default_name

Set the default credential cache name for all processes for the current
user.  Currently implemented, for windows only, by setting
HKEY_CURRENT_USER\Software\MIT\Kerberos5:ccname to the specified
ccache name.  This will not override the environment variable 'KRB5CCNAME'.
It will override HKEY_LOCAL_MACHINE and 'indirect' registry values.

Signed-off-by: Kevin Wasserman <kevin.wasserman@painless-security.com>

(cherry picked from commit 80097093062822dde3f1140d250023576e52f59c)

ticket: 7199
version_fixed: 1.10.3
status: resolved
Always recreate acl files during dejagnu tests

The dejagnu tests create some persistent acl files containing
hostname-derived principal names.  These can get out of date if the
host has changed names since the last time the dejagnu tests were run,
causing failures (notably in iprop.exp).  To avoid this problem,
change the dejagnu tests to always create new acl files for each test
run.

(cherry picked from commit 244bb3fde58dd6bab0969e0501b537c5871088f0)

ticket: 7200
version_fixed: 1.10.3
status: resolved
Handle huge /bin directories in libdb2 test

The test suite for libdb2 uses /bin as a source of filenames and
contents for insertion into databases.  Fedora 17 (and possibly other
OSes) have /bin symlinked to /usr/bin, which can vastly increase the
number of files found, exceeding some limits of the test databases.
Truncate this list of files at 100 to prevent this problem.

(cherry picked from commit 18a378eb43a7a5a5e14a7e6c3b6504fe32804781)

ticket: 7201
version_fixed: 1.10.3
status: resolved
kfw add preauth_sam2 to OBJS for windows build

Signed-off-by: Kevin Wasserman <kevin.wasserman@painless-security.com>

(cherry picked from commit d319617ba9dd1256784fe325ae5a3858cf4603e7)

ticket: 7203
version_fixed: 1.10.3
status: resolved
KFW win-mac.h fixes

kfw: add int16_t, uint16_t typedefs to win-mac.h
uint16_t is used in chpw.c

include stdlib.h, crtdbg.h in win-mac.h

Allows leak-tracking using built-in msvc tools on windows.
crtdbg.h needs to come _after_ stdlib.h, but _before_ checking for
strdup.  Define DEBUG and CRTDBG_MAP_ALLOC for full tracking.

Signed-off-by: Kevin Wasserman <kevin.wasserman@painless-security.com>

(cherry picked from commit 0a27c56e300990909317630e626ccdd8ae8e7f41)

ticket: 7204
version_fixed: 1.10.3
status: resolved
Use %i, not %s to Tprintf GetLastError()

Signed-off-by: Kevin Wasserman <kevin.wasserman@painless-security.com>

(cherry picked from commit 692c1ccea5af4549437937a424b64ab40178fcc2)

ticket: 7206
version_fixed: 1.10.3
status: resolved
Define USE_CCAPI_V3 in krb5/ccache on windows

USE_CCAPI_V3 provides cccol iteration support for ccapi.

Signed-off-by: Kevin Wasserman <kevin.wasserman@painless-security.com>

(cherry picked from commit 227a1b093cb22eb7c6d7fee0759f28816572db70)

Build lib/krb5/ccache/ccapi on Windows only

Signed-off-by: Kevin Wasserman <kevin.wasserman@painless-security.com>

(cherry picked from commit 8c3d2bfab7017a587d0c9a7de262cdcf18ce21c8)

ticket: 7209
version_fixed: 1.10.3
status: resolved
Remove the UNICODE defines from wshelper

wshelper is clearly not intended to use unicode:
wprintf is used extensively and exclusively to write to char[] buffers and
fields in dns structs are used as explicitly ASCII text.

Signed-off-by: Alexey Melnikov <aamelnikov@gmail.com>

(cherry picked from commit 7d156d88ce5cdc40b1df02f051d65b3ad93c60e1)

ticket: 7210
version_fixed: 1.10.3
status: resolved
MSLSA Don't use lstrcpy on ANSI strings

Also change parameter types to eliminate casts.

Signed-off-by: Kevin Wasserman <kevin.wasserman@painless-security.com>

(cherry picked from commit 7acb524f5aa00274771dbbfac19d2dd779aad409)

ticket: 7212
version_fixed: 1.10.3
status: resolved