]>
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"}, |
cf2efd94 | 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"}, | |
5370cb14 | 64 | {"gaus", "TYPE", "LIST"}, |
65 | {"gaus", "TYPE", "USER"}, | |
66 | {"gaus", "TYPE", "RLIST"}, | |
67 | {"gaus", "TYPE", "RUSER"}, | |
231e51c5 | 68 | {"lockertype", "TYPE", "COURSE"}, |
5370cb14 | 69 | {"lockertype", "TYPE", "HOMEDIR"}, |
70 | {"lockertype", "TYPE", "OTHER"}, | |
71 | {"lockertype", "TYPE", "PROJECT"}, | |
72 | {"lockertype", "TYPE", "SYSTEM"}, | |
231e51c5 | 73 | {"mac_type", "TYPE", "MAC"}, |
74 | {"mac_type", "TYPE", "NEXT"}, | |
75 | {"mac_type", "TYPE", "PMAX"}, | |
51e7c423 | 76 | {"mac_type", "TYPE", "RT"}, |
77 | {"mac_type", "TYPE", "VAX"}, | |
4d8e9ab9 | 78 | {"member", "TYPE", "KERBEROS"}, |
51e7c423 | 79 | {"member", "TYPE", "LIST"}, |
80 | {"member", "TYPE", "STRING"}, | |
81 | {"member", "TYPE", "USER"}, | |
82 | {"pobox", "TYPE", "SMTP"}, | |
83 | {"pobox", "TYPE", "NONE"}, | |
84 | {"pobox", "TYPE", "POP"}, | |
8c802d11 | 85 | {"quota_type", "TYPE", "USER"}, |
86 | {"quota_type", "TYPE", "GROUP"}, | |
87 | {"quota_type", "TYPE", "ANY"}, | |
5370cb14 | 88 | {"rmember", "TYPE", "LIST"}, |
89 | {"rmember", "TYPE", "STRING"}, | |
90 | {"rmember", "TYPE", "USER"}, | |
4d8e9ab9 | 91 | {"rmember", "TYPE", "KERBEROS"}, |
5370cb14 | 92 | {"rmember", "TYPE", "RLIST"}, |
93 | {"rmember", "TYPE", "RSTRING"}, | |
94 | {"rmember", "TYPE", "RUSER"}, | |
4d8e9ab9 | 95 | {"rmember", "TYPE", "RKERBEROS"}, |
5370cb14 | 96 | {"service", "TYPE", "REPLICAT"}, |
231e51c5 | 97 | {"service", "TYPE", "REPLICATED"}, |
5370cb14 | 98 | {"service", "TYPE", "UNIQUE"}, |
231e51c5 | 99 | {"slabel", "TYPE", "LPR"}, |
100 | {"slabel", "TYPE", "KERBEROS"}, | |
101 | {"slabel", "TYPE", "USRLIB"}, | |
102 | {"slabel", "TYPE", "SYSLIB"}, | |
103 | {"slabel", "TYPE", "ZEPHYR"}, | |
8c802d11 | 104 | {"ANY", "TYPEDATA", "none"}, |
4d8e9ab9 | 105 | {"KERBEROS", "TYPEDATA", "string"}, |
8c802d11 | 106 | {"GROUP", "TYPEDATA", "list"}, |
51e7c423 | 107 | {"LIST", "TYPEDATA", "list"}, |
5370cb14 | 108 | {"NONE", "TYPEDATA", "none"}, |
51e7c423 | 109 | {"POP", "TYPEDATA", "machine"}, |
5370cb14 | 110 | {"RLIST", "TYPEDATA", "list"}, |
111 | {"RSTRING", "TYPEDATA", "string"}, | |
112 | {"RUSER", "TYPEDATA", "user"}, | |
51e7c423 | 113 | {"SMTP", "TYPEDATA", "string"}, |
114 | {"STRING", "TYPEDATA", "string"}, | |
5370cb14 | 115 | {"USER", "TYPEDATA", "user"}, |
51e7c423 | 116 | 0 }; |
117 | ||
118 | ||
119 | main(argc, argv) | |
120 | int argc; | |
121 | char **argv; | |
122 | { | |
123 | char buffer[256]; | |
5370cb14 | 124 | ## char *table, *user, *value, *query, *trans, *type, *db; |
51e7c423 | 125 | ## int i, flag; |
126 | ||
5370cb14 | 127 | if (argc == 2) |
128 | db = argv[1]; | |
129 | else | |
130 | db = "sms"; | |
51e7c423 | 131 | IIseterr(ingerr); |
5370cb14 | 132 | ## ingres db |
51e7c423 | 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 | } | |
e846e035 | 207 | ## append machine (name = "[NONE]", #type="NONE") |
51e7c423 | 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 | } | |
4abd1043 | 222 | ## append filesys (label = "[none]", #type = "NONE") |
ab826364 | 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) { | |
7b3e6c73 | 229 | printf("Unable to install 0 nfsphys\n"); |
ab826364 | 230 | exit(1); |
231 | } | |
51e7c423 | 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 | } | |
231e51c5 | 244 | ## append imembers (list_id = 1, member_type = "USER", member_id = 1, |
245 | ## ref_count = 1, direct = 1) | |
51e7c423 | 246 | if (ingres_errno) { |
247 | printf("Unable to install default user on default list\n"); | |
248 | exit(1); | |
249 | } | |
250 | ||
7b3e6c73 | 251 | /* Privileged users */ |
51e7c423 | 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 | ||
7b3e6c73 | 263 | printf("What is the name of a privileged user: "); |
51e7c423 | 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 | } | |
b527dce4 | 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 | } | |
231e51c5 | 278 | ## append imembers (list_id = 2, member_type = "USER", member_id = 3, |
279 | ## ref_count = 1, direct = 1) | |
51e7c423 | 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 */ | |
6ea27ce4 | 286 | for (i = 0; i < QueryCount2; i++) { |
287 | query = Queries2[i].name; | |
288 | value = Queries2[i].shortname; | |
51e7c423 | 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 | } | |
5370cb14 | 295 | ## append capacls (capability = "trigger_dcm", tag = "tdcm", list_id = 2) |
51e7c423 | 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 */ | |
51e7c423 | 326 | int access_user() {} |
5370cb14 | 327 | int access_login() {} |
cf2efd94 | 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() {} | |
5370cb14 | 334 | int access_filesys() {} |
51e7c423 | 335 | int setup_ausr() {} |
cf2efd94 | 336 | int setup_dusr() {} |
337 | int setup_spop() {} | |
338 | int setup_dpob() {} | |
51e7c423 | 339 | int setup_dmac() {} |
51e7c423 | 340 | int setup_dclu() {} |
cf2efd94 | 341 | int setup_alis() {} |
342 | int setup_dlis() {} | |
51e7c423 | 343 | int setup_dsin() {} |
344 | int setup_dshi() {} | |
5370cb14 | 345 | int setup_afil() {} |
346 | int setup_ufil() {} | |
cf2efd94 | 347 | int setup_dfil() {} |
348 | int setup_dnfp() {} | |
349 | int setup_dqot() {} | |
5370cb14 | 350 | int setup_sshi() {} |
cf2efd94 | 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() {} | |
51e7c423 | 360 | int set_modtime() {} |
361 | int set_modtime_by_id() {} | |
51e7c423 | 362 | int set_finger_modtime() {} |
cf2efd94 | 363 | int set_pobox_modtime() {} |
364 | int set_uppercase_modtime() {} | |
51e7c423 | 365 | int set_mach_modtime_by_id() {} |
cf2efd94 | 366 | int set_cluster_modtime_by_id() {} |
51e7c423 | 367 | int set_serverhost_modtime() {} |
cf2efd94 | 368 | int set_nfsphys_modtime() {} |
369 | int set_filesys_modtime() {} | |
5370cb14 | 370 | int set_zephyr_modtime() {} |
51e7c423 | 371 | int set_pobox() {} |
cf2efd94 | 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() {} | |
51e7c423 | 378 | int qualified_get_server() {} |
379 | int qualified_get_serverhost() {} | |
380 | int trigger_dcm() {} | |
cf2efd94 | 381 | int count_members_of_list() {} |
5370cb14 | 382 | int get_lists_of_member() {} |
5370cb14 | 383 | int register_user() {} |
a1e8476e | 384 | int followup_gpce() {} |