]>
Commit | Line | Data |
---|---|---|
51e7c423 | 1 | /* $Header$ |
2 | * | |
3 | * Creates a new sms database | |
4 | * | |
5 | * Copyright 1988 by the Massachusetts Institute of Technology. | |
5370cb14 | 6 | * For copying and distribution information, please see the file |
7 | * <mit-copyright.h>. | |
51e7c423 | 8 | */ |
9 | ||
5370cb14 | 10 | #include <mit-copyright.h> |
51e7c423 | 11 | #include <stdio.h> |
12 | #include "../server/query.h" | |
13 | ||
14 | static int ingres_errno = 0; | |
15 | int ingerr(); | |
16 | ||
17 | extern char *tables[]; | |
18 | extern struct query Queries1[], Queries2[]; | |
19 | extern int QueryCount1, QueryCount2; | |
20 | ||
5370cb14 | 21 | char *values[] = { "users_id", "mach_id", "clu_id", "list_id", |
22 | "nfsphys_id", "filsys_id", "strings_id", "dcm_enable", | |
23 | 0 }; | |
51e7c423 | 24 | |
25 | struct alias { char *name; | |
26 | char *type; | |
27 | char *trans; | |
28 | } aliases[] = { | |
5370cb14 | 29 | {"ace_type", "TYPE", "USER"}, |
30 | {"ace_type", "TYPE", "LIST"}, | |
31 | {"ace_type", "TYPE", "NONE"}, | |
32 | {"alias", "TYPE", "FILESYS"}, | |
51e7c423 | 33 | {"alias", "TYPE", "TYPE"}, |
5370cb14 | 34 | {"alias", "TYPE", "SERVICE"}, |
51e7c423 | 35 | {"alias", "TYPE", "TYPEDATA"}, |
5370cb14 | 36 | {"alias", "TYPE", "VALUE"}, |
51e7c423 | 37 | {"boolean", "TYPE", "FALSE"}, |
38 | {"boolean", "TYPE", "DONTCARE"}, | |
39 | {"boolean", "TYPE", "TRUE"}, | |
5370cb14 | 40 | {"class", "TYPE", "STAFF"}, |
51e7c423 | 41 | {"class", "TYPE", "1988"}, |
42 | {"class", "TYPE", "1989"}, | |
43 | {"class", "TYPE", "1990"}, | |
44 | {"class", "TYPE", "1991"}, | |
45 | {"class", "TYPE", "1992"}, | |
5370cb14 | 46 | {"class", "TYPE", "FACULTY"}, |
51e7c423 | 47 | {"class", "TYPE", "G"}, |
5370cb14 | 48 | {"class", "TYPE", "GUEST"}, |
49 | {"class", "TYPE", "UNKNOWN"}, | |
50 | {"filesys", "TYPE", "ERR"}, | |
4915459e | 51 | {"filesys", "TYPE", "FSGROUP"}, |
51e7c423 | 52 | {"filesys", "TYPE", "NFS"}, |
53 | {"filesys", "TYPE", "RVD"}, | |
5370cb14 | 54 | {"gaus", "TYPE", "LIST"}, |
55 | {"gaus", "TYPE", "USER"}, | |
56 | {"gaus", "TYPE", "RLIST"}, | |
57 | {"gaus", "TYPE", "RUSER"}, | |
58 | {"lockertype", "TYPE", "HOMEDIR"}, | |
59 | {"lockertype", "TYPE", "OTHER"}, | |
60 | {"lockertype", "TYPE", "PROJECT"}, | |
61 | {"lockertype", "TYPE", "SYSTEM"}, | |
62 | {"lockertype", "TYPE", "UNKNOWN"}, | |
51e7c423 | 63 | {"mac_type", "TYPE", "RT"}, |
64 | {"mac_type", "TYPE", "VAX"}, | |
65 | {"member", "TYPE", "LIST"}, | |
66 | {"member", "TYPE", "STRING"}, | |
67 | {"member", "TYPE", "USER"}, | |
68 | {"pobox", "TYPE", "SMTP"}, | |
69 | {"pobox", "TYPE", "NONE"}, | |
70 | {"pobox", "TYPE", "POP"}, | |
5370cb14 | 71 | {"rmember", "TYPE", "LIST"}, |
72 | {"rmember", "TYPE", "STRING"}, | |
73 | {"rmember", "TYPE", "USER"}, | |
74 | {"rmember", "TYPE", "RLIST"}, | |
75 | {"rmember", "TYPE", "RSTRING"}, | |
76 | {"rmember", "TYPE", "RUSER"}, | |
77 | {"service", "TYPE", "REPLICAT"}, | |
78 | {"service", "TYPE", "UNIQUE"}, | |
51e7c423 | 79 | {"LIST", "TYPEDATA", "list"}, |
5370cb14 | 80 | {"NONE", "TYPEDATA", "none"}, |
51e7c423 | 81 | {"POP", "TYPEDATA", "machine"}, |
5370cb14 | 82 | {"RLIST", "TYPEDATA", "list"}, |
83 | {"RSTRING", "TYPEDATA", "string"}, | |
84 | {"RUSER", "TYPEDATA", "user"}, | |
51e7c423 | 85 | {"SMTP", "TYPEDATA", "string"}, |
86 | {"STRING", "TYPEDATA", "string"}, | |
5370cb14 | 87 | {"USER", "TYPEDATA", "user"}, |
51e7c423 | 88 | 0 }; |
89 | ||
90 | ||
91 | main(argc, argv) | |
92 | int argc; | |
93 | char **argv; | |
94 | { | |
95 | char buffer[256]; | |
5370cb14 | 96 | ## char *table, *user, *value, *query, *trans, *type, *db; |
51e7c423 | 97 | ## int i, flag; |
98 | ||
5370cb14 | 99 | if (argc == 2) |
100 | db = argv[1]; | |
101 | else | |
102 | db = "sms"; | |
51e7c423 | 103 | IIseterr(ingerr); |
5370cb14 | 104 | ## ingres db |
51e7c423 | 105 | if (ingres_errno) { |
106 | printf("Unable to open the database\n"); | |
107 | exit(1); | |
108 | } | |
109 | ||
110 | strcpy(buffer, "root"); | |
111 | user = buffer; | |
112 | while (buffer[0]) { | |
113 | for (i = 0; table = tables[i]; i++) { | |
114 | ## define permit all on table to user | |
115 | if (ingres_errno) { | |
116 | printf("Unable to give %s permission to access table %s\n", | |
117 | user, table); | |
118 | exit(1); | |
119 | } | |
120 | } | |
121 | printf("Enter the name of another user to be given direct access to\n"); | |
122 | printf("the database, or [RETURN] if none: "); | |
123 | fflush(stdout); | |
124 | gets(user); | |
125 | } | |
126 | ||
127 | for (i = 0; table = tables[i]; i++) { | |
128 | ## repeat append tblstats (#table = @table, modtime = "now") | |
129 | if (ingres_errno) { | |
130 | printf("Unable to initialize tblstats for %s\n", table); | |
131 | exit(1); | |
132 | } | |
133 | } | |
134 | ||
135 | for (i = 0; value = values[i]; i++) { | |
136 | ## repeat append values (#name = @value, #value = 1) | |
137 | if (ingres_errno) { | |
138 | printf("Unable to install initial value of %s\n", value); | |
139 | exit(1); | |
140 | } | |
141 | } | |
142 | ||
143 | printf("What is the starting UID to assign: "); | |
144 | fflush(stdout); | |
145 | gets(buffer); | |
146 | i = atoi(buffer); | |
147 | ## append values (#name = "uid", #value = i) | |
148 | if (ingres_errno) { | |
149 | printf("Unable to install value for uid\n"); | |
150 | exit(1); | |
151 | } | |
152 | ||
153 | printf("What is the starting GID to assign: "); | |
154 | fflush(stdout); | |
155 | gets(buffer); | |
156 | i = atoi(buffer); | |
157 | ## append values (#name = "gid", #value = i) | |
158 | if (ingres_errno) { | |
159 | printf("Unable to install value for gid\n"); | |
160 | exit(1); | |
161 | } | |
162 | ||
163 | printf("What is the default NFS quota to assign: "); | |
164 | fflush(stdout); | |
165 | gets(buffer); | |
166 | i = atoi(buffer); | |
167 | ## append values (#name = "def_quota", #value = i) | |
168 | if (ingres_errno) { | |
169 | printf("Unable to install value for def_quota\n"); | |
170 | exit(1); | |
171 | } | |
172 | ||
173 | /* place holder records */ | |
174 | ## append users (login = "[nobody]", potype="NONE") | |
175 | if (ingres_errno) { | |
176 | printf("Unable to install 0 user\n"); | |
177 | exit(1); | |
178 | } | |
e846e035 | 179 | ## append machine (name = "[NONE]", #type="NONE") |
51e7c423 | 180 | if (ingres_errno) { |
181 | printf("Unable to install 0 machine\n"); | |
182 | exit(1); | |
183 | } | |
184 | ## append cluster (name = "[unassigned]") | |
185 | if (ingres_errno) { | |
186 | printf("Unable to install 0 cluster\n"); | |
187 | exit(1); | |
188 | } | |
189 | ## append list (name = "[none]", acl_type = "NONE") | |
190 | if (ingres_errno) { | |
191 | printf("Unable to install 0 list\n"); | |
192 | exit(1); | |
193 | } | |
194 | ||
195 | /* magic for ALL_USERS */ | |
196 | ## append users (login = "default", users_id = 1, potype="NONE") | |
197 | if (ingres_errno) { | |
198 | printf("Unable to install default user\n"); | |
199 | exit(1); | |
200 | } | |
201 | ## append list (name = "default", list_id = 1, acl_type = "NONE") | |
202 | if (ingres_errno) { | |
203 | printf("Unable to install default list\n"); | |
204 | exit(1); | |
205 | } | |
206 | ## append members (list_id = 1, member_type = "USER", member_id = 1) | |
207 | if (ingres_errno) { | |
208 | printf("Unable to install default user on default list\n"); | |
209 | exit(1); | |
210 | } | |
211 | ||
212 | /* Priveleged users */ | |
213 | ## append users (login = "root", users_id = 2, potype="NONE") | |
214 | if (ingres_errno) { | |
215 | printf("Unable to install root user\n"); | |
216 | exit(1); | |
217 | } | |
218 | ## append list (name = "dbadmin", list_id = 2, acl_type = "LIST", acl_id = 2) | |
219 | if (ingres_errno) { | |
220 | printf("Unable to install default dbadmin list\n"); | |
221 | exit(1); | |
222 | } | |
223 | ||
224 | printf("What is the name of a priveleged user: "); | |
225 | fflush(stdout); | |
226 | gets(buffer); | |
227 | user = buffer; | |
228 | ## append users (login = user, users_id = 3, potype="NONE") | |
229 | if (ingres_errno) { | |
230 | printf("Unable to install user %s\n", buffer); | |
231 | exit(1); | |
232 | } | |
233 | ## append members (list_id = 2, member_type = "USER", member_id = 3) | |
234 | if (ingres_errno) { | |
235 | printf("Unable to put user %s on list dbadmin\n", buffer); | |
236 | exit(1); | |
237 | } | |
238 | ||
239 | /* And the capacls */ | |
240 | for (i = 0; i < QueryCount1; i++) { | |
241 | query = Queries1[i].name; | |
242 | value = Queries1[i].shortname; | |
243 | ## repeat append capacls (capability = @query, tag = @value, list_id = 2) | |
244 | if (ingres_errno) { | |
245 | printf("Unable to install query ACL for %s (%s)\n", query, value); | |
246 | exit(1); | |
247 | } | |
248 | } | |
249 | for (i = 0; i < QueryCount2; i++) { | |
250 | query = Queries2[i].name; | |
251 | value = Queries2[i].shortname; | |
252 | ## repeat retrieve (flag = any(capacls.tag where capacls.tag = @value)) | |
253 | if (!flag) { | |
254 | ## repeat append capacls (capability = @query, tag = @value, list_id = 2) | |
255 | if (ingres_errno) { | |
256 | printf("Unable to install query ACL for %s (%s)\n", query, value); | |
257 | exit(1); | |
258 | } | |
259 | } | |
260 | } | |
5370cb14 | 261 | ## append capacls (capability = "trigger_dcm", tag = "tdcm", list_id = 2) |
51e7c423 | 262 | |
263 | /* and the aliases */ | |
264 | for (i = 0; aliases[i].name ; i++) { | |
265 | value = aliases[i].name; | |
266 | type = aliases[i].type; | |
267 | trans = aliases[i].trans; | |
268 | ## repeat append alias (#name = @value, #type = @type, #trans = @trans) | |
269 | } | |
270 | ||
271 | ## exit | |
272 | printf("done.\n"); | |
273 | exit(0); | |
274 | } | |
275 | ||
276 | ||
277 | /* | |
278 | * ingerr: (supposedly) called when Ingres indicates an error. | |
279 | * I have not yet been able to get this to work to intercept a | |
280 | * database open error. | |
281 | */ | |
282 | ||
283 | int ingerr(num) | |
284 | int *num; | |
285 | { | |
286 | ingres_errno = *num; | |
287 | return *num; | |
288 | } | |
289 | ||
290 | ||
291 | /* dummy routines */ | |
292 | int access_list() {} | |
293 | int access_visible_list() {} | |
294 | int access_maillist() {} | |
295 | int access_user() {} | |
5370cb14 | 296 | int access_login() {} |
297 | int access_filesys() {} | |
51e7c423 | 298 | int setup_ausr() {} |
51e7c423 | 299 | int setup_umac() {} |
300 | int setup_dmac() {} | |
301 | int setup_uclu() {} | |
302 | int setup_dclu() {} | |
303 | int setup_dusr() {} | |
304 | int setup_dsin() {} | |
305 | int setup_dshi() {} | |
306 | int setup_dlis() {} | |
5370cb14 | 307 | int setup_afil() {} |
308 | int setup_ufil() {} | |
309 | int setup_ssif() {} | |
310 | int setup_sshi() {} | |
311 | int setup_dnfq() {} | |
51e7c423 | 312 | int uusr_login_check() {} |
51e7c423 | 313 | int set_modtime() {} |
314 | int set_modtime_by_id() {} | |
315 | int set_user_modtime() {} | |
316 | int set_user_modtime_by_id() {} | |
317 | int set_finger_modtime() {} | |
318 | int set_filesys_modtime() {} | |
319 | int set_mach_modtime() {} | |
320 | int set_mach_modtime_by_id() {} | |
321 | int set_serverhost_modtime() {} | |
5370cb14 | 322 | int set_zephyr_modtime() {} |
51e7c423 | 323 | int followup_amtl() {} |
324 | int followup_ausr() {} | |
325 | int followup_delete_list() {} | |
326 | int followup_add_pobox() {} | |
327 | int followup_delete_pobox() {} | |
328 | int followup_usha() {} | |
329 | int followup_old_gpob() {} | |
5370cb14 | 330 | int followup_gsha() {} |
331 | int followup_anfq() {} | |
332 | int followup_gzcl() {} | |
51e7c423 | 333 | int followup_fix_acl() {} |
5370cb14 | 334 | int followup_fix_modby() {} |
51e7c423 | 335 | int translate_ids() {} |
336 | int expand_list_flags() {} | |
337 | int add_new_quota() {} | |
5370cb14 | 338 | int count_members_of_list() {} |
51e7c423 | 339 | int get_list_is_group() {} |
340 | int get_list_is_maillist() {} | |
341 | int add_locker() {} | |
342 | int delete_locker() {} | |
343 | int add_user_group() {} | |
344 | int set_user_pobox() {} | |
345 | int get_members_of_list() {} | |
346 | int get_groups_of_user() {} | |
347 | int get_groups_of_all_users() {} | |
348 | int get_all_poboxes() {} | |
349 | int get_new_poboxes() {} | |
350 | int get_lists_of_administrator() {} | |
351 | int followup_gpob() {} | |
352 | int set_pobox() {} | |
353 | int setup_spop() {} | |
354 | int set_pobox_modtime() {} | |
355 | int setup_dpob() {} | |
356 | int set_cluster_modtime_by_id() {} | |
357 | int access_service() {} | |
358 | int followup_glin() {} | |
359 | int qualified_get_server() {} | |
360 | int qualified_get_serverhost() {} | |
361 | int trigger_dcm() {} | |
362 | int set_nfsphys_modtime() {} | |
363 | int setup_alis() {} | |
364 | int access_member() {} | |
5370cb14 | 365 | int get_ace_use() {} |
51e7c423 | 366 | int access_qgli() {} |
367 | int qualified_get_lists() {} | |
5370cb14 | 368 | int delete_current_quota() {} |
369 | int setup_add_group() {} | |
370 | int setup_dfil() {} | |
371 | int setup_dnfp() {} | |
372 | int get_lists_of_member() {} | |
373 | int access_all() {} | |
374 | int get_list_info() {} | |
375 | int register_user() {} | |
376 | int access_vis_list_by_name() {} | |
629827f2 | 377 | int set_uppercase_modtime() {} |