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

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