BUILDTOP=..
mrbindir=@mrbindir@
-LIB_OBJS=util.o moddiff.o tar.o genacl.o
-LIB_CFILES=moddiff.c genacl.c
+LIB_OBJS=util.o tar.o genacl.o
+LIB_CFILES=genacl.c
LIB_TARGET=libdcm.a
OBJS= acl.o boot.o dhcp.o directory.o hesiod.o hosts.o mailhub.o \
{
FILE *out = stdout;
char *outf = NULL, outft[MAXPATHLEN];
- struct stat sb;
- int flag;
EXEC SQL BEGIN DECLARE SECTION;
char login[USERS_LOGIN_SIZE], last_name[USERS_LAST_SIZE];
char first_name[USERS_FIRST_SIZE], middle_name[USERS_MIDDLE_SIZE];
if (argc == 2)
{
- if (stat(argv[1], &sb) == 0)
- {
- if (ModDiff (&flag, "users", sb.st_mtime))
- exit(MR_DATE);
- if (flag < 0)
- {
- fprintf(stderr, "File %s does not need to be rebuilt.\n",
- argv[1]);
- exit(MR_NO_CHANGE);
- }
- }
outf = argv[1];
sprintf(outft, "%s~", outf);
if (!(out = fopen(outft, "w")))
FILE *pout, *uout, *bout;
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 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];
- int uid, flag1, flag2, id, pid, iid, mid, status;
+ int uid, id, pid, iid, mid, status;
EXEC SQL END DECLARE SECTION;
sprintf(poutf, "%s/passwd.db", hesiod_dir);
sprintf(uoutf, "%s/uid.db", hesiod_dir);
sprintf(boutf, "%s/pobox.db", hesiod_dir);
- if (stat(poutf, &psb) == 0 && stat(uoutf, &usb) == 0 &&
- stat(boutf, &bsb) == 0)
- {
- ftime = min(min(psb.st_mtime, usb.st_mtime), bsb.st_mtime);
- if (ModDiff (&flag1, "users", ftime) ||
- ModDiff (&flag2, "machine", ftime))
- exit(MR_DATE);
- if (flag1 < 0 && flag2 < 0)
- {
- fprintf(stderr, "Files passwd.db, uid.db, and pobox.db "
- "do not need to be rebuilt.\n");
- return 0;
- }
- }
-
sprintf(poutft, "%s~", poutf);
pout = fopen(poutft, "w");
if (!pout)
struct bucket *b, **p;
struct grp *g;
struct user *u;
- struct stat isb, gsb, lsb;
- time_t ftime;
EXEC SQL BEGIN DECLARE SECTION;
char name[LIST_NAME_SIZE];
- int gid, id, lid, flag1, flag2, flag3, len;
+ int gid, id, lid, len;
EXEC SQL END DECLARE SECTION;
/* open files */
sprintf(goutf, "%s/group.db", hesiod_dir);
sprintf(loutf, "%s/grplist.db", hesiod_dir);
- if (stat(ioutf, &isb) == 0 && stat(goutf, &gsb) == 0 &&
- stat(loutf, &lsb) == 0)
- {
- ftime = min(isb.st_mtime, min(gsb.st_mtime, lsb.st_mtime));
- if (ModDiff (&flag1, "users", ftime) ||
- ModDiff (&flag2, "list", ftime) ||
- ModDiff (&flag3, "imembers", ftime))
- exit(MR_DATE);
- if (flag1 < 0 && flag2 < 0 && flag3 < 0)
- {
- fprintf(stderr, "Files gid.db, group.db and grplist.db "
- "do not need to be rebuilt.\n");
- return 0;
- }
- }
-
sprintf(buf, "%s~", ioutf);
iout = fopen(buf, "w");
if (!iout)
{
FILE *out;
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[FILESYS_LABEL_SIZE], type[FILESYS_TYPE_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;
+ int flag, id, fid;
EXEC SQL END DECLARE SECTION;
sprintf(outf, "%s/filsys.db", hesiod_dir);
- if (stat(outf, &sb) == 0)
- {
- ftime = sb.st_mtime;
-
- if (ModDiff(&flag1, "filesys", ftime))
- exit(MR_DATE);
- if (ModDiff(&flag2, "machine", ftime))
- exit(MR_DATE);
- if (ModDiff(&flag3, "alias", ftime))
- exit(MR_DATE);
- if (ModDiff(&flag4, "fsgroup", ftime))
- exit(MR_DATE);
-
- if (flag1 < 0 && flag2 < 0 && flag3 < 0 && flag4 < 0)
- {
- fprintf(stderr, "File filsys.db does not need to be rebuilt.\n");
- return 0;
- }
- }
-
sprintf(outft, "%s~", outf);
out = fopen(outft, "w");
if (!out)
WHERE f.filsys_id = g.filsys_id AND g.group_id = :fid
ORDER BY key, label;
EXEC SQL OPEN f_cursor2;
- for (flag1 = 1; ; flag1++)
+ for (flag = 1; ; flag++)
{
EXEC SQL FETCH f_cursor2 INTO :type, :loc, :id, :access, :mount,
:comments, :name, :key;
{
fprintf(out, "%s.filsys\t%s %s \"%s %s %s %s %s %d\"\n",
group, HCLASS, HTYPE, type, strtrim(loc), mach,
- strtrim(access), strtrim(mount), flag1);
+ strtrim(access), strtrim(mount), flag);
}
}
else if (!strcmp(type, "AFS"))
{
fprintf(out, "%s.filsys\t%s %s \"AFS %s %s %s %d\"\n",
group, HCLASS, HTYPE, strtrim(loc), strtrim(access),
- strtrim(mount), flag1);
+ strtrim(mount), flag);
}
else if (!strcmp(type, "ERR"))
{
FILE *out;
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;
+ int maxmach, maxclu, mid, cid, id;
char name[CLUSTERS_NAME_SIZE];
char label[SVC_SERV_LABEL_SIZE], data[SVC_SERV_CLUSTER_SIZE];
EXEC SQL END DECLARE SECTION;
sprintf(outf, "%s/cluster.db", hesiod_dir);
- if (stat(outf, &sb) == 0)
- {
- ftime = sb.st_mtime;
- if (ModDiff (&flag1, "clusters", ftime)
- || ModDiff (&flag2, "machine", ftime)
- || ModDiff (&flag3, "mcmap", ftime)
- || ModDiff (&flag4, "svc", ftime))
- exit(MR_DATE);
- if (flag1 < 0 && flag2 < 0 && flag3 < 0 && flag4 < 0)
- {
- fprintf(stderr, "File cluster.db does not need to be rebuilt.\n");
- return 0;
- }
- }
-
sprintf(outft, "%s~", outf);
out = fopen(outft, "w");
if (!out)
{
FILE *out;
char outf[MAXPATHLEN], outft[MAXPATHLEN];
- struct stat sb;
- time_t ftime;
EXEC SQL BEGIN DECLARE SECTION;
char name[PRINTERS_NAME_SIZE], duplexname[PRINTERS_DUPLEXNAME_SIZE];
char rp[PRINTERS_RP_SIZE], type[PRINTERS_TYPE_SIZE];
char duplexrp[PRINTERS_RP_SIZE], pskind[PRINTSERVERS_KIND_SIZE];
- int flag1, flag2, ka, rm, mc;
+ int ka, rm, mc;
EXEC SQL END DECLARE SECTION;
char *rmname;
sprintf(outf, "%s/printcap.db", hesiod_dir);
- if (stat(outf, &sb) == 0)
- {
- ftime = sb.st_mtime;
- if (ModDiff (&flag1, "printers", ftime)
- || ModDiff (&flag2, "printservers", ftime)
- || ModDiff (&flag2, "machine", ftime))
- exit(MR_DATE);
- if (flag1 < 0 && flag2 < 0)
- {
- fprintf(stderr, "File printcap.db does not need to be rebuilt.\n");
- return 0;
- }
- }
-
sprintf(outft, "%s~", outf);
out = fopen(outft, "w");
if (!out)
{
FILE *out;
char outf[MAXPATHLEN], outft[MAXPATHLEN], *mach;
- struct stat sb;
- time_t ftime;
EXEC SQL BEGIN DECLARE SECTION;
char service[SERVERHOSTS_SERVICE_SIZE];
- int flag1, flag2, id;
+ int id;
EXEC SQL END DECLARE SECTION;
sprintf(outf, "%s/sloc.db", hesiod_dir);
- if (stat(outf, &sb) == 0)
- {
- ftime = sb.st_mtime;
- if ((ModDiff (&flag1, "serverhosts", ftime)) ||
- (ModDiff (&flag2, "machine", ftime)))
- exit(MR_DATE);
- if (flag1 < 0 && flag2 < 0)
- {
- fprintf(stderr, "File sloc.db does not need to be rebuilt.\n");
- return 0;
- }
- }
-
sprintf(outft, "%s~", outf);
out = fopen(outft, "w");
if (!out)
{
FILE *out;
char outf[MAXPATHLEN], outft[MAXPATHLEN];
- struct stat sb;
- time_t ftime;
EXEC SQL BEGIN DECLARE SECTION;
char service[SERVICES_NAME_SIZE], protocol[SERVICES_PROTOCOL_SIZE];
char aname[ALIAS_NAME_SIZE], trans[ALIAS_TRANS_SIZE];
- int port, flag1;
+ int port;
EXEC SQL END DECLARE SECTION;
sprintf(outf, "%s/service.db", hesiod_dir);
- if (stat(outf, &sb) == 0)
- {
- ftime = sb.st_mtime;
- if (ModDiff (&flag1, "services", ftime))
- exit(MR_DATE);
- if (flag1 < 0)
- {
- fprintf(stderr, "File service.db does not need to be rebuilt.\n");
- return 0;
- }
- }
-
sprintf(outft, "%s~", outf);
out = fopen(outft, "w");
if (!out)
{
FILE *out = stdout;
char *outf = NULL, outft[MAXPATHLEN], *p;
- struct stat sb;
struct timeval now;
- int flag1, flag2, i;
+ int i;
struct hash *aliases;
EXEC SQL BEGIN DECLARE SECTION;
int id;
if (argc == 2)
{
- if (stat(argv[1], &sb) == 0)
- {
- if (ModDiff(&flag1, "machine", sb.st_mtime) ||
- ModDiff(&flag2, "subnet", sb.st_mtime))
- exit(MR_DATE);
- if (flag1 < 0 && flag2 < 0)
- {
- fprintf(stderr, "File %s does not need to be rebuilt.\n",
- argv[1]);
- exit(MR_NO_CHANGE);
- }
- }
outf = argv[1];
sprintf(outft, "%s~", outf);
if (!(out = fopen(outft, "w")))
{
time_t tm = time(NULL);
char filename[MAXPATHLEN], *targetfile;
- struct stat sb;
- int flag1, flag2;
FILE *out = stdout;
srand(tm);
if (argc == 2)
{
- if (stat(argv[1], &sb) == 0)
- {
- if (ModDiff(&flag1, "users", sb.st_mtime) ||
- ModDiff(&flag2, "list", sb.st_mtime))
- exit(MR_DATE);
- if (flag1 < 0 && flag2 < 0)
- {
- fprintf(stderr, "File %s does not need to be rebuilt.\n",
- argv[1]);
- exit(MR_NO_CHANGE);
- }
- }
targetfile = argv[1];
sprintf(filename, "%s~", targetfile);
if (!(out = fopen(filename, "w")))
+++ /dev/null
-/* $Id$
- *
- * Copyright (C) 1990-1998 by the Massachusetts Institute of Technology.
- * For copying and distribution information, please see the file
- * <mit-copyright.h>.
- */
-
-#include <mit-copyright.h>
-#include <moira.h>
-
-#include <sys/types.h>
-
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "util.h"
-
-EXEC SQL INCLUDE sqlca;
-
-/* Julian day of the UNIX epoch (January 1, 1970) */
-#define UNIX_EPOCH 2440588
-
-/****************************************************************/
-/** Return the difference between the modtime & table modtime **/
-/** in flag variable. Return 0 if success, else errno. **/
-/****************************************************************/
-
-int ModDiff(int *flag, char *tbl, time_t ModTime)
-{
- time_t filetimeno;
- EXEC SQL BEGIN DECLARE SECTION;
- char filetime[48], *tbl_name, *unixtime_fmt = UNIXTIME_FMT;
- EXEC SQL END DECLARE SECTION;
-
- *flag = 0;
- tbl_name = tbl;
- /* Get modtime as Julian day, hours, minutes, and seconds */
- EXEC SQL SELECT TO_CHAR(modtime, :unixtime_fmt)
- INTO :filetime FROM tblstats
- WHERE table_name = :tbl_name;
- if (sqlca.sqlcode)
- {
- fprintf(stderr, "Moddiff Query failed: %ld\n", sqlca.sqlcode);
- return MR_DATE;
- }
-
- *flag = (int) (unixtime(filetime) - ModTime);
- return 0;
-}
-
-time_t unixtime(char *timestring)
-{
- time_t t;
-
- t = strtol(timestring, ×tring, 10) - UNIX_EPOCH;
- t = t * 24 + strtol(timestring, ×tring, 10);
- t = t * 60 + strtol(timestring, ×tring, 10);
- t = t * 60 + strtol(timestring, ×tring, 10);
-
- return t;
-}
{
FILE *out = stdout;
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[SUBNET_NAME_SIZE], description[SUBNET_DESCRIPTION_SIZE];
if (argc == 2)
{
- if (stat(argv[1], &sb) == 0)
- {
- if (ModDiff(&flag1, "subnet", sb.st_mtime))
- exit(MR_DATE);
- if (flag1 < 0)
- {
- fprintf(stderr, "File %s does not need to be rebuilt.\n",
- argv[1]);
- exit(MR_NO_CHANGE);
- }
- }
outf = argv[1];
sprintf(outft, "%s~", outf);
if (!(out = fopen(outft, "w")))
EXEC SQL END DECLARE SECTION;
sprintf(file, "%s/list-", nfs_dir);
-#if 0
- if (stat(file, &sb) == 0)
- {
- if ((ModDiff (&flag1, "users", sb.st_mtime)) ||
- (ModDiff (&flag2, "list", sb.st_mtime)) ||
- (ModDiff (&flag3, "imembers", sb.st_mtime)) ||
- (ModDiff (&flag4, "serverhosts", sb.st_mtime)))
- exit(MR_DATE);
- if (flag1 < 0 && flag2 < 0 && flag3 < 0 && flag4 < 0)
- {
- fprintf(stderr, "The lists do not need to be rebuilt.\n");
- return 0;
- }
- }
-#endif
/* build the list of everyone, and store it in a file whose name
* corresponds to the empty list.
{
FILE *out = stdout;
char *outf = NULL, outft[MAXPATHLEN];
- struct stat sb;
- int flag, i;
+ int i;
EXEC SQL BEGIN DECLARE SECTION;
char login[USERS_LOGIN_SIZE], id[USERS_CLEARID_SIZE];
char string[STRINGS_STRING_SIZE];
if (argc == 2)
{
- if (stat(argv[1], &sb) == 0)
- {
- if (ModDiff(&flag, "users", sb.st_mtime))
- exit(MR_DATE);
- if (flag < 0)
- {
- fprintf(stderr, "File %s does not need to be rebuilt.\n",
- argv[1]);
- exit(MR_NO_CHANGE);
- }
- }
outf = argv[1];
sprintf(outft, "%s~", outf);
if (!(out = fopen(outft, "w")))
char po_dir[MAXPATHLEN], wpo_dir[MAXPATHLEN];
struct stat sb;
char *c;
- int flag;
initialize_sms_error_table();
EXEC SQL CONNECT :db;
- flag = 0;
- if (stat(po_dir, &sb) == 0)
- {
- if (ModDiff (&flag, "filesys", sb.st_mtime))
- exit(MR_DATE);
- }
- if (flag < 0)
- {
- fprintf(stderr, "%s: %s does not need to be rebuilt.\n", whoami, po_dir);
- unlink(wpo_dir);
- }
- else
- {
- fprintf(stderr, "%s: building po databases...\n", whoami);
- pobox(wpo_dir);
+ fprintf(stderr, "%s: building po databases...\n", whoami);
+ pobox(wpo_dir);
- if (stat(po_dir, &sb) != -1)
+ if (stat(po_dir, &sb) != -1)
+ {
+ fprintf(stderr, "%s: removing %s\n", whoami, po_dir);
+ sprintf(cmd, "rm -r %s", po_dir);
+ if (strncmp(po_dir, wpo_dir, strlen(po_dir)))
+ exit(MR_CCONFIG);
+ if (system(cmd))
{
- fprintf(stderr, "%s: removing %s\n", whoami, po_dir);
- sprintf(cmd, "rm -r %s", po_dir);
- if (strncmp(po_dir, wpo_dir, strlen(po_dir)))
- exit(MR_CCONFIG);
- if (system(cmd))
- {
- fprintf(stderr, "%s: unable to remove %s (%s)", whoami, po_dir,
- strerror(errno));
- exit(MR_CCONFIG);
- }
+ fprintf(stderr, "%s: unable to remove %s (%s)", whoami, po_dir,
+ strerror(errno));
+ exit(MR_CCONFIG);
}
-
- rename(wpo_dir, po_dir);
}
+ rename(wpo_dir, po_dir);
+
fprintf(stderr, "%s: building tar file...\n", whoami);
sprintf(cmd, "(cd %s; tar cf - . ) > %s.out", po_dir, po_dir);
if (system(cmd))
RCSID("$Header$");
+/* Julian day of the UNIX epoch (January 1, 1970) */
+#define UNIX_EPOCH 2440588
+
extern void sqlglm(char buf[], int *, int *);
void fix_file(char *targetfile)
return s;
}
+time_t unixtime(char *timestring)
+{
+ time_t t;
+
+ t = strtol(timestring, ×tring, 10) - UNIX_EPOCH;
+ t = t * 24 + strtol(timestring, ×tring, 10);
+ t = t * 60 + strtol(timestring, ×tring, 10);
+ t = t * 60 + strtol(timestring, ×tring, 10);
+
+ return t;
+}
void db_error(int code)
{
char *outf = NULL, outft[MAXPATHLEN];
char control_fn[MAXPATHLEN], cmd[256];
FILE *f;
- struct stat sb;
- int flag1;
int records = 0;
EXEC SQL BEGIN DECLARE SECTION;
char login[USERS_LOGIN_SIZE];
if (argc == 2)
{
- if (stat(argv[1], &sb) == 0)
- {
- if (ModDiff(&flag1, "users", sb.st_mtime) == 0 && flag1 < 0)
- {
- fprintf(stderr, "File %s does not need to be rebuilt.\n",
- argv[1]);
- exit(MR_NO_CHANGE);
- }
- }
outf = argv[1];
sprintf(outft, "%s/username_id.map", warehouse_dir);
if ((out = open(outft, O_WRONLY|O_APPEND|O_CREAT|O_TRUNC, 0666)) < 0)
FILE *outfsf;
struct stat sb;
char *c;
- int flag;
initialize_sms_error_table();
sprintf(wkgrp, "%s/group~", www_dir);
sprintf(wkfs, "%s/filsys~", www_dir);
- flag = 0;
- if (stat(outfs, &sb) == 0)
+ fprintf(stderr, "%s: building fs database...\n", whoami);
+ if (!(outfsf = fopen(wkfs, "w")))
{
- if (ModDiff (&flag, "filesys", sb.st_mtime))
- exit(MR_DATE);
+ fprintf(stderr, "%s: cannot open %s for writing (%s)\n", whoami,
+ wkfs, strerror(errno));
+ exit(MR_OCONFIG);
}
- if (flag < 0)
- fprintf(stderr, "%s: %s does not need to be rebuilt.\n", whoami, outfs);
- else
+ filsys(outfsf);
+ if (fclose(outfsf))
{
- fprintf(stderr, "%s: building fs database...\n", whoami);
- if (!(outfsf = fopen(wkfs, "w")))
- {
- fprintf(stderr, "%s: cannot open %s for writing (%s)\n", whoami,
- wkfs, strerror(errno));
- exit(MR_OCONFIG);
- }
- filsys(outfsf);
- if (fclose(outfsf))
- {
- fprintf(stderr, "%s: close of %s failed (%s)", whoami,
- wkfs, strerror(errno));
- exit(MR_CCONFIG);
- }
- fix_file(outfs);
+ fprintf(stderr, "%s: close of %s failed (%s)", whoami,
+ wkfs, strerror(errno));
+ exit(MR_CCONFIG);
}
+ fix_file(outfs);
- flag = 0;
- if (stat(outgrp, &sb) == 0)
+ fprintf(stderr, "%s: building group database...\n", whoami);
+ if (!(outgrpf = fopen(wkgrp, "w")))
{
- if (ModDiff (&flag, "list", sb.st_mtime) ||
- ModDiff (&flag, "users", sb.st_mtime))
- exit(MR_DATE);
+ fprintf(stderr, "%s: cannot open %s for writing (%s)\n", whoami,
+ wkgrp, strerror(errno));
+ exit(MR_OCONFIG);
}
- if (flag < 0)
- fprintf(stderr, "%s: %s does not need to be rebuilt.\n", whoami, outgrp);
- else
+ group(outgrpf);
+ if (fclose(outgrpf))
{
- fprintf(stderr, "%s: building group database...\n", whoami);
- if (!(outgrpf = fopen(wkgrp, "w")))
- {
- fprintf(stderr, "%s: cannot open %s for writing (%s)\n", whoami,
- wkgrp, strerror(errno));
- exit(MR_OCONFIG);
- }
- group(outgrpf);
- if (fclose(outgrpf))
- {
- fprintf(stderr, "%s: close of %s failed (%s)", whoami, wkgrp,
- strerror(errno));
- exit(MR_CCONFIG);
- }
- fix_file(outgrp);
+ fprintf(stderr, "%s: close of %s failed (%s)", whoami, wkgrp,
+ strerror(errno));
+ exit(MR_CCONFIG);
}
-
+ fix_file(outgrp);
+
fprintf(stderr, "%s: building tar file...\n", whoami);
sprintf(cmd, "(cd %s; tar cf - . ) > %s.out", www_dir, www_dir);
if (system(cmd))