]>
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 | } | |
4abd1043 | 210 | ## append filesys (label = "[none]", #type = "NONE") |
ab826364 | 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) { | |
7b3e6c73 | 217 | printf("Unable to install 0 nfsphys\n"); |
ab826364 | 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 | ||
7b3e6c73 | 239 | /* Privileged users */ |
51e7c423 | 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 | ||
7b3e6c73 | 251 | printf("What is the name of a privileged user: "); |
51e7c423 | 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 | } | |
b527dce4 | 260 | ## append imembers (list_id = 2, member_type = "USER", member_id = 2, |
261 | ## ref_count = 1, direct = 1) | |
262 | if (ingres_errno) { | |
263 | printf("Unable to put user root on list dbadmin\n"); | |
264 | exit(1); | |
265 | } | |
231e51c5 | 266 | ## append imembers (list_id = 2, member_type = "USER", member_id = 3, |
267 | ## ref_count = 1, direct = 1) | |
51e7c423 | 268 | if (ingres_errno) { |
269 | printf("Unable to put user %s on list dbadmin\n", buffer); | |
270 | exit(1); | |
271 | } | |
272 | ||
273 | /* And the capacls */ | |
6ea27ce4 | 274 | for (i = 0; i < QueryCount2; i++) { |
275 | query = Queries2[i].name; | |
276 | value = Queries2[i].shortname; | |
51e7c423 | 277 | ## repeat append capacls (capability = @query, tag = @value, list_id = 2) |
278 | if (ingres_errno) { | |
279 | printf("Unable to install query ACL for %s (%s)\n", query, value); | |
280 | exit(1); | |
281 | } | |
282 | } | |
5370cb14 | 283 | ## append capacls (capability = "trigger_dcm", tag = "tdcm", list_id = 2) |
51e7c423 | 284 | |
285 | /* and the aliases */ | |
286 | for (i = 0; aliases[i].name ; i++) { | |
287 | value = aliases[i].name; | |
288 | type = aliases[i].type; | |
289 | trans = aliases[i].trans; | |
290 | ## repeat append alias (#name = @value, #type = @type, #trans = @trans) | |
291 | } | |
292 | ||
293 | ## exit | |
294 | printf("done.\n"); | |
295 | exit(0); | |
296 | } | |
297 | ||
298 | ||
299 | /* | |
300 | * ingerr: (supposedly) called when Ingres indicates an error. | |
301 | * I have not yet been able to get this to work to intercept a | |
302 | * database open error. | |
303 | */ | |
304 | ||
305 | int ingerr(num) | |
306 | int *num; | |
307 | { | |
308 | ingres_errno = *num; | |
309 | return *num; | |
310 | } | |
311 | ||
312 | ||
313 | /* dummy routines */ | |
314 | int access_list() {} | |
315 | int access_visible_list() {} | |
316 | int access_maillist() {} | |
317 | int access_user() {} | |
5370cb14 | 318 | int access_login() {} |
319 | int access_filesys() {} | |
51e7c423 | 320 | int setup_ausr() {} |
51e7c423 | 321 | int setup_umac() {} |
322 | int setup_dmac() {} | |
323 | int setup_uclu() {} | |
324 | int setup_dclu() {} | |
325 | int setup_dusr() {} | |
326 | int setup_dsin() {} | |
327 | int setup_dshi() {} | |
328 | int setup_dlis() {} | |
5370cb14 | 329 | int setup_afil() {} |
330 | int setup_ufil() {} | |
331 | int setup_ssif() {} | |
332 | int setup_sshi() {} | |
333 | int setup_dnfq() {} | |
51e7c423 | 334 | int uusr_login_check() {} |
51e7c423 | 335 | int set_modtime() {} |
336 | int set_modtime_by_id() {} | |
337 | int set_user_modtime() {} | |
338 | int set_user_modtime_by_id() {} | |
339 | int set_finger_modtime() {} | |
340 | int set_filesys_modtime() {} | |
341 | int set_mach_modtime() {} | |
342 | int set_mach_modtime_by_id() {} | |
343 | int set_serverhost_modtime() {} | |
5370cb14 | 344 | int set_zephyr_modtime() {} |
51e7c423 | 345 | int followup_amtl() {} |
346 | int followup_ausr() {} | |
347 | int followup_delete_list() {} | |
348 | int followup_add_pobox() {} | |
349 | int followup_delete_pobox() {} | |
350 | int followup_usha() {} | |
351 | int followup_old_gpob() {} | |
5370cb14 | 352 | int followup_gsha() {} |
353 | int followup_anfq() {} | |
354 | int followup_gzcl() {} | |
51e7c423 | 355 | int followup_fix_acl() {} |
5370cb14 | 356 | int followup_fix_modby() {} |
51e7c423 | 357 | int translate_ids() {} |
358 | int expand_list_flags() {} | |
359 | int add_new_quota() {} | |
5370cb14 | 360 | int count_members_of_list() {} |
51e7c423 | 361 | int get_list_is_group() {} |
362 | int get_list_is_maillist() {} | |
363 | int add_locker() {} | |
364 | int delete_locker() {} | |
365 | int add_user_group() {} | |
366 | int set_user_pobox() {} | |
367 | int get_members_of_list() {} | |
368 | int get_groups_of_user() {} | |
369 | int get_groups_of_all_users() {} | |
370 | int get_all_poboxes() {} | |
371 | int get_new_poboxes() {} | |
372 | int get_lists_of_administrator() {} | |
373 | int followup_gpob() {} | |
374 | int set_pobox() {} | |
375 | int setup_spop() {} | |
376 | int set_pobox_modtime() {} | |
377 | int setup_dpob() {} | |
378 | int set_cluster_modtime_by_id() {} | |
379 | int access_service() {} | |
380 | int followup_glin() {} | |
381 | int qualified_get_server() {} | |
382 | int qualified_get_serverhost() {} | |
383 | int trigger_dcm() {} | |
384 | int set_nfsphys_modtime() {} | |
385 | int setup_alis() {} | |
386 | int access_member() {} | |
5370cb14 | 387 | int get_ace_use() {} |
51e7c423 | 388 | int access_qgli() {} |
389 | int qualified_get_lists() {} | |
5370cb14 | 390 | int delete_current_quota() {} |
391 | int setup_add_group() {} | |
392 | int setup_dfil() {} | |
393 | int setup_dnfp() {} | |
394 | int get_lists_of_member() {} | |
395 | int access_all() {} | |
396 | int get_list_info() {} | |
397 | int register_user() {} | |
398 | int access_vis_list_by_name() {} | |
629827f2 | 399 | int set_uppercase_modtime() {} |
4d8e9ab9 | 400 | int add_member_to_list() {} |
401 | int delete_member_from_list() {} | |
2d03da35 | 402 | int setup_akum() {} |
403 | int followup_gnfq() {} |