]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
secret: add is_kernel_secret function
authorJosh Durgin <josh.durgin@dreamhost.com>
Tue, 29 Nov 2011 00:54:27 +0000 (16:54 -0800)
committerJosh Durgin <josh.durgin@dreamhost.com>
Tue, 6 Dec 2011 18:26:24 +0000 (10:26 -0800)
This will let us know whether we can add a key mount option
if no secret is specified.

Signed-off-by: Josh Durgin <josh.durgin@dreamhost.com>
src/common/secret.c
src/common/secret.h

index fb37b6db74b8e406cddee498c41df04822222693..bc136d65fc7c135a5e15b4e7b4e3bc0ef849eb89 100644 (file)
@@ -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;
index 8ae0df8d572d35d47f901287bb0d0e0ffdfacbc5..8a4f3e949b609862d80be36516d6f5ab211429a0 100644 (file)
@@ -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