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