1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * Copyright (C) 2004 Cluster File Systems, Inc.
6 * This file is part of Lustre, http://www.lustre.org.
8 * Lustre is free software; you can redistribute it and/or
9 * modify it under the terms of version 2 of the GNU General Public
10 * License as published by the Free Software Foundation.
12 * Lustre is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Lustre; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 # define EXPORT_SYMTAB
25 #define DEBUG_SUBSYSTEM S_SEC
27 #include <linux/init.h>
28 #include <linux/module.h>
29 #include <linux/slab.h>
31 #include <liblustre.h>
34 #include <libcfs/kp30.h>
35 #include <linux/obd_support.h>
36 #include <linux/lustre_idl.h>
37 #include <linux/lustre_net.h>
38 #include <linux/lustre_sec.h>
41 int null_svcsec_accept(struct ptlrpc_request *req, enum ptlrpcs_error *res)
43 struct ptlrpcs_wire_hdr *hdr = buf_to_sec_hdr(req->rq_reqbuf);
46 LASSERT(hdr->flavor == PTLRPC_SEC_NULL);
48 if (hdr->sec_len != 0) {
49 CERROR("security payload %d not zero\n", hdr->sec_len);
50 *res = PTLRPCS_REJECTEDCRED;
54 req->rq_reqmsg = (struct lustre_msg *)(hdr + 1);
55 req->rq_reqlen = hdr->msg_len;
57 CDEBUG(D_SEC, "req %p: set reqmsg at %p, len %d\n",
58 req, req->rq_reqmsg, req->rq_reqlen);
63 int null_svcsec_authorize(struct ptlrpc_request *req)
65 struct ptlrpc_reply_state *rs = req->rq_reply_state;
66 struct ptlrpcs_wire_hdr *hdr;
70 LASSERT(rs->rs_repbuf_len >= 4 * 4);
72 hdr = buf_to_sec_hdr(rs->rs_repbuf);
73 hdr->flavor = cpu_to_le32(PTLRPC_SEC_NULL);
74 hdr->sectype = cpu_to_le32(PTLRPC_SEC_TYPE_AUTH);
75 hdr->msg_len = cpu_to_le32(req->rq_replen);
76 hdr->sec_len = cpu_to_le32(0);
78 CDEBUG(D_SEC, "fill in datasize %d\n", rs->rs_repdata_len);
82 static struct ptlrpc_svcsec null_svcsec = {
83 .pss_owner = THIS_MODULE,
84 .pss_name = "NULL_SVCSEC",
85 .pss_flavor = {PTLRPC_SEC_NULL, 0},
86 .accept = null_svcsec_accept,
87 .authorize = null_svcsec_authorize,
90 int svcsec_null_init()
94 rc = svcsec_register(&null_svcsec);
96 CERROR("failed to register SVCNULL security: %d\n", rc);
101 int svcsec_null_exit()
105 rc = svcsec_unregister(&null_svcsec);
107 CERROR("cannot unregister SVCNULL security: %d\n", rc);