Preparing for launch.
Misc buffer fixes and documentation improvements from PR 1361.

(cherry picked from commit b4f4e539451eb7025bb19ca9a7057166da735687)
Correct vzps usage

Conflicts:
	libpromises/cf3.extern.h
	libpromises/cf3globals.c
	libpromises/classes.c
	libpromises/processes_select.c

(cherry picked from commit 2bfcc5db3d7346ed864c32e4d7c9dc4ea97e9e56)
Augment acceptance tests with mix of empty/non-empty lists.

Also, move testcase that fails due to bug in format() into
correct directory.

Test cases for Redmine #6553

(cherry picked from commit 56a93b0ee9d3c79b09e317544dbbde3cebebb3fd)
Iterate correctly over multiple lists.

If any list in an implict iteration is null or contains only null-values,
then the promise shall be skipped entirely.

The previous logic tried to account for (and to some degree, rely
on cf_null) in the list of variable values (var_states). The resulting
logic was overly complicated and didn't correctly abort iteration if
any of the lists was null.

Instead, store in the iterator if we encounter a list that has no
valid values, and implement NullIterators (a function declared
in iterate.h but never implemented) to return true if that was the case
so that we can skip the entire promise.

Remove dead code. This goes a long way towards a complete purging of
cf_null. We can't do so completely as we need to account for policies
that explicitly insert cf_null (many tests), and for functions. If we
were to remove it, then rval.item being NULL would become a valid case,
but a lot of evaluation code treats that as an error.

Fixes Redmine #6553

(cherry picked from commit ba8454c190910aa153b9e7a042b7471be1a672d3)
Refactoring: Remove cf_null handling from functions.

Instead of making sure in every list-returning function that we don't
return the null-pointer, centralize the appending of CF_NULL_VALUE
in FnCallEvaluate.

Remove unnecessary null-pointer checks. Allow sum() and product() to
successfully calculate 0 and 1 for null-lists, respectively.

(cherry picked from commit e2f1963e8c02ce3c3fdcf511f32073cce40f7d71)
Clarify the end-steps of WaitForIncoming().

(cherry picked from commit 784516cf6014724a0d1c30296840880adec6f075)
Dumb down some simple code.

(cherry picked from commit 7e45b31df2915ab23511e2acdb26884429fffb2c)
Correct test for openvz support

(cherry picked from commit ada8e7c0cb9d95f573ba283046d25b9b33963910)
Acceptance test for nested list expansion.

Covering various cases that have been problematic:

- nested lists where one list combination will be empty
- expansion of foreign lists
- passing of empty lists into methods as parameters

See Redmine #6553

(cherry picked from commit eb69514929b0778be5c225481a9d8319e411efbf)
Follow up to fixes for redmine/6553

With the previous fix, iteration skips the entire promise if
any of the lists to be iterated over is empty. This leads to
incorrect behavior in case of nested lists, where one of the
combinations of lists would be empty. Acceptance test addition
covers this case as well now.

The fix is now more intrusive. We don't include empty lists
any longer when parsing the string during expansion. Instead,
abort expansion, and skip this particular promise iteration.

The previous fixes remain in place.

(cherry picked from commit 776dd89981afb62efee83b84a2e53c1c8845a1fa)
Skip method evaluation if any parameter is cf_null

Fixes another Redmine #6553 case

(cherry picked from commit 753ea1fedd6c14e0af6c3c35e9b55b2b059f9c84)

Conflicts:
	cf-agent/verify_methods.c
Add: Acceptance test for ifelapsed

Ifelapsed should always be respected, especially at the individual
promise level.

Ref: https://dev.cfengine.com/issues/6334
(cherry picked from commit c2dde33f9f6dd7980787173d3ec3a1aa8523edcc)
Catch errors resulting from miscalculating the number of test results.

This will save us if we make a mistake in testall which leaves out
some test results.

(cherry picked from commit b004bb6c83b2a0500c7b4128c17af60f8442716b)
Rework KeepServerRolePromise().

I noticed a spurious continue (it was a no-op), so looked closely.
The inner loop tested a condition that didn't depend on any inner loop
variable, so I moved that outside the loop.  Different branches of the
switch on rval's type tested lval against various things; it makes
more sense to test the lval first and use that to decide what the
rval's type should be.  In particular, even if an "authorize" has a
value of the wrong type, we should report it even if it's currently
not active due to depending on a class that's not defined.  Moved a
function call outside a loop condition, made a variable more local.
Simplify loop by traversing Seq in reverse order.

(cherry picked from commit 737b84091cc1c272247e97238f6bf183fe4e1c54)
Canonify promiser name before testing if class is set

Also clean up some code; the function now asserts that
excluded is valid, and there is only one caller.

Add uncanonifed promiser to existing test case.

Fixes Redmine #6561

(cherry picked from commit 9f4ee1c9b1ca782a6fd6712c81b5f4d702b0d537)

Conflicts:
	libpromises/promises.c
UMR-fix: EvalContext's ->pass was unset by default.

There's logging code (PromiseBanner) that reports the pass and
valgrind reported it as an uninitialized memory read.  So change
EvalContextNew() to use calloc and ditch a bunch of initializations
to NULL and false that this does for us.

(cherry picked from commit f8aa78dfcfe1ab327a94907b82057049cfe78a8c)

Conflicts:
	libpromises/eval_context.c
Adjust test so that it fails for the right reasons.

Test passes if second cf-agent invokation also uses -K, which
is expected (and a crude workaround). But at least it shows that
the test is implemented correctly now.

Using ifelapsed => 0 in the method promise in bundle example
is necessary.

The regex can probably be made less aggressive, but it does the job.

(cherry picked from commit 81dfa3517d675b21bd9e06a48c1016cd09681867)
Implement the currently held locks as a stack.

The atexit handler can then clean up the entire stack of
currently held locks, rather than only the one that was
acquired last.

If any promise sets an abort class, the exit handler is
called, cleaning up the stack. Promises in the next run
are then no longer blocked, and usual lock elapse kicks in.

Fixes Redmine #6334

(cherry picked from commit 0653d5af46028245f65b8ff1d1a412f1f33851e0)
Don't pass literal strings when a char* is needed.

Perhaps IsUserNameValid() shouldn't need to modify its parameter; but
its test shouldn't pass it a const char* parameter as long as it
claims it does.  Turn the literals into initializers for non-const
arrays.

(cherry picked from commit 4ed0e2aed9733c25f121a3bba66c3cd67f0d8d17)