]>
Commit | Line | Data |
---|---|---|
eab30d01 | 1 | /* |
2 | * $Source$ | |
3 | * $Author$ | |
4 | * $Header$ | |
5 | * | |
6 | * Copyright (C) 1987 by the Massachusetts Institute of Technology | |
7 | * | |
eab30d01 | 8 | */ |
9 | ||
5dbd09a0 | 10 | #include <sys/types.h> |
11 | #include <sys/uio.h> | |
12 | #include <sys/socket.h> | |
13 | #include <netinet/in.h> | |
d548a4e7 | 14 | #include "mr_proto.h" |
15 | #include <moira_site.h> | |
0311b667 | 16 | #include <krb.h> |
03c05291 | 17 | #include <com_err.h> |
18 | #include <stdlib.h> | |
5dbd09a0 | 19 | |
c27b3454 | 20 | typedef struct returned_tuples { |
21 | struct returned_tuples *next; | |
22 | OPERATION op; | |
d548a4e7 | 23 | mr_params *retval; |
c27b3454 | 24 | } returned_tuples; |
5dbd09a0 | 25 | |
0311b667 | 26 | /* |
27 | * This should be in the kerberos header file. | |
28 | */ | |
29 | ||
30 | struct krbname { | |
31 | char name[ANAME_SZ]; | |
32 | char inst[INST_SZ]; | |
33 | char realm[REALM_SZ]; | |
34 | }; | |
35 | ||
36 | /* | |
37 | * This structure holds all per-client information; one of these is | |
38 | * allocated for each active client. | |
39 | */ | |
5d354f89 | 40 | |
0fa91a0a | 41 | typedef struct _client { |
0311b667 | 42 | OPERATION pending_op; /* Primary pending operation */ |
43 | CONNECTION con; /* Connection to the client */ | |
0311b667 | 44 | int action; /* what action is pending? */ |
d548a4e7 | 45 | mr_params *args, reply; |
eab30d01 | 46 | int id; /* Unique id of client */ |
0311b667 | 47 | struct sockaddr_in haddr; /* IP address of client */ |
5d354f89 | 48 | char clname[MAX_K_NAME_SZ];/* Name client authenticated to */ |
0311b667 | 49 | struct krbname kname; /* Parsed version of the above */ |
d548a4e7 | 50 | int users_id; /* MR internal ID of authenticated user */ |
51 | int client_id; /* MR internal ID of client for modby field */ | |
c27b3454 | 52 | returned_tuples *first, *last; |
50f51267 | 53 | time_t last_time_used; /* Last time connection used */ |
5d354f89 | 54 | char entity[9]; /* entity on other end of the connection */ |
0fa91a0a | 55 | } client; |
56 | ||
57 | /* | |
58 | * States | |
59 | */ | |
60 | ||
61 | #define CL_DEAD 0 | |
62 | #define CL_STARTING 1 | |
63 | ||
64 | /* | |
65 | * Actions. | |
66 | */ | |
67 | ||
68 | #define CL_ACCEPT 0 | |
69 | #define CL_RECEIVE 1 | |
70 | #define CL_SEND 2 | |
71 | ||
0311b667 | 72 | extern char *krb_realm; |
16904979 | 73 | |
74 | /* | |
75 | * Debugging options. | |
76 | */ | |
77 | ||
78 | extern int log_flags; | |
79 | ||
80 | #define LOG_CONNECT 0x0001 | |
81 | #define LOG_REQUESTS 0x0002 | |
82 | #define LOG_ARGS 0x0004 | |
83 | #define LOG_RESP 0x0008 | |
84 | #define LOG_RES 0x0010 | |
15516f43 | 85 | #define LOG_VALID 0x0020 |
5264ec89 | 86 | #define LOG_SQL 0x0040 |
87 | #define LOG_GDSS 0x0080 | |
16904979 | 88 | |
90052a6f | 89 | |
90 | /* max length of query argument allowed */ | |
9608e722 | 91 | #define ARGLEN 257 |
58e1747c | 92 | /* Used to setup static argv, maximum argc */ |
bf78bafe | 93 | #define QMAXARGS 22 |
7a2ebcdf | 94 | |
95 | /* statistics on number of queries by version number */ | |
96 | extern int newqueries, oldqueries; | |
97 | ||
fcd67f6a | 98 | /* Maximum and minimum values that will ever be chosen for IDs */ |
3c8eca90 | 99 | #define MAX_ID_VALUE 31999 |
fcd67f6a | 100 | #define MIN_ID_VALUE 100 |
87f17989 | 101 | |
102 | /* Sleepy states for the server! */ | |
103 | #define AWAKE 0 | |
104 | #define SLEEPY 1 | |
105 | #define ASLEEP 2 | |
106 | #define GROGGY 3 | |
107 | extern int dormant; | |
108 | ||
13f6b8bb | 109 | /* state for the incremental update system */ |
110 | extern int inc_running, inc_pid; | |
111 | extern time_t inc_started, now; | |
112 | #define INC_TIMEOUT (3 * 60) /* 3 minutes */ | |
03c05291 | 113 | |
114 | ||
115 | #define SQL_NO_MATCH 1403 /* oracle, not ingres (= 100) */ | |
116 | ||
117 | /* prototypes from gdb */ | |
118 | int gdb_init(void); | |
119 | int gdb_debug(int flag); | |
120 | void start_accepting_client(CONNECTION, OPERATION, CONNECTION *, | |
121 | char *, int*, TUPLE *); | |
122 | int initialize_operation(OPERATION, int (*init_function)(), char *, | |
123 | int (*cancel_function)()); | |
124 | int reset_operation(OPERATION); | |
125 | int delete_operation(OPERATION); | |
126 | int start_replying_to_client(OPERATION, CONNECTION, int, char *, char *); | |
127 | int op_select(LIST_OF_OPERATIONS, int, fd_set *, fd_set *, fd_set *, | |
128 | struct timeval *); | |
129 | ||
130 | /* prototypes from libmoira */ | |
131 | struct save_queue *sq_create(void); | |
960b073b | 132 | int sq_save_data(struct save_queue *sq, void *data); |
133 | int sq_save_unique_data(struct save_queue *sq, void *data); | |
134 | int sq_save_args(int argc, void *argv[], struct save_queue *sq); | |
03c05291 | 135 | int sq_get_data(struct save_queue *sq, void *data); |
136 | int sq_remove_data(struct save_queue *sq, void *data); | |
137 | int sq_empty(struct save_queue *sq); | |
138 | void sq_destroy(struct save_queue *sq); | |
139 | ||
140 | void send_zgram(char *instance, char *buf); | |
141 | void critical_alert(char *, char *, ...); | |
142 | void mr_destroy_reply(mr_params *reply); | |
143 | int gdss2et(int); | |
144 | ||
145 | /* prototypes from increment.dc */ | |
146 | void incremental_init(void); | |
147 | void next_incremental(void); | |
148 | void incremental_update(void); | |
149 | void incremental_flush(void); | |
150 | ||
151 | /* prototypes from qrtn.dc */ | |
152 | void dbmserr(void); | |
153 | void dosql(char *buffers[]); | |
154 | int mr_open_database(void); | |
155 | void mr_close_database(void); | |
156 | int mr_process_query(client *cl, char *name, int argc, char *argv_ro[], | |
157 | int (*action)(), char *actarg); | |
158 | int mr_check_access(client *cl, char *name, int argc, char *argv_ro[]); | |
159 | void sanity_check_queries(void); | |
160 | int set_krb_mapping(char *name, char *login, int ok, int *kid, int *uid); | |
f3c08a60 | 161 | int find_member(char *list_type, int list_id, client *cl); |
03c05291 | 162 | int do_for_all_rows(char *query, int count, int (*action)(), int actarg); |
163 | int build_qual(char *fmt, int argc, char *argv[], char *qual); | |
164 | ||
165 | ||
166 | /* prototyoes from qsupport.dc */ | |
167 | int set_pop_usage(int id, int cnt); | |
168 | ||
169 | /* prototypes from qvalidate.dc */ | |
170 | void sanity_check_database(void); | |
171 | int add_string(char *name); | |
172 | int convert_wildcards(char *arg); | |
173 | ||
174 | /* prototypes from mr_main.c */ | |
175 | void clist_delete(client *cp); | |
176 | ||
177 | /* prototypes from mr_sauth.c */ | |
178 | void do_auth(client *cl); | |
179 | ||
180 | /* prototypes from mr_scall.c */ | |
181 | void do_client(client *cp); | |
182 | int trigger_dcm(int dummy0, int dummy1, client *cl); | |
183 | ||
184 | /* prototypes from mr_shutdown.c */ | |
185 | void sigshut(int); | |
186 | void do_shutdown(client *cl); | |
187 | ||
188 | /* prototypes from mr_util.c */ | |
189 | char *requote(char *buf, char *cp, int len); | |
190 | void log_args(char *tag, int version, int argc, char **argv); | |
191 | void mr_com_err(char *whoami, int code, char *fmt, caddr_t pvar); | |
192 | int mr_trim_args(int argc, char **argv); | |
193 | char **mr_copy_args(char **argv, int argc); |