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