warn when starting without keys
[openafs.git] / src / auth / cellconfig.p.h
1 /*
2  * Copyright 2000, International Business Machines Corporation and others.
3  * All Rights Reserved.
4  *
5  * This software has been released under the terms of the IBM Public
6  * License.  For details, see the LICENSE file in the top-level source
7  * directory or online at http://www.openafs.org/dl/license10.html
8  */
9
10 /*
11 cellconfig.h:
12
13     Interface to the routines used by the FileServer to manipulate the cell/server database
14     for the Cellular Andrew system, along with an operation to determine the name of the
15     local cell.  Included are a string variable used to hold the local cell name, definitions for
16     the database file format and routines for:
17         1) Acquiring the local cell name.
18         2) Reading in the cell/server database from disk.
19         3) Reporting the set of servers associated with a given cell name.
20         4) Printing out the contents of the cell/server database.
21         5) Reclaiming the space used by an in-memory database.
22
23 Creation date:
24     17 August 1987
25
26 --------------------------------------------------------------------------------------------------------------*/
27
28 #ifndef __CELLCONFIG_AFS_INCL_
29 #define __CELLCONFIG_AFS_INCL_  1
30
31 #ifndef IPPROTO_MAX
32         /* get sockaddr_in */
33 #ifdef AFS_NT40_ENV
34 #include <winsock2.h>
35 #else
36 #include <sys/types.h>
37 #include <netinet/in.h>
38 #endif
39 #endif
40 #include <rx/rx_opaque.h>
41 #include <opr/queue.h>
42
43 #include <rx/rxgk_types.h>
44
45 #define MAXCELLCHARS    64
46 #define MAXHOSTCHARS    64
47 #define MAXHOSTSPERCELL  8
48
49 /*
50  * Return codes.
51  */
52 #define AFSCONF_SUCCESS   0     /* worked */
53
54 /*
55  * Complete server info for one cell.
56  */
57 struct afsconf_cell {
58     char name[MAXCELLCHARS];    /*Cell name */
59     short numServers;           /*Num active servers for the cell */
60     short flags;                /* useful flags */
61     struct sockaddr_in hostAddr[MAXHOSTSPERCELL];       /*IP addresses for cell's servers */
62     char hostName[MAXHOSTSPERCELL][MAXHOSTCHARS];       /*Names for cell's servers */
63     char clone[MAXHOSTSPERCELL];                        /*Indicates which ones are clones */
64     char *linkedCell;           /* Linked cell name, if any */
65     int timeout;                /* Data timeout, if non-zero */
66 };
67
68 #define AFSCONF_CELL_FLAG_DNS_QUERIED   1
69
70 struct afsconf_cellalias {
71     char aliasName[MAXCELLCHARS];
72     char realName[MAXCELLCHARS];
73 };
74
75 struct afsconf_entry {
76     struct afsconf_entry *next; /* next guy in afsconf_dir */
77     struct afsconf_cell cellInfo;       /* info for this cell */
78 };
79
80 struct afsconf_aliasentry {
81     struct afsconf_aliasentry *next;
82     struct afsconf_cellalias aliasInfo;
83 };
84
85 /*!
86  * A set of bit flags to control the selection of a security object
87  */
88 #define AFSCONF_SECOPTS_NOAUTH        0x1
89 #define AFSCONF_SECOPTS_LOCALAUTH     0x2
90 #define AFSCONF_SECOPTS_ALWAYSENCRYPT 0x4
91 #define AFSCONF_SECOPTS_FALLBACK_NULL 0x8
92 #define AFSCONF_SECOPTS_NEVERENCRYPT  0x10
93 #define AFSCONF_SECOPTS_ALWAYSCLEAR   0x20
94 #define AFSCONF_SECOPTS_RXGK          0x40
95 typedef afs_uint32 afsconf_secflags;
96
97 struct afsconf_dir {
98     char *name;                 /* pointer to dir prefix */
99     char *cellName;             /* cell name, if any, we're in */
100     char *cellservDB;           /* pathname of the CellServDB file */
101     struct afsconf_entry *entries;      /* list of cell entries */
102     struct opr_queue keyList;           /* list of keys */
103     afs_int32 timeRead;         /* time stamp of file last read */
104     afs_int32 timeCheck;        /* time of last check for update */
105     struct afsconf_aliasentry *alias_entries;   /* cell aliases */
106     afsconf_secflags securityFlags;
107     struct afsconf_realms *local_realms;        /* local realms */
108     struct afsconf_realms *exclusions;          /* excluded principals */
109 };
110
111 extern afs_int32 afsconf_FindService(const char *aname);
112 extern const char *afsconf_FindIANAName(const char *aname);
113 extern struct afsconf_dir *afsconf_Open(const char *adir);
114 extern int afsconf_CellApply(struct afsconf_dir *adir,
115                              int (*aproc) (struct afsconf_cell * cell,
116                                            void *arock,
117                                            struct afsconf_dir * dir),
118                              void *arock);
119 extern int afsconf_CellAliasApply(struct afsconf_dir *adir,
120                                   int (*aproc) (struct afsconf_cellalias *
121                                                 alias, void *arock,
122                                                 struct afsconf_dir * dir),
123                                   void *arock);
124 extern int afsconf_GetExtendedCellInfo(struct afsconf_dir *adir,
125                                        char *acellName, char *aservice,
126                                        struct afsconf_cell *acellInfo,
127                                        char clones[]);
128 extern int afsconf_GetAfsdbInfo(char *acellName, char *aservice,
129                                 struct afsconf_cell *acellInfo);
130 extern int afsconf_GetCellInfo(struct afsconf_dir *adir, char *acellName,
131                                char *aservice,
132                                struct afsconf_cell *acellInfo);
133 extern int afsconf_GetLocalCell(struct afsconf_dir *adir,
134                                 char *aname, afs_int32 alen);
135 extern int afsconf_Close(struct afsconf_dir *adir);
136 extern int afsconf_UpToDate(void *rock);
137
138 struct afsconf_keys;
139 extern int afsconf_GetKeys(struct afsconf_dir *adir,
140                            struct afsconf_keys *astr);
141
142 struct ktc_encryptionKey;
143 extern afs_int32 afsconf_GetLatestKey(struct afsconf_dir *adir,
144                                       afs_int32 * avno,
145                                       struct ktc_encryptionKey *akey);
146 extern afs_int32 afsconf_GetLatestRXGKKey(struct afsconf_dir *adir,
147                                           afs_int32 *avno, afs_int32 *enctype,
148                                           rxgk_key *key);
149 extern int afsconf_GetKey(void *rock, int avno,
150                           struct ktc_encryptionKey *akey);
151 extern int afsconf_GetRXGKKey(void *rock, afs_int32 *avno, afs_int32 *enctype,
152                               rxgk_key *key);
153 extern int afsconf_AddKey(struct afsconf_dir *adir, afs_int32 akvno,
154                           char akey[8], afs_int32 overwrite);
155 extern int afsconf_DeleteKey(struct afsconf_dir *adir, afs_int32 akvno);
156
157 struct afsconf_typedKey;
158 struct afsconf_typedKeyList {
159     int nkeys;
160     struct afsconf_typedKey **keys;
161 };
162
163 typedef enum {
164     afsconf_rxkad = 0,
165     afsconf_rxgk  =1,
166     afsconf_rxkad_krb5  =2
167 } afsconf_keyType;
168
169 extern struct afsconf_typedKey *
170         afsconf_typedKey_get(struct afsconf_typedKey *);
171 extern void afsconf_typedKey_put(struct afsconf_typedKey **);
172 extern struct afsconf_typedKey *
173         afsconf_typedKey_new(afsconf_keyType type, int kvno,
174                              int subType, struct rx_opaque *key);
175 extern void afsconf_typedKey_free(struct afsconf_typedKey **);
176
177 extern void afsconf_typedKey_values(struct afsconf_typedKey *key,
178                                   afsconf_keyType *type,
179                                   int *kvno,
180                                   int *minorType,
181                                   struct rx_opaque **keyMaterial);
182
183 extern int afsconf_CountKeys(struct afsconf_dir *);
184 extern int afsconf_GetAllKeys(struct afsconf_dir *,
185                               struct afsconf_typedKeyList **);
186 extern int afsconf_GetKeysByType(struct afsconf_dir *dir,
187                                  afsconf_keyType type, int kvno,
188                                  struct afsconf_typedKeyList **);
189 extern int afsconf_GetKeyByTypes(struct afsconf_dir *dir,
190                                  afsconf_keyType type, int kvno, int subType,
191                                  struct afsconf_typedKey **);
192 extern int afsconf_GetLatestKeysByType(struct afsconf_dir *dir,
193                                        afsconf_keyType type,
194                                        struct afsconf_typedKeyList **);
195 extern int afsconf_GetLatestKeyByTypes(struct afsconf_dir *dir,
196                                        afsconf_keyType type, int subType,
197                                        struct afsconf_typedKey **);
198 extern void afsconf_PutTypedKeyList(struct afsconf_typedKeyList **keys);
199 extern int afsconf_AddTypedKey(struct afsconf_dir *dir,
200                                struct afsconf_typedKey *key,
201                                int overwrite);
202 extern int afsconf_DeleteKeyByType(struct afsconf_dir *dir,
203                                    afsconf_keyType type, int kvno);
204 extern int afsconf_DeleteKeyBySubType(struct afsconf_dir *dir,
205                                       afsconf_keyType type, int kvno,
206                                       int subType);
207
208 /* authcon.c */
209 struct rx_securityClass;
210 extern afs_int32 afsconf_ServerAuth(void *arock,
211                                     struct rx_securityClass **,
212                                     afs_int32 *);
213 extern afs_int32 afsconf_ClientAuth(void *arock,
214                                     struct rx_securityClass **astr,
215                                     afs_int32 * aindex);
216 extern afs_int32 afsconf_ClientAuthSecure(void *arock,
217                                           struct rx_securityClass **astr,
218                                           afs_int32 * aindex);
219 extern afs_int32 afsconf_ClientAuthRXGKClear(void *arock,
220                                              struct rx_securityClass **aclass,
221                                              afs_int32 *aindex);
222 extern afs_int32 afsconf_ClientAuthRXGKAuth(void *arock,
223                                             struct rx_securityClass **aclass,
224                                             afs_int32 *aindex);
225 extern afs_int32 afsconf_ClientAuthRXGKCrypt(void *arock,
226                                              struct rx_securityClass **aclass,
227                                              afs_int32 *aindex);
228
229
230 extern afs_int32 afsconf_ClientAuthToken(struct afsconf_cell *info,
231                                          afsconf_secflags flags,
232                                          struct rx_securityClass **sc,
233                                          afs_int32 *scIndex,
234                                          time_t *expires);
235
236
237 extern afs_int32 afsconf_PickClientSecObj(struct afsconf_dir *dir,
238                                           afsconf_secflags flags,
239                                           struct afsconf_cell *info,
240                                           char *cellName,
241                                           struct rx_securityClass **sc,
242                                           afs_int32 *scIndex,
243                                           time_t *expires);
244
245 extern void afsconf_SetSecurityFlags(struct afsconf_dir *dir,
246                                      afsconf_secflags flags);
247
248 extern void afsconf_BuildServerSecurityObjects(void *,
249                                                struct rx_securityClass ***,
250                                                afs_int32 *);
251
252 /* writeconfig.c */
253 int afsconf_SetExtendedCellInfo(struct afsconf_dir *adir, const char *apath,
254                                 struct afsconf_cell *acellInfo, char clones[]);
255 int afsconf_SetCellInfo(struct afsconf_dir *adir, const char *apath,
256                         struct afsconf_cell *acellInfo);
257
258
259 /* userok.c */
260
261 struct rx_call;
262 struct rx_identity;
263 extern int afsconf_CheckAuth(void *arock, struct rx_call *acall);
264 extern int afsconf_GetNoAuthFlag(struct afsconf_dir *adir);
265 extern void afsconf_SetNoAuthFlag(struct afsconf_dir *adir, int aflag);
266 extern int afsconf_DeleteUser(struct afsconf_dir *adir, char *auser);
267 extern int afsconf_DeleteIdentity(struct afsconf_dir *, struct rx_identity *);
268 extern int afsconf_GetNthUser(struct afsconf_dir *adir, afs_int32 an,
269                               char *abuffer, afs_int32 abufferLen);
270 extern int afsconf_GetNthIdentity(struct afsconf_dir *, int,
271                                   struct rx_identity **);
272 extern int afsconf_AddUser(struct afsconf_dir *adir, char *aname);
273 extern int afsconf_AddIdentity(struct afsconf_dir *adir, struct rx_identity *);
274 extern int afsconf_SuperUser(struct afsconf_dir *adir, struct rx_call *acall,
275                              char *namep);
276 extern int afsconf_SuperIdentity(struct afsconf_dir *, struct rx_call *,
277                                  struct rx_identity **);
278 extern int afsconf_IsSuperIdentity(struct afsconf_dir *, struct rx_identity *);
279 extern int afsconf_CheckRestrictedQuery(struct afsconf_dir *adir,
280                                         struct rx_call *acall,
281                                         int needed_level);
282
283 /*
284  * Level constants for the -restricted_query option used by vlserver
285  * and volser.  Once we have vlserver and volserver to ptserver
286  * connection, we can add more access levels, like AUTHUSER or
287  * AUTHANDFOREIGNUSER.
288  */
289 #define RESTRICTED_QUERY_ANYUSER  0
290 #define RESTRICTED_QUERY_ADMIN    1
291
292 /* realms.c */
293 extern int afsconf_SetLocalRealm(const char *realm);
294 extern int afsconf_IsLocalRealmMatch(struct afsconf_dir *dir, afs_int32 * local,
295                                 const char *name, const char *instance,
296                                 const char *cell);
297
298 /* netrestrict.c */
299
300 extern int afsconf_ParseNetRestrictFile(afs_uint32 outAddrs[],
301                                         afs_uint32 * mask, afs_uint32 * mtu,
302                                         afs_uint32 maxAddrs, afs_uint32 * nAddrs,
303                                         char reason[], const char *fileName);
304
305 extern int afsconf_ParseNetFiles(afs_uint32 addrbuf[], afs_uint32 maskbuf[],
306                                  afs_uint32 mtubuf[], afs_uint32 max,
307                                  char reason[], const char *niFileName,
308                                  const char *nrFileName);
309
310 /* some well-known ports and their names; new additions to table in cellconfig.c, too */
311 #define AFSCONF_FILESERVICE             "afs"
312 #define AFSCONF_FILEPORT                7000
313 #define AFSCONF_CALLBACKSERVICE         "afscb"
314 #define AFSCONF_CALLBACKPORT            7001
315 #define AFSCONF_PROTSERVICE             "afsprot"
316 #define AFSCONF_PROTPORT                7002
317 #define AFSCONF_VLDBSERVICE             "afsvldb"
318 #define AFSCONF_VLDBPORT                7003
319 #define AFSCONF_KAUTHSERVICE            "afskauth"
320 #define AFSCONF_KAUTHPORT               7004
321 #define AFSCONF_VOLUMESERVICE           "afsvol"
322 #define AFSCONF_VOLUMEPORT              7005
323 #define AFSCONF_ERRORSERVICE            "afserror"
324 #define AFSCONF_ERRORPORT               7006
325 #define AFSCONF_NANNYSERVICE            "afsnanny"
326 #define AFSCONF_NANNYPORT               7007
327 #define AFSCONF_UPDATESERVICE           "afsupdate"
328 #define AFSCONF_UPDATEPORT              7008
329 #define AFSCONF_RMTSYSSERVICE           "afsrmtsys"
330 #define AFSCONF_RMTSYSPORT              7009
331 #define AFSCONF_RSDBSERVICE             "afsres"
332 #define AFSCONF_RESPORT                 7010
333 #define AFSCONF_REMIODBSERVICE          "afsremio"
334 #define AFSCONF_REMIOPORT               7011
335
336 #endif /* __CELLCONFIG_AFS_INCL_ */