3 * This generates a list of users and their MIT ID numbers and the
4 * signatures which guarentee this mapping.
6 * (c) Copyright 1992 by the Massachusetts Institute of Technology.
7 * For copying and distribution information, please see the file
11 #include <mit-copyright.h>
14 #include <moira_site.h>
18 #include <sys/types.h>
25 EXEC SQL INCLUDE sqlca;
28 char *whoami = "sis.gen";
29 char *db = "moira/moira";
35 int out = 1 /* stdout */;
36 char *outf = NULL, outft[64];
41 EXEC SQL BEGIN DECLARE SECTION;
42 char login[9], sig[257], id[17], kname[257];
43 EXEC SQL VAR sig IS STRING(257);
45 struct { char login[12];
49 EXEC SQL END DECLARE SECTION;
51 initialize_sms_error_table ();
56 if (stat(argv[1], &sb) == 0) {
57 if (ModDiff (&flag1, "users", sb.st_mtime) == 0 &&
59 fprintf(stderr, "File %s does not need to be rebuilt.\n",
65 sprintf(outft, "%s~", outf);
66 if ((out = open(outft, O_WRONLY|O_APPEND|O_CREAT|O_TRUNC, 0666)) < 0) {
67 fprintf(stderr, "unable to open %s for output\n", outf);
70 } else if (argc != 1) {
71 fprintf(stderr, "usage: %s [outfile]\n", argv[0]);
77 /* The following is declarative, not executed,
78 * and so is dependent on where it is in the file,
79 * not in the order of execution of statements.
81 EXEC SQL WHENEVER SQLERROR GOTO sqlerr;
83 EXEC SQL DECLARE x CURSOR FOR
84 SELECT u.login, u.clearid, u.signature, u.sigdate, s.string
85 FROM users u, strings s
86 WHERE u.status = 1 and u.sigwho = s.string_id and u.sigwho != 0
90 EXEC SQL FETCH x INTO :login, :id, :sig, :timestamp, :kname;
91 if (sqlca.sqlcode != 0) break;
92 if (id == 0) continue;
93 if (!isdigit(id[1])) continue;
97 memset(&outrec, 0, sizeof(outrec));
98 strcpy(outrec.login, login);
99 strcpy(outrec.id, id);
100 si.timestamp = timestamp;
101 si.SigInfoVersion = 0; /* XXXXXX this isn't used */
102 kname_parse(si.pname, si.pinst, si.prealm, kname);
103 si.rawsig = (unsigned char *)sig;
104 GDSS_Recompose(&si, outrec.sig);
105 write(out, &outrec, sizeof(outrec));
112 perror("close failed");
120 db_error(sqlca.sqlcode);