]> andersk Git - moira.git/blob - db/newmoira.qc
added libraries
[moira.git] / db / newmoira.qc
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
11 static int ingres_errno = 0;
12 int ingerr();
13
14 extern char *tables[];
15 extern struct query Queries1[], Queries2[];
16 extern int QueryCount1, QueryCount2;
17
18 char *values[] = { "users_id", "machine_id", "cluster_id", "list_id",
19                    "nfsphys_id", "filsys_id", "strings_id", 0 };
20
21 struct 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
68 main(argc, argv)
69 int argc;
70 char **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
255 int ingerr(num)
256     int *num;
257 {
258     ingres_errno = *num;
259     return *num;
260 }
261
262
263 /* dummy routines */
264 int access_list() {}
265 int access_visible_list() {}
266 int access_maillist() {}
267 int access_user() {}
268 int setup_ausr() {}
269 int setup_add_group() {}
270 int setup_add_filesys() {}
271 int setup_update_filesys() {}
272 int setup_umac() {}
273 int setup_dmac() {}
274 int setup_uclu() {}
275 int setup_dclu() {}
276 int setup_dusr() {}
277 int setup_dsin() {}
278 int setup_dshi() {}
279 int setup_dlis() {}
280 int validate_label() {}
281 int validate_label_2() {}
282 int uusr_login_check() {}
283 int delete_user_poboxes() {}
284 int delete_current_quota() {}
285 int set_modtime() {}
286 int set_modtime_by_id() {}
287 int set_user_modtime() {}
288 int set_user_modtime_by_id() {}
289 int set_finger_modtime() {}
290 int set_filesys_modtime() {}
291 int set_mach_modtime() {}
292 int set_mach_modtime_by_id() {}
293 int set_serverhost_modtime() {}
294 int followup_amtl() {}
295 int followup_ausr() {}
296 int followup_delete_list() {}
297 int followup_add_pobox() {}
298 int followup_delete_pobox() {}
299 int followup_usha() {}
300 int followup_old_gpob() {}
301 int followup_fix_acl() {}
302 int translate_ids() {}
303 int expand_list_flags() {}
304 int add_new_quota() {}
305 int add_hostaccess() {}
306 int delete_hostaccess() {}
307 int get_query_need() {}
308 int get_list_is_group() {}
309 int get_list_is_maillist() {}
310 int add_locker() {}
311 int delete_locker() {}
312 int add_user_group() {}
313 int set_user_pobox() {}
314 int get_members_of_list() {}
315 int get_groups_of_user() {}
316 int get_groups_of_all_users() {}
317 int get_all_poboxes() {}
318 int get_new_poboxes() {}
319 int get_lists_of_administrator() {}
320 int followup_gpob() {}
321 int set_pobox() {}
322 int setup_spop() {}
323 int set_pobox_modtime() {}
324 int setup_dpob() {}
325 int set_cluster_modtime_by_id() {}
326 int access_service() {}
327 int followup_glin() {}
328 int qualified_get_server() {}
329 int qualified_get_serverhost() {}
330 int trigger_dcm() {}
331 int set_nfsphys_modtime() {}
332 int setup_alis() {}
333 int access_member() {}
334 int get_acl_use() {}
335 int access_qgli() {}
336 int qualified_get_lists() {}
This page took 0.0750690000000001 seconds and 5 git commands to generate.