]> andersk Git - moira.git/blob - server/mr_server.h
c70bd84bb4cc668c37d668271b8d5e5329b13e3f
[moira.git] / server / mr_server.h
1 /* $Id$
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
20 enum 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
27 typedef 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
48 extern char krb_realm[REALM_SZ];
49
50 /* max length of query argument allowed */
51 #define ARGLEN  257
52 /* Used to setup static argv, maximum argc */
53 #define QMAXARGS        25
54
55 /* statistics on number of queries by version number */
56 extern int newqueries;
57
58 /* Maximum and minimum values that will be used for uids and gids */
59 #define MAX_ID_VALUE    131072
60 #define MIN_ID_VALUE    100
61
62 /* Sleepy states for the server! */
63 #define AWAKE 0
64 #define SLEEPY 1
65 #define ASLEEP 2
66 #define GROGGY 3
67 extern int dormant;
68
69 /* state for the incremental update system */
70 extern int inc_running, inc_pid;
71 extern time_t inc_started, now;
72 #define INC_TIMEOUT (3 * 60)    /* 3 minutes */
73
74
75 #define SQL_NO_MATCH 1403 /* oracle, not ingres (= 100) */
76
77 /* types needed for prototypes */
78 struct query;
79 struct validate;
80 struct valobj;
81
82 /* prototypes from increment.dc */
83 void incremental_init(void);
84 void next_incremental(void);
85 void incremental_update(void);
86 void incremental_flush(void);
87
88 /* prototypes from qrtn.dc */
89 void dbmserr(void);
90 void dosql(char *buffers[]);
91 int mr_open_database(void);
92 void mr_close_database(void);
93 int mr_process_query(client *cl, char *name, int argc, char *argv_ro[],
94                      int (*action)(int, char *[], void *), void *actarg);
95 int mr_check_access(client *cl, char *name, int argc, char *argv_ro[]);
96 void sanity_check_queries(void);
97 int set_krb_mapping(char *name, char *login, int ok, int *kid, int *uid);
98 int find_member(char *list_type, int list_id, client *cl);
99 int do_for_all_rows(char *query, int count,
100                     int (*action)(int, char *[], void *), void *actarg);
101 char *build_qual(char *fmt, int argc, char *argv[]);
102
103
104 /* prototyoes from qsupport.dc */
105 int set_pop_usage(int id, int cnt);
106
107 /* prototypes from qvalidate.dc */
108 void sanity_check_database(void);
109 int add_string(char *name);
110 int convert_wildcards(char *arg);
111
112 /* prototypes from mr_main.c */
113 void clist_delete(client *cp);
114
115 /* prototypes from mr_sauth.c */
116 void do_auth(client *cl);
117 void do_proxy(client *cl);
118 void do_krb5_auth(client *cl);
119
120 /* prototypes from mr_scall.c */
121 void do_client(client *cl);
122 void client_reply(client *cl, long status);
123 void client_return_tuple(client *cl, int argc, char **argv);
124 void client_read(client *cl);
125 void client_write(client *cl);
126
127 /* prototypes from mr_shutdown.c */
128 void sigshut(int);
129 void do_shutdown(client *cl);
130
131 /* prototypes from mr_util.c */
132 char *requote(char *buf);
133 void log_args(char *tag, int version, int argc, char **argv);
134 void mr_com_err(const char *whoami, long code, const char *fmt, va_list pvar);
135 int mr_trim_args(int argc, char **argv);
136 char **mr_copy_args(char **argv, int argc);
137 void *xmalloc(size_t);
138 void *xrealloc(void *, size_t);
139 char *xstrdup(char *);
140
141 /* prototypes from qaccess.pc */
142 int access_user(struct query *q, char *argv[], client *cl);
143 int access_login(struct query *q, char *argv[], client *cl);
144 int access_spob(struct query *q, char *argv[], client *cl);
145 int access_list(struct query *q, char *argv[], client *cl);
146 int access_visible_list(struct query *q, char *argv[], client *cl);
147 int access_vis_list_by_name(struct query *q, char *argv[], client *cl);
148 int access_member(struct query *q, char *argv[], client *cl);
149 int access_qgli(struct query *q, char *argv[], client *cl);
150 int access_service(struct query *q, char *argv[], client *cl);
151 int access_filesys(struct query *q, char *argv[], client *cl);
152 int access_host(struct query *q, char *argv[], client *cl);
153 int access_ahal(struct query *q, char *argv[], client *cl);
154 int access_snt(struct query *q, char *argv[], client *cl);
155 int access_printer(struct query *q, char *argv[], client *cl);
156 int access_zephyr(struct query *q, char *argv[], client *cl);
157 int access_container(struct query *q, char *argv[], client *cl);
158 int access_update_user(struct query *q, char *argv[], client *cl);
159
160 /* prototypes from qfollow.pc */
161 int followup_fix_modby(struct query *q, struct save_queue *sq,
162                        struct validate *v, int (*action)(int, char **, void *),
163                        void *actarg, client *cl);
164 int followup_gpob(struct query *q, struct save_queue *sq, struct validate *v,
165                   int (*action)(int, char **, void *), void *actarg,
166                   client *cl);
167 int followup_glin(struct query *q, struct save_queue *sq, struct validate *v,
168                   int (*action)(int, char **, void *), void *actarg,
169                   client *cl);
170 int followup_gsin(struct query *q, struct save_queue *sq, struct validate *v,
171                   int (*action)(int, char **, void *), void *actarg,
172                   client *cl);
173 int followup_gzcl(struct query *q, struct save_queue *sq, struct validate *v,
174                   int (*action)(int, char **, void *), void *actarg,
175                   client *cl);
176 int followup_gsha(struct query *q, struct save_queue *sq, struct validate *v,
177                   int (*action)(int, char **, void *), void *actarg,
178                   client *cl);
179 int followup_gqot(struct query *q, struct save_queue *sq, struct validate *v,
180                   int (*action)(int, char **, void *), void *actarg,
181                   client *cl);
182 int followup_guax(struct query *q, struct save_queue *sq, struct validate *v,
183                   int (*action)(int, char **, void *), void *actarg,
184                   client *cl);
185 int followup_gsnt(struct query *q, struct save_queue *sq, struct validate *v,
186                   int (*action)(int, char **, void *), void *actarg,
187                   client *cl);
188 int followup_ghst(struct query *q, struct save_queue *sq, struct validate *v,
189                   int (*action)(int, char **, void *), void *actarg,
190                   client *cl);
191 int followup_gpsv(struct query *q, struct save_queue *sq, struct validate *v,
192                   int (*action)(int, char **, void *), void *actarg,
193                   client *cl);
194 int followup_gcon(struct query *q, struct save_queue *sq, struct validate *v,
195                   int (*action)(int, char **, void *), void *actarg,
196                   client *cl);
197 int followup_get_user(struct query *q, struct save_queue *sq, 
198                       struct validate *v, int (*action)(int, char **, void *), 
199                       void *actarg, client *cl);
200
201 int followup_ausr(struct query *q, char *argv[], client *cl);
202 int followup_aqot(struct query *q, char *argv[], client *cl);
203 int followup_dqot(struct query *q, char *argv[], client *cl);
204
205 int set_modtime(struct query *q, char *argv[], client *cl);
206 int set_modtime_by_id(struct query *q, char *argv[], client *cl);
207 int set_finger_modtime(struct query *q, char *argv[], client *cl);
208 int set_pobox_modtime(struct query *q, char *argv[], client *cl);
209 int set_uppercase_modtime(struct query *q, char *argv[], client *cl);
210 int set_mach_modtime_by_id(struct query *q, char *argv[], client *cl);
211 int set_cluster_modtime_by_id(struct query *q, char *argv[], client *cl);
212 int set_serverhost_modtime(struct query *q, char *argv[], client *cl);
213 int set_nfsphys_modtime(struct query *q, char *argv[], client *cl);
214 int set_filesys_modtime(struct query *q, char *argv[], client *cl);
215 int set_zephyr_modtime(struct query *q, char *argv[], client *cl);
216 int set_service_modtime(struct query *q, char *argv[], client *cl);
217 int _sdl_followup(struct query *q, char *argv[], client *cl);
218 int trigger_dcm(struct query *q, char *argv[], client *cl);
219
220 /* prototypes from qsetup.pc */
221 int prefetch_value(struct query *q, char *argv[], client *cl);
222 int prefetch_filesys(struct query *q, char *argv[], client *cl);
223 int setup_ausr(struct query *q, char *argv[], client *cl);
224 int setup_dusr(struct query *q, char *argv[], client *cl);
225 int setup_dpob(struct query *q, char *argv[], client *cl);
226 int setup_dmac(struct query *q, char *argv[], client *cl);
227 int setup_dclu(struct query *q, char *argv[], client *cl);
228 int setup_alis(struct query *q, char *argv[], client *cl);
229 int setup_dlis(struct query *q, char *argv[], client *cl);
230 int setup_dsin(struct query *q, char *argv[], client *cl);
231 int setup_dshi(struct query *q, char *argv[], client *cl);
232 int setup_afil(struct query *q, char *argv[], client *cl);
233 int setup_ufil(struct query *q, char *argv[], client *cl);
234 int setup_dfil(struct query *q, char *argv[], client *cl);
235 int setup_aftg(struct query *q, char *argv[], client *cl);
236 int setup_dnfp(struct query *q, char *argv[], client *cl);
237 int setup_dqot(struct query *q, char *argv[], client *cl);
238 int setup_asnt(struct query *q, char *argv[], client *cl);
239 int setup_dsnt(struct query *q, char *argv[], client *cl);
240 int setup_ghst(struct query *q, char *argv[], client *cl);
241 int setup_ahst(struct query *q, char *argv[], client *cl);
242 int setup_ahal(struct query *q, char *argv[], client *cl);
243 int setup_uhha(struct query *q, char *argv[], client *cl);
244 int setup_aprn(struct query *q, char *argv[], client *cl);
245 int setup_dpsv(struct query *q, char *argv[], client *cl);
246 int setup_dcon(struct query *q, char *argv[], client *cl);
247 int setup_acon(struct query *q, char *argv[], client *cl);
248 int setup_scli(struct query *q, char *argv[], client *cl);
249
250 /* prototypes from qsupport.pc */
251 int set_pobox(struct query *q, char *argv[], client *cl);
252 int set_pobox_pop(struct query *q, char *argv[], client *cl);
253 int add_member_to_list(struct query *q, char *argv[], client *cl);
254 int delete_member_from_list(struct query *q, char *argv[], client *cl);
255 int tag_member_of_list(struct query *q, char *argv[], client *cl);
256 int register_user(struct query *q, char *argv[], client *cl);
257 int do_user_reservation(struct query *q, char *argv[], client *cl);
258 int update_container(struct query *q, char *argv[], client *cl);
259 int set_container_list(struct query *q, char *argv[], client *cl);
260
261 int get_ace_use(struct query *q, char **argv, client *cl,
262                 int (*action)(int, char *[], void *), void *actarg);
263 int get_host_by_owner(struct query *q, char **argv, client *cl,
264                 int (*action)(int, char *[], void *), void *actarg);
265 int get_user_account_by_sponsor(struct query *q, char **argv, client *cl,
266                                 int (*action)(int, char *[], void *),
267                                 void *actarg);
268 int qualified_get_lists(struct query *q, char **argv, client *cl,
269                         int (*action)(int, char *[], void *), void *actarg);
270 int get_members_of_list(struct query *q, char **argv, client *cl,
271                         int (*action)(int, char *[], void *), void *actarg);
272 int qualified_get_server(struct query *q, char **argv, client *cl,
273                          int (*action)(int, char *[], void *), void *actarg);
274 int qualified_get_serverhost(struct query *q, char **argv, client *cl,
275                              int (*action)(int, char *[], void *),
276                              void *actarg);
277 int count_members_of_list(struct query *q, char **argv, client *cl,
278                           int (*action)(int, char *[], void *), void *actarg);
279 int get_lists_of_member(struct query *q, char **argv, client *cl,
280                         int (*action)(int, char *[], void *), void *actarg);
281 int get_user_reservations(struct query *q, char **argv, client *cl,
282                           int (*action)(int, char *[], void *), void *actarg);
283 int get_user_by_reservation(struct query *q, char **argv, client *cl,
284                             int (*action)(int, char *[], void *),
285                             void *actarg);
286 int get_machines_of_container(struct query *q, char **argv, client *cl,
287                             int (*action)(int, char *[], void *),
288                             void *actarg);
289 int get_subcontainers_of_container(struct query *q, char **argv, client *cl,
290                             int (*action)(int, char *[], void *),
291                             void *actarg);
292
293
294 /* prototypes from qvalidate.pc */
295 int validate_fields(struct query *q, char *argv[], struct valobj *vo, int n);
296 int validate_row(struct query *q, char *argv[], struct validate *v);
This page took 0.558225 seconds and 3 git commands to generate.