]> andersk Git - moira.git/blob - server/mr_server.h
second code style cleanup: void/void * usage, proper #includes. try to
[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_proto.h>
10 #include <moira_site.h>
11
12 #include <netinet/in.h>
13
14 #include <stdarg.h>
15
16 #include <krb.h>
17
18 typedef struct returned_tuples {
19   struct returned_tuples *next;
20   OPERATION op;
21   mr_params *retval;
22 } returned_tuples;
23
24 /*
25  * This should be in the kerberos header file.
26  */
27
28 struct krbname {
29   char name[ANAME_SZ];
30   char inst[INST_SZ];
31   char realm[REALM_SZ];
32 };
33
34 /*
35  * This structure holds all per-client information; one of these is
36  * allocated for each active client.
37  */
38
39 typedef struct _client {
40   OPERATION pending_op;         /* Primary pending operation */
41   CONNECTION con;               /* Connection to the client */
42   int action;                   /* what action is pending? */
43   mr_params *args, reply;
44   int id;                       /* Unique id of client */
45   struct sockaddr_in haddr;     /* IP address of client */
46   char clname[MAX_K_NAME_SZ];   /* Name client authenticated to */
47   struct krbname kname;         /* Parsed version of the above */
48   int users_id;                 /* Moira-internal ID of authenticated user */
49   int client_id;                /* Moira-internal ID of client for modby field */
50   returned_tuples *first, *last;
51   time_t last_time_used;        /* Last time connection used */
52   char entity[9];               /* entity on other end of the connection */
53 } client;
54
55 /*
56  * States
57  */
58
59 #define CL_DEAD 0
60 #define CL_STARTING 1
61
62 /*
63  * Actions.
64  */
65
66 #define CL_ACCEPT 0
67 #define CL_RECEIVE 1
68 #define CL_SEND 2
69
70 extern char *krb_realm;
71
72 /*
73  * Debugging options.
74  */
75
76 extern int log_flags;
77
78 #define LOG_CONNECT             0x0001
79 #define LOG_REQUESTS            0x0002
80 #define LOG_ARGS                0x0004
81 #define LOG_RESP                0x0008
82 #define LOG_RES                 0x0010
83 #define LOG_VALID               0x0020
84 #define LOG_SQL                 0x0040
85 #define LOG_GDSS                0x0080
86
87
88 /* max length of query argument allowed */
89 #define ARGLEN  257
90 /* Used to setup static argv, maximum argc */
91 #define QMAXARGS        22
92
93 /* statistics on number of queries by version number */
94 extern int newqueries, oldqueries;
95
96 /* Maximum and minimum values that will ever be chosen for IDs */
97 #define MAX_ID_VALUE    31999
98 #define MIN_ID_VALUE    100
99
100 /* Sleepy states for the server! */
101 #define AWAKE 0
102 #define SLEEPY 1
103 #define ASLEEP 2
104 #define GROGGY 3
105 extern int dormant;
106
107 /* state for the incremental update system */
108 extern int inc_running, inc_pid;
109 extern time_t inc_started, now;
110 #define INC_TIMEOUT (3 * 60)    /* 3 minutes */
111
112
113 #define SQL_NO_MATCH 1403 /* oracle, not ingres (= 100) */
114
115 /* types needed for prototypes */
116 struct query;
117 struct validate;
118 struct valobj;
119
120 /* prototypes from gdb */
121 int gdb_init(void);
122 int gdb_debug(int flag);
123 void start_accepting_client(CONNECTION, OPERATION, CONNECTION *,
124                              char *, int *, TUPLE *);
125 int initialize_operation(OPERATION, int (*init_function)(OPERATION, HALF_CONNECTION, void *),
126                          char *, int (*cancel_function)(HALF_CONNECTION, void *));
127 int reset_operation(OPERATION);
128 int delete_operation(OPERATION);
129 int start_replying_to_client(OPERATION, CONNECTION, int, char *, char *);
130 int op_select(LIST_OF_OPERATIONS, int, fd_set *, fd_set *, fd_set *,
131               struct timeval *);
132
133 /* prototypes from increment.dc */
134 void incremental_init(void);
135 void next_incremental(void);
136 void incremental_update(void);
137 void incremental_flush(void);
138
139 /* prototypes from qrtn.dc */
140 void dbmserr(void);
141 void dosql(char *buffers[]);
142 int mr_open_database(void);
143 void mr_close_database(void);
144 int mr_process_query(client *cl, char *name, int argc, char *argv_ro[],
145                      int (*action)(int, char *[], void *), void *actarg);
146 int mr_check_access(client *cl, char *name, int argc, char *argv_ro[]);
147 void sanity_check_queries(void);
148 int set_krb_mapping(char *name, char *login, int ok, int *kid, int *uid);
149 int find_member(char *list_type, int list_id, client *cl);
150 int do_for_all_rows(char *query, int count,
151                     int (*action)(int, char *[], void *), void *actarg);
152 void build_qual(char *fmt, int argc, char *argv[], char *qual);
153
154
155 /* prototyoes from qsupport.dc */
156 int set_pop_usage(int id, int cnt);
157
158 /* prototypes from qvalidate.dc */
159 void sanity_check_database(void);
160 int add_string(char *name);
161 int convert_wildcards(char *arg);
162
163 /* prototypes from mr_main.c */
164 void clist_delete(client *cp);
165
166 /* prototypes from mr_sauth.c */
167 void do_auth(client *cl);
168
169 /* prototypes from mr_scall.c */
170 void do_client(client *cp);
171 int trigger_dcm(struct query *q, char *argv[], client *cl);
172
173 /* prototypes from mr_shutdown.c */
174 void sigshut(int);
175 void do_shutdown(client *cl);
176
177 /* prototypes from mr_util.c */
178 char *requote(char *buf, char *cp, int len);
179 void log_args(char *tag, int version, int argc, char **argv);
180 void mr_com_err(const char *whoami, long code, const char *fmt, va_list pvar);
181 int mr_trim_args(int argc, char **argv);
182 char **mr_copy_args(char **argv, int argc);
183
184 /* prototypes from qaccess.pc */
185 int access_user(struct query *q, char *argv[], client *cl);
186 int access_login(struct query *q, char *argv[], client *cl);
187 int access_list(struct query *q, char *argv[], client *cl);
188 int access_visible_list(struct query *q, char *argv[], client *cl);
189 int access_vis_list_by_name(struct query *q, char *argv[], client *cl);
190 int access_member(struct query *q, char *argv[], client *cl);
191 int access_qgli(struct query *q, char *argv[], client *cl);
192 int access_service(struct query *q, char *argv[], client *cl);
193 int access_filesys(struct query *q, char *argv[], client *cl);
194 int access_host(struct query *q, char *argv[], client *cl);
195 int access_ahal(struct query *q, char *argv[], client *cl);
196 int access_snt(struct query *q, char *argv[], client *cl);
197
198 /* prototypes from qfollow.pc */
199 int followup_fix_modby(struct query *q, struct save_queue *sq,
200                        struct validate *v, int (*action)(int, char **, void *),
201                        void *actarg, client *cl);
202 int followup_gpob(struct query *q, struct save_queue *sq, struct validate *v,
203                   int (*action)(int, char **, void *), void *actarg,
204                   client *cl);
205 int followup_glin(struct query *q, struct save_queue *sq, struct validate *v,
206                   int (*action)(int, char **, void *), void *actarg,
207                   client *cl);
208 int followup_gzcl(struct query *q, struct save_queue *sq, struct validate *v,
209                   int (*action)(int, char **, void *), void *actarg,
210                   client *cl);
211 int followup_gsha(struct query *q, struct save_queue *sq, struct validate *v,
212                   int (*action)(int, char **, void *), void *actarg,
213                   client *cl);
214 int followup_gqot(struct query *q, struct save_queue *sq, struct validate *v,
215                   int (*action)(int, char **, void *), void *actarg,
216                   client *cl);
217 int followup_gpce(struct query *q, struct save_queue *sq, struct validate *v,
218                   int (*action)(int, char **, void *), void *actarg,
219                   client *cl);
220 int followup_guax(struct query *q, struct save_queue *sq, struct validate *v,
221                   int (*action)(int, char **, void *), void *actarg,
222                   client *cl);
223 int followup_gsnt(struct query *q, struct save_queue *sq, struct validate *v,
224                   int (*action)(int, char **, void *), void *actarg,
225                   client *cl);
226 int followup_ghst(struct query *q, struct save_queue *sq, struct validate *v,
227                   int (*action)(int, char **, void *), void *actarg,
228                   client *cl);
229
230 int followup_ausr(struct query *q, char *argv[], client *cl);
231 int followup_aqot(struct query *q, char *argv[], client *cl);
232 int followup_dqot(struct query *q, char *argv[], client *cl);
233 int followup_uuac(struct query *q, char *argv[], client *cl);
234
235 int set_modtime(struct query *q, char *argv[], client *cl);
236 int set_modtime_by_id(struct query *q, char *argv[], client *cl);
237 int set_finger_modtime(struct query *q, char *argv[], client *cl);
238 int set_pobox_modtime(struct query *q, char *argv[], client *cl);
239 int set_uppercase_modtime(struct query *q, char *argv[], client *cl);
240 int set_mach_modtime_by_id(struct query *q, char *argv[], client *cl);
241 int set_cluster_modtime_by_id(struct query *q, char *argv[], client *cl);
242 int set_serverhost_modtime(struct query *q, char *argv[], client *cl);
243 int set_nfsphys_modtime(struct query *q, char *argv[], client *cl);
244 int set_filesys_modtime(struct query *q, char *argv[], client *cl);
245 int set_zephyr_modtime(struct query *q, char *argv[], client *cl);
246 int _sdl_followup(struct query *q, char *argv[], client *cl);
247
248 /* prototypes from qsetup.pc */
249 int prefetch_value(struct query *q, char *argv[], client *cl);
250 int prefetch_filesys(struct query *q, char *argv[], client *cl);
251 int setup_ausr(struct query *q, char *argv[], client *cl);
252 int setup_dusr(struct query *q, char *argv[], client *cl);
253 int setup_spop(struct query *q, char *argv[], client *cl);
254 int setup_dpob(struct query *q, char *argv[], client *cl);
255 int setup_dmac(struct query *q, char *argv[], client *cl);
256 int setup_dclu(struct query *q, char *argv[], client *cl);
257 int setup_alis(struct query *q, char *argv[], client *cl);
258 int setup_dlis(struct query *q, char *argv[], client *cl);
259 int setup_dsin(struct query *q, char *argv[], client *cl);
260 int setup_dshi(struct query *q, char *argv[], client *cl);
261 int setup_afil(struct query *q, char *argv[], client *cl);
262 int setup_ufil(struct query *q, char *argv[], client *cl);
263 int setup_dfil(struct query *q, char *argv[], client *cl);
264 int setup_aftg(struct query *q, char *argv[], client *cl);
265 int setup_dnfp(struct query *q, char *argv[], client *cl);
266 int setup_dqot(struct query *q, char *argv[], client *cl);
267 int setup_akum(struct query *q, char *argv[], client *cl);
268 int setup_dsnt(struct query *q, char *argv[], client *cl);
269 int setup_ahst(struct query *q, char *argv[], client *cl);
270 int setup_ahal(struct query *q, char *argv[], client *cl);
271
272 /* prototypes from qsupport.pc */
273 int set_pobox(struct query *q, char *argv[], client *cl);
274 int add_member_to_list(struct query *q, char *argv[], client *cl);
275 int delete_member_from_list(struct query *q, char *argv[], client *cl);
276 int register_user(struct query *q, char *argv[], client *cl);
277
278 int get_list_info(struct query *q, char **argv, client *cl,
279                   int (*action)(int, char *[], void *), void *actarg);
280 int get_ace_use(struct query *q, char **argv, client *cl,
281                 int (*action)(int, char *[], void *), void *actarg);
282 int qualified_get_lists(struct query *q, char **argv, client *cl,
283                         int (*action)(int, char *[], void *), void *actarg);
284 int get_members_of_list(struct query *q, char **argv, client *cl,
285                         int (*action)(int, char *[], void *), void *actarg);
286 int get_end_members_of_list(struct query *q, char **argv, client *cl,
287                             int (*action)(int, char *[], void *),
288                             void *actarg);
289 int qualified_get_server(struct query *q, char **argv, client *cl,
290                          int (*action)(int, char *[], void *), void *actarg);
291 int qualified_get_serverhost(struct query *q, char **argv, client *cl,
292                              int (*action)(int, char *[], void *),
293                              void *actarg);
294 int count_members_of_list(struct query *q, char **argv, client *cl,
295                           int (*action)(int, char *[], void *), void *actarg);
296 int get_lists_of_member(struct query *q, char **argv, client *cl,
297                         int (*action)(int, char *[], void *), void *actarg);
298
299 /* prototypes from qvalidate.pc */
300 /* from qvalidate.dc */
301 int validate_fields(struct query *q, char *argv[], struct valobj *vo, int n);
302 int validate_row(struct query *q, char *argv[], struct validate *v);
This page took 0.089175 seconds and 5 git commands to generate.