aboutsummaryrefslogtreecommitdiffstats
path: root/net/ceph/ceph_common.c
diff options
context:
space:
mode:
authorTommi Virtanen <tommi.virtanen@dreamhost.com>2011-03-25 19:32:57 -0400
committerSage Weil <sage@newdream.net>2011-03-29 15:11:16 -0400
commit8323c3aa74cd92465350294567142d12ffdcc963 (patch)
tree052e7374393994eea8d534f98ee1bc7acea4c2d9 /net/ceph/ceph_common.c
parentfbdb9190482fd83a3eb20cdeb0da454759f479d7 (diff)
ceph: Move secret key parsing earlier.
This makes the base64 logic be contained in mount option parsing, and prepares us for replacing the homebew key management with the kernel key retention service. Signed-off-by: Tommi Virtanen <tommi.virtanen@dreamhost.com> Signed-off-by: Sage Weil <sage@newdream.net>
Diffstat (limited to 'net/ceph/ceph_common.c')
-rw-r--r--net/ceph/ceph_common.c43
1 files changed, 36 insertions, 7 deletions
diff --git a/net/ceph/ceph_common.c b/net/ceph/ceph_common.c
index 9bbb356b12e7..02e084f29d24 100644
--- a/net/ceph/ceph_common.c
+++ b/net/ceph/ceph_common.c
@@ -20,6 +20,7 @@
20#include <linux/ceph/decode.h> 20#include <linux/ceph/decode.h>
21#include <linux/ceph/mon_client.h> 21#include <linux/ceph/mon_client.h>
22#include <linux/ceph/auth.h> 22#include <linux/ceph/auth.h>
23#include "crypto.h"
23 24
24 25
25 26
@@ -117,9 +118,29 @@ int ceph_compare_options(struct ceph_options *new_opt,
117 if (ret) 118 if (ret)
118 return ret; 119 return ret;
119 120
120 ret = strcmp_null(opt1->secret, opt2->secret); 121 if (opt1->key && !opt2->key)
121 if (ret) 122 return -1;
122 return ret; 123 if (!opt1->key && opt2->key)
124 return 1;
125 if (opt1->key && opt2->key) {
126 if (opt1->key->type != opt2->key->type)
127 return -1;
128 if (opt1->key->created.tv_sec != opt2->key->created.tv_sec)
129 return -1;
130 if (opt1->key->created.tv_nsec != opt2->key->created.tv_nsec)
131 return -1;
132 if (opt1->key->len != opt2->key->len)
133 return -1;
134 if (opt1->key->key && !opt2->key->key)
135 return -1;
136 if (!opt1->key->key && opt2->key->key)
137 return 1;
138 if (opt1->key->key && opt2->key->key) {
139 ret = memcmp(opt1->key->key, opt2->key->key, opt1->key->len);
140 if (ret)
141 return ret;
142 }
143 }
123 144
124 /* any matching mon ip implies a match */ 145 /* any matching mon ip implies a match */
125 for (i = 0; i < opt1->num_mon; i++) { 146 for (i = 0; i < opt1->num_mon; i++) {
@@ -203,7 +224,10 @@ void ceph_destroy_options(struct ceph_options *opt)
203{ 224{
204 dout("destroy_options %p\n", opt); 225 dout("destroy_options %p\n", opt);
205 kfree(opt->name); 226 kfree(opt->name);
206 kfree(opt->secret); 227 if (opt->key) {
228 ceph_crypto_key_destroy(opt->key);
229 kfree(opt->key);
230 }
207 kfree(opt); 231 kfree(opt);
208} 232}
209EXPORT_SYMBOL(ceph_destroy_options); 233EXPORT_SYMBOL(ceph_destroy_options);
@@ -295,9 +319,14 @@ int ceph_parse_options(struct ceph_options **popt, char *options,
295 GFP_KERNEL); 319 GFP_KERNEL);
296 break; 320 break;
297 case Opt_secret: 321 case Opt_secret:
298 opt->secret = kstrndup(argstr[0].from, 322 opt->key = kzalloc(sizeof(*opt->key), GFP_KERNEL);
299 argstr[0].to-argstr[0].from, 323 if (!opt->key) {
300 GFP_KERNEL); 324 err = -ENOMEM;
325 goto out;
326 }
327 err = ceph_crypto_key_unarmor(opt->key, argstr[0].from);
328 if (err < 0)
329 goto out;
301 break; 330 break;
302 331
303 /* misc */ 332 /* misc */