auth: token jar handling should realloc correctly
[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 #define MAXCELLCHARS    64
44 #define MAXHOSTCHARS    64
45 #define MAXHOSTSPERCELL  8
46
47 /*
48  * Return codes.
49  */
50 #define AFSCONF_SUCCESS   0     /* worked */
51
52 /*
53  * Complete server info for one cell.
54  */
55 struct afsconf_cell {
56     char name[MAXCELLCHARS];    /*Cell name */
57     short numServers;           /*Num active servers for the cell */
58     short flags;                /* useful flags */
59     struct sockaddr_in hostAddr[MAXHOSTSPERCELL];       /*IP addresses for cell's servers */
60     char hostName[MAXHOSTSPERCELL][MAXHOSTCHARS];       /*Names for cell's servers */
61     char *linkedCell;           /* Linked cell name, if any */
62     int timeout;                /* Data timeout, if non-zero */
63 };
64
65 #define AFSCONF_CELL_FLAG_DNS_QUERIED   1
66
67 struct afsconf_cellalias {
68     char aliasName[MAXCELLCHARS];
69     char realName[MAXCELLCHARS];
70 };
71
72 struct afsconf_entry {
73     struct afsconf_entry *next; /* next guy in afsconf_dir */
74     struct afsconf_cell cellInfo;       /* info for this cell */
75 };
76
77 struct afsconf_aliasentry {
78     struct afsconf_aliasentry *next;
79     struct afsconf_cellalias aliasInfo;
80 };
81
82 /*!
83  * A set of bit flags to control the selection of a security object
84  */
85 #define AFSCONF_SECOPTS_NOAUTH        0x1
86 #define AFSCONF_SECOPTS_LOCALAUTH     0x2
87 #define AFSCONF_SECOPTS_ALWAYSENCRYPT 0x4
88 #define AFSCONF_SECOPTS_FALLBACK_NULL 0x8
89 typedef afs_uint32 afsconf_secflags;
90
91 struct afsconf_dir {
92     char *name;                 /* pointer to dir prefix */
93     char *cellName;             /* cell name, if any, we're in */
94     struct afsconf_entry *entries;      /* list of cell entries */
95     struct opr_queue keyList;           /* list of keys */
96     afs_int32 timeRead;         /* time stamp of file last read */
97     afs_int32 timeCheck;        /* time of last check for update */
98     struct afsconf_aliasentry *alias_entries;   /* cell aliases */
99     afsconf_secflags securityFlags;
100     struct afsconf_realms *local_realms;        /* local realms */
101     struct afsconf_realms *exclusions;          /* excluded principals */
102 };
103
104 extern afs_int32 afsconf_FindService(const char *aname);
105 extern const char *afsconf_FindIANAName(const char *aname);
106 extern struct afsconf_dir *afsconf_Open(const char *adir);
107 extern int afsconf_CellApply(struct afsconf_dir *adir,
108                              int (*aproc) (struct afsconf_cell * cell,
109                                            void *arock,
110                                            struct afsconf_dir * dir),
111                              void *arock);
112 extern int afsconf_CellAliasApply(struct afsconf_dir *adir,
113                                   int (*aproc) (struct afsconf_cellalias *
114                                                 alias, void *arock,
115                                                 struct afsconf_dir * dir),
116                                   void *arock);
117 extern int afsconf_GetExtendedCellInfo(struct afsconf_dir *adir,
118                                        char *acellName, char *aservice,
119                                        struct afsconf_cell *acellInfo,
120                                        char clones[]);
121 extern int afsconf_GetAfsdbInfo(char *acellName, char *aservice,
122                                 struct afsconf_cell *acellInfo);
123 extern int afsconf_GetCellInfo(struct afsconf_dir *adir, char *acellName,
124                                char *aservice,
125                                struct afsconf_cell *acellInfo);
126 extern int afsconf_GetLocalCell(struct afsconf_dir *adir,
127                                 char *aname, afs_int32 alen);
128 extern int afsconf_Close(struct afsconf_dir *adir);
129 extern int afsconf_UpToDate(void *rock);
130
131 struct afsconf_keys;
132 extern int afsconf_GetKeys(struct afsconf_dir *adir,
133                            struct afsconf_keys *astr);
134
135 struct ktc_encryptionKey;
136 extern afs_int32 afsconf_GetLatestKey(struct afsconf_dir *adir,
137                                       afs_int32 * avno,
138                                       struct ktc_encryptionKey *akey);
139 extern int afsconf_GetKey(void *rock, int avno,
140                           struct ktc_encryptionKey *akey);
141 extern int afsconf_AddKey(struct afsconf_dir *adir, afs_int32 akvno,
142                           char akey[8], afs_int32 overwrite);
143 extern int afsconf_DeleteKey(struct afsconf_dir *adir, afs_int32 akvno);
144
145 struct afsconf_typedKey;
146 struct afsconf_typedKeyList {
147     int nkeys;
148     struct afsconf_typedKey **keys;
149 };
150
151 typedef enum {
152     afsconf_rxkad = 0,
153     afsconf_rxgk  =1
154 } afsconf_keyType;
155
156 extern struct afsconf_typedKey *
157         afsconf_typedKey_get(struct afsconf_typedKey *);
158 extern void afsconf_typedKey_put(struct afsconf_typedKey **);
159 extern struct afsconf_typedKey *
160         afsconf_typedKey_new(afsconf_keyType type, int kvno,
161                              int subType, struct rx_opaque *key);
162 extern void afsconf_typedKey_free(struct afsconf_typedKey **);
163
164 extern void afsconf_typedKey_values(struct afsconf_typedKey *key,
165                                   afsconf_keyType *type,
166                                   int *kvno,
167                                   int *minorType,
168                                   struct rx_opaque **keyMaterial);
169
170 extern int afsconf_GetAllKeys(struct afsconf_dir *,
171                               struct afsconf_typedKeyList **);
172 extern int afsconf_GetKeysByType(struct afsconf_dir *dir,
173                                  afsconf_keyType type, int kvno,
174                                  struct afsconf_typedKeyList **);
175 extern int afsconf_GetKeyByTypes(struct afsconf_dir *dir,
176                                  afsconf_keyType type, int kvno, int subType,
177                                  struct afsconf_typedKey **);
178 extern int afsconf_GetLatestKeysByType(struct afsconf_dir *dir,
179                                        afsconf_keyType type,
180                                        struct afsconf_typedKeyList **);
181 extern int afsconf_GetLatestKeyByTypes(struct afsconf_dir *dir,
182                                        afsconf_keyType type, int subType,
183                                        struct afsconf_typedKey **);
184 extern void afsconf_PutTypedKeyList(struct afsconf_typedKeyList **keys);
185 extern int afsconf_AddTypedKey(struct afsconf_dir *dir,
186                                struct afsconf_typedKey *key,
187                                int overwrite);
188 extern int afsconf_DeleteKeyByType(struct afsconf_dir *dir,
189                                    afsconf_keyType type, int kvno);
190 extern int afsconf_DeleteKeyBySubType(struct afsconf_dir *dir,
191                                       afsconf_keyType type, int kvno,
192                                       int subType);
193
194 /* authcon.c */
195 struct rx_securityClass;
196 extern afs_int32 afsconf_ServerAuth(void *arock,
197                                     struct rx_securityClass **,
198                                     afs_int32 *);
199 extern afs_int32 afsconf_ClientAuth(void *arock,
200                                     struct rx_securityClass **astr,
201                                     afs_int32 * aindex);
202 extern afs_int32 afsconf_ClientAuthSecure(void *arock,
203                                           struct rx_securityClass **astr,
204                                           afs_int32 * aindex);
205
206
207 extern afs_int32 afsconf_ClientAuthToken(struct afsconf_cell *info,
208                                          afsconf_secflags flags,
209                                          struct rx_securityClass **sc,
210                                          afs_int32 *scIndex,
211                                          time_t *expires);
212
213
214 extern afs_int32 afsconf_PickClientSecObj(struct afsconf_dir *dir,
215                                           afsconf_secflags flags,
216                                           struct afsconf_cell *info,
217                                           char *cellName,
218                                           struct rx_securityClass **sc,
219                                           afs_int32 *scIndex,
220                                           time_t *expires);
221
222 extern void afsconf_SetSecurityFlags(struct afsconf_dir *dir,
223                                      afsconf_secflags flags);
224
225 extern void afsconf_BuildServerSecurityObjects(void *,
226                                                struct rx_securityClass ***,
227                                                afs_int32 *);
228
229 /* writeconfig.c */
230 int afsconf_SetExtendedCellInfo(struct afsconf_dir *adir, const char *apath,
231                                 struct afsconf_cell *acellInfo, char clones[]);
232 int afsconf_SetCellInfo(struct afsconf_dir *adir, const char *apath,
233                         struct afsconf_cell *acellInfo);
234
235
236 /* userok.c */
237
238 struct rx_call;
239 struct rx_identity;
240 extern int afsconf_CheckAuth(void *arock, struct rx_call *acall);
241 extern int afsconf_GetNoAuthFlag(struct afsconf_dir *adir);
242 extern void afsconf_SetNoAuthFlag(struct afsconf_dir *adir, int aflag);
243 extern int afsconf_DeleteUser(struct afsconf_dir *adir, char *auser);
244 extern int afsconf_DeleteIdentity(struct afsconf_dir *, struct rx_identity *);
245 extern int afsconf_GetNthUser(struct afsconf_dir *adir, afs_int32 an,
246                               char *abuffer, afs_int32 abufferLen);
247 extern int afsconf_GetNthIdentity(struct afsconf_dir *, int,
248                                   struct rx_identity **);
249 extern int afsconf_AddUser(struct afsconf_dir *adir, char *aname);
250 extern int afsconf_AddIdentity(struct afsconf_dir *adir, struct rx_identity *);
251 extern int afsconf_SuperUser(struct afsconf_dir *adir, struct rx_call *acall,
252                              char *namep);
253 extern int afsconf_SuperIdentity(struct afsconf_dir *, struct rx_call *,
254                                  struct rx_identity **);
255 extern int afsconf_IsSuperIdentity(struct afsconf_dir *, struct rx_identity *);
256
257 /* realms.c */
258 extern int afsconf_SetLocalRealm(const char *realm);
259 extern int afsconf_IsLocalRealmMatch(struct afsconf_dir *dir, afs_int32 * local,
260                                 const char *name, const char *instance,
261                                 const char *cell);
262
263 /* netrestrict.c */
264
265 extern int afsconf_ParseNetRestrictFile(afs_uint32 outAddrs[],
266                                         afs_uint32 * mask, afs_uint32 * mtu,
267                                         afs_uint32 maxAddrs, afs_uint32 * nAddrs,
268                                         char reason[], const char *fileName);
269
270 extern int afsconf_ParseNetFiles(afs_uint32 addrbuf[], afs_uint32 maskbuf[],
271                                  afs_uint32 mtubuf[], afs_uint32 max,
272                                  char reason[], const char *niFileName,
273                                  const char *nrFileName);
274
275 /* some well-known ports and their names; new additions to table in cellconfig.c, too */
276 #define AFSCONF_FILESERVICE             "afs"
277 #define AFSCONF_FILEPORT                7000
278 #define AFSCONF_CALLBACKSERVICE         "afscb"
279 #define AFSCONF_CALLBACKPORT            7001
280 #define AFSCONF_PROTSERVICE             "afsprot"
281 #define AFSCONF_PROTPORT                7002
282 #define AFSCONF_VLDBSERVICE             "afsvldb"
283 #define AFSCONF_VLDBPORT                7003
284 #define AFSCONF_KAUTHSERVICE            "afskauth"
285 #define AFSCONF_KAUTHPORT               7004
286 #define AFSCONF_VOLUMESERVICE           "afsvol"
287 #define AFSCONF_VOLUMEPORT              7005
288 #define AFSCONF_ERRORSERVICE            "afserror"
289 #define AFSCONF_ERRORPORT               7006
290 #define AFSCONF_NANNYSERVICE            "afsnanny"
291 #define AFSCONF_NANNYPORT               7007
292 #define AFSCONF_UPDATESERVICE           "afsupdate"
293 #define AFSCONF_UPDATEPORT              7008
294 #define AFSCONF_RMTSYSSERVICE           "afsrmtsys"
295 #define AFSCONF_RMTSYSPORT              7009
296 #define AFSCONF_RSDBSERVICE             "afsres"
297 #define AFSCONF_RESPORT                 7010
298 #define AFSCONF_REMIODBSERVICE          "afsremio"
299 #define AFSCONF_REMIOPORT               7011
300
301 #endif /* __CELLCONFIG_AFS_INCL_ */