diff options
author | Stef Walter <stef@thewalter.net> | 2013-07-03 12:46:41 +0200 |
---|---|---|
committer | Stef Walter <stef@thewalter.net> | 2013-07-03 13:14:45 +0200 |
commit | 269c4c2e82543de273fa9415dec1b9b6e00c51af (patch) | |
tree | 4021b692ee2a15bb1fe4d0be77934195f04ff9c7 | |
parent | 4bbb7038816d3664c92cb442e3d1ccac8f92f83c (diff) |
trust: If token path is a file, don't try loading subdirectories
-rw-r--r-- | trust/token.c | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/trust/token.c b/trust/token.c index cbb522e..6b88fc6 100644 --- a/trust/token.c +++ b/trust/token.c @@ -293,7 +293,8 @@ loader_load_directory (p11_token *token, static int loader_load_path (p11_token *token, - const char *path) + const char *path, + bool *is_dir) { p11_dictiter iter; p11_dict *present; @@ -312,6 +313,8 @@ loader_load_path (p11_token *token, } if (S_ISDIR (sb.st_mode)) { + *is_dir = true; + ret = 0; /* All the files we know about at this path */ present = p11_dict_new (p11_dict_str_hash, p11_dict_str_equal, NULL, NULL); @@ -342,6 +345,7 @@ loader_load_path (p11_token *token, loader_was_loaded (token, path, &sb); } else { + *is_dir = false; ret = loader_load_file (token, path, &sb); } @@ -377,19 +381,22 @@ int p11_token_load (p11_token *token) { int total = 0; + bool is_dir; int ret; - ret = loader_load_path (token, token->path); + ret = loader_load_path (token, token->path, &is_dir); return_val_if_fail (ret >= 0, -1); total += ret; - ret = loader_load_path (token, token->anchors); - return_val_if_fail (ret >= 0, -1); - total += ret; + if (is_dir) { + ret = loader_load_path (token, token->anchors, &is_dir); + return_val_if_fail (ret >= 0, -1); + total += ret; - ret = loader_load_path (token, token->blacklist); - return_val_if_fail (ret >= 0, -1); - total += ret; + ret = loader_load_path (token, token->blacklist, &is_dir); + return_val_if_fail (ret >= 0, -1); + total += ret; + } return total; } |