source: trunk/third/moira/server/mr_server.h @ 23740

Revision 23740, 12.6 KB checked in by broder, 15 years ago (diff)
In moira: * New CVS snapshot (Trac: #195) * Drop patches that have been incorporated upstream. * Update to build without krb4 on systems that no longer have it. This doesn't build yet on squeeze, which lacks a krb4 library, but I'm committing now before I start hacking away at a patch to fix that.
Line 
1/* $Id: mr_server.h,v 1.67 2008-09-30 18:42:42 zacheiss Exp $
2 *
3 * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology
4 * For copying and distribution information, please see the file
5 * <mit-copyright.h>.
6 */
7
8#include <moira.h>
9#include <mr_private.h>
10#include <moira_site.h>
11#include <moira_schema.h>
12
13#include <netinet/in.h>
14
15#include <stdarg.h>
16
17#include <krb.h>
18#include <krb5.h>
19
20enum clstate { CL_ACCEPTING, CL_ACTIVE, CL_CLOSING };
21
22/*
23 * This structure holds all per-client information; one of these is
24 * allocated for each active client.
25 */
26
27typedef struct _client {
28  int con;                      /* Connection to the client */
29  int id;                       /* Unique id of client */
30  struct sockaddr_in haddr;     /* IP address of client */
31  enum clstate state;           /* State of the connection */
32  char clname[MAX_K_NAME_SZ];   /* Name client authenticated to */
33  char entity[USERS_MODWITH_SIZE]; /* client program being used */
34  int users_id;                 /* Moira-internal ID of authenticated user */
35  int client_id;                /* Moira-internal ID of client */
36  int proxy_id;                 /* client_id of orig user, if proxied */
37  int version;                  /* Max query version known by client */
38  time_t last_time_used;        /* Last time connection used */
39  mr_params req;                /* Current request */
40  mr_params *tuples;            /* Tuples waiting to send back to client */
41  int ntuples;                  /* Number of tuples waiting */
42  int tuplessize;               /* Current size of tuple array */
43  int nexttuple;                /* Next tuple to return */
44  char *hsbuf;                  /* Buffer for initial connection handshaking */
45  int hslen;                    /* Length of data in hsbuf */
46} client;
47
48struct mxentry
49{
50  char *name;
51  int pref;
52};
53
54extern char krb_realm[REALM_SZ];
55
56/* max length of query argument allowed */
57#define ARGLEN  257
58/* Used to setup static argv, maximum argc */
59#define QMAXARGS        25
60
61/* statistics on number of queries by version number */
62extern int newqueries;
63
64/* Maximum and minimum values that will be used for uids and gids */
65#define MAX_ID_VALUE    131072
66#define MIN_ID_VALUE    100
67
68/* Sleepy states for the server! */
69#define AWAKE 0
70#define SLEEPY 1
71#define ASLEEP 2
72#define GROGGY 3
73extern int dormant;
74
75/* state for the incremental update system */
76extern int inc_running, inc_pid;
77extern time_t inc_started, now;
78#define INC_TIMEOUT (3 * 60)    /* 3 minutes */
79
80
81#define SQL_NO_MATCH 1403 /* oracle, not ingres (= 100) */
82
83/* types needed for prototypes */
84struct query;
85struct validate;
86struct valobj;
87
88/* prototypes from increment.dc */
89void incremental_init(void);
90void next_incremental(void);
91void incremental_update(void);
92void incremental_flush(void);
93
94/* prototypes from qrtn.dc */
95void dbmserr(void);
96void dosql(char *buffers[]);
97int mr_open_database(void);
98void mr_close_database(void);
99int mr_process_query(client *cl, char *name, int argc, char *argv_ro[],
100                     int (*action)(int, char *[], void *), void *actarg);
101int mr_check_access(client *cl, char *name, int argc, char *argv_ro[]);
102void sanity_check_queries(void);
103int set_krb_mapping(char *name, char *login, int ok, int *kid, int *uid);
104int find_member(char *list_type, int list_id, client *cl);
105int do_for_all_rows(char *query, int count,
106                    int (*action)(int, char *[], void *), void *actarg);
107char *build_qual(char *fmt, int argc, char *argv[]);
108
109
110/* prototyoes from qsupport.dc */
111int set_pop_usage(int id, int cnt);
112
113/* prototypes from qvalidate.dc */
114void sanity_check_database(void);
115int add_string(char *name);
116int convert_wildcards(char *arg);
117
118/* prototypes from mr_main.c */
119void clist_delete(client *cp);
120
121/* prototypes from mr_sauth.c */
122void do_auth(client *cl);
123void do_proxy(client *cl);
124void do_krb5_auth(client *cl);
125
126/* prototypes from mr_scall.c */
127void do_client(client *cl);
128void client_reply(client *cl, long status);
129void client_return_tuple(client *cl, int argc, char **argv);
130void client_read(client *cl);
131void client_write(client *cl);
132
133/* prototypes from mr_shutdown.c */
134void sigshut(int);
135void do_shutdown(client *cl);
136
137/* prototypes from mr_util.c */
138char *requote(char *buf);
139void log_args(char *tag, int version, int argc, char **argv);
140void mr_com_err(const char *whoami, long code, const char *fmt, va_list pvar);
141int mr_trim_args(int argc, char **argv);
142char **mr_copy_args(char **argv, int argc);
143void *xmalloc(size_t);
144void *xrealloc(void *, size_t);
145char *xstrdup(char *);
146
147/* prototypes from qaccess.pc */
148int access_user(struct query *q, char *argv[], client *cl);
149int access_login(struct query *q, char *argv[], client *cl);
150int access_spob(struct query *q, char *argv[], client *cl);
151int access_list(struct query *q, char *argv[], client *cl);
152int access_visible_list(struct query *q, char *argv[], client *cl);
153int access_vis_list_by_name(struct query *q, char *argv[], client *cl);
154int access_member(struct query *q, char *argv[], client *cl);
155int access_qgli(struct query *q, char *argv[], client *cl);
156int access_service(struct query *q, char *argv[], client *cl);
157int access_filesys(struct query *q, char *argv[], client *cl);
158int access_host(struct query *q, char *argv[], client *cl);
159int access_ahal(struct query *q, char *argv[], client *cl);
160int access_snt(struct query *q, char *argv[], client *cl);
161int access_printer(struct query *q, char *argv[], client *cl);
162int access_zephyr(struct query *q, char *argv[], client *cl);
163int access_container(struct query *q, char *argv[], client *cl);
164int access_update_user(struct query *q, char *argv[], client *cl);
165int check_mail_string(char *mailstring);
166struct mxentry *getmxrecords(const char *);
167
168/* prototypes from qfollow.pc */
169int followup_fix_modby(struct query *q, struct save_queue *sq,
170                       struct validate *v, int (*action)(int, char **, void *),
171                       void *actarg, client *cl);
172int followup_gpob(struct query *q, struct save_queue *sq, struct validate *v,
173                  int (*action)(int, char **, void *), void *actarg,
174                  client *cl);
175int followup_glin(struct query *q, struct save_queue *sq, struct validate *v,
176                  int (*action)(int, char **, void *), void *actarg,
177                  client *cl);
178int followup_gsin(struct query *q, struct save_queue *sq, struct validate *v,
179                  int (*action)(int, char **, void *), void *actarg,
180                  client *cl);
181int followup_gzcl(struct query *q, struct save_queue *sq, struct validate *v,
182                  int (*action)(int, char **, void *), void *actarg,
183                  client *cl);
184int followup_gsha(struct query *q, struct save_queue *sq, struct validate *v,
185                  int (*action)(int, char **, void *), void *actarg,
186                  client *cl);
187int followup_gqot(struct query *q, struct save_queue *sq, struct validate *v,
188                  int (*action)(int, char **, void *), void *actarg,
189                  client *cl);
190int followup_guax(struct query *q, struct save_queue *sq, struct validate *v,
191                  int (*action)(int, char **, void *), void *actarg,
192                  client *cl);
193int followup_gsnt(struct query *q, struct save_queue *sq, struct validate *v,
194                  int (*action)(int, char **, void *), void *actarg,
195                  client *cl);
196int followup_ghst(struct query *q, struct save_queue *sq, struct validate *v,
197                  int (*action)(int, char **, void *), void *actarg,
198                  client *cl);
199int followup_gpsv(struct query *q, struct save_queue *sq, struct validate *v,
200                  int (*action)(int, char **, void *), void *actarg,
201                  client *cl);
202int followup_gcon(struct query *q, struct save_queue *sq, struct validate *v,
203                  int (*action)(int, char **, void *), void *actarg,
204                  client *cl);
205int followup_get_user(struct query *q, struct save_queue *sq,
206                      struct validate *v, int (*action)(int, char **, void *),
207                      void *actarg, client *cl);
208
209int followup_ausr(struct query *q, char *argv[], client *cl);
210int followup_aqot(struct query *q, char *argv[], client *cl);
211int followup_dqot(struct query *q, char *argv[], client *cl);
212
213int set_modtime(struct query *q, char *argv[], client *cl);
214int set_modtime_by_id(struct query *q, char *argv[], client *cl);
215int set_finger_modtime(struct query *q, char *argv[], client *cl);
216int set_pobox_modtime(struct query *q, char *argv[], client *cl);
217int set_uppercase_modtime(struct query *q, char *argv[], client *cl);
218int set_mach_modtime_by_id(struct query *q, char *argv[], client *cl);
219int set_cluster_modtime_by_id(struct query *q, char *argv[], client *cl);
220int set_serverhost_modtime(struct query *q, char *argv[], client *cl);
221int set_nfsphys_modtime(struct query *q, char *argv[], client *cl);
222int set_filesys_modtime(struct query *q, char *argv[], client *cl);
223int set_zephyr_modtime(struct query *q, char *argv[], client *cl);
224int set_service_modtime(struct query *q, char *argv[], client *cl);
225int _sdl_followup(struct query *q, char *argv[], client *cl);
226int trigger_dcm(struct query *q, char *argv[], client *cl);
227
228/* prototypes from qsetup.pc */
229int prefetch_value(struct query *q, char *argv[], client *cl);
230int prefetch_filesys(struct query *q, char *argv[], client *cl);
231int setup_ausr(struct query *q, char *argv[], client *cl);
232int setup_dusr(struct query *q, char *argv[], client *cl);
233int setup_dpob(struct query *q, char *argv[], client *cl);
234int setup_dmac(struct query *q, char *argv[], client *cl);
235int setup_dclu(struct query *q, char *argv[], client *cl);
236int setup_alis(struct query *q, char *argv[], client *cl);
237int setup_dlis(struct query *q, char *argv[], client *cl);
238int setup_dsin(struct query *q, char *argv[], client *cl);
239int setup_dshi(struct query *q, char *argv[], client *cl);
240int setup_afil(struct query *q, char *argv[], client *cl);
241int setup_ufil(struct query *q, char *argv[], client *cl);
242int setup_dfil(struct query *q, char *argv[], client *cl);
243int setup_aftg(struct query *q, char *argv[], client *cl);
244int setup_dnfp(struct query *q, char *argv[], client *cl);
245int setup_dqot(struct query *q, char *argv[], client *cl);
246int setup_asnt(struct query *q, char *argv[], client *cl);
247int setup_dsnt(struct query *q, char *argv[], client *cl);
248int setup_ghst(struct query *q, char *argv[], client *cl);
249int setup_ahst(struct query *q, char *argv[], client *cl);
250int setup_ahal(struct query *q, char *argv[], client *cl);
251int setup_uhha(struct query *q, char *argv[], client *cl);
252int setup_aprn(struct query *q, char *argv[], client *cl);
253int setup_dpsv(struct query *q, char *argv[], client *cl);
254int setup_dcon(struct query *q, char *argv[], client *cl);
255int setup_acon(struct query *q, char *argv[], client *cl);
256int setup_scli(struct query *q, char *argv[], client *cl);
257int setup_aali(struct query *q, char *argv[], client *cl);
258
259/* prototypes from qsupport.pc */
260int set_pobox(struct query *q, char *argv[], client *cl);
261int set_pobox_pop(struct query *q, char *argv[], client *cl);
262int add_member_to_list(struct query *q, char *argv[], client *cl);
263int delete_member_from_list(struct query *q, char *argv[], client *cl);
264int tag_member_of_list(struct query *q, char *argv[], client *cl);
265int register_user(struct query *q, char *argv[], client *cl);
266int do_user_reservation(struct query *q, char *argv[], client *cl);
267int update_container(struct query *q, char *argv[], client *cl);
268int set_container_list(struct query *q, char *argv[], client *cl);
269
270int get_ace_use(struct query *q, char **argv, client *cl,
271                int (*action)(int, char *[], void *), void *actarg);
272int get_host_by_owner(struct query *q, char **argv, client *cl,
273                int (*action)(int, char *[], void *), void *actarg);
274int get_user_account_by_sponsor(struct query *q, char **argv, client *cl,
275                                int (*action)(int, char *[], void *),
276                                void *actarg);
277int qualified_get_lists(struct query *q, char **argv, client *cl,
278                        int (*action)(int, char *[], void *), void *actarg);
279int get_members_of_list(struct query *q, char **argv, client *cl,
280                        int (*action)(int, char *[], void *), void *actarg);
281int qualified_get_server(struct query *q, char **argv, client *cl,
282                         int (*action)(int, char *[], void *), void *actarg);
283int qualified_get_serverhost(struct query *q, char **argv, client *cl,
284                             int (*action)(int, char *[], void *),
285                             void *actarg);
286int count_members_of_list(struct query *q, char **argv, client *cl,
287                          int (*action)(int, char *[], void *), void *actarg);
288int get_lists_of_member(struct query *q, char **argv, client *cl,
289                        int (*action)(int, char *[], void *), void *actarg);
290int get_user_reservations(struct query *q, char **argv, client *cl,
291                          int (*action)(int, char *[], void *), void *actarg);
292int get_user_by_reservation(struct query *q, char **argv, client *cl,
293                            int (*action)(int, char *[], void *),
294                            void *actarg);
295int get_machines_of_container(struct query *q, char **argv, client *cl,
296                            int (*action)(int, char *[], void *),
297                            void *actarg);
298int get_subcontainers_of_container(struct query *q, char **argv, client *cl,
299                            int (*action)(int, char *[], void *),
300                            void *actarg);
301
302
303/* prototypes from qvalidate.pc */
304int validate_fields(struct query *q, char *argv[], struct valobj *vo, int n);
305int validate_row(struct query *q, char *argv[], struct validate *v);
Note: See TracBrowser for help on using the repository browser.