From: Josh Durgin Date: Tue, 29 Nov 2011 00:54:27 +0000 (-0800) Subject: secret: add is_kernel_secret function X-Git-Tag: v0.40~214 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=0ad0fbfe3a244e849e0511743e80fc28a4c545a1;p=ceph.git secret: add is_kernel_secret function This will let us know whether we can add a key mount option if no secret is specified. Signed-off-by: Josh Durgin --- diff --git a/src/common/secret.c b/src/common/secret.c index fb37b6db74b8..bc136d65fc7c 100644 --- a/src/common/secret.c +++ b/src/common/secret.c @@ -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; diff --git a/src/common/secret.h b/src/common/secret.h index 8ae0df8d572d..8a4f3e949b60 100644 --- a/src/common/secret.h +++ b/src/common/secret.h @@ -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