Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8323c3aa authored by Tommi Virtanen's avatar Tommi Virtanen Committed by Sage Weil
Browse files

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: default avatarTommi Virtanen <tommi.virtanen@dreamhost.com>
Signed-off-by: default avatarSage Weil <sage@newdream.net>
parent fbdb9190
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -353,7 +353,7 @@ static int ceph_show_options(struct seq_file *m, struct vfsmount *mnt)


	if (opt->name)
	if (opt->name)
		seq_printf(m, ",name=%s", opt->name);
		seq_printf(m, ",name=%s", opt->name);
	if (opt->secret)
	if (opt->key)
		seq_puts(m, ",secret=<hidden>");
		seq_puts(m, ",secret=<hidden>");


	if (opt->mount_timeout != CEPH_MOUNT_TIMEOUT_DEFAULT)
	if (opt->mount_timeout != CEPH_MOUNT_TIMEOUT_DEFAULT)
+2 −2
Original line number Original line Diff line number Diff line
@@ -67,12 +67,12 @@ struct ceph_auth_client {
	bool negotiating;       /* true if negotiating protocol */
	bool negotiating;       /* true if negotiating protocol */
	const char *name;       /* entity name */
	const char *name;       /* entity name */
	u64 global_id;          /* our unique id in system */
	u64 global_id;          /* our unique id in system */
	const char *secret;     /* our secret key */
	const struct ceph_crypto_key *key;     /* our secret key */
	unsigned want_keys;     /* which services we want */
	unsigned want_keys;     /* which services we want */
};
};


extern struct ceph_auth_client *ceph_auth_init(const char *name,
extern struct ceph_auth_client *ceph_auth_init(const char *name,
					       const char *secret);
					       const struct ceph_crypto_key *key);
extern void ceph_auth_destroy(struct ceph_auth_client *ac);
extern void ceph_auth_destroy(struct ceph_auth_client *ac);


extern void ceph_auth_reset(struct ceph_auth_client *ac);
extern void ceph_auth_reset(struct ceph_auth_client *ac);
+1 −1
Original line number Original line Diff line number Diff line
@@ -61,7 +61,7 @@ struct ceph_options {
					      pointer type of args */
					      pointer type of args */
	int num_mon;
	int num_mon;
	char *name;
	char *name;
	char *secret;
	struct ceph_crypto_key *key;
};
};


/*
/*
+4 −4
Original line number Original line Diff line number Diff line
@@ -35,12 +35,12 @@ static int ceph_auth_init_protocol(struct ceph_auth_client *ac, int protocol)
/*
/*
 * setup, teardown.
 * setup, teardown.
 */
 */
struct ceph_auth_client *ceph_auth_init(const char *name, const char *secret)
struct ceph_auth_client *ceph_auth_init(const char *name, const struct ceph_crypto_key *key)
{
{
	struct ceph_auth_client *ac;
	struct ceph_auth_client *ac;
	int ret;
	int ret;


	dout("auth_init name '%s' secret '%s'\n", name, secret);
	dout("auth_init name '%s'\n", name);


	ret = -ENOMEM;
	ret = -ENOMEM;
	ac = kzalloc(sizeof(*ac), GFP_NOFS);
	ac = kzalloc(sizeof(*ac), GFP_NOFS);
@@ -52,8 +52,8 @@ struct ceph_auth_client *ceph_auth_init(const char *name, const char *secret)
		ac->name = name;
		ac->name = name;
	else
	else
		ac->name = CEPH_AUTH_NAME_DEFAULT;
		ac->name = CEPH_AUTH_NAME_DEFAULT;
	dout("auth_init name %s secret %s\n", ac->name, secret);
	dout("auth_init name %s\n", ac->name);
	ac->secret = secret;
	ac->key = key;
	return ac;
	return ac;


out:
out:
+5 −3
Original line number Original line Diff line number Diff line
@@ -662,14 +662,16 @@ int ceph_x_init(struct ceph_auth_client *ac)
		goto out;
		goto out;


	ret = -EINVAL;
	ret = -EINVAL;
	if (!ac->secret) {
	if (!ac->key) {
		pr_err("no secret set (for auth_x protocol)\n");
		pr_err("no secret set (for auth_x protocol)\n");
		goto out_nomem;
		goto out_nomem;
	}
	}


	ret = ceph_crypto_key_unarmor(&xi->secret, ac->secret);
	ret = ceph_crypto_key_clone(&xi->secret, ac->key);
	if (ret)
	if (ret < 0) {
		pr_err("cannot clone key: %d\n", ret);
		goto out_nomem;
		goto out_nomem;
	}


	xi->starting = true;
	xi->starting = true;
	xi->ticket_handlers = RB_ROOT;
	xi->ticket_handlers = RB_ROOT;
Loading