Skip to content

Commit

Permalink
secret: add is_kernel_secret function
Browse files Browse the repository at this point in the history
This will let us know whether we can add a key mount option
if no secret is specified.

Signed-off-by: Josh Durgin <[email protected]>
  • Loading branch information
jdurgin committed Dec 6, 2011
1 parent 01d30e6 commit 0ad0fbf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/common/secret.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,13 @@ static int add_secret_to_kernel(const char *secret, const char *key_name)
return ret;
}

int is_kernel_secret(const char *key_name)
{
key_serial_t serial;
serial = request_key("ceph", key_name, NULL, KEY_SPEC_USER_KEYRING);
return serial != -1;
}

int get_secret_option(const char *secret, const char *key_name, char *secret_option, size_t max_len)
{
int ret;
Expand Down
2 changes: 2 additions & 0 deletions src/common/secret.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ int read_secret_from_file(const char *filename, char *secret, size_t max_len);
*/
int get_secret_option(const char *secret, const char *key_name, char *secret_option, size_t secret_option_len);

int is_kernel_secret(const char *key_name);

#ifdef __cplusplus
}
#endif
Expand Down

0 comments on commit 0ad0fbf

Please sign in to comment.