TEST: Make search/valid aware that the behaviour of the kernel changed

The kernel changed its behaviour with regard to the error code it returns when
the first key a search found was revoked and no valid key was found.  It used
to return ENOKEY and now returns EKEYREVOKED.

Signed-off-by: David Howells <dhowells@redhat.com>
Lib: Fix error-path memory leaks

Fix some memory leaks in error paths where a previously allocated buffer is
not freed if we get an error.

Signed-off-by: David Howells <dhowells@redhat.com>
Use keyctl_describe_alloc() in dump_key_tree_aux()

Use the keyctl_describe_alloc() library function in dump_key_tree_aux() in the
keyctl program rather than open coding it.

Signed-off-by: David Howells <dhowells@redhat.com>
keyctl: Exit rather than returning from act_xxx() functions

Exit rather than returning from act_xxx() functions so that the Coverity
checker doesn't think that memory is leaked from functions that allocate
memory.

Signed-off-by: David Howells <dhowells@redhat.com>
Fix memory leak in dump_key_tree_aux() in the keyctl program

Fix a leak of the description string memory from each key visited in
dump_key_tree_aux() in the keyctl program.

Signed-off-by: David Howells <dhowells@redhat.com>
Only get the groups list if calc_perms() is called

Only get the groups list if calc_perms() is called as there's no point
grabbing the list otherwise.

Signed-off-by: David Howells <dhowells@redhat.com>
Lib: Don't trust sscanf()'s %n argument

Don't trust sscanf()'s %n argument just in case the space immediately before
it didn't match anything as sscanf() doesn't tell you if it was set.

Signed-off-by: David Howells <dhowells@redhat.com>
Lib: Check the description string is NUL-terminated when retrieved

Check the description string is NUL-terminated retrieved by keyctl_describe()
included a NUL-terminator in its length.

Signed-off-by: David Howells <dhowells@redhat.com>
spec: Use the correct path macros in the specfile

Use the correct path macros in the specfile.

Signed-off-by: David Howells <dhowells@redhat.com>