From: danw Date: Mon, 23 Feb 1998 19:23:34 +0000 (+0000) Subject: Use moira_schema.h X-Git-Url: http://andersk.mit.edu/gitweb/moira.git/commitdiff_plain/dfaf9b689acdde6a56d3874ee14cd53d192bb4ae Use moira_schema.h --- diff --git a/dcm/dcm.pc b/dcm/dcm.pc index d4c0bf57..150fe174 100644 --- a/dcm/dcm.pc +++ b/dcm/dcm.pc @@ -10,6 +10,7 @@ #include #include #include +#include #include "update.h" #include @@ -45,7 +46,7 @@ int main(int argc, char **argv) { 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; @@ -143,13 +144,13 @@ int generate_service(char *name, int force) 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) { @@ -231,7 +232,8 @@ int generate_service(char *name, int force) 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; diff --git a/gen/directory.pc b/gen/directory.pc index b34623c0..d79804db 100644 --- a/gen/directory.pc +++ b/gen/directory.pc @@ -16,6 +16,8 @@ #include #include +#include "util.h" + EXEC SQL INCLUDE sqlca; RCSID("$Header$"); @@ -26,14 +28,16 @@ char *db = "moira/moira"; 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; diff --git a/gen/hesiod.pc b/gen/hesiod.pc index d014ad99..ff5f1d65 100644 --- a/gen/hesiod.pc +++ b/gen/hesiod.pc @@ -41,7 +41,7 @@ RCSID("$Header$"); */ #define MAXHESSIZE 446 -char hesiod_dir[64]; +char hesiod_dir[MAXPATHLEN]; #define min(x, y) ((x) < (y) ? (x) : (y)) struct hash *machines = NULL; @@ -54,7 +54,7 @@ struct grp { char *lid; }; struct user { - char name[9]; + char name[USERS_LOGIN_SIZE]; struct grp *lists; }; @@ -138,7 +138,7 @@ void get_mach(void) { EXEC SQL BEGIN DECLARE SECTION; int id; - char name[41]; + char name[MACHINE_NAME_SIZE]; EXEC SQL END DECLARE SECTION; if (machines) @@ -168,14 +168,17 @@ void get_mach(void) 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; @@ -281,7 +284,8 @@ int do_passwd(void) 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; @@ -289,7 +293,7 @@ int do_groups(void) 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; @@ -354,6 +358,8 @@ int do_groups(void) 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; @@ -462,13 +468,16 @@ sqlerr: 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; @@ -541,13 +550,15 @@ int do_filsys(void) } 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; @@ -567,7 +578,7 @@ int do_filsys(void) 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); @@ -610,7 +621,7 @@ int do_filsys(void) 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)); @@ -628,11 +639,11 @@ int do_filsys(void) 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; @@ -650,7 +661,7 @@ sqlerr: return 0; } - int nbitsset(set_mask *set) +int nbitsset(set_mask *set) { int i, ret; ret = 0; @@ -666,12 +677,14 @@ sqlerr: 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; @@ -750,13 +763,13 @@ int do_cluster(void) 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; } @@ -818,14 +831,14 @@ int do_cluster(void) 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; @@ -846,11 +859,11 @@ sqlerr: 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; @@ -922,11 +935,12 @@ sqlerr: 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; @@ -981,12 +995,13 @@ int do_palladium(void) 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; @@ -1008,11 +1023,11 @@ sqlerr: 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; @@ -1076,11 +1091,12 @@ sqlerr: 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; @@ -1132,13 +1148,13 @@ int do_service(void) 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; diff --git a/gen/hosts.pc b/gen/hosts.pc index c8dd7792..6b24dff5 100644 --- a/gen/hosts.pc +++ b/gen/hosts.pc @@ -32,14 +32,17 @@ char *db = "moira/moira"; 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; diff --git a/gen/mailhub.pc b/gen/mailhub.pc index 615f5a4d..96170459 100644 --- a/gen/mailhub.pc +++ b/gen/mailhub.pc @@ -39,9 +39,6 @@ FILE *out = stdout; struct hash *users, *machines, *strings, *lists, *names; struct user { char *login; - char *first; - char *last; - char mi; char *pobox; }; struct member { @@ -67,7 +64,6 @@ struct names { 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); @@ -80,7 +76,7 @@ void do_people(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; @@ -146,7 +142,10 @@ void get_info(void) { 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; @@ -170,17 +169,17 @@ void get_info(void) 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); @@ -201,10 +200,10 @@ void get_info(void) 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); @@ -219,32 +218,26 @@ void get_info(void) 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; @@ -269,13 +262,13 @@ void get_info(void) 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; @@ -375,25 +368,6 @@ void insert_login(int id, void *user, void *hint) 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) @@ -513,10 +487,6 @@ void sort_info(void) 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 } @@ -538,15 +508,7 @@ void output_data(int dummy, void *names, void *out) 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 } } diff --git a/gen/ndb.pc b/gen/ndb.pc index 7b592dab..f374b69d 100644 --- a/gen/ndb.pc +++ b/gen/ndb.pc @@ -30,7 +30,7 @@ void hosts(FILE *out); int main(int argc, char **argv) { FILE *out = stdout; - char *outf = NULL, outft[64]; + char *outf = NULL, outft[MAXPATHLEN]; struct stat sb; int flag; @@ -61,7 +61,7 @@ int main(int argc, char **argv) fprintf(stderr, "hosts...\n"); hosts(out); - if(fclose(out) < 0) + if (fclose(out) < 0) { perror("close failed"); exit(MR_CCONFIG); @@ -76,30 +76,36 @@ void users(FILE *out) { 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; @@ -119,7 +125,8 @@ void hosts(FILE *out) 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; @@ -140,7 +147,7 @@ void hosts(FILE *out) 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; @@ -152,40 +159,15 @@ void hosts(FILE *out) 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; @@ -193,17 +175,13 @@ void hosts(FILE *out) 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"); } diff --git a/gen/network.pc b/gen/network.pc index 1c347b2c..4fc586aa 100644 --- a/gen/network.pc +++ b/gen/network.pc @@ -30,14 +30,14 @@ char *db = "moira/moira"; 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; diff --git a/gen/nfs.pc b/gen/nfs.pc index 447bbf39..2eaed208 100644 --- a/gen/nfs.pc +++ b/gen/nfs.pc @@ -29,7 +29,7 @@ RCSID("$Header$"); char *whoami = "nfs.gen"; char *db = "moira/moira"; -char nfs_dir[64]; +char nfs_dir[MAXPATHLEN]; struct hash *users, *groups; int do_nfs(void); @@ -82,7 +82,7 @@ int main(int argc, char **argv) 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; @@ -127,7 +127,7 @@ sqlerr: int do_lists(struct save_queue *lists) { - char file[64], *u; + char file[MAXPATHLEN], *u; FILE *fd; EXEC SQL BEGIN DECLARE SECTION; char *listname; @@ -208,8 +208,9 @@ struct grp { struct grp *next; char *lid; }; + struct user { - char name[9]; + char name[USERS_LOGIN_SIZE]; int uid; struct grp *lists; }; @@ -217,12 +218,12 @@ struct user { 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; @@ -327,10 +328,12 @@ sqlerr: 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; @@ -531,3 +534,4 @@ sqlerr: db_error(sqlca.sqlcode); exit(MR_DBMS_ERR); } + diff --git a/gen/pobox.pc b/gen/pobox.pc index 6e066f6a..a36ba6b7 100644 --- a/gen/pobox.pc +++ b/gen/pobox.pc @@ -29,11 +29,12 @@ char *db = "moira/moira"; 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; diff --git a/gen/util.h b/gen/util.h index 3b4c3bc7..aedbc468 100644 --- a/gen/util.h +++ b/gen/util.h @@ -1,3 +1,8 @@ +#include + +/* for MAXPATHLEN */ +#include + void fix_file(char *targetfile); char *dequote(char *s); void db_error(int code); diff --git a/gen/warehouse.pc b/gen/warehouse.pc index 3e18bdb0..ddfd975d 100644 --- a/gen/warehouse.pc +++ b/gen/warehouse.pc @@ -38,22 +38,24 @@ char *db = "moira/moira"; #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]; diff --git a/incremental/Imakefile b/incremental/Imakefile index e0d53b5b..525ccf81 100644 --- a/incremental/Imakefile +++ b/incremental/Imakefile @@ -9,7 +9,7 @@ AFSLIBS=$(AFSDIR)/lib/afs/libprot.a $(AFSDIR)/lib/afs/libauth.a \ 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 diff --git a/incremental/afs.c b/incremental/afs.c index 14035722..16dc0c0b 100644 --- a/incremental/afs.c +++ b/incremental/afs.c @@ -7,6 +7,10 @@ * . */ +#include +#include +#include + #include #include #include @@ -18,8 +22,6 @@ #include #include -#include -#include #include #include @@ -64,9 +66,9 @@ extern long pr_SIdToName(); 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; @@ -197,7 +199,7 @@ void do_user(char **before, int beforec, char **after, int afterc) 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)) @@ -321,7 +323,7 @@ void do_list(char **before, int beforec, char **after, int afterc) 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; diff --git a/regtape/employee.pc b/regtape/employee.pc index b4bf328b..3e4b159e 100644 --- a/regtape/employee.pc +++ b/regtape/employee.pc @@ -10,6 +10,7 @@ #include #include #include +#include #include #include @@ -97,7 +98,7 @@ int main(int argc, char **argv) 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; @@ -152,7 +153,7 @@ int main(int argc, char **argv) { printf("Next"); fflush(stdout); - gets(buf); + fgets(buf, sizeof(buf), stdin); } } @@ -258,24 +259,28 @@ struct entry *get_next_entry(FILE *in) 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; @@ -370,19 +375,19 @@ void process_entry(struct entry *e) { 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; @@ -397,18 +402,18 @@ void process_entry(struct entry *e) { 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); @@ -416,18 +421,18 @@ void process_entry(struct entry *e) { 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; @@ -476,15 +481,17 @@ void newuser(struct entry *e) 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, ':'))) @@ -499,8 +506,8 @@ void newuser(struct entry *e) } *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); diff --git a/regtape/sign.pc b/regtape/sign.pc index 669bd067..d159bbe6 100644 --- a/regtape/sign.pc +++ b/regtape/sign.pc @@ -10,6 +10,7 @@ #include #include #include +#include #include #include @@ -33,7 +34,8 @@ int main(int argc, char **argv) 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; diff --git a/regtape/students.pc b/regtape/students.pc index 43d57f40..597e9559 100644 --- a/regtape/students.pc +++ b/regtape/students.pc @@ -10,6 +10,7 @@ #include #include #include +#include #include #include @@ -104,7 +105,7 @@ int main(int argc, char **argv) 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; @@ -159,7 +160,7 @@ int main(int argc, char **argv) { printf("Next"); fflush(stdout); - gets(buf); + fgets(buf, sizeof(buf), stdin); } } @@ -289,24 +290,29 @@ struct entry *get_next_entry(FILE *in) 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; @@ -422,19 +428,19 @@ void process_entry(struct entry *e) { 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; @@ -449,18 +455,18 @@ void process_entry(struct entry *e) { 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; @@ -475,36 +481,36 @@ void process_entry(struct entry *e) { 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; @@ -583,8 +589,11 @@ void newuser(struct entry *e) 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; @@ -605,7 +614,8 @@ void newuser(struct entry *e) 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) @@ -615,7 +625,8 @@ void newuser(struct entry *e) 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) @@ -625,8 +636,10 @@ void newuser(struct entry *e) 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);