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