3 * This generates the zone files necessary to load a hesiod server.
4 * The following zones are generated: passwd, uid, pobox, group,
5 * grplist, gid, filsys, cluster, pcap, sloc, service.
7 * (c) Copyright 1988 by the Massachusetts Institute of Technology.
8 * For copying and distribution information, please see the file
12 #include <mit-copyright.h>
25 #define min(x,y) ((x) < (y) ? (x) : (y))
26 struct hash *users = NULL;
27 char *whoami = "sync";
29 char *malloc(), *strsave();
41 fprintf(stderr, "usage: %s outfile\n", argv[0]);
45 dbase_fd = open(argv[1], O_RDWR|O_CREAT, 0660);
47 perror("opening file %s", argv[1]);
51 initialize_sms_error_table ();
54 ## set lockmode session where level = table
58 status = PR_AddToGroup(NULL, USERSMS, SYSADMINID);
60 prserror(status, "adding SMS to system:administrators", 0, 0);
72 * ingerr: (supposedly) called when Ingres indicates an error.
73 * I have not yet been able to get this to work to intercept a
74 * database open error.
76 #define INGRES_DEADLOCK 4700
78 static int ingerr(num)
86 ingres_errno = SMS_DEADLOCK;
89 ingres_errno = SMS_INGRES_ERR;
91 com_err(whoami, SMS_INGRES_ERR, " code %d\n", *num);
96 prserror(status, msg, arg1, arg2)
99 unsigned long arg1, arg2;
103 sprintf(buf, msg, arg1, arg2);
106 msg = "name already exists";
109 msg = "ID already exists";
112 msg = "no IDs available";
115 msg = "database failed";
118 msg = "no space left in database";
121 msg = "permission denied";
136 msg = "unknown code";
139 fprintf(stderr, "%s (%d): %s\n", msg, status, buf);
147 ## int uid, id, status;
149 fprintf(stderr, "Doing users\n");
150 users = create_hash(10000);
151 ## range of u is users
152 ## retrieve (login = u.#login, uid = u.#uid, id = u.users_id)
153 ## where u.#status = 1 {
155 hash_store(users, id, uid);
156 status = PR_INewEntry(NULL, login, uid, 0);
158 prserror(status, "adding user %s uid %d", login, uid);
169 ## char name[33], namebuf[128];
172 fprintf(stderr, "Doing groups\n");
174 /* make space for group list */
175 groups = create_hash(15000);
177 /* retrieve simple groups */
178 ## range of l is list
179 ## range of m is imembers
180 /* get lock records */
181 ## retrieve (name = l.modtime) where l.list_id = 0
182 ## retrieve (name = users.modtime) where users.users_id = 0
184 ## retrieve (name = l.#name, gid = l.#gid, lid = l.list_id)
185 ## where l.group != 0 and l.active != 0 {
187 sprintf(namebuf, "system:%s", name);
188 hash_store(groups, lid, -gid);
189 status = PR_INewEntry(NULL, namebuf, -gid, SYSADMINID);
191 prserror(status, "adding list %s gid %d", namebuf, -gid);
195 fprintf(stderr, "Doing members\n");
197 ## retrieve (lid = m.list_id, id = m.member_id)
198 ## where m.member_type = "USER" {
199 if ((u = (long) hash_lookup(users, id)) &&
200 (g = (long) hash_lookup(groups, lid))) {
201 status = PR_AddToGroup(NULL, u, g);
203 prserror(status, "adding %d to group %d", u, -g);