Whamcloud - gitweb
LU-14462 gss: fix support for namespace in lgss_keyring
[fs/lustre-release.git] / lustre / utils / gss / lsupport.h
1 /*
2  * GPL HEADER START
3  *
4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 only,
8  * as published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * General Public License version 2 for more details (a copy is included
14  * in the LICENSE file that accompanied this code).
15  *
16  * You should have received a copy of the GNU General Public License
17  * version 2 along with this program; if not, write to the
18  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19  * Boston, MA 021110-1307, USA
20  *
21  * GPL HEADER END
22  */
23 /*
24  * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
25  * Use is subject to license terms.
26  *
27  * Copyright (c) 2014, Intel Corporation.
28  */
29 /*
30  * This file is part of Lustre, http://www.lustre.org/
31  * Lustre is a trademark of Sun Microsystems, Inc.
32  *
33  * lustre/utils/gss/lsupport.h
34  */
35
36 #ifndef __LSUPPORT_H__
37 #define __LSUPPORT_H__
38
39 #include <assert.h>
40 #include <unistd.h>
41 #include <stdbool.h>
42 #include <stdint.h>
43
44 #include <libcfs/util/list.h>
45 #include <linux/lnet/lnet-types.h>
46 #include <linux/lnet/nidstr.h>
47
48 #define GSSD_CLI        (0)
49 #define GSSD_SVC        (1)
50
51 void gssd_init_unique(int type);
52 void gssd_exit_unique(int type);
53
54 /*
55  * copied from lustre source
56  */
57
58 #define LUSTRE_GSS_SVC_MGS      0
59 #define LUSTRE_GSS_SVC_MDS      1
60 #define LUSTRE_GSS_SVC_OSS      2
61
62 #define LUSTRE_GSS_SVC_MASK     0x0000FFFF
63 #define LUSTRE_GSS_MECH_MASK    0xFFFF0000
64 #define LUSTRE_GSS_MECH_SHIFT   16
65
66 extern const char * lustre_svc_name[];
67
68 enum lgss_mech {
69         LGSS_MECH_KRB5  = 0,
70         LGSS_MECH_NULL  = 1,
71         LGSS_MECH_SK    = 2,
72 };
73
74 enum {
75         /* sec part flags */
76         LGSS_ROOT_CRED_ROOT     = 0x01,
77         LGSS_ROOT_CRED_MDT      = 0x02,
78         LGSS_ROOT_CRED_OST      = 0x04,
79         /* service type flags */
80         LGSS_SVC_NULL           = 0x10,
81         LGSS_SVC_AUTH           = 0x20,
82         LGSS_SVC_INTG           = 0x40,
83         LGSS_SVC_PRIV           = 0x80,
84         /* Number of sec part flags */
85         LGSS_ROOT_CRED_NR       = 3,
86 };
87
88 struct lgssd_upcall_data {
89         uint32_t        seq;
90         uint32_t        uid;
91         uint32_t        gid;
92         uint32_t        svc;
93         uint64_t        nid;
94         char            obd[64];
95 };
96
97 #define GSSD_INTERFACE_VERSION          GSSD_INTERFACE_VERSION_V2
98 #define GSSD_INTERFACE_VERSION_V2       (2)
99 #define GSSD_INTERFACE_VERSION_V1       (1)
100
101 struct lgssd_ioctl_param {
102         int             version;        /* in   */
103         int             secid;          /* in   */
104         char           *uuid;           /* in   */
105         int             lustre_svc;     /* in   */
106         uid_t           uid;            /* in   */
107         gid_t           gid;            /* in   */
108         long            send_token_size;/* in   */
109         char           *send_token;     /* in   */
110         long            reply_buf_size; /* in   */
111         char           *reply_buf;      /* in   */
112         long            status;         /* out  */
113         long            reply_length;   /* out  */
114 };
115
116 #define GSSD_DEFAULT_GETHOSTNAME_EX     "/etc/lustre/nid2hostname"
117 #define MAPPING_DATABASE_FILE           "/etc/lustre/idmap.conf"
118
119 int lnet_nid2hostname(lnet_nid_t nid, char *buf, int buflen);
120 void cleanup_mapping(void);
121 int lookup_mapping(char *princ, lnet_nid_t nid, uid_t *uid);
122
123 #endif /* __LSUPPORT_H__ */