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