]>
Commit | Line | Data |
---|---|---|
0138e073 | 1 | /* $Header$ |
2 | * | |
3 | * This program will bulk sign user records in the database. | |
4 | */ | |
5 | ||
6 | #include <stdio.h> | |
7 | #include <strings.h> | |
8 | #include <ctype.h> | |
9 | #include <sys/time.h> | |
10 | #include <moira.h> | |
11 | #include <moira_site.h> | |
12 | #include <des.h> | |
13 | #include <krb.h> | |
14 | #include <krb_err.h> | |
15 | #include <gdss.h> | |
16 | ||
17 | ||
18 | char *program; | |
19 | ||
20 | main(argc, argv) | |
21 | int argc; | |
22 | char **argv; | |
23 | ##{ | |
24 | char buf[BUFSIZ], *data, *p; | |
25 | struct save_queue *sq; | |
26 | SigInfo si; | |
27 | int found, status, i, wait; | |
28 | ## char login[10], mid[32], rawsig[256]; | |
29 | ## int id, timestamp, sms; | |
30 | ||
31 | program = "sign"; | |
32 | init_krb_err_tbl(); | |
33 | init_sms_err_tbl(); | |
34 | ||
35 | for (i = 1; i < argc; i++) { | |
36 | if (!strcmp(argv[i], "-w")) | |
37 | wait++; | |
38 | else if (!strcmp(argv[i], "-D")) | |
39 | setenv("ING_SET", "set printqry"); | |
40 | else | |
41 | fprintf(stderr, "Usage: %s [-w] [-D]\n", argv[0]); | |
42 | } | |
43 | ||
44 | /* Set the name of our kerberos ticket file */ | |
45 | krb_set_tkt_string("/tmp/tkt_sign"); | |
46 | status = 1; | |
47 | while (status) { | |
48 | printf("Authenticating as moira.extra:\n"); | |
49 | status = krb_get_pw_in_tkt("moira", "extra", "ATHENA.MIT.EDU", | |
50 | "krbtgt", "ATHENA.MIT.EDU", | |
51 | DEFAULT_TKT_LIFE, 0); | |
52 | if (status != 0) | |
53 | com_err(program, status + krb_err_base, " in krb_get_pw_in_tkt"); | |
54 | } | |
55 | ||
56 | ## ingres #sms | |
57 | ## range of u is users | |
58 | ## range of s is strings | |
59 | ||
60 | sms = 0; | |
61 | ## retrieve (sms = s.string_id) where s.string="moira.extra@ATHENA.MIT.EDU" | |
62 | if (sms == 0) { | |
63 | com_err(program, 0, " failed to find string moira.extra@ATHENA.MIT.EDU in database"); | |
64 | dest_tkt(); | |
65 | exit(1); | |
66 | } | |
67 | ||
68 | found = 0; | |
69 | sq = sq_create(); | |
70 | ||
71 | ## retrieve (id = u.users_id, login = u.#login, mid = u.mit_id) | |
72 | ## where u.signature = "" and u.xmodtime > date("01-jul-92") { | |
73 | if (login[0] == '#' || !isdigit(mid[0])) | |
74 | continue; | |
75 | sprintf(buf, "%d:%s:%s", id, strtrim(login), strtrim(mid)); | |
76 | sq_save_data(sq, strsave(buf)); | |
77 | found++; | |
78 | ## } | |
79 | ||
80 | printf("Found %d users to sign.\n", found); | |
81 | ||
82 | si.rawsig = (unsigned char *) &rawsig[0]; | |
83 | ||
84 | while (sq_get_data(sq, &data)) { | |
85 | p = index(data, ':'); | |
86 | if (!p) { | |
87 | com_err(program, 0, " malformatted data"); | |
88 | continue; | |
89 | } | |
90 | *p++ = 0; | |
91 | id = atoi(data); | |
92 | data = p; | |
93 | status = GDSS_Sign(data, strlen(data), buf); | |
94 | if (status) { | |
95 | com_err(program, gdss2et(status), "signing data"); | |
96 | continue; | |
97 | } | |
98 | status = GDSS_Verify(data, strlen(data), buf, &si); | |
99 | if (status) { | |
100 | com_err(program, gdss2et(status), "verifying data"); | |
101 | continue; | |
102 | } | |
103 | ||
104 | timestamp = si.timestamp; | |
105 | ## replace u (signature = rawsig, sigwho = sms, sigdate = timestamp) | |
106 | ## where u.users_id = id | |
107 | if (wait) { | |
108 | printf("Next"); | |
109 | fflush(stdout); | |
110 | gets(buf); | |
111 | } | |
112 | } | |
113 | dest_tkt(); | |
114 | ## exit | |
115 | exit(0); | |
116 | ##} |