Redmine #6611: Fix incorrect key extraction when upgrading from < 3.6.1

Versions before 3.6.1 don't have the appsettings.php secret key at
all, so we need to detect when our extraction has failed and delete
the key file so that we will generate a key instead. We do this by
matching the extracted key file against the regular expression and by
making sure it contains exactly one such line.

(cherry picked from commit 4e09afd99db8c46fcefbc9b6afdbd077a12fcb59)
Fix libldap linking to /var/cfengine/lib/libcrypto.so instead of /usr/lib/.

(cherry picked from commit 59a3cd30f70a02fd13aaedcb6c0ca57f788e2d48)
Remove shady stuff.

(cherry picked from commit 82a46bff88e7d655f699aa8ccd04ad3d58b50990)
zlib: Make sure all .so files are part of run time dependencies.

The old code omitted .so without a numbered suffix, which would make
it a build time dependency instead of run time dependency.
(cherry picked from commit 72ed4e0a0fb10ee89a47b5ed4a106576c5179299)
Repeat fix 72ed4e0a for all dependencies.

As it turns out all Solaris dependencies suffer from the same problem,
so fix them all (and do FreeBSD as well, while we're at it). The fix
is:

Make sure all .so files are part of run time dependencies. The old
code omitted .so without a numbered suffix, which would make it a
build time dependency instead of run time dependency.
(cherry picked from commit d17db809b2e091fb38f3e853ed45c63688e709cc)
Inside WORKDIR/build/buildscripts we need the full .git/ directory to be available in order for the "revision" file to take the correct git SHA.

(cherry picked from commit 09e2383e5173ab33d3e1914174f3fe6f48b2c26a)
Remove stale comment.

(cherry picked from commit f4e3456993536653bc2b815c8f46eb50f311b3cb)
Bind redis to listen only on local host.

Redmine: #6720
(cherry picked from commit 459fe5cc10240a56bda7f2522faedc03233177e7)