1 | #include <sys/time.h> |
---|
2 | #include <openssl/des.h> |
---|
3 | |
---|
4 | typedef struct reg_client { |
---|
5 | int fd; /* socket */ |
---|
6 | int clientid; /* client id */ |
---|
7 | unsigned char *buf; /* buffer for data read */ |
---|
8 | int nread, nmax; /* # of bytes cur/max in buffer */ |
---|
9 | time_t lastmod; /* last time we sent/received */ |
---|
10 | int encrypted; /* set if sched is valid */ |
---|
11 | des_key_schedule sched; /* DES key schedule */ |
---|
12 | long uid; /* uid of user. set by RIFO */ |
---|
13 | char *id; /* stored MIT ID if "six words" are |
---|
14 | needed. NULL otherwise. Set by |
---|
15 | RIFO, cleared by SWRD */ |
---|
16 | char *suggestions; /* suggested usernames */ |
---|
17 | char *username; /* desired username. set by LOGN */ |
---|
18 | int reserved_username; /* if username wasn't picked by user */ |
---|
19 | unsigned short *random; /* random state */ |
---|
20 | int user_status; /* Status of account */ |
---|
21 | } reg_client; |
---|
22 | |
---|
23 | void RIFO(reg_client *rc, int argc, char **argv); |
---|
24 | void SWRD(reg_client *rc, int argc, char **argv); |
---|
25 | void SPIN(reg_client *rc, int argc, char **argv); |
---|
26 | void CLGN(reg_client *rc, int argc, char **argv); |
---|
27 | void LOGN(reg_client *rc, int argc, char **argv); |
---|
28 | void PSWD(reg_client *rc, int argc, char **argv); |
---|
29 | void QUIT(reg_client *rc, int argc, char **argv); |
---|
30 | |
---|
31 | #define REG_SVR_PRINCIPAL "sms" |
---|
32 | #define REG_SVR_INSTANCE "" |
---|
33 | |
---|
34 | #define REG_SVR_RSA_KEY "/moira/reg_svr/rsa_key" |
---|
35 | #define REG_SVR_HMAC_KEY "/moira/reg_svr/hmac_key" |
---|
36 | |
---|
37 | #define REG_SVR_ERROR_MESSAGES "/moira/reg_svr/errors" |
---|
38 | enum { NO_MESSAGE, INTERNAL_ERROR, PROTOCOL_ERROR, DATABASE_CLOSED, |
---|
39 | ENCRYPT_KEY, NOT_FOUND_IN_DATABASE, ALREADY_REGISTERED, |
---|
40 | ACCOUNT_DELETED, NOT_ELIGIBLE, FOUND, FORCED_USERNAME, |
---|
41 | BAD_SIX_WORDS, BAD_USERNAME, USERNAME_UNAVAILABLE, |
---|
42 | RESERVED_USERNAME_UNAVAILABLE, USERNAME_OK, PASSWORD_SHORT, |
---|
43 | PASSWORD_SIMPLE, PASSWORD_SAMPLE, KADM_ERROR, DONE, BAD_PIN, |
---|
44 | USERNAME_AVAILABLE, NUM_REG_ERRORS }; |
---|
45 | |
---|
46 | #define TIMEOUT 300 /* 5 minutes */ |
---|
47 | |
---|
48 | #define REG_RSA_ENCRYPTED_KEY 0x43 |
---|
49 | #define REG_ENCRYPTED 0x45 |
---|
50 | #define REG_UNENCRYPTED 0x50 |
---|
51 | |
---|
52 | /* Prototypes from kerberos.c */ |
---|
53 | long init_kerberos(void); |
---|
54 | long check_kerberos(char *username); |
---|
55 | long register_kerberos(char *username, char *password); |
---|
56 | |
---|
57 | /* Prototypes from procotol.c */ |
---|
58 | int read_rsa_key(void); |
---|
59 | int read_errors(void); |
---|
60 | void reply(reg_client *rc, int msg, char *state, char *clean, char *data, |
---|
61 | ...); |
---|
62 | void parse_packet(reg_client *rc, int type, int len, char *buf, int sleeping); |
---|
63 | |
---|
64 | /* prototypes from reg_svr.pc */ |
---|
65 | void *xmalloc(size_t); |
---|
66 | void *xrealloc(void *, size_t); |
---|
67 | char *xstrdup(char *); |
---|
68 | |
---|
69 | /* Prototypes from words.c */ |
---|
70 | int read_hmac_key(void); |
---|
71 | unsigned short *init_rand(void *); |
---|
72 | void getwordlist(char *input, char *words[]); |
---|