]>
Commit | Line | Data |
---|---|---|
3fb06882 | 1 | /* $Header$ |
2 | * | |
3 | * This program will bulk resign 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, moira; | |
30 | ||
31 | program = "resign"; | |
32 | init_krb_err_tbl(); | |
33 | init_sms_err_tbl(); | |
34 | ||
35 | /* Set the name of our kerberos ticket file */ | |
36 | krb_set_tkt_string("/tmp/tkt_sign"); | |
37 | status = 1; | |
38 | while (status) { | |
39 | printf("Authenticating as moira.extra:\n"); | |
40 | status = krb_get_pw_in_tkt("moira", "extra", "ATHENA.MIT.EDU", | |
41 | "krbtgt", "ATHENA.MIT.EDU", | |
42 | DEFAULT_TKT_LIFE, 0); | |
43 | if (status != 0) | |
44 | com_err(program, status + krb_err_base, " in krb_get_pw_in_tkt"); | |
45 | } | |
46 | ||
47 | for (i = 1; i < argc; i++) { | |
48 | if (!strcmp(argv[i], "-w")) | |
49 | wait++; | |
50 | else if (!strcmp(argv[i], "-D")) | |
51 | setenv("ING_SET", "set printqry"); | |
52 | else | |
53 | fprintf(stderr, "Usage: %s [-w] [-D]\n", argv[0]); | |
54 | } | |
55 | ||
56 | ||
57 | ## ingres #sms | |
58 | ## range of u is users | |
59 | ## range of s is strings | |
60 | ||
61 | sms = 0; | |
62 | ## retrieve (sms = s.string_id) where s.string="sms@ATHENA.MIT.EDU" | |
63 | if (sms == 0) { | |
64 | com_err(program, 0, " failed to find string sms@ATHENA.MIT.EDU in database"); | |
65 | dest_tkt(); | |
66 | exit(1); | |
67 | } | |
68 | moira = 0; | |
69 | ## retrieve (moira = s.string_id) where s.string="moira.extra@ATHENA.MIT.EDU" | |
70 | if (moira == 0) { | |
71 | com_err(program, 0, " failed to find string moira.extra@ATHENA.MIT.EDU in database"); | |
72 | dest_tkt(); | |
73 | exit(1); | |
74 | } | |
75 | ||
76 | found = 0; | |
77 | sq = sq_create(); | |
78 | ||
79 | ## retrieve (id = u.users_id, login = u.#login, mid = u.mit_id) | |
80 | ## where u.sigwho = sms { | |
81 | sprintf(buf, "%d:%s:%s", id, strtrim(login), strtrim(mid)); | |
82 | sq_save_data(sq, strsave(buf)); | |
83 | found++; | |
84 | ## } | |
85 | ||
86 | printf("Found %d users to resign.\n", found); | |
87 | ||
88 | si.rawsig = (unsigned char *) &rawsig[0]; | |
89 | ||
90 | while (sq_get_data(sq, &data)) { | |
91 | p = index(data, ':'); | |
92 | if (!p) { | |
93 | com_err(program, 0, " malformatted data"); | |
94 | continue; | |
95 | } | |
96 | *p++ = 0; | |
97 | id = atoi(data); | |
98 | data = p; | |
99 | status = GDSS_Sign(data, strlen(data), buf); | |
100 | if (status) { | |
101 | com_err(program, gdss2et(status), "resigning data"); | |
102 | continue; | |
103 | } | |
104 | status = GDSS_Verify(data, strlen(data), buf, &si); | |
105 | if (status) { | |
106 | com_err(program, gdss2et(status), "verifying data"); | |
107 | continue; | |
108 | } | |
109 | ||
110 | timestamp = si.timestamp; | |
111 | ## replace u (signature = rawsig, sigwho = moira, sigdate = timestamp) | |
112 | ## where u.users_id = id | |
113 | if (wait) { | |
114 | printf("Next"); | |
115 | fflush(stdout); | |
116 | gets(buf); | |
117 | } | |
118 | } | |
119 | ## exit | |
120 | dest_tkt(); | |
121 | exit(0); | |
122 | ##} |