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(SEC_FLAVOR_MAJOR(hdr->flavor) == PTLRPCS_FLVR_MAJOR_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_req_secflvr = PTLRPCS_FLVR_NULL;
56 req->rq_reqmsg = (struct lustre_msg *)(hdr + 1);
57 req->rq_reqlen = hdr->msg_len;
59 CDEBUG(D_SEC, "req %p: set reqmsg at %p, len %d\n",
60 req, req->rq_reqmsg, req->rq_reqlen);
65 int null_svcsec_authorize(struct ptlrpc_request *req)
67 struct ptlrpc_reply_state *rs = req->rq_reply_state;
68 struct ptlrpcs_wire_hdr *hdr;
72 LASSERT(rs->rs_repbuf_len >= 4 * 4);
74 hdr = buf_to_sec_hdr(rs->rs_repbuf);
75 hdr->flavor = cpu_to_le32(PTLRPCS_FLVR_NULL);
76 hdr->msg_len = cpu_to_le32(req->rq_replen);
77 hdr->sec_len = cpu_to_le32(0);
79 CDEBUG(D_SEC, "fill in datasize %d\n", rs->rs_repdata_len);
83 static struct ptlrpc_svcsec null_svcsec = {
84 .pss_owner = THIS_MODULE,
85 .pss_name = "svcsec.null",
86 .pss_flavor = PTLRPCS_FLVR_MAJOR_NULL,
87 .accept = null_svcsec_accept,
88 .authorize = null_svcsec_authorize,
91 int svcsec_null_init()
95 rc = svcsec_register(&null_svcsec);
97 CERROR("failed to register SVCNULL security: %d\n", rc);
102 int svcsec_null_exit()
106 rc = svcsec_unregister(&null_svcsec);
108 CERROR("cannot unregister SVCNULL security: %d\n", rc);