3 #include <linux/module.h>
5 #include <linux/slab.h>
18 static u32 supported_protocols[] = {
43 dout(
"auth_init name '%s'\n", name);
55 dout(
"auth_init name %s\n", ac->
name);
65 dout(
"auth_destroy %p\n", ac);
76 dout(
"auth_reset %p\n", ac);
86 if (*p + 2*
sizeof(
u32) + len > end)
89 ceph_encode_32(p, len);
90 ceph_encode_copy(p, name, len);
101 void *
p = monhdr + 1, *
end = buf + len, *lenp;
105 dout(
"auth_build_hello\n");
110 ceph_encode_32(&p, 0);
116 ceph_encode_8(&p, 1);
118 ceph_encode_32(&p, num);
120 for (i = 0; i < num; i++)
121 ceph_encode_32(&p, supported_protocols[i]);
129 ceph_encode_32(&lenp, p - lenp -
sizeof(
u32));
140 void *
p = monhdr + 1;
150 ret = ac->
ops->build_request(ac, p +
sizeof(
u32), end);
152 pr_err(
"error %d building auth method %s request\n", ret,
156 dout(
" built request %d bytes\n", ret);
157 ceph_encode_32(&p, ret);
165 void *
buf,
size_t len,
169 void *end = buf + len;
179 dout(
"handle_auth_reply %p %p\n", p, end);
181 protocol = ceph_decode_32(&p);
182 result = ceph_decode_32(&p);
183 global_id = ceph_decode_64(&p);
184 payload_len = ceph_decode_32(&p);
188 result_msg_len = ceph_decode_32(&p);
194 dout(
" result %d '%.*s' gid %llu len %d\n", result, result_msg_len,
195 result_msg, global_id, payload_len);
199 if (global_id && ac->
global_id != global_id) {
200 dout(
" set global_id %lld -> %lld\n", ac->
global_id, global_id);
206 if (!protocol && result < 0) {
212 ac->
ops->destroy(ac);
217 ret = ceph_auth_init_protocol(ac, protocol);
219 pr_err(
"error %d on auth protocol %d init\n",
228 ret = ac->
ops->handle_reply(ac, result, payload, payload_end);
230 return ceph_build_auth_request(ac, reply_buf, reply_len);
232 pr_err(
"auth method '%s' error %d\n", ac->
ops->name, ret);
238 pr_err(
"failed to decode auth msg\n");
244 void *msg_buf,
size_t msg_len)
249 if (ac->
ops->should_authenticate(ac))
250 return ceph_build_auth_request(ac, msg_buf, msg_len);
258 return ac->
ops->is_authenticated(ac);