#include <mit-copyright.h>
#include <stdio.h>
#include <sys/file.h>
-#include <strings.h>
+#include <string.h>
#include <rx/xdr.h>
#include "ptint.h"
char db[33] = "moira";
EXEC SQL END DECLARE SECTION;
+#ifndef min
#define min(x,y) ((x) < (y) ? (x) : (y))
+#endif
char *whoami = "sync";
int dbase_fd;
int status;
long t;
+ setvbuf(stdout, NULL, _IOLBF, BUFSIZ);
+
if (argc > 2 && !strcmp(argv[1], "-db")) {
strncpy(db, argv[2], sizeof(db)-1);
argc -= 2;
initialize_sms_error_table();
initialize_pt_error_table();
Initdb(); /* Initialize prdb */
- setlinebuf(stdout);
users = create_hash(10000);
groups = create_hash(15000);
strings = create_hash(1000);
#endif
- EXEC SQL WHENEVER SQLERROR CALL sqlerr;
-#ifsql INGRES
- EXEC SQL CONNECT :db;
- EXEC SQL SET LOCKMODE SESSION WHERE LEVEL=TABLE, READLOCK=SHARED;
-#endsql
-#ifsql INFORMIX
- EXEC SQL DATABASE :db;
-#endsql
+ EXEC SQL WHENEVER SQLERROR DO sqlerr();
+ EXEC SQL CONNECT :db IDENTIFIED BY :db;
do_passwd();
do_groups();
fprintf(stderr, "Done (%d users, %d groups, %d kerberos, %d members): %s",
ucount, gcount, kcount, mcount, ctime(&t));
-#ifsql INGRES
- EXEC SQL DISCONNECT;
-#endsql
-#ifsql INFORMIX
- EXEC SQL CLOSE DATABASE;
-#endsql
+ EXEC SQL COMMIT;
exit(MR_SUCCESS);
}
t = time(0);
fprintf(stderr, "Doing users: %s", ctime(&t));
- /* get locks */
- EXEC SQL SELECT modtime INTO :name FROM users WHERE users_id = 0;
-
EXEC SQL DECLARE u_cursor CURSOR FOR
- SELECT u.login, u.uid, u.users_id
+ SELECT u.login, u.unix_uid, u.users_id
FROM users u
- WHERE u.uid > 0 AND (u.status = 1 OR u.status = 2)
- ORDER BY uid;
+ WHERE u.unix_uid > 0 AND (u.status = 1 OR u.status = 2)
+ ORDER BY unix_uid;
EXEC SQL OPEN u_cursor;
while (1) {
EXEC SQL FETCH u_cursor INTO :login, :uid, :id;
t = time(0);
fprintf(stderr, "Doing groups: %s", ctime(&t));
- /* get locks */
- EXEC SQL SELECT modtime INTO :name FROM list WHERE list_id = 0;
-
EXEC SQL DECLARE l_cursor CURSOR FOR
SELECT l.name, l.gid, l.list_id, l.hidden
FROM list l
if (aid == 0) {
EXEC SQL DECLARE k_cursor2 CURSOR FOR
- SELECT uid, status
+ SELECT unix_uid, status
FROM users
WHERE login = :name
- ORDER BY uid;
+ ORDER BY unix_uid;
EXEC SQL OPEN k_cursor2;
while (1) {
if (sqlca.sqlcode) break;
sqlerr()
{
- com_err(whoami, MR_INGRES_ERR, " code %d\n", sqlca.sqlcode);
- exit(MR_INGRES_ERR);
+ char buf[256];
+ int size=256, len=0;
+
+ sqlglm(buf, &size, &len);
+ buf[len]='\0';
+ com_err(whoami, MR_DBMS_ERR, " code %d\n%s", sqlca.sqlcode, buf);
+ exit(MR_DBMS_ERR);
}