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