Redmine#6674 Modifying hashing function to add info about index boudaries

When using multi-index arrays hash function is looping through each
character in index without modifying hashed value once moving form one
index to another. That's why entries like a[te][st], a[tes][t], a[t][e][st]
and all other variations are resulting in having exactly the same hash.
While trying to add new array entry to RB tree having the same characters
in indexes previous entry is updated instead of new one being created.
(cherry picked from commit 0f84c0c4e0ff5d755cc2447918ffb2c3b8f24d46)
Adjust acceptance test for Redmine#6674
(cherry picked from commit 5e4b4c1bb1fc7506f60361f71cb8c392578c4709)
Fix test relying on specific order of getindices.

As getindices returned list is not guaranteed to be in any specific
order we should sort the results before comparing expected and actual
test results.
(cherry picked from commit 165a1c9feeaf06b456cdb782ecb2574a36a4d299)
Fixing arrays hashing.

To avoid having the same hashes for variables like a[10] and a1[0]
array boundary hash moved above index hashing.
(cherry picked from commit b87c03c1c8f5964fa34ae90252362ff4d5365671)
Test case testing multi-index array hashing updated.

Now cases like a[10] and a1[0] covered while checking if hashing is
working accurately.
(cherry picked from commit fca4d13eda78143ebb53dfcb819e76a40ca81e56)
Fix test relying on ordering of array elements returning by mergedata.

This one is simple change of expected strings. We can think how to modify
this test in future to sort the merged array elements before comparing.
(cherry picked from commit c065939cdbfe1130dca404be82db17172acaf30a)
Merge pull request #2041 from pasinskim/3.6.x

Redmine#6674 cherries
cf_popen() generates an error message on distributions where ifconfig cannot be found during IPv6 discovery, affects RHEL 7

(cherry picked from commit b957ad6eb19c3fdb3c62940c61a24266f4fbcff3)
cf_popen() generates an error message on distributions where netstat et al cannot be found during monitoring probing, affects RHEL 7

(cherry picked from commit 6bebdcc08a1899a89f17a8a0e9e2b4904c61c1bb)
Add: Acceptance tests for warn only and mustache templating

Modified by: Kristian Amlie <kristian.amlie@cfengine.com>
(cherry picked from commit b4c5f6fd9ff7209896eb3b46a96d22b92616186d)
support dry-run for mustache templates. Redmine #6739
(cherry picked from commit 8924c1e66f7a2e531e28462107e5a0ac431fa989)
tag mustace acceptance tests with story_id 5535
(cherry picked from commit 832691fb6041651651a6d0be200f5ad50cd33a1b)
Fix broken variables tree iteration.

This fixes whole number of problems with iterating through RB tree
containing variables. Especially:
https://dev.cfengine.com/issues/6033
https://dev.cfengine.com/issues/6779

EvalContextVariableTableIteratorNew is calling VariableTableIteratorNew
which is not aware of variable indexes (VarRef->indices). Then while picking
value form tree to be iterator it might or might not contain indexes.
Randomly selecting variable with wrong index (and number of indexes)
is causing wrong behavior while iterating through list of variables.
VariableTableIteratorNext is checking indexes and returning variables
based on VariableTableIterator selected previously by
EvalContextVariableTableIteratorNew which is totally unreliable in case
of arrays.
(cherry picked from commit e2c8cd0f2fb9724e47330ecaca7fdd452a7bc60a)

Conflicts:

	libpromises/evalfunction.c
Fix relaying on order of keys returned by maparray.
(cherry picked from commit e4809443a5b959f3166ea718df87792380733712)
Merge pull request #2042 from pasinskim/3.6.x

Redmine#6779 cherries
Convert bogus strncat() - no pre-zeroed buffer - to strlcat().

(cherry picked from commit d829109fed815966fc78032d71ed38ecd962fc1f)
Fix very old code, if read is partial (n_read < toget) this would write garbage.

(cherry picked from commit 076d45c1216fd7694f1a18745e9bfd49272f84b5)

Conflicts:
	libcfnet/client_code.c
Make sure list is free'd in case of error. A bit cleanups as well.

(cherry picked from commit f62c0e43dba947b237da044278dd48319c604e80)

Conflicts:
	libcfnet/client_code.c
Exit with error if connection is closed before having received CFD_TERMINATOR.

(cherry picked from commit 7359e88682dfa60e13ec42edaacf27adced23b03)
If client fails to run time() send 0 in SYNCH packet. Server should then not fail, unless denybadclocks is set.

(cherry picked from commit 8208d1c3717c5944c534b9d1fa2bdeb67f028cf9)

Conflicts:
	libcfnet/stat_cache.c