#include <mit-copyright.h>
#include <moira.h>
#include <moira_site.h>
+#include <moira_schema.h>
#include "update.h"
#include <sys/param.h>
{
int i;
EXEC SQL BEGIN DECLARE SECTION;
- char buf[16], *name;
+ char buf[SERVERS_NAME_SIZE], *name;
int enable;
EXEC SQL END DECLARE SECTION;
struct save_queue *sq;
time_t now;
const char *errmsg;
EXEC SQL END DECLARE SECTION;
- char dfgen_prog[64], dfgen_cmd[128];
+ char dfgen_prog[MAXPATHLEN], dfgen_cmd[2 * MAXPATHLEN];
struct sigaction action, prevaction;
int waits;
EXEC SQL CONNECT :db IDENTIFIED BY :db;
- EXEC SQL SELECT update_int, dfcheck INTO :interval, :dfcheck
+ EXEC SQL SELECT update_int, dfcheck INTO :interval, :dfcheck
FROM servers WHERE name = UPPER(:name);
if (sqlca.sqlcode == SQL_NO_MATCH)
{
void do_hosts(char *service)
{
EXEC SQL BEGIN DECLARE SECTION;
- char type[16], host[73], target[64], script[128];
+ char type[SERVERS_TYPE_SIZE], host[MACHINE_NAME_SIZE];
+ char target[SERVERS_TARGET_FILE_SIZE], script[SERVERS_SCRIPT_SIZE];
const char *errmsg;
int status = 0, dfgen, replicated;
time_t now;
#include <stdio.h>
#include <time.h>
+#include "util.h"
+
EXEC SQL INCLUDE sqlca;
RCSID("$Header$");
int main(int argc, char **argv)
{
FILE *out = stdout;
- char *outf = NULL, outft[64];
+ char *outf = NULL, outft[MAXPATHLEN];
struct stat sb;
int flag;
EXEC SQL BEGIN DECLARE SECTION;
- char login[9], last_name[17], first_name[17], middle_name[16];
- char office_address[17], office_phone[13];
- char home_address[82], home_phone[17];
- char id[17], type[9];
+ char login[USERS_LOGIN_SIZE], last_name[USERS_LAST_SIZE];
+ char first_name[USERS_FIRST_SIZE], middle_name[USERS_MIDDLE_SIZE];
+ char office_address[USERS_OFFICE_ADDR_SIZE];
+ char office_phone[USERS_OFFICE_PHONE_SIZE];
+ char home_address[USERS_HOME_ADDR_SIZE], home_phone[USERS_HOME_PHONE_SIZE];
+ char id[USERS_CLEARID_SIZE], type[USERS_TYPE_SIZE];
EXEC SQL END DECLARE SECTION;
EXEC SQL CONNECT :db;
*/
#define MAXHESSIZE 446
-char hesiod_dir[64];
+char hesiod_dir[MAXPATHLEN];
#define min(x, y) ((x) < (y) ? (x) : (y))
struct hash *machines = NULL;
char *lid;
};
struct user {
- char name[9];
+ char name[USERS_LOGIN_SIZE];
struct grp *lists;
};
{
EXEC SQL BEGIN DECLARE SECTION;
int id;
- char name[41];
+ char name[MACHINE_NAME_SIZE];
EXEC SQL END DECLARE SECTION;
if (machines)
int do_passwd(void)
{
FILE *pout, *uout, *bout;
- char poutf[64], uoutf[64], poutft[64], uoutft[64], boutf[64], boutft[64];
+ char poutf[MAXPATHLEN], uoutf[MAXPATHLEN], poutft[MAXPATHLEN];
+ char uoutft[MAXPATHLEN], boutf[MAXPATHLEN], boutft[MAXPATHLEN];
struct stat psb, usb, bsb;
time_t ftime;
struct user *u;
char *mach;
EXEC SQL BEGIN DECLARE SECTION;
- char login[9], shell[33], fullname[33], oa[17], op[13], hp[17];
- char nn[17], ptype[9];
+ char login[USERS_LOGIN_SIZE], shell[USERS_SHELL_SIZE];
+ char fullname[USERS_FULLNAME_SIZE], oa[USERS_OFFICE_ADDR_SIZE];
+ char op[USERS_OFFICE_PHONE_SIZE], hp[USERS_HOME_PHONE_SIZE];
+ char nn[USERS_NICKNAME_SIZE], ptype[USERS_POTYPE_SIZE];
int uid, flag1, flag2, id, pid, status;
EXEC SQL END DECLARE SECTION;
int do_groups(void)
{
FILE *iout, *gout, *lout;
- char ioutf[64], goutf[64], loutf[64], buf[2048], *l;
+ char ioutf[MAXPATHLEN], goutf[MAXPATHLEN], loutf[MAXPATHLEN];
+ char buf[MAXPATHLEN], *l;
struct hash *groups;
struct bucket *b, **p;
struct grp *g;
struct stat isb, gsb, lsb;
time_t ftime;
EXEC SQL BEGIN DECLARE SECTION;
- char name[33];
+ char name[LIST_NAME_SIZE];
int gid, id, lid, flag1, flag2, flag3, len;
EXEC SQL END DECLARE SECTION;
EXEC SQL OPEN l_cursor;
while (1)
{
+ char buf[LIST_NAME_SIZE + 10];
+
EXEC SQL FETCH l_cursor INTO :name, :gid, :lid;
if (sqlca.sqlcode)
break;
int do_filsys(void)
{
FILE *out;
- char outf[64], outft[64], *mach, *group;
+ char outf[MAXPATHLEN], outft[MAXPATHLEN], *mach, *group;
struct stat sb;
time_t ftime;
struct save_queue *sq, *sq2;
EXEC SQL BEGIN DECLARE SECTION;
- char name[33], type[9], loc[81], access[2], mount[33], trans[257];
- char comments[65];
+ char name[FILESYS_LABEL_SIZE], type[FILESYS_TYPE_SIZE];
+ char loc[FILESYS_NAME_SIZE], access[FILESYS_RWACCESS_SIZE];
+ char mount[FILESYS_MOUNT_SIZE], comments[FILESYS_COMMENTS_SIZE];
+ char key[FSGROUP_KEY_SIZE];
+ char aname[ALIAS_NAME_SIZE], trans[ALIAS_TRANS_SIZE];
int flag1, flag2, flag3, flag4, id, fid;
EXEC SQL END DECLARE SECTION;
}
else if (!strcmp(type, "FSGROUP"))
{
- sprintf(trans, "%s:%d", strtrim(name), fid);
- sq_save_data(sq, strdup(trans));
+ char buf[FILESYS_NAME_SIZE + 10];
+ sprintf(buf, "%s:%d", strtrim(name), fid);
+ sq_save_data(sq, strdup(buf));
}
else if (!strcmp(type, "MUL"))
{
- sprintf(trans, "%s:%d", strtrim(name), fid);
- sq_save_data(sq2, strdup(trans));
+ char buf[FILESYS_NAME_SIZE + 10];
+ sprintf(buf, "%s:%d", strtrim(name), fid);
+ sq_save_data(sq2, strdup(buf));
}
}
EXEC SQL CLOSE f_cursor;
for (flag1 = 1; ; flag1++)
{
EXEC SQL FETCH f_cursor2 INTO :type, :loc, :id, :access, :mount,
- :comments, :name, :trans;
+ :comments, :name, :key;
if (sqlca.sqlcode)
break;
strtrim(type);
EXEC SQL OPEN f_cursor3;
while (1)
{
- EXEC SQL FETCH f_cursor3 INTO :name, :trans;
+ EXEC SQL FETCH f_cursor3 INTO :name, :key;
if (sqlca.sqlcode)
break;
fprintf(out, " %s", strtrim(name));
EXEC SQL OPEN a_cursor;
while (1)
{
- EXEC SQL FETCH a_cursor INTO :name, :trans;
+ EXEC SQL FETCH a_cursor INTO :aname, :trans;
if (sqlca.sqlcode)
break;
fprintf(out, "%s.filsys\t%s CNAME %s.filsys\n",
- strtrim(name), HCLASS, strtrim(trans));
+ strtrim(aname), HCLASS, strtrim(trans));
}
EXEC SQL CLOSE a_cursor;
return 0;
}
- int nbitsset(set_mask *set)
+int nbitsset(set_mask *set)
{
int i, ret;
ret = 0;
int do_cluster(void)
{
FILE *out;
- char outf[64], outft[64], *mach, machbuf[64], clubuf[64], *p;
+ char outf[MAXPATHLEN], outft[MAXPATHLEN], *mach;
+ char machbuf[MACHINE_NAME_SIZE], clubuf[CLUSTERS_NAME_SIZE], *p;
struct stat sb;
time_t ftime;
EXEC SQL BEGIN DECLARE SECTION;
int flag1, flag2, flag3, flag4, maxmach, maxclu, mid, cid, id;
- char name[41], label2[17], data[33];
+ char name[CLUSTERS_NAME_SIZE];
+ char label[SVC_SERV_LABEL_SIZE], data[SVC_SERV_CLUSTER_SIZE];
EXEC SQL END DECLARE SECTION;
set_mask **machs, *ms, *ps;
EXEC SQL OPEN d_cursor;
while (1)
{
- EXEC SQL FETCH d_cursor INTO :label2, :data;
+ EXEC SQL FETCH d_cursor INTO :label, :data;
if (sqlca.sqlcode)
break;
- strtrim(label2);
+ strtrim(label);
strtrim(data);
fprintf(out, "%s.cluster\t%s %s \"%s %s\"\n",
- clubuf, HCLASS, HTYPE, label2, data);
+ clubuf, HCLASS, HTYPE, label, data);
}
EXEC SQL CLOSE d_cursor;
}
EXEC SQL OPEN d_cursor2;
while (1)
{
- EXEC SQL FETCH d_cursor2 INTO :name, :label2, :data;
+ EXEC SQL FETCH d_cursor2 INTO :name, :label, :data;
if (sqlca.sqlcode)
break;
strtrim(name);
- strtrim(label2);
+ strtrim(label);
strtrim(data);
fprintf(out, "%s.cluster\t%s %s \"%s %s\"\n",
- name, HCLASS, HTYPE, label2, data);
+ name, HCLASS, HTYPE, label, data);
}
free(machs);
EXEC SQL COMMIT;
int do_printcap(void)
{
FILE *out;
- char outf[64], outft[64];
+ char outf[MAXPATHLEN], outft[MAXPATHLEN];
struct stat sb;
time_t ftime;
EXEC SQL BEGIN DECLARE SECTION;
- char name[17], rp[17], sd[33];
+ char name[PRINTCAP_NAME_SIZE], rp[PRINTCAP_RP_SIZE], sd[PRINTCAP_DIR_SIZE];
int flag1, flag2, ka, pc, rm, rq;
EXEC SQL END DECLARE SECTION;
int do_palladium(void)
{
FILE *out;
- char outf[64], outft[64];
+ char outf[MAXPATHLEN], outft[MAXPATHLEN];
struct stat sb;
time_t ftime;
EXEC SQL BEGIN DECLARE SECTION;
- char name[33], trans[129];
+ char name[PALLADIUM_NAME_SIZE], trans[ALIAS_TRANS_SIZE];
+ char aname[ALIAS_NAME_SIZE];
int flag, flag1, identifier, rm;
EXEC SQL END DECLARE SECTION;
EXEC SQL OPEN a_cursor2;
while (1)
{
- EXEC SQL FETCH a_cursor2 INTO :name, :trans;
+ EXEC SQL FETCH a_cursor2 INTO :aname, :trans;
if (sqlca.sqlcode)
break;
- strtrim(name);
+ strtrim(aname);
strtrim(trans);
- fprintf(out, "%s.palladium\t%s %s \"%s\"\n", name, HCLASS, HTYPE, trans);
+ fprintf(out, "%s.palladium\t%s %s \"%s\"\n",
+ aname, HCLASS, HTYPE, trans);
}
EXEC SQL CLOSE a_cursor2;
int do_sloc(void)
{
FILE *out;
- char outf[64], outft[64], *mach;
+ char outf[MAXPATHLEN], outft[MAXPATHLEN], *mach;
struct stat sb;
time_t ftime;
EXEC SQL BEGIN DECLARE SECTION;
- char service[17];
+ char service[SERVERHOSTS_SERVICE_SIZE];
int flag1, flag2, id;
EXEC SQL END DECLARE SECTION;
int do_service(void)
{
FILE *out;
- char outf[64], outft[64];
+ char outf[MAXPATHLEN], outft[MAXPATHLEN];
struct stat sb;
time_t ftime;
EXEC SQL BEGIN DECLARE SECTION;
- char service[33], protocol[9], altserv[129];
+ char service[SERVICES_NAME_SIZE], protocol[SERVICES_PROTOCOL_SIZE];
+ char aname[ALIAS_NAME_SIZE], trans[ALIAS_TRANS_SIZE];
int port, flag1;
EXEC SQL END DECLARE SECTION;
EXEC SQL OPEN a_cursor3;
while (1)
{
- EXEC SQL FETCH a_cursor3 INTO :service, :altserv;
+ EXEC SQL FETCH a_cursor3 INTO :aname, :trans;
if (sqlca.sqlcode)
break;
- strtrim(service);
- strtrim(altserv);
- fprintf(out, "%s.service\t%s CNAME %s.service\n", service, HCLASS,
- altserv);
+ strtrim(aname);
+ strtrim(trans);
+ fprintf(out, "%s.service\t%s CNAME %s.service\n", aname, HCLASS,
+ trans);
}
EXEC SQL CLOSE a_cursor3;
int main(int argc, char **argv)
{
FILE *out = stdout;
- char *outf = NULL, outft[64], *p, buf[256];
+ char *outf = NULL, outft[MAXPATHLEN], *p;
+ char buf[MACHINE_NAME_SIZE + ALIAS_NAME_SIZE];
struct stat sb;
struct timeval now;
int flag1, flag2, i;
struct hash *aliases;
EXEC SQL BEGIN DECLARE SECTION;
int id;
- char name[65], vendor[33], model[33], os[33], addr[17];
+ char name[MACHINE_NAME_SIZE], vendor[MACHINE_VENDOR_SIZE];
+ char model[MACHINE_MODEL_SIZE], os[MACHINE_OS_SIZE];
+ char addr[MACHINE_ADDRESS_SIZE];
EXEC SQL END DECLARE SECTION;
EXEC SQL CONNECT :db;
struct hash *users, *machines, *strings, *lists, *names;
struct user {
char *login;
- char *first;
- char *last;
- char mi;
char *pobox;
};
struct member {
void get_info(void);
void save_mlist(int id, void *list, void *force);
void insert_login(int id, void *user, void *hint);
-void insert_names(int id, void *user, void *hint);
void insert_name(char *s, int id, int nodups, int copy);
int hashstr(char *s);
void sort_info(void);
int main(int argc, char **argv)
{
long tm = time(NULL);
- char filename[64], *targetfile;
+ char filename[MAXPATHLEN], *targetfile;
struct stat sb;
EXEC SQL BEGIN DECLARE SECTION;
int flag;
{
EXEC SQL BEGIN DECLARE SECTION;
int id, pid, bid, cnt, maillistp, acl, mid;
- char name[129], type[9], fname[17], mname[17], lname[17], buf[257];
+ char mname[MACHINE_NAME_SIZE], str[STRINGS_STRING_SIZE];
+ char login[USERS_LOGIN_SIZE], potype[USERS_POTYPE_SIZE];
+ char lname[LIST_NAME_SIZE], desc[LIST_DESCRIPTION_SIZE];
+ char type[LIST_ACL_TYPE_SIZE];
EXEC SQL END DECLARE SECTION;
char *s;
struct user *u;
EXEC SQL OPEN m_cursor;
while (1)
{
- EXEC SQL FETCH m_cursor INTO :id, :name;
+ EXEC SQL FETCH m_cursor INTO :id, :mname;
if (sqlca.sqlcode)
break;
- if ((s = strchr(name, '.')))
+ if ((s = strchr(mname, '.')))
*s = '\0';
else
- strtrim(name);
+ strtrim(mname);
#ifdef ATHENA
- strcat(name, ".LOCAL");
+ strcat(mname, ".LOCAL");
#endif
- if (hash_store(machines, id, strdup(name)) < 0)
+ if (hash_store(machines, id, strdup(mname)) < 0)
{
fprintf(stderr, "Out of memory!\n");
exit(MR_NO_MEM);
EXEC SQL OPEN s_cursor;
while (1)
{
- EXEC SQL FETCH s_cursor INTO :id, :name;
+ EXEC SQL FETCH s_cursor INTO :id, :str;
if (sqlca.sqlcode)
break;
- if (hash_store(strings, id, strdup(strtrim(name))) < 0)
+ if (hash_store(strings, id, strdup(strtrim(str))) < 0)
{
fprintf(stderr, "Out of memory!\n");
exit(MR_NO_MEM);
users = create_hash(13001);
EXEC SQL DECLARE u_cursor CURSOR FOR
- SELECT users_id, login, first, middle, last, potype, pop_id, box_id
+ SELECT users_id, login, potype, pop_id, box_id
FROM users
WHERE status != 3
ORDER BY users_id;
EXEC SQL OPEN u_cursor;
while (1)
{
- EXEC SQL FETCH u_cursor INTO :id, :name, :fname, :mname, :lname,
- :type, :pid, :bid;
+ EXEC SQL FETCH u_cursor INTO :id, :login, :potype, :pid, :bid;
if (sqlca.sqlcode)
break;
u = malloc(sizeof(struct user));
- u->login = strdup(strtrim(name));
- u->first = strdup(strtrim(fname));
- u->last = strdup(strtrim(lname));
- if (mname[0] != ' ')
- u->mi = mname[0];
- else
- u->mi = 0;
+ u->login = strdup(strtrim(login));
- if (type[0] == 'P' && (s = hash_lookup(machines, pid)))
+ if (potype[0] == 'P' && (s = hash_lookup(machines, pid)))
{
+ char *buf = malloc(strlen(u->login) + strlen(s) + 2);
sprintf(buf, "%s@%s", u->login, s);
- u->pobox = strdup(buf);
+ u->pobox = buf;
}
- else if (type[0] == 'S')
+ else if (potype[0] == 'S')
u->pobox = hash_lookup(strings, bid);
else
u->pobox = NULL;
EXEC SQL OPEN l_cursor;
while (1)
{
- EXEC SQL FETCH l_cursor INTO :id, :name, :maillistp, :buf, :type, :acl;
+ EXEC SQL FETCH l_cursor INTO :id, :lname, :maillistp, :desc, :type, :acl;
if (sqlca.sqlcode)
break;
l = malloc(sizeof(struct list));
- l->name = strdup(strtrim(name));
+ l->name = strdup(strtrim(lname));
l->maillist = maillistp;
- l->description = strdup(strtrim(buf));
+ l->description = strdup(strtrim(desc));
l->acl_t = type[0];
l->acl_id = acl;
l->m = NULL;
insert_name(u->login, id, TRUE, FALSE);
}
-void insert_names(int id, void *user, void *hint)
-{
- char buffer[256];
- struct user *u = user;
-
- insert_name(u->last, id, FALSE, FALSE);
- sprintf(buffer, "%s_%s", u->first, u->last);
- insert_name(buffer, id, FALSE, TRUE);
-#if 0
- sprintf(buffer, "%c_%s", u->first[0], u->last);
- insert_name(buffer, id, FALSE, TRUE);
-#endif
- if (u->mi)
- {
- sprintf(buffer, "%s_%c_%s", u->first, u->mi, u->last);
- insert_name(buffer, id, FALSE, TRUE);
- }
-}
-
int incount = 0;
void insert_name(char *s, int id, int nodups, int copy)
fprintf(out, "\n%s\n# Mailing lists\n%s\n", divide, divide);
hash_step(lists, save_mlist, FALSE);
fprintf(stderr, "Output %d lists\n", incount);
-#ifdef NAME_ALIASES
- hash_step(users, insert_names, NULL);
- fprintf(stderr, "Inserted %d names\n", incount);
-#endif
}
u = hash_lookup(users, ns->id);
if (u->pobox)
fprintf(out, "%s: %s\n", ns->name, u->pobox);
-#ifdef NAME_ALIASES
- else
- fprintf(out, "%s: =%s=@nobox\n", ns->name, ns->name);
-#endif
}
-#ifdef NAME_ALIASES
- else if (ns->id == 0)
- fprintf(out, "%s: =%s=@ambig\n", ns->name, ns->name);
-#endif
}
}
int main(int argc, char **argv)
{
FILE *out = stdout;
- char *outf = NULL, outft[64];
+ char *outf = NULL, outft[MAXPATHLEN];
struct stat sb;
int flag;
fprintf(stderr, "hosts...\n");
hosts(out);
- if(fclose(out) < 0)
+ if (fclose(out) < 0)
{
perror("close failed");
exit(MR_CCONFIG);
{
char *c;
EXEC SQL BEGIN DECLARE SECTION;
- char login[9], id[17];
+ char login[USERS_LOGIN_SIZE], id[USERS_CLEARID_SIZE];
+ char first[USERS_FIRST_SIZE], middle[USERS_MIDDLE_SIZE];
+ char last[USERS_LAST_SIZE], type[USERS_TYPE_SIZE];
+ int status, users_id;
EXEC SQL END DECLARE SECTION;
EXEC SQL WHENEVER SQLERROR GOTO sqlerr;
- EXEC SQL DECLARE users1 CURSOR FOR SELECT login, clearid
+ EXEC SQL DECLARE users1 CURSOR FOR
+ SELECT login, clearid, users_id, type, status, first, middle, last
FROM users WHERE clearid != '0' AND clearid != '999999999'
- AND login NOT LIKE '#%';
+ AND login NOT LIKE '#%';
EXEC SQL OPEN users1;
while (1)
{
- EXEC SQL FETCH users1 INTO :login, id;
+ EXEC SQL FETCH users1 INTO :login, :id, :users_id, :type, :status,
+ :first, :middle, :last;
if (sqlca.sqlcode)
break;
strtrim(login);
strtrim(id);
- c = login;
- while (*c)
- {
- if (!isdigit(*c++))
- break;
- }
- fprintf(out, "user,%s,%s\n", id, login);
+ strtrim(type);
+ strtrim(first);
+ strtrim(middle);
+ strtrim(last);
+ if (!*id)
+ continue;
+ fprintf(out, "user,%d,%s,%s,%s,%d,%s,%s,%s\n", users_id, id, login,
+ type, status, first, middle, last);
}
EXEC SQL CLOSE users1;
char *p;
int i;
EXEC SQL BEGIN DECLARE SECTION;
- char name[128], mitid[17], owner_type[9], addr[17], inuse[64];
+ char name[MACHINE_NAME_SIZE], owner_type[MACHINE_OWNER_TYPE_SIZE];
+ char addr[MACHINE_ADDRESS_SIZE];
int id, use, status, owner;
EXEC SQL END DECLARE SECTION;
continue;
if (!*strtrim(name))
continue;
- if ((i = strlen(name)) < 9 || strcmp(&name[i-8], ".MIT.EDU"))
+ if ((i = strlen(name)) < 9 || strcmp(&name[i - 8], ".MIT.EDU"))
{
fprintf(stderr, "Name %s not in MIT domain\n", name);
continue;
EXEC SQL COMMIT;
- fprintf(stderr, "users (again)...\n");
-
- EXEC SQL DECLARE hosts2 CURSOR FOR SELECT
- users_id, clearid FROM users
- WHERE clearid != '0' and clearid !='999999999';
- EXEC SQL OPEN hosts2;
- users = create_hash(20001);
-
- while (1)
- {
- EXEC SQL FETCH hosts2 INTO :id, :mitid;
- if (sqlca.sqlcode)
- break;
- if (id == 0)
- continue;
- if (!*strtrim(mitid))
- continue;
-
- hash_store(users, id, strdup(mitid));
- }
-
- EXEC SQL CLOSE hosts2;
-
- EXEC SQL COMMIT;
-
fprintf(stderr, "hosts (for real)...\n");
EXEC SQL DECLARE hosts3 CURSOR FOR SELECT
- name, mach_id, address, use, inuse, status, owner_type, owner_id
+ name, mach_id, address, use, status, owner_type, owner_id
FROM machine;
EXEC SQL OPEN hosts3;
while (1)
{
- EXEC SQL FETCH hosts3 INTO :name, :id, :addr, :use, :inuse, :status,
+ EXEC SQL FETCH hosts3 INTO :name, :id, :addr, :use, :status,
:owner_type, :owner;
if (sqlca.sqlcode)
break;
continue;
if (!*strtrim(name))
continue;
- if ((i = strlen(name)) < 9 || strcmp(&name[i-8], ".MIT.EDU"))
+ if ((i = strlen(name)) < 9 || strcmp(&name[i - 8], ".MIT.EDU"))
continue;
strtrim(addr);
strtrim(owner_type);
- strtrim(inuse);
- fprintf(out, "host,%d,%s,%s,%d,0,%d", id,name,addr,use,status);
+ fprintf(out, "host,%d,%s,%s,%d,0,%d", id, name, addr, use, status);
if (!strcmp(owner_type, "USER"))
- {
- if (p = hash_lookup(users, owner))
- fprintf(out, ",USER,%s\n", p);
- }
+ fprintf(out, ",USER,%d\n", owner);
else
fprintf(out, ",NONE,0\n");
}
int main(int argc, char **argv)
{
FILE *out = stdout;
- char *outf = NULL, outft[64];
+ char *outf = NULL, outft[MAXPATHLEN];
struct stat sb;
struct timeval now;
struct in_addr addr;
int flag1;
EXEC SQL BEGIN DECLARE SECTION;
int id, saddr;
- char name[65], description[65];
+ char name[SUBNET_NAME_SIZE], description[SUBNET_DESCRIPTION_SIZE];
EXEC SQL END DECLARE SECTION;
EXEC SQL CONNECT :db;
char *whoami = "nfs.gen";
char *db = "moira/moira";
-char nfs_dir[64];
+char nfs_dir[MAXPATHLEN];
struct hash *users, *groups;
int do_nfs(void);
int do_nfs(void)
{
EXEC SQL BEGIN DECLARE SECTION;
- char machname[41], listname[33];
+ char machname[MACHINE_NAME_SIZE], listname[SERVERHOSTS_VALUE3_SIZE];
EXEC SQL END DECLARE SECTION;
struct save_queue *machs, *lists;
int changed;
int do_lists(struct save_queue *lists)
{
- char file[64], *u;
+ char file[MAXPATHLEN], *u;
FILE *fd;
EXEC SQL BEGIN DECLARE SECTION;
char *listname;
struct grp *next;
char *lid;
};
+
struct user {
- char name[9];
+ char name[USERS_LOGIN_SIZE];
int uid;
struct grp *lists;
};
void do_everyone(void)
{
- char buf[BUFSIZ], *l;
+ char buf[MAXPATHLEN], *l;
struct user *u;
struct grp *g;
struct bucket *b, **p;
EXEC SQL BEGIN DECLARE SECTION;
- char name[33];
+ char name[USERS_LOGIN_SIZE];
int gid, id, lid, uid;
EXEC SQL END DECLARE SECTION;
FILE *fd;
int do_machs(struct save_queue *machs)
{
EXEC SQL BEGIN DECLARE SECTION;
- char *machname, listname[33], dev[33], dir[81], fstype[9];
+ char *machname, listname[SERVERHOSTS_VALUE3_SIZE];
+ char dev[NFSPHYS_DEVICE_SIZE], dir[FILESYS_NAME_SIZE];
+ char fstype[FILESYS_LOCKERTYPE_SIZE];
int uid, quota, id, gid, flag1, flag2, flag3;
EXEC SQL END DECLARE SECTION;
- char file[64], f1[64], f2[64], *cp;
+ char file[MAXPATHLEN], f1[MAXPATHLEN], f2[MAXPATHLEN], *cp;
int prevuid, quotasum, olddev, oldmach;
FILE *fd;
struct hash *machines;
db_error(sqlca.sqlcode);
exit(MR_DBMS_ERR);
}
+
int main(int argc, char **argv)
{
FILE *out = stdout;
- char *outf = NULL, outft[64];
+ char *outf = NULL, outft[MAXPATHLEN];
struct stat sb;
int flag, i;
EXEC SQL BEGIN DECLARE SECTION;
- char login[9], id[18], string[257];
+ char login[USERS_LOGIN_SIZE], id[USERS_CLEARID_SIZE];
+ char string[STRINGS_STRING_SIZE];
EXEC SQL END DECLARE SECTION;
EXEC SQL CONNECT :db;
+#include <moira_schema.h>
+
+/* for MAXPATHLEN */
+#include <sys/param.h>
+
void fix_file(char *targetfile);
char *dequote(char *s);
void db_error(int code);
#define WAREHOUSE_SUBDIR "warehouse"
#endif
-char warehouse_dir[128];
+char warehouse_dir[MAXPATHLEN];
int main(int argc, char **argv)
{
int out = STDOUT_FILENO;
- char *outf = NULL, outft[64];
- char control_fn[80], cmd[256];
+ char *outf = NULL, outft[MAXPATHLEN];
+ char control_fn[MAXPATHLEN], cmd[256];
FILE *f;
struct stat sb;
int flag1;
SigInfo si;
int records = 0;
EXEC SQL BEGIN DECLARE SECTION;
- char login[9], sig[257], id[17], kname[257];
- char fname[17], lname[17], middle[17];
- EXEC SQL VAR sig IS STRING(257);
+ char login[USERS_LOGIN_SIZE], sig[USERS_SIGNATURE_SIZE];
+ char id[USERS_CLEARID_SIZE], kname[MAX_K_NAME_SZ];
+ char fname[USERS_FIRST_SIZE], lname[USERS_LAST_SIZE];
+ char middle[USERS_MIDDLE_SIZE];
+ EXEC SQL VAR sig IS STRING(USERS_SIGNATURE_SIZE);
int timestamp, sigwho;
struct {
char login[12];
SRCS = afs.c ksrvtgt.c
CODE = $(SRCS)
-CFLAGS = -I../include -I../lib -I$(AFSDIR)/include -I/usr/athena/include $(DBG)
+CFLAGS = -I../include -I../lib -I../db -I$(AFSDIR)/include -I/usr/athena/include $(DBG)
LIBS = -L../lib -L/usr/athena/lib -lmoira -lzephyr -lcom_err -lhesiod -lkrb -ldes
SRCDIR = $(SRCTOP)/incremental
* <mit-copyright.h>.
*/
+#include <moira.h>
+#include <moira_site.h>
+#include <moira_schema.h>
+
#include <stdio.h>
#include <stdlib.h>
#include <sys/resource.h>
#include <com_err.h>
#include <krb.h>
-#include <moira.h>
-#include <moira_site.h>
#include <afs/param.h>
#include <afs/cellconfig.h>
static char tbl_buf[1024];
static struct member {
int op;
- char list[33];
- char type[9];
- char member[129];
+ char list[LIST_NAME_SIZE];
+ char type[IMEMBERS_MEMBER_TYPE_SIZE];
+ char member[MAX_FIELD_WIDTH];
struct member *next;
} *member_head = NULL;
from Moira but not AFS */
if (code == PRIDEXIST)
{
- char ename[255];
+ char ename[PR_MAXNAMELEN];
if (pr_try(pr_SIdToName, auid, ename) == 0 &&
!strcmp(after[U_NAME], ename))
code = pr_try(pr_CreateGroup, g1, g2, &id);
if (code == PRIDEXIST)
{
- char ename[255];
+ char ename[PR_MAXNAMELEN];
if (pr_try(pr_SIdToName, -agid, ename) == 0 && !strcmp(g1, ename))
return;
#include <mit-copyright.h>
#include <moira.h>
#include <moira_site.h>
+#include <moira_schema.h>
#include <ctype.h>
#include <stdio.h>
FILE *in;
struct entry *e;
int i, wait = 0;
- char buf[BUFSIZ], *file = NULL;
+ char buf[80], *file = NULL;
EXEC SQL BEGIN DECLARE SECTION;
char *db = "moira";
EXEC SQL END DECLARE SECTION;
{
printf("Next");
fflush(stdout);
- gets(buf);
+ fgets(buf, sizeof(buf), stdin);
}
}
void process_entry(struct entry *e)
{
int changed, nochange, encrypted;
- char buf[BUFSIZ], *from, *to;
+ char buf[MAX_FIELD_WIDTH], *from, *to;
EXEC SQL BEGIN DECLARE SECTION;
char *first, *last, *middle, *eid, *sid, *name, *rdept;
char *rtitle, *raddr, *rhphone, *rophone, *prog;
- char class[9], oaddr[25], ophone[17], dept[128];
- char dfirst[17], dlast[17], dmiddle[17];
+ char class[USERS_TYPE_SIZE], oaddr[USERS_OFFICE_ADDR_SIZE];
+ char ophone[USERS_OFFICE_PHONE_SIZE], dept[USERS_DEPARTMENT_SIZE];
+ char dfirst[USERS_FIRST_SIZE], dlast[USERS_LAST_SIZE];
+ char dmiddle[USERS_MIDDLE_SIZE];
int id, status, who;
EXEC SQL END DECLARE SECTION;
who = WHO;
prog = PROG;
first = e->first;
- if (strlen(first) > 16)
- first[16] = '\0';
+ if (strlen(first) > USERS_FIRST_SIZE - 1)
+ first[USERS_FIRST_SIZE - 1] = '\0';
last = e->last;
- if (strlen(last) > 16)
- last[16] = '\0';
+ if (strlen(last) > USERS_LAST_SIZE - 1)
+ last[USERS_LAST_SIZE - 1] = '\0';
middle = e->middle;
+ if (strlen(middle) > USERS_MIDDLE_SIZE - 1)
+ middle[USERS_MIDDLE_SIZE - 1] = '\0';
eid = e->eid;
sid = e->id;
id = 0;
{
if (oaddr[0] == ' ' && buf[0])
{
- strncpy(oaddr, buf, 16);
- oaddr[16] = '\0';
+ strncpy(oaddr, buf, USERS_OFFICE_ADDR_SIZE - 1);
+ oaddr[USERS_OFFICE_ADDR_SIZE - 1] = '\0';
changed++;
}
- else if (strncmp(strtrim(oaddr), buf, 15))
+ else if (strncmp(strtrim(oaddr), buf, USERS_OFFICE_ADDR_SIZE - 1))
nochange++;
}
else
{
- if (strncmp(strtrim(oaddr), buf, 15))
+ if (strncmp(strtrim(oaddr), buf, USERS_OFFICE_ADDR_SIZE - 1))
changed++;
- strncpy(oaddr, buf, 16);
- oaddr[16] = '\0';
+ strncpy(oaddr, buf, USERS_OFFICE_ADDR_SIZE - 1);
+ oaddr[USERS_OFFICE_ADDR_SIZE - 1] = '\0';
}
from = e->phone;
to = buf;
{
if (ophone[0] == ' ')
{
- strncpy(ophone, buf, 16);
- ophone[16] = '\0';
+ strncpy(ophone, buf, USERS_OFFICE_PHONE_SIZE - 1);
+ ophone[USERS_OFFICE_PHONE_SIZE - 1] = '\0';
}
- else if (strncmp(strtrim(ophone), buf, 11))
+ else if (strncmp(strtrim(ophone), buf, USERS_OFFICE_PHONE_SIZE - 1))
nochange++;
}
else
{
- if (strncmp(strtrim(ophone), buf, 11))
+ if (strncmp(strtrim(ophone), buf, USERS_OFFICE_PHONE_SIZE - 1))
changed++;
- strncpy(ophone, buf, 16);
- ophone[16] = '\0';
+ strncpy(ophone, buf, USERS_OFFICE_PHONE_SIZE - 1);
+ ophone[USERS_OFFICE_PHONE_SIZE - 1] = '\0';
}
FixCase(e->dept);
FixCase(e->title);
{
if (dept[0] == ' ')
{
- strncpy(dept, e->dept, 12);
- dept[12] = '\0';
+ strncpy(dept, e->dept, USERS_DEPARTMENT_SIZE - 1);
+ dept[USERS_DEPARTMENT_SIZE - 1] = '\0';
}
- else if (strncmp(strtrim(dept), e->dept, 11))
+ else if (strncmp(strtrim(dept), e->dept, USERS_DEPARTMENT_SIZE - 1))
nochange++;
}
else
{
- if (strncmp(strtrim(dept), e->dept, 11))
+ if (strncmp(strtrim(dept), e->dept, USERS_DEPARTMENT_SIZE - 1))
changed++;
- strncpy(dept, e->dept, 12);
- dept[12] = '\0';
+ strncpy(dept, e->dept, USERS_DEPARTMENT_SIZE - 1);
+ dept[USERS_DEPARTMENT_SIZE - 1] = '\0';
}
sid = e->id;
name = e->name;
char *from, *to;
EXEC SQL BEGIN DECLARE SECTION;
int id, uid, st, who;
- char *last, *first, *class, *middle, login[9], *sid, fullname[65], *prog;
- char oaddr[81], ophone[17], dept[128], *name, *title;
+ char *last, *first, *class, *middle, login[USERS_LOGIN_SIZE], *sid;
+ char fullname[USERS_FULLNAME_SIZE], *prog;
+ char oaddr[USERS_OFFICE_ADDR_SIZE], ophone[USERS_OFFICE_PHONE_SIZE];
+ char dept[USERS_DEPARTMENT_SIZE], *name, *title;
char *rdept, *rhphone, *rophone;
EXEC SQL END DECLARE SECTION;
who = WHO;
prog = PROG;
- strncpy(oaddr, e->address, 16);
- oaddr[16] = '\0';
+ strncpy(oaddr, e->address, USERS_OFFICE_ADDR_SIZE - 1);
+ oaddr[USERS_OFFICE_ADDR_SIZE - 1] = '\0';
while ((to = strchr(oaddr, ',')))
*to = ';';
while ((to = strchr(oaddr, ':')))
}
*to = '\0';
FixCase(e->dept);
- strncpy(dept, e->dept, 12);
- dept[12] = '\0';
+ strncpy(dept, e->dept, USERS_DEPARTMENT_SIZE - 1);
+ dept[USERS_DEPARTMENT_SIZE] = '\0';
id = set_next_users_id(0);
uid = set_next_uid(e->highid);
#include <mit-copyright.h>
#include <moira.h>
#include <moira_site.h>
+#include <moira_schema.h>
#include <ctype.h>
#include <stdio.h>
SigInfo si;
int found, status, i, wait;
EXEC SQL BEGIN DECLARE SECTION;
- char login[10], mid[32], rawsig[256], *db = "moira";
+ char login[USERS_LOGIN_SIZE], mid[USERS_CLEARID_SIZE];
+ char rawsig[512], *db = "moira";
int id, timestamp, sms;
EXEC SQL END DECLARE SECTION;
#include <mit-copyright.h>
#include <moira.h>
#include <moira_site.h>
+#include <moira_schema.h>
#include <ctype.h>
#include <stdio.h>
FILE *in;
struct entry *e;
int i, wait = 0;
- char buf[BUFSIZ], *file = NULL;
+ char buf[80], *file = NULL;
EXEC SQL BEGIN DECLARE SECTION;
char *db = "moira";
EXEC SQL END DECLARE SECTION;
{
printf("Next");
fflush(stdout);
- gets(buf);
+ fgets(buf, sizeof(buf), stdin);
}
}
void process_entry(struct entry *e)
{
int changed, nochange, encrypted;
- char buf[BUFSIZ], *from, *to;
+ char buf[MAX_FIELD_WIDTH], *from, *to;
EXEC SQL BEGIN DECLARE SECTION;
char *first, *last, *middle, *eid, *sid, *name, *rdept;
char *rtitle, *rophone, *rhphone, *prog;
- char class[9], haddr[128], hphone[33], ophone[33], dept[33], raddr[128];
- char dfirst[17], dlast[17], dmiddle[17];
+ char class[USERS_TYPE_SIZE], haddr[USERS_HOME_ADDR_SIZE];
+ char hphone[USERS_HOME_PHONE_SIZE], ophone[USERS_OFFICE_PHONE_SIZE];
+ char dept[USERS_DEPARTMENT_SIZE], raddr[USERS_XADDRESS_SIZE];
+ char dfirst[USERS_FIRST_SIZE], dlast[USERS_LAST_SIZE];
+ char dmiddle[USERS_MIDDLE_SIZE];
int id, status, who;
EXEC SQL END DECLARE SECTION;
who = WHO;
prog = PROG;
first = e->first;
- if (strlen(first) > 16)
- first[16] = '\0';
+ if (strlen(first) > USERS_FIRST_SIZE - 1)
+ first[USERS_FIRST_SIZE - 1] = '\0';
last = e->last;
- if (strlen(last) > 16)
- last[16] = '\0';
+ if (strlen(last) > USERS_LAST_SIZE - 1)
+ last[USERS_LAST_SIZE - 1] = '\0';
middle = e->middle;
+ if (strlen(middle) > USERS_MIDDLE_SIZE - 1)
+ middle[USERS_MIDDLE_SIZE - 1] = '\0';
eid = e->eid;
sid = e->id;
id = 0;
{
if (haddr[0] == ' ')
{
- strncpy(haddr, buf, 80);
- haddr[80] = '\0';
+ strncpy(haddr, buf, USERS_HOME_ADDR_SIZE - 1);
+ haddr[USERS_HOME_ADDR_SIZE - 1] = '\0';
changed++;
}
- else if (strncmp(strtrim(haddr), buf, 80))
+ else if (strncmp(strtrim(haddr), buf, USERS_HOME_ADDR_SIZE - 1))
nochange++;
}
else
{
- if (strncmp(strtrim(haddr), buf, 80))
+ if (strncmp(strtrim(haddr), buf, USERS_HOME_ADDR_SIZE - 1))
changed++;
- strncpy(haddr, buf, 80);
- haddr[80] = '\0';
+ strncpy(haddr, buf, USERS_HOME_ADDR_SIZE - 1);
+ haddr[USERS_HOME_ADDR_SIZE - 1] = '\0';
}
from = e->dphone;
to = buf;
{
if (hphone[0] == ' ')
{
- strncpy(hphone, buf, 16);
- hphone[16] = '\0';
+ strncpy(hphone, buf, USERS_HOME_PHONE_SIZE - 1);
+ hphone[USERS_HOME_PHONE_SIZE - 1] = '\0';
}
- else if (strncmp(strtrim(hphone), buf, 16))
+ else if (strncmp(strtrim(hphone), buf, USERS_HOME_PHONE_SIZE - 1))
nochange++;
}
else
{
- if (strncmp(strtrim(hphone), buf, 16))
+ if (strncmp(strtrim(hphone), buf, USERS_HOME_PHONE_SIZE - 1))
changed++;
- strncpy(hphone, buf, 16);
- hphone[16] = '\0';
+ strncpy(hphone, buf, USERS_HOME_PHONE_SIZE - 1);
+ hphone[USERS_HOME_PHONE_SIZE - 1] = '\0';
}
from = e->mphone;
to = buf;
{
if (ophone[0] == ' ')
{
- strncpy(ophone, buf, 12);
- ophone[12] = '\0';
+ strncpy(ophone, buf, USERS_OFFICE_PHONE_SIZE - 1);
+ ophone[USERS_OFFICE_PHONE_SIZE - 1] = '\0';
}
- else if (strncmp(strtrim(ophone), buf, 12))
+ else if (strncmp(strtrim(ophone), buf, USERS_OFFICE_PHONE_SIZE - 1))
nochange++;
}
else
{
- if (strncmp(strtrim(ophone), buf, 12))
+ if (strncmp(strtrim(ophone), buf, USERS_OFFICE_PHONE_SIZE - 1))
changed++;
- strncpy(ophone, buf, 12);
- ophone[12] = '\0';
+ strncpy(ophone, buf, USERS_OFFICE_PHONE_SIZE - 1);
+ ophone[USERS_OFFICE_PHONE_SIZE - 1] = '\0';
}
e->course = e->course;
if (newfinger)
{
if (dept[0] == ' ')
{
- strncpy(dept, e->course, 12);
- dept[12] = '\0';
+ strncpy(dept, e->course, USERS_DEPARTMENT_SIZE - 1);
+ dept[USERS_DEPARTMENT_SIZE - 1] = '\0';
}
- else if (strncmp(strtrim(dept), e->course, 11))
+ else if (strncmp(strtrim(dept), e->course, USERS_DEPARTMENT_SIZE - 1))
nochange++;
}
else
{
- if (strncmp(strtrim(dept), e->course, 11))
+ if (strncmp(strtrim(dept), e->course, USERS_DEPARTMENT_SIZE - 1))
changed++;
- strncpy(dept, e->course, 12);
- dept[12] = '\0';
+ strncpy(dept, e->course, USERS_DEPARTMENT_SIZE - 1);
+ dept[USERS_DEPARTMENT_SIZE - 1] = '\0';
}
sid = e->id;
name = e->name;
char buf[512], *from, *to;
EXEC SQL BEGIN DECLARE SECTION;
int id, uid, who;
- char *last, *first, *class, *middle, login[9], *sid, fullname[65], *prog;
- char haddr[81], hphone[17], ophone[13], dept[24], *title, raddr[81], *name;
+ char *last, *first, *class, *middle, login[USERS_LOGIN_SIZE], *sid;
+ char fullname[USERS_FULLNAME_SIZE], *prog;
+ char haddr[USERS_HOME_ADDR_SIZE], hphone[USERS_HOME_PHONE_SIZE];
+ char ophone[USERS_OFFICE_PHONE_SIZE], dept[USERS_DEPARTMENT_SIZE];
+ char *title, raddr[USERS_XADDRESS_SIZE], *name;
EXEC SQL END DECLARE SECTION;
who = WHO;
strcat(buf, " ");
strcat(buf, e->state);
}
- strncpy(haddr, buf, 80);
+ strncpy(haddr, buf, USERS_HOME_ADDR_SIZE - 1);
+ haddr[USERS_HOME_ADDR_SIZE - 1] = '\0';
from = e->dphone;
to = buf;
while (*from)
from++;
}
*to = '\0';
- strncpy(hphone, buf, 16);
+ strncpy(hphone, buf, USERS_HOME_PHONE_SIZE - 1);
+ hphone[USERS_HOME_PHONE_SIZE - 1] = '\0';
from = e->mphone;
to = buf;
while (*from)
from++;
}
*to = '\0';
- strncpy(ophone, buf, 12);
- strncpy(dept, e->course, 12);
+ strncpy(ophone, buf, USERS_OFFICE_PHONE_SIZE - 1);
+ ophone[USERS_OFFICE_PHONE_SIZE - 1] = '\0';
+ strncpy(dept, e->course, USERS_DEPARTMENT_SIZE - 1);
+ dept[USERS_DEPARTMENT_SIZE - 1] = '\0';
id = set_next_users_id(0);
uid = set_next_uid(1);