]> andersk Git - moira.git/blame - db/newmoira.qc
several changes: quotas & filsys & phys_id's in particular
[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.
6 */
7
8#include <stdio.h>
9#include "../server/query.h"
10
11static int ingres_errno = 0;
12int ingerr();
13
14extern char *tables[];
15extern struct query Queries1[], Queries2[];
16extern int QueryCount1, QueryCount2;
17
18char *values[] = { "users_id", "machine_id", "cluster_id", "list_id",
19 "nfsphys_id", "filsys_id", "strings_id", 0 };
20
21struct alias { char *name;
22 char *type;
23 char *trans;
24 } aliases[] = {
25 {"acl_type", "TYPE", "USER"},
26 {"acl_type", "TYPE", "LIST"},
27 {"acl_type", "TYPE", "NONE"},
28 {"alias", "TYPE", "TYPE"},
29 {"alias", "TYPE", "TYPEDATA"},
30 {"boolean", "TYPE", "FALSE"},
31 {"boolean", "TYPE", "DONTCARE"},
32 {"boolean", "TYPE", "TRUE"},
33 {"class", "TYPE", "staff"},
34 {"class", "TYPE", "1988"},
35 {"class", "TYPE", "1989"},
36 {"class", "TYPE", "1990"},
37 {"class", "TYPE", "1991"},
38 {"class", "TYPE", "1992"},
39 {"class", "TYPE", "G"},
40 {"class", "TYPE", "guest"},
41 {"filesys", "TYPE", "NFS"},
42 {"filesys", "TYPE", "RVD"},
43 {"mac_type", "TYPE", "#"},
44 {"mac_type", "TYPE", "RT"},
45 {"mac_type", "TYPE", "VAX"},
46 {"member", "TYPE", "LIST"},
47 {"member", "TYPE", "STRING"},
48 {"member", "TYPE", "USER"},
49 {"pobox", "TYPE", "SMTP"},
50 {"pobox", "TYPE", "NONE"},
51 {"pobox", "TYPE", "POP"},
52 {"service", "TYPE", "replicated"},
53 {"service", "TYPE", "unique"},
54 {"slabel", "TYPE", "usrlib"},
55 {"slabel", "TYPE", "syslib"},
56 {"slabel", "TYPE", "lpr"},
57 {"slabel", "TYPE", "zephyr"},
58 {"slabel", "TYPE", "kerberos"},
59 {"LIST", "TYPEDATA", "list"},
60 {"NONE", "TYPEDATA", ""},
61 {"POP", "TYPEDATA", "machine"},
62 {"SMTP", "TYPEDATA", "string"},
63 {"STRING", "TYPEDATA", "string"},
64 {"USER", "TYPEDATA", "user"},
65 0 };
66
67
68main(argc, argv)
69int argc;
70char **argv;
71{
72 char buffer[256];
73## char *table, *user, *value, *query, *trans, *type;
74## int i, flag;
75
76 IIseterr(ingerr);
77## ingres testsms
78 if (ingres_errno) {
79 printf("Unable to open the database\n");
80 exit(1);
81 }
82
83 strcpy(buffer, "root");
84 user = buffer;
85 while (buffer[0]) {
86 for (i = 0; table = tables[i]; i++) {
87## define permit all on table to user
88 if (ingres_errno) {
89 printf("Unable to give %s permission to access table %s\n",
90 user, table);
91 exit(1);
92 }
93 }
94 printf("Enter the name of another user to be given direct access to\n");
95 printf("the database, or [RETURN] if none: ");
96 fflush(stdout);
97 gets(user);
98 }
99
100 for (i = 0; table = tables[i]; i++) {
101## repeat append tblstats (#table = @table, modtime = "now")
102 if (ingres_errno) {
103 printf("Unable to initialize tblstats for %s\n", table);
104 exit(1);
105 }
106 }
107
108 for (i = 0; value = values[i]; i++) {
109## repeat append values (#name = @value, #value = 1)
110 if (ingres_errno) {
111 printf("Unable to install initial value of %s\n", value);
112 exit(1);
113 }
114 }
115
116 printf("What is the starting UID to assign: ");
117 fflush(stdout);
118 gets(buffer);
119 i = atoi(buffer);
120## append values (#name = "uid", #value = i)
121 if (ingres_errno) {
122 printf("Unable to install value for uid\n");
123 exit(1);
124 }
125
126 printf("What is the starting GID to assign: ");
127 fflush(stdout);
128 gets(buffer);
129 i = atoi(buffer);
130## append values (#name = "gid", #value = i)
131 if (ingres_errno) {
132 printf("Unable to install value for gid\n");
133 exit(1);
134 }
135
136 printf("What is the default NFS quota to assign: ");
137 fflush(stdout);
138 gets(buffer);
139 i = atoi(buffer);
140## append values (#name = "def_quota", #value = i)
141 if (ingres_errno) {
142 printf("Unable to install value for def_quota\n");
143 exit(1);
144 }
145
146 /* place holder records */
147## append users (login = "[nobody]", potype="NONE")
148 if (ingres_errno) {
149 printf("Unable to install 0 user\n");
150 exit(1);
151 }
152## append machine (name = "[none]", #type="NONE")
153 if (ingres_errno) {
154 printf("Unable to install 0 machine\n");
155 exit(1);
156 }
157## append cluster (name = "[unassigned]")
158 if (ingres_errno) {
159 printf("Unable to install 0 cluster\n");
160 exit(1);
161 }
162## append list (name = "[none]", acl_type = "NONE")
163 if (ingres_errno) {
164 printf("Unable to install 0 list\n");
165 exit(1);
166 }
167
168 /* magic for ALL_USERS */
169## append users (login = "default", users_id = 1, potype="NONE")
170 if (ingres_errno) {
171 printf("Unable to install default user\n");
172 exit(1);
173 }
174## append list (name = "default", list_id = 1, acl_type = "NONE")
175 if (ingres_errno) {
176 printf("Unable to install default list\n");
177 exit(1);
178 }
179## append members (list_id = 1, member_type = "USER", member_id = 1)
180 if (ingres_errno) {
181 printf("Unable to install default user on default list\n");
182 exit(1);
183 }
184
185 /* Priveleged users */
186## append users (login = "root", users_id = 2, potype="NONE")
187 if (ingres_errno) {
188 printf("Unable to install root user\n");
189 exit(1);
190 }
191## append list (name = "dbadmin", list_id = 2, acl_type = "LIST", acl_id = 2)
192 if (ingres_errno) {
193 printf("Unable to install default dbadmin list\n");
194 exit(1);
195 }
196
197 printf("What is the name of a priveleged user: ");
198 fflush(stdout);
199 gets(buffer);
200 user = buffer;
201## append users (login = user, users_id = 3, potype="NONE")
202 if (ingres_errno) {
203 printf("Unable to install user %s\n", buffer);
204 exit(1);
205 }
206## append members (list_id = 2, member_type = "USER", member_id = 3)
207 if (ingres_errno) {
208 printf("Unable to put user %s on list dbadmin\n", buffer);
209 exit(1);
210 }
211
212 /* And the capacls */
213 for (i = 0; i < QueryCount1; i++) {
214 query = Queries1[i].name;
215 value = Queries1[i].shortname;
216## repeat append capacls (capability = @query, tag = @value, list_id = 2)
217 if (ingres_errno) {
218 printf("Unable to install query ACL for %s (%s)\n", query, value);
219 exit(1);
220 }
221 }
222 for (i = 0; i < QueryCount2; i++) {
223 query = Queries2[i].name;
224 value = Queries2[i].shortname;
225## repeat retrieve (flag = any(capacls.tag where capacls.tag = @value))
226 if (!flag) {
227## repeat append capacls (capability = @query, tag = @value, list_id = 2)
228 if (ingres_errno) {
229 printf("Unable to install query ACL for %s (%s)\n", query, value);
230 exit(1);
231 }
232 }
233 }
234
235 /* and the aliases */
236 for (i = 0; aliases[i].name ; i++) {
237 value = aliases[i].name;
238 type = aliases[i].type;
239 trans = aliases[i].trans;
240## repeat append alias (#name = @value, #type = @type, #trans = @trans)
241 }
242
243## exit
244 printf("done.\n");
245 exit(0);
246}
247
248
249/*
250 * ingerr: (supposedly) called when Ingres indicates an error.
251 * I have not yet been able to get this to work to intercept a
252 * database open error.
253 */
254
255int ingerr(num)
256 int *num;
257{
258 ingres_errno = *num;
259 return *num;
260}
261
262
263/* dummy routines */
264int access_list() {}
265int access_visible_list() {}
266int access_maillist() {}
267int access_user() {}
268int setup_ausr() {}
269int setup_add_group() {}
270int setup_add_filesys() {}
271int setup_update_filesys() {}
272int setup_umac() {}
273int setup_dmac() {}
274int setup_uclu() {}
275int setup_dclu() {}
276int setup_dusr() {}
277int setup_dsin() {}
278int setup_dshi() {}
279int setup_dlis() {}
280int validate_label() {}
281int validate_label_2() {}
282int uusr_login_check() {}
283int delete_user_poboxes() {}
284int delete_current_quota() {}
285int set_modtime() {}
286int set_modtime_by_id() {}
287int set_user_modtime() {}
288int set_user_modtime_by_id() {}
289int set_finger_modtime() {}
290int set_filesys_modtime() {}
291int set_mach_modtime() {}
292int set_mach_modtime_by_id() {}
293int set_serverhost_modtime() {}
294int followup_amtl() {}
295int followup_ausr() {}
296int followup_delete_list() {}
297int followup_add_pobox() {}
298int followup_delete_pobox() {}
299int followup_usha() {}
300int followup_old_gpob() {}
301int followup_fix_acl() {}
302int translate_ids() {}
303int expand_list_flags() {}
304int add_new_quota() {}
305int add_hostaccess() {}
306int delete_hostaccess() {}
307int get_query_need() {}
308int get_list_is_group() {}
309int get_list_is_maillist() {}
310int add_locker() {}
311int delete_locker() {}
312int add_user_group() {}
313int set_user_pobox() {}
314int get_members_of_list() {}
315int get_groups_of_user() {}
316int get_groups_of_all_users() {}
317int get_all_poboxes() {}
318int get_new_poboxes() {}
319int get_lists_of_administrator() {}
320int followup_gpob() {}
321int set_pobox() {}
322int setup_spop() {}
323int set_pobox_modtime() {}
324int setup_dpob() {}
325int set_cluster_modtime_by_id() {}
326int access_service() {}
327int followup_glin() {}
328int qualified_get_server() {}
329int qualified_get_serverhost() {}
330int trigger_dcm() {}
331int set_nfsphys_modtime() {}
332int setup_alis() {}
333int access_member() {}
334int get_acl_use() {}
335int access_qgli() {}
336int qualified_get_lists() {}
This page took 0.09751 seconds and 5 git commands to generate.