zkey: Fix listing of keys on file systems reporting DT_UNKNOWN

The zkey list function uses scandir() to look for files in the
zkey key repository directory. It checks the dirent.d_type field
to consider only regular files, but skip all others.

Unfortunately, not all file systems have full support for returning
the file type in d_type. When the zkey repository is located in a file
system that does not support d_type, such as xfs, zkey list shows no
keys, although the key repository contains keys.

Fix this by also considering directory entries with d_type = DT_UNKNOWN.

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
Ingo Franzki
2020-01-07 13:01:29 +01:00
committed by Jan Höppner
parent 27a6409a4a
commit 0de533aef9

View File

@@ -906,7 +906,7 @@ static int _keystore_info_file_filter(const struct dirent *dirent)
{
size_t len;
if (dirent->d_type != DT_REG)
if (dirent->d_type != DT_REG && dirent->d_type != DT_UNKNOWN)
return 0;
len = strlen(dirent->d_name);