#include "f_defs.h"
#include "globals.h"
-#include <sys/time.h>
-
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
-#include <krb.h>
-#ifdef HAVE_GDSS
-#include <gdss.h>
-#endif
-
RCSID("$Header$");
void CorrectCapitalization(char **name);
char **AskUserInfo(char **info, Bool name);
struct mqelem *GetUserInfo(int type, char *name1, char *name2);
+static void PrintLogin(char **info);
+struct mqelem *GetUserBySponsor(char *type, char *name);
#define LOGIN 0
#define UID 1
#define ID 4
#ifdef ATHENA
-#define DEFAULT_SHELL "/bin/athena/tcsh"
+#define DEFAULT_SHELL "/bin/athena/bash"
#else
-#define DEFAULT_SHELL "/bin/csh"
+#define DEFAULT_SHELL "/bin/bash"
#endif
#define DEFAULT_CLASS "?"
+#define DEFAULT_WINCONSOLESHELL "cmd"
+#define DEFAULT_WINHOMEDIR "[DFS]"
+#define DEFAULT_WINPROFILEDIR "[DFS]"
/* Function Name: UserState
* Description: Convert a numeric state into a descriptive string.
"Not registerable (4)",
"Enrolled/Registerable (5)",
"Enrolled/Not Registerable (6)",
- "Half Enrolled (7)"
+ "Half Enrolled (7)",
+ "Registerable, Kerberos only (8)",
+ "Active, Kerberos only (9)"
};
static char *UserState(int state)
static void PrintUserInfo(char **info)
{
- char name[BUFSIZ], buf[BUFSIZ];
+ char name[BUFSIZ], buf[BUFSIZ], sponsor[BUFSIZ];
int status;
-#ifdef HAVE_GDSS
- SigInfo si;
-#endif
sprintf(name, "%s, %s %s", info[U_LAST], info[U_FIRST], info[U_MIDDLE]);
sprintf(buf, "Login name: %-20s Full name: %s", info[U_NAME], name);
Put_message(buf);
- sprintf(buf, "User id: %-23s Login shell %-10s Class: %s",
- info[U_UID], info[U_SHELL], info[U_CLASS]);
+ sprintf(buf, "User id: %-23s Login shell: %-10s",
+ info[U_UID], info[U_SHELL]);
Put_message(buf);
-
-#ifdef HAVE_GDSS
- sprintf(buf, "%s:%s", info[U_NAME], info[U_MITID]);
- si.rawsig = NULL;
- status = GDSS_Verify(buf, strlen(buf), info[U_SIGNATURE], &si);
-#else /* GDSS */
- status = 0;
-#endif /* GDSS */
-
- sprintf(buf, "Account is: %-20s MIT ID number: %s Signed: %s",
- UserState(atoi(info[U_STATE])), info[U_MITID],
- *info[U_SIGNATURE] ? (status ? "Bad" : "Yes") : "No");
+ sprintf(buf, "Class: %-25s Windows Console Shell: %-10s",
+ info[U_CLASS], info[U_WINCONSOLESHELL]);
Put_message(buf);
- if (atoi(info[U_SECURE]))
- sprintf(buf, "Secure password set on %s.", atot(info[U_SECURE]));
- else
- sprintf(buf, "No secure password set.");
+ sprintf(sponsor, "%s %s", info[U_SPONSOR_TYPE], info[U_SPONSOR_NAME]);
+ sprintf(buf, "Sponsor: %-23s Expiration date: %s", sponsor, info[U_EXPIRATION]);
Put_message(buf);
+ sprintf(buf, "Account is: %-20s MIT ID number: %s",
+ UserState(atoi(info[U_STATE])), info[U_MITID]);
+ Put_message(buf);
+ sprintf(buf, "Windows Home Directory: %s", info[U_WINHOMEDIR]);
+ Put_message(buf);
+ sprintf(buf, "Windows Profile Directory: %s", info[U_WINPROFILEDIR]);
+ Put_message(buf);
+ status = atoi(info[U_STATE]);
+ if (status == 0 || status == 2)
+ {
+ sprintf(buf, "User %s secure Account Coupon to register",
+ atoi(info[U_SECURE]) ? "needs" : "does not need");
+ Put_message(buf);
+ }
sprintf(buf, "Comments: %s", info[U_COMMENT]);
Put_message(buf);
+ sprintf(buf, "Created by %s on %s.", info[U_CREATOR], info[U_CREATED]);
+ Put_message(buf);
sprintf(buf, MOD_FORMAT, info[U_MODBY], info[U_MODTIME], info[U_MODWITH]);
Put_message(buf);
}
info[U_NAME] = strdup(UNIQUE_LOGIN);
info[U_UID] = strdup(UNIQUE_UID);
info[U_SHELL] = strdup(DEFAULT_SHELL);
+ info[U_WINCONSOLESHELL] = strdup(DEFAULT_WINCONSOLESHELL);
info[U_LAST] = strdup(DEFAULT_NONE);
info[U_FIRST] = strdup(DEFAULT_NONE);
info[U_MIDDLE] = strdup(DEFAULT_NONE);
info[U_COMMENT] = strdup("");
info[U_SIGNATURE] = strdup("");
info[U_SECURE] = strdup("0");
+ info[U_WINHOMEDIR] = strdup(DEFAULT_WINHOMEDIR);
+ info[U_WINPROFILEDIR] = strdup(DEFAULT_WINPROFILEDIR);
+ info[U_SPONSOR_TYPE] = strdup("NONE");
+ info[U_SPONSOR_NAME] = strdup("NONE");
+ info[U_EXPIRATION] = strdup("");
info[U_MODTIME] = info[U_MODBY] = info[U_MODWITH] = info[U_END] = NULL;
+ info[U_CREATED] = info[U_CREATOR] = NULL;
return info;
}
{
Put_message("You entered a name which does not follow the capitalization conventions.");
sprintf(temp_buf, "Correct it to \"%s\"", fixname);
- if (YesNoQuestion(temp_buf, 1) == TRUE)
+ if (YesNoQuestion(temp_buf, 0) == TRUE)
{
free(*name);
*name = strdup(fixname);
char **AskUserInfo(char **info, Bool name)
{
- int i;
-#ifdef HAVE_GDSS
- SigInfo si;
-#endif
+ int state;
char temp_buf[BUFSIZ], *newname;
if (name)
SUB_ERROR)
return NULL;
+ strcpy(temp_buf, info[U_UID]);
if (GetValueFromUser("User's UID", &info[U_UID]) == SUB_ERROR)
return NULL;
+ if (strcmp(info[U_UID], UNIQUE_UID) && strcmp(info[U_UID], temp_buf))
+ {
+ struct mqelem *elem = NULL;
+ if (do_mr_query("get_user_account_by_uid", 1, &info[U_UID],
+ StoreInfo, &elem) == MR_SUCCESS)
+ {
+ Put_message("A user with that uid already exists in the database.");
+ Loop(QueueTop(elem), PrintUserInfo);
+ Loop(QueueTop(elem), FreeInfo);
+ FreeQueue(elem);
+ if (YesNoQuestion("Add new user anyway", TRUE) != TRUE)
+ return NULL;
+ }
+ }
+
if (GetValueFromUser("User's shell", &info[U_SHELL]) == SUB_ERROR)
return NULL;
+ if (GetValueFromUser("Windows console shell", &info[U_WINCONSOLESHELL])
+ == SUB_ERROR)
+ return NULL;
if (name)
{
if (GetValueFromUser("User's last name", &info[U_LAST]) == SUB_ERROR)
if (GetValueFromUser("Comments", &info[U_COMMENT]) == SUB_ERROR)
return NULL;
- if (YesNoQuestion("Secure password set",
- atoi(info[U_SECURE]) ? TRUE : FALSE) == FALSE)
- {
- free(info[U_SECURE]);
- info[U_SECURE] = strdup("0");
- }
- else if (!strcmp(info[U_SECURE], "0"))
- {
- char buf[16];
- struct timeval tv;
+ if (GetValueFromUser("Windows Home Directory", &info[U_WINHOMEDIR]) ==
+ SUB_ERROR)
+ return NULL;
- gettimeofday(&tv, NULL);
- sprintf(buf, "%ld", (long) tv.tv_sec);
- free(info[U_SECURE]);
- info[U_SECURE] = strdup(buf);
- }
+ if (GetValueFromUser("Windows Profile Directory", &info[U_WINPROFILEDIR]) ==
+ SUB_ERROR)
+ return NULL;
+
+ if (GetTypeFromUser("User's sponsor type", "ace_type", &info[U_SPONSOR_TYPE])
+ == SUB_ERROR)
+ return NULL;
+ if (strcmp(info[U_SPONSOR_TYPE], "NONE") &&
+ GetValueFromUser("Sponsor's Name", &info[U_SPONSOR_NAME]) == SUB_ERROR)
+ return NULL;
+
+ if (GetValueFromUser("Expiration date", &info[U_EXPIRATION]) == SUB_ERROR)
+ return NULL;
- /* Sign record */
-#ifdef HAVE_GDSS
- if (strcmp(info[U_NAME], UNIQUE_LOGIN))
+ state = atoi(info[U_STATE]);
+ if (!name || state == 0 || state == 2)
{
- if (name)
- sprintf(temp_buf, "%s:%s", newname, info[U_MITID]);
+ if (YesNoQuestion("User needs secure Account Coupon to register",
+ atoi(info[U_SECURE]) ? TRUE : FALSE) == FALSE)
+ {
+ free(info[U_SECURE]);
+ info[U_SECURE] = strdup("0");
+ }
else
- sprintf(temp_buf, "%s:%s", info[U_NAME], info[U_MITID]);
- si.rawsig = NULL;
- i = GDSS_Verify(temp_buf, strlen(temp_buf), info[U_SIGNATURE], &si);
- /* If it's already signed OK, don't resign it. */
- if (i != GDSS_SUCCESS)
{
- free(info[U_SIGNATURE]);
- info[U_SIGNATURE] = malloc(GDSS_Sig_Size() * 2);
- sign_again:
- i = GDSS_Sign(temp_buf, strlen(temp_buf), info[U_SIGNATURE]);
- if (i != GDSS_SUCCESS)
- com_err(program_name, gdss2et(i), "Failed to create signature");
- else
- {
- unsigned char buf[256];
- si.rawsig = buf;
- i = GDSS_Verify(temp_buf, strlen(temp_buf),
- info[U_SIGNATURE], &si);
- if (strlen(buf) > 68)
- goto sign_again;
- }
+ free(info[U_SECURE]);
+ info[U_SECURE] = strdup("1");
}
}
-#else /* GDSS */
+
info[U_SIGNATURE] = strdup("");
-#endif /* GDSS */
FreeAndClear(&info[U_MODTIME], TRUE);
FreeAndClear(&info[U_MODBY], TRUE);
static void GiveBackLogin(char *name)
{
name = name; /* make saber happy. */
- Put_message("kerberos code not implimented, name not given back.");
+ Put_message("kerberos code not implemented, name not given back.");
/* send mail to db maintainer if this fails. */
}
int RegisterUser(int argc, char **argv)
{
char *args[MAX_ARGS_SIZE];
- char *login, *fstype = NULL;
+ char *login, *potype = NULL;
char temp_buf[BUFSIZ];
- int status;
+ int status, i;
+
+ for (i = 0; i < MAX_ARGS_SIZE; i++)
+ args[i] = NULL;
Put_message("This function has NO kerberos support, so strange things");
Put_message("may happen if you use it to register a user.");
sprintf(temp_buf, "u%s", args[0]);
login = strdup(temp_buf);
- if ((GetValueFromUser("Login name for this user? ", &login) == SUB_ERROR) ||
- (GetFSTypes(&fstype, FALSE) == SUB_ERROR))
+ if (GetValueFromUser("Login name for this user? ", &login) == SUB_ERROR)
{
args[1] = login;
FreeInfo(args); /* This work because the NULL temination is ok. */
}
Put_message("KERBEROS code not added, did not reserve name with kerberos.");
args[1] = login;
- args[2] = fstype;
+
+ sprintf(temp_buf, "IMAP");
+ potype = strdup(temp_buf);
+ if (GetValueFromUser("P.O. Box Type for this user? ", &potype) == SUB_ERROR)
+ {
+ args[2] = potype;
+ FreeInfo(args);
+ return DM_NORMAL;
+ }
+ if (strcmp(potype, "POP") && strcmp(potype, "IMAP") && strcmp(potype, "EXCHANGE"))
+ {
+ sprintf(temp_buf, "Unknown P.O. Box type.");
+ Put_message(temp_buf);
+ FreeInfo(args);
+ return DM_NORMAL;
+ }
+ args[2] = potype;
args[3] = NULL;
switch ((status = do_mr_query("register_user", CountArgs(args),
FreeAndClear(&args[L_MODTIME], TRUE);
FreeAndClear(&args[L_MODBY], TRUE);
FreeAndClear(&args[L_MODWITH], TRUE);
- SlipInNewName(args, args[L_NAME]);
+ SlipInNewName(args, strdup(args[L_NAME]));
if ((status = do_mr_query("update_list", CountArgs(args), args,
NULL, NULL)))
{
{
com_err(program_name, status, " getting filsys info, "
"not deactivating filesystem");
- FreeInfo(args);
- FreeQueue(elem);
return;
}
args = QueueTop(elem)->q_data;
FreeAndClear(&args[FS_MODTIME], TRUE);
FreeAndClear(&args[FS_MODBY], TRUE);
FreeAndClear(&args[FS_MODWITH], TRUE);
- SlipInNewName(args, args[FS_NAME]);
+ SlipInNewName(args, strdup(args[FS_NAME]));
if ((status = do_mr_query("update_filesys", CountArgs(args), args,
NULL, NULL)))
{
return DM_NORMAL;
}
-
-/* Function Name: GetDirFlags
- * Description: Shows MITdir listing preferences
- * Arguments: argc, argv - argv[1] contains the user login name
- * Returns: none.
- */
-
-int GetDirFlags(int argc, char **argv)
+int GetUserReservations(int argc, char **argv)
{
int stat;
- struct mqelem *elem = NULL;
- char buf[BUFSIZ], **info;
-
- if (!ValidName(argv[1]))
- return DM_NORMAL;
+ struct mqelem *elem = NULL, *top;
+ char buf[BUFSIZ];
- if ((stat = do_mr_query("get_user_directory_flags", 1, &argv[1],
+ if ((stat = do_mr_query("get_user_reservations", 1, &argv[1],
StoreInfo, &elem)))
{
- com_err(program_name, stat, " in GetDirFlags.");
+ com_err(program_name, stat, " in GetUserReservations.");
return DM_NORMAL;
}
- info = QueueTop(elem)->q_data;
- FreeQueue(QueueTop(elem));
-
+ top = elem = QueueTop(elem);
Put_message("");
- sprintf(buf, "User: %s", argv[1]);
- Put_message(buf);
- if (atoi(info[0]) == 0)
- Put_message("Does NOT appear in the on-line directory.");
- else
+ if (!elem)
+ Put_message("No reservations for that user.");
+ while (elem)
{
- Put_message("Does appear in the on-line directory.");
- if (atoi(info[1]) == 0)
- Put_message("Is listed with non-MIT.EDU email address (if any)");
- else
- Put_message("Is listed with MIT.EDU email address.");
+ char **info = elem->q_data;
+ sprintf(buf, "Reservation: %s", info[0]);
+ Put_message(buf);
+ elem = elem->q_forw;
+ }
+
+ FreeQueue(QueueTop(top));
+ return DM_NORMAL;
+}
+
+int AddUserReservation(int argc, char **argv)
+{
+ int stat;
+ char buf[BUFSIZ];
+
+ switch (stat = do_mr_query("add_user_reservation", 2, &argv[1],
+ NULL, NULL))
+ {
+ case MR_SUCCESS:
+ break;
+ case MR_STRING:
+ sprintf(buf, "The reservation %s is not valid.", argv[2]);
+ Put_message(buf);
+ PrintReservationTypes();
+ break;
+ default:
+ com_err(program_name, stat, " in AddUserReservation.");
+ break;
}
+
+ return DM_NORMAL;
+}
+
+int DelUserReservation(int argc, char **argv)
+{
+ int stat;
+ char buf[BUFSIZ];
+ switch (stat = do_mr_query("delete_user_reservation", 2, &argv[1],
+ NULL, NULL))
+ {
+ case MR_SUCCESS:
+ break;
+ case MR_STRING:
+ sprintf(buf, "The reservation %s is not valid.", argv[2]);
+ Put_message(buf);
+ PrintReservationTypes();
+ break;
+ default:
+ com_err(program_name, stat, " in DelUserReservation.");
+ break;
+ }
+
return DM_NORMAL;
}
-/* Function Name: SetDirFlags
- * Description: Update online directory preferences
- * Arguments: argc, argv - the login name of the user in argv[1].
- * Returns: DM_NORMAL.
- */
+int GetUserByReservation(int argc, char **argv)
+{
+ int stat;
+ struct mqelem *elem = NULL, *top;
+ char buf[BUFSIZ];
-int SetDirFlags(int argc, char **argv)
+ switch (stat = do_mr_query("get_user_by_reservation", 1, &argv[1],
+ StoreInfo, &elem))
+ {
+ case MR_SUCCESS:
+ break;
+ case MR_STRING:
+ sprintf(buf, "The reservation %s is not valid.", argv[1]);
+ Put_message(buf);
+ PrintReservationTypes();
+ return DM_NORMAL;
+ default:
+ com_err(program_name, stat, " in GetUserByReservation.");
+ return DM_NORMAL;
+ }
+
+ top = elem = QueueTop(elem);
+ Put_message("");
+ while (elem)
+ {
+ char **info = elem->q_data;
+ sprintf(buf, "User: %s", info[0]);
+ Put_message(buf);
+ elem = elem->q_forw;
+ }
+
+ FreeQueue(QueueTop(top));
+ return DM_NORMAL;
+}
+
+void PrintReservationTypes(void)
{
int stat;
- char **info, buf[BUFSIZ], *args[3];
- struct mqelem *elem = NULL;
+ struct mqelem *elem = NULL, *top;
+ char buf[BUFSIZ];
+ char *qargs[2];
- if (!ValidName(argv[1]))
+ Put_message("Valid types of reservations are: ");
+ Put_message("");
+ qargs[0] = "*";
+ qargs[1] = "RESERVE";
+ qargs[2] = "*";
+ if ((stat = do_mr_query("get_alias", 3, &qargs[0],
+ StoreInfo, &elem)))
+ {
+ com_err(program_name, stat, "in PrintReservationTypes.");
+ }
+ top = elem = QueueTop(elem);
+ while (elem)
+ {
+ char **info = elem->q_data;
+ sprintf(buf, "%s", info[2]);
+ Put_message(buf);
+ elem = elem->q_forw;
+ }
+
+ FreeQueue(QueueTop(top));
+}
+
+int UserBySponsor(int argc, char **argv)
+{
+ char buf[BUFSIZ], temp_buf[BUFSIZ], *type, *name;
+ struct mqelem *top;
+
+ type = strdup("USER");
+ if (GetTypeFromUser("Type of sponsor", "search_ace_type", &type) == SUB_ERROR)
return DM_NORMAL;
- /* Fetch current prefs */
- if ((stat = do_mr_query("get_user_directory_flags", 1, &argv[1],
- StoreInfo, &elem)))
+ sprintf(buf, "Name of %s", type);
+ name = strdup(user);
+ if (GetValueFromUser(buf, &name) == SUB_ERROR)
+ return DM_NORMAL;
+
+ switch (YesNoQuestion("Do you want a recursive search (y/n)", FALSE))
{
- com_err(program_name, stat, " in GetDirFlags.");
+ case TRUE:
+ sprintf(temp_buf, "R%s", type); /* "USER to "RUSER", etc. */
+ free(type);
+ type = strdup(temp_buf);
+ break;
+ case FALSE:
+ break;
+ default:
return DM_NORMAL;
}
- info = QueueTop(elem)->q_data;
- FreeQueue(QueueTop(elem));
- sprintf(buf, "List %s in the on-line directory (y/n)", argv[1]);
- if (YesNoQuestion(buf, !atoi(info[0])))
- args[1] = "0";
- else
- args[1] = "1";
+ top = GetUserBySponsor(type, name);
+ Loop(top, PrintLogin);
- sprintf(buf, "List MIT.EDU email address even when mail is "
- "forwarded elsewhere? (y/n)");
- if (YesNoQuestion(buf, !atoi(info[1])))
- args[2] = "0";
- else
- args[2] = "1";
+ FreeQueue(top);
+ return DM_NORMAL;
+}
- args[0] = argv[1];
- if ((stat = do_mr_query("update_user_directory_flags", 3,
- args, NULL, NULL)))
- com_err(program_name, stat, " in SetDirFlags");
- else
- Put_message("Directory preferences set.");
+static void PrintLogin(char **info)
+{
+ char buf[BUFSIZ];
- return DM_NORMAL;
+ sprintf(buf, "Login: %s", info[U_NAME]);
+ Put_message(buf);
+}
+
+struct mqelem *GetUserBySponsor(char *type, char *name)
+{
+ char *args[2];
+ struct mqelem *elem = NULL;
+ int status;
+
+ args[0] = type;
+ args[1] = name;
+ if ((status = do_mr_query("get_user_account_by_sponsor", 2, args, StoreInfo,
+ &elem)))
+ {
+ com_err(program_name, status, " in get_user_account_by_sponsor");
+ return NULL;
+ }
+ return QueueTop(elem);
}