int inc_running = 0;
time_t inc_started;
-#define MAXARGC 15
+#define MAXARGC 16
EXEC SQL WHENEVER SQLERROR DO dbmserr();
+EXEC SQL BEGIN DECLARE SECTION;
/* structures to save before args */
static char *before[MAXARGC];
static int beforec;
/* structures to save after args */
static char *after[MAXARGC];
static int afterc;
+EXEC SQL END DECLARE SECTION;
/* structures to save entire sets of incremental changes */
struct save_queue *incremental_sq = NULL;
int id;
EXEC SQL END DECLARE SECTION;
- char *name;
+ char *name, *name2;
beforetable = table;
switch (table)
{
case USERS_TABLE:
- sprintf(stmt_buf, "SELECT u.login, u.unix_uid, u.shell, u.last, "
- "u.first, u.middle, u.status, u.clearid, u.type "
- "FROM users u WHERE %s", qual);
+ sprintf(stmt_buf, "SELECT u.login, u.unix_uid, u.shell, "
+ "u.winconsoleshell, u.last, u.first, u.middle, u.status, "
+ "u.clearid, u.type, u.users_id, u.winhomedir, u.winprofiledir, "
+ "u.potype FROM users u WHERE %s", qual);
dosql(before);
- beforec = 9;
+ beforec = 14;
break;
case MACHINE_TABLE:
- sprintf(stmt_buf, "SELECT m.name, m.vendor FROM machine m "
+ sprintf(stmt_buf, "SELECT m.name, m.vendor, m.mach_id FROM machine m "
"WHERE %s", qual);
dosql(before);
- beforec = 2;
+ beforec = 3;
break;
case CLUSTERS_TABLE:
- sprintf(stmt_buf, "SELECT c.name, c.description, c.location "
- "FROM clusters c WHERE %s", qual);
+ sprintf(stmt_buf, "SELECT c.name, c.description, c.location, "
+ "c.clu_id FROM clusters c WHERE %s", qual);
dosql(before);
- beforec = 3;
+ beforec = 4;
+ break;
+ case CONTAINERS_TABLE:
+ sprintf(stmt_buf, "SELECT c.name, c.description, c.location, c.contact, "
+ "c.acl_type, c.acl_id, c.cnt_id, c.list_id FROM containers c "
+ "WHERE %s", qual);
+ dosql(before);
+ beforec = 8;
+ name = xmalloc(0);
+ id = atoi(before[5]);
+ if (!strncmp(before[4], "USER", 4))
+ {
+ id_to_name(id, USERS_TABLE, &name);
+ strcpy(before[5], name);
+ }
+ else if (!strncmp(before[4], "LIST", 4))
+ {
+ id_to_name(id, LIST_TABLE, &name);
+ strcpy(before[5], name);
+ }
+ else if (!strncmp(before[4], "KERBEROS", 8))
+ {
+ id_to_name(id, STRINGS_TABLE, &name);
+ strcpy(before[5], name);
+ }
+ id = atoi(before[7]);
+ id_to_name(id, LIST_TABLE, &name);
+ strcpy(before[7], name);
break;
case MCMAP_TABLE:
strcpy(before[0], argv[0]);
strcpy(before[1], argv[1]);
beforec = 2;
break;
+ case MCNTMAP_TABLE:
+ strcpy(before[0], argv[0]);
+ strcpy(before[1], argv[1]);
+ name_to_id(before[0], MACHINE_TABLE, &id);
+ sprintf(before[2], "%d", id);
+ name_to_id(before[1], CONTAINERS_TABLE, &id);
+ sprintf(before[3], "%d", id);
+ name = xmalloc(0);
+ EXEC SQL SELECT list_id INTO :before[4] FROM containers
+ WHERE cnt_id = :id;
+ id = atoi(before[4]);
+ id_to_name(id, LIST_TABLE, &name);
+ strcpy(before[4], name);
+ beforec = 5;
+ break;
case SVC_TABLE:
strcpy(before[0], argv[0]);
strcpy(before[1], argv[1]);
case FILESYS_TABLE:
sprintf(stmt_buf, "SELECT fs.label, fs.type, fs.mach_id, fs.name, "
"fs.mount, fs.rwaccess, fs.comments, fs.owner, fs.owners, "
- "fs.createflg, fs.lockertype FROM filesys fs WHERE %s", qual);
+ "fs.createflg, fs.lockertype, fs.filsys_id FROM filesys fs "
+ "WHERE %s", qual);
dosql(before);
- name = malloc(0);
+ name = xmalloc(0);
id = atoi(before[2]);
id_to_name(id, MACHINE_TABLE, &name);
strcpy(before[2], name);
id_to_name(id, LIST_TABLE, &name);
strcpy(before[8], name);
free(name);
- beforec = 11;
+ beforec = 12;
break;
case QUOTA_TABLE:
strcpy(before[0], "?");
case LIST_TABLE:
sprintf(stmt_buf, "SELECT l.name, l.active, l.publicflg, l.hidden, "
"l.maillist, l.grouplist, l.gid, l.acl_type, l.acl_id, "
- "l.description FROM list l WHERE %s", qual);
+ "l.description, l.list_id, l.nfsgroup FROM list l WHERE %s", qual);
dosql(before);
- beforec = 10;
+ beforec = 12;
break;
case IMEMBERS_TABLE:
id = (int) argv[0];
sprintf(stmt_buf, "SELECT active, publicflg, hidden, maillist, "
- "grouplist, gid FROM list WHERE list_id = %d", id);
+ "grouplist, gid, nfsgroup FROM list WHERE list_id = %d", id);
dosql(&(before[3]));
- name = malloc(0);
+ name = xmalloc(0);
id_to_name(id, LIST_TABLE, &name);
+ name2 = xmalloc(0);
strcpy(before[0], name);
strcpy(before[1], argv[1]);
id = (int) argv[2];
- beforec = 9;
+ beforec = 11;
if (!strcmp(before[1], "USER"))
{
- id_to_name(id, USERS_TABLE, &name);
- EXEC SQL SELECT status INTO :before[9] FROM users
- WHERE users_id = :id;
- beforec = 10;
+ id_to_name(id, USERS_TABLE, &name2);
+ EXEC SQL SELECT status, users_id INTO :before[10], :before[12]
+ FROM users WHERE users_id = :id;
+ EXEC SQL SELECT list_id INTO :before[11] FROM list
+ WHERE name = :name;
+ beforec = 13;
}
else if (!strcmp(before[1], "LIST"))
- id_to_name(id, LIST_TABLE, &name);
+ {
+ id_to_name(id, LIST_TABLE, &name2);
+ EXEC SQL SELECT list_id INTO :before[10] FROM list
+ WHERE name = :name;
+ sprintf(before[11], "%d", id);
+ beforec = 12;
+ }
else if (!strcmp(before[1], "STRING") || !strcmp(before[1], "KERBEROS"))
- id_to_name(id, STRINGS_TABLE, &name);
- strcpy(before[2], name);
+ {
+ id_to_name(id, STRINGS_TABLE, &name2);
+ EXEC SQL SELECT list_id INTO :before[10] FROM list
+ WHERE name = :name;
+ }
+ else if (!strcmp(before[1], "MACHINE"))
+ {
+ id_to_name(id, MACHINE_TABLE, &name2);
+ EXEC SQL SELECT list_id INTO :before[10] FROM list
+ WHERE name = :name;
+ sprintf(before[11], "%d", id);
+ beforec = 12;
+ }
+ strcpy(before[2], name2);
free(name);
+ free(name2);
break;
default:
/*
void incremental_after(enum tables table, char *qual, char **argv)
{
- char *name;
+ char *name, *name2;
EXEC SQL BEGIN DECLARE SECTION;
- int id;
+ int id;
EXEC SQL END DECLARE SECTION;
struct iupdate *iu;
switch (table)
{
case USERS_TABLE:
- sprintf(stmt_buf, "SELECT u.login, u.unix_uid, u.shell, u.last, "
- "u.first, u.middle, u.status, u.clearid, u.type "
- "FROM users u WHERE %s", qual);
+ sprintf(stmt_buf, "SELECT u.login, u.unix_uid, u.shell, "
+ "u.winconsoleshell, u.last, u.first, u.middle, u.status, "
+ "u.clearid, u.type, u.users_id, u.winhomedir, u.winprofiledir, "
+ "u.potype FROM users u WHERE %s", qual);
dosql(after);
- afterc = 9;
+ afterc = 14;
break;
case MACHINE_TABLE:
- sprintf(stmt_buf, "SELECT m.name, m.vendor FROM machine m "
+ sprintf(stmt_buf, "SELECT m.name, m.vendor, m.mach_id FROM machine m "
"WHERE %s", qual);
dosql(after);
- afterc = 2;
+ afterc = 3;
break;
case CLUSTERS_TABLE:
- sprintf(stmt_buf, "SELECT c.name, c.description, c.location "
- "FROM clusters c WHERE %s", qual);
+ sprintf(stmt_buf, "SELECT c.name, c.description, c.location, "
+ "c.clu_id FROM clusters c WHERE %s", qual);
dosql(after);
- afterc = 3;
+ afterc = 4;
+ break;
+ case CONTAINERS_TABLE:
+ sprintf(stmt_buf, "SELECT c.name, c.description, c.location, c.contact, "
+ "c.acl_type, c.acl_id, c.cnt_id, c.list_id FROM containers c "
+ "WHERE %s", qual);
+ dosql(after);
+ afterc = 8;
+ name = xmalloc(0);
+ id = atoi(after[5]);
+ if (!strncmp(after[4], "USER", 4))
+ {
+ id_to_name(id, USERS_TABLE, &name);
+ strcpy(after[5], name);
+ }
+ else if (!strncmp(after[4], "LIST", 4))
+ {
+ id_to_name(id, LIST_TABLE, &name);
+ strcpy(after[5], name);
+ }
+ else if (!strncmp(after[4], "KERBEROS", 8))
+ {
+ id_to_name(id, STRINGS_TABLE, &name);
+ strcpy(after[5], name);
+ }
+ id = atoi(after[7]);
+ id_to_name(id, LIST_TABLE, &name);
+ strcpy(after[7], name);
break;
case MCMAP_TABLE:
strcpy(after[0], argv[0]);
strcpy(after[1], argv[1]);
afterc = 2;
break;
+ case MCNTMAP_TABLE:
+ strcpy(after[0], argv[0]);
+ strcpy(after[1], argv[1]);
+ name_to_id(after[0], MACHINE_TABLE, &id);
+ sprintf(after[2], "%d", id);
+ name_to_id(after[1], CONTAINERS_TABLE, &id);
+ sprintf(after[3], "%d", id);
+ name = xmalloc(0);
+ EXEC SQL SELECT list_id INTO :after[4] FROM containers
+ WHERE cnt_id = :id;
+ id = atoi(after[4]);
+ id_to_name(id, LIST_TABLE, &name);
+ strcpy(after[4], name);
+ afterc = 5;
+ break;
case SVC_TABLE:
strcpy(after[0], argv[0]);
strcpy(after[1], argv[1]);
case FILESYS_TABLE:
sprintf(stmt_buf, "SELECT fs.label, fs.type, fs.mach_id, fs.name, "
"fs.mount, fs.rwaccess, fs.comments, fs.owner, fs.owners, "
- "fs.createflg, fs.lockertype FROM filesys fs WHERE %s", qual);
+ "fs.createflg, fs.lockertype, fs.filsys_id FROM filesys fs "
+ "WHERE %s", qual);
dosql(after);
- name = malloc(0);
+ name = xmalloc(0);
id = atoi(after[2]);
id_to_name(id, MACHINE_TABLE, &name);
strcpy(after[2], name);
id_to_name(id, LIST_TABLE, &name);
strcpy(after[8], name);
free(name);
- afterc = 11;
+ afterc = 12;
break;
case QUOTA_TABLE:
strcpy(after[0], "?");
case LIST_TABLE:
sprintf(stmt_buf, "SELECT l.name, l.active, l.publicflg, l.hidden, "
"l.maillist, l.grouplist, l.gid, l.acl_type, l.acl_id, "
- "l.description FROM list l WHERE %s", qual);
+ "l.description, l.list_id, l.nfsgroup FROM list l WHERE %s", qual);
dosql(after);
- afterc = 10;
+ afterc = 12;
break;
case IMEMBERS_TABLE:
id = (int) argv[0];
sprintf(stmt_buf, "SELECT active, publicflg, hidden, maillist, "
- "grouplist, gid FROM list WHERE list_id = %d", id);
+ "grouplist, gid, nfsgroup FROM list WHERE list_id = %d", id);
dosql(&(after[3]));
- name = malloc(0);
+ name = xmalloc(0);
id_to_name(id, LIST_TABLE, &name);
+ name2 = xmalloc(0);
strcpy(after[0], name);
strcpy(after[1], argv[1]);
id = (int) argv[2];
- afterc = 9;
+ afterc = 11;
if (!strcmp(after[1], "USER"))
{
- id_to_name(id, USERS_TABLE, &name);
- EXEC SQL SELECT status INTO :after[9] FROM users
- WHERE users_id = :id;
- afterc = 10;
+ id_to_name(id, USERS_TABLE, &name2);
+ EXEC SQL SELECT status, users_id INTO :after[10], :after[12]
+ FROM users WHERE users_id = :id;
+ EXEC SQL SELECT list_id INTO :after[11] FROM list
+ WHERE name = :name;
+ afterc = 13;
}
else if (!strcmp(after[1], "LIST"))
- id_to_name(id, LIST_TABLE, &name);
+ {
+ id_to_name(id, LIST_TABLE, &name2);
+ EXEC SQL SELECT list_id INTO :after[10] FROM list
+ WHERE name = :name;
+ sprintf(after[11], "%d", id);
+ afterc = 12;
+ }
else if (!strcmp(after[1], "STRING") || !strcmp(after[1], "KERBEROS"))
- id_to_name(id, STRINGS_TABLE, &name);
- strcpy(after[2], name);
+ {
+ id_to_name(id, STRINGS_TABLE, &name2);
+ EXEC SQL SELECT list_id INTO :after[10] FROM list
+ WHERE name = :name;
+ }
+ else if (!strcmp(after[1], "MACHINE"))
+ {
+ id_to_name(id, MACHINE_TABLE, &name2);
+ EXEC SQL SELECT list_id INTO :after[10] FROM list
+ WHERE name = :name;
+ sprintf(after[11], "%d", id);
+ afterc = 12;
+ }
+ strcpy(after[2], name2);
free(name);
+ free(name2);
break;
case NO_TABLE:
afterc = 0;
EXEC SQL BEGIN DECLARE SECTION;
char tab[INCREMENTAL_TABLE_NAME_SIZE], serv[INCREMENTAL_SERVICE_SIZE];
EXEC SQL END DECLARE SECTION;
- struct iupdate *iu;
+ struct iupdate *iu, *iu_save;
if (!inited)
{
if (!strcmp(c->table, iu->table))
{
iu->service = c->service;
- sq_save_data(incremental_exec, iu);
- break;
+ iu_save = xmalloc(sizeof(struct iupdate));
+ iu_save->service = iu->service;
+ iu_save->table = iu->table;
+ iu_save->beforec = iu->beforec;
+ iu_save->afterc = iu->afterc;
+ iu_save->before = copy_argv(iu->before, iu->beforec);
+ iu_save->after = copy_argv(iu->after, iu->afterc);
+ sq_save_data(incremental_exec, iu_save);
}
}
if (!c)
next_incremental();
}
+/* Pro*C 2.2.4 can't cope with the sigset_t below, at least in Solaris 2.6.
+ We add DEFINE=_PROC_ to the proc invocation and then #ifndef that around
+ this function so proc will pass it through without reading it. */
+#ifndef _PROC_
void next_incremental(void)
{
struct iupdate *iu;
free_argv(iu->after, iu->afterc);
free(iu);
}
-
+#endif
/* Called when the current transaction is aborted to throw away any queued
* incremental updates