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