-/*
- * $Source$
- * $Author$
- * $Header$
- *
- * Copyright (C) 1987 by the Massachusetts Institute of Technology
- *
- * Server for user registration with SMS and Kerberos.
- *
- * This file contains all the information needed by all source
- * files for the user registration server.
- */
-
-#include <stdio.h>
-#include <strings.h>
-#include <ctype.h>
-#include <sys/types.h>
-#include <sys/file.h>
-#include <krb.h>
+#include <sys/time.h>
#include <des.h>
-#include <errno.h>
-#include "ureg_err.h"
-#include "ureg_proto.h"
-#include "sms.h"
-#include "sms_app.h"
-#include "infodefs.h"
-
-#ifndef TRUE
-#define TRUE 1
-#endif
-
-#ifndef FALSE
-#define FALSE 0
-#endif
-#define FAIL_INST "reg_svr" /* Instance for failure zephyrgrams */
+typedef struct reg_client {
+ int fd; /* socket */
+ int clientid; /* client id */
+ unsigned char *buf; /* buffer for data read */
+ int nread, nmax; /* # of bytes cur/max in buffer */
+ time_t lastmod; /* last time we sent/received */
+ int encrypted; /* set if sched is valid */
+ des_key_schedule sched; /* DES key schedule */
+ long uid; /* uid of user. set by RIFO */
+ char *id; /* stored MIT ID if "six words" are
+ needed. NULL otherwise. Set by
+ RIFO, cleared by SWRD */
+ char *suggestions; /* suggested usernames */
+ char *username; /* desired username. set by LOGN */
+ int reserved_username; /* if username wasn't picked by user */
+ unsigned short *random; /* random state */
+ int user_status; /* Status of account */
+} reg_client;
-#define CUR_UREG_VERSION 1 /* Version for the register protocol */
-#define SUCCESS 0 /* General purpose success code */
-#define FAILURE 1 /* To use when any non-zero number will work */
-#define min(a,b) ((a)>(b)?(b):(a))
-#define MIN_UNAME 3 /* Username must be between three and */
-#define MAX_UNAME 8 /* eight characters long. */
-#define CRYPT_LEN 14 /* crypt() returns a 13 char string */
-#define LOGIN_LEN MAX_UNAME + 1 /* Leave room for a null */
-#define UID_LEN 7 /* Allow room for a 16 bit number */
+void RIFO(reg_client *rc, int argc, char **argv);
+void SWRD(reg_client *rc, int argc, char **argv);
+void SPIN(reg_client *rc, int argc, char **argv);
+void CLGN(reg_client *rc, int argc, char **argv);
+void LOGN(reg_client *rc, int argc, char **argv);
+void PSWD(reg_client *rc, int argc, char **argv);
+void QUIT(reg_client *rc, int argc, char **argv);
-#define DEBUG
+#define REG_SVR_PRINCIPAL "sms"
+#define REG_SVR_INSTANCE ""
-extern char *strdup();
-extern char *malloc();
+#define REG_SVR_RSA_KEY "/moira/reg_svr/rsa_key"
+#define REG_SVR_HMAC_KEY "/moira/reg_svr/hmac_key"
-extern char *whoami; /* Name of program - used by libraries */
-extern int errno; /* Unix error number */
+#define REG_SVR_ERROR_MESSAGES "/moira/reg_svr/errors"
+enum { NO_MESSAGE, INTERNAL_ERROR, PROTOCOL_ERROR, DATABASE_CLOSED,
+ ENCRYPT_KEY, NOT_FOUND_IN_DATABASE, ALREADY_REGISTERED,
+ ACCOUNT_DELETED, NOT_ELIGIBLE, FOUND, FORCED_USERNAME,
+ BAD_SIX_WORDS, BAD_USERNAME, USERNAME_UNAVAILABLE,
+ RESERVED_USERNAME_UNAVAILABLE, USERNAME_OK, PASSWORD_SHORT,
+ PASSWORD_SIMPLE, PASSWORD_SAMPLE, KADM_ERROR, DONE, BAD_PIN,
+ USERNAME_AVAILABLE, NUM_REG_ERRORS };
-/* This structure holds information from the SMS database that will be
- worth holding on to. An instance of it appears in the formatted
- packet structure. */
-struct db_data
-{
- char mit_id[CRYPT_LEN]; /* Encrypted MIT ID */
- int reg_status; /* Registration status */
- char uid[UID_LEN]; /* Reserved uid */
- char login[LOGIN_LEN]; /* Login (username) */
-};
+#define TIMEOUT 300 /* 5 minutes */
-/* This structure stores information sent over in the packet in a
- more convenient format and also stores some information obtained
- from the database that will be needed for each transaction. It
- initialized from format_pkt() and find_user(). */
-struct msg
-{
- U_32BIT version; /* User registration protocol version */
- U_32BIT request; /* Request */
- char *first; /* First name */
- char *last; /* Last name */
- char *encrypted; /* Encrypted information in packet */
- int encrypted_len; /* Length of encrypted information in packet */
- char *leftover; /* Leftover information sent in the packet */
- int leftover_len; /* Length of leftover information */
- struct db_data db; /* Information from the SMS database */
-};
+#define REG_RSA_ENCRYPTED_KEY 0x43
+#define REG_ENCRYPTED 0x45
+#define REG_UNENCRYPTED 0x50
-void failure_alert(); /* Log an unexplainable failure */
-int parse_pkt(); /* Parse a packet from the client */
-int format_pkt(); /* Prepare a packet to send to client*/
-int verify_user(); /* Make sure user is allowed to register */
-int reserve_user(); /* Reserve a login for this user */
-int set_password(); /* Set this user's password */
+/* Prototypes from kerberos.c */
+long init_kerberos(void);
+long check_kerberos(char *username);
+long register_kerberos(char *username, char *password);
+/* Prototypes from procotol.c */
+int read_rsa_key(void);
+int read_errors(void);
+void reply(reg_client *rc, int msg, char *state, char *clean, char *data,
+ ...);
+void parse_packet(reg_client *rc, int type, long len, char *buf, int sleeping);
-/* For logging successful database transactions */
-#define JOURNAL "/u1/sms/journal.reg"
-extern FILE *journal;
+/* prototypes from reg_svr.pc */
+void *xmalloc(size_t);
+void *xrealloc(void *, size_t);
+char *xstrdup(char *);
+/* Prototypes from words.c */
+int read_hmac_key(void);
+unsigned short *init_rand(void *);
+void getwordlist(char *input, char *words[]);