-/* $Id $
+/* $Id$
*
* This is the file user.c for the Moira Client, which allows users
* to quickly and easily maintain most parts of the Moira database.
#include <stdlib.h>
#include <string.h>
#include <time.h>
-#ifdef GDSS
+
+#include <krb.h>
+#ifdef HAVE_GDSS
#include <gdss.h>
#endif
{
char name[BUFSIZ], buf[BUFSIZ];
int status;
-#ifdef GDSS
+#ifdef HAVE_GDSS
SigInfo si;
#endif
info[U_UID], info[U_SHELL], info[U_CLASS]);
Put_message(buf);
-#ifdef GDSS
+#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);
+ status = GDSS_Verify((unsigned char *)buf, strlen(buf),
+ (unsigned char *)info[U_SIGNATURE], &si);
#else /* GDSS */
status = 0;
#endif /* GDSS */
UserState(atoi(info[U_STATE])), info[U_MITID],
*info[U_SIGNATURE] ? (status ? "Bad" : "Yes") : "No");
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.");
- Put_message(buf);
+ if (!atoi(info[U_STATE]))
+ {
+ 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, MOD_FORMAT, info[U_MODBY], info[U_MODTIME], info[U_MODWITH]);
char **AskUserInfo(char **info, Bool name)
{
int i;
-#ifdef GDSS
+#ifdef HAVE_GDSS
SigInfo si;
#endif
char temp_buf[BUFSIZ], *newname;
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 (name)
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"))
+ if (!name || !atoi(info[U_STATE]))
{
- char buf[16];
- struct timeval tv;
-
- gettimeofday(&tv, NULL);
- sprintf(buf, "%ld", (long) tv.tv_sec);
- free(info[U_SECURE]);
- info[U_SECURE] = strdup(buf);
+ 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
+ {
+ free(info[U_SECURE]);
+ info[U_SECURE] = strdup("1");
+ }
}
/* Sign record */
-#ifdef GDSS
+#ifdef HAVE_GDSS
if (strcmp(info[U_NAME], UNIQUE_LOGIN))
{
if (name)
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);
+ i = GDSS_Verify((unsigned char *)temp_buf, strlen(temp_buf),
+ (unsigned char *)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]);
+ i = GDSS_Sign((unsigned char *)temp_buf, strlen(temp_buf),
+ (unsigned char *)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)
+ i = GDSS_Verify((unsigned char *)temp_buf, strlen(temp_buf),
+ (unsigned char *)info[U_SIGNATURE], &si);
+ if (strlen((char *)buf) > 68)
goto sign_again;
}
}
{
com_err(program_name, status, " getting filsys info, "
"not deactivating filesystem");
- FreeInfo(args);
- FreeQueue(elem);
return;
}
args = QueueTop(elem)->q_data;
com_err(program_name, stat, " in DeleteKrbMap.");
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 stat, flags;
- struct mqelem *elem = NULL;
- char buf[BUFSIZ], **info;
-
- if (!ValidName(argv[1]))
- return DM_NORMAL;
-
- if ((stat = do_mr_query("get_user_directory_flags", 1, &argv[1],
- StoreInfo, &elem)))
- {
- com_err(program_name, stat, " in GetDirFlags.");
- return DM_NORMAL;
- }
-
- info = QueueTop(elem)->q_data;
- flags = atoi(info[0]);
- FreeQueue(QueueTop(elem));
-
- Put_message("");
- sprintf(buf, "User: %s", argv[1]);
- Put_message(buf);
- if (flags & DIRFLAGS_SUPPRESS)
- Put_message("Does NOT appear in the on-line directory.");
- else
- {
- Put_message("Does appear in the on-line directory.");
- if (flags & DIRFLAGS_NONLOCAL)
- Put_message("Is listed with non-MIT.EDU email address (if known)");
- else
- Put_message("Is listed with MIT.EDU email address.");
- }
-
- 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 SetDirFlags(int argc, char **argv)
-{
- int stat, flags;
- char **info, buf[BUFSIZ], *args[2];
- struct mqelem *elem = NULL;
-
- if (!ValidName(argv[1]))
- return DM_NORMAL;
-
- /* Fetch current prefs */
- if ((stat = do_mr_query("get_user_directory_flags", 1, &argv[1],
- StoreInfo, &elem)))
- {
- com_err(program_name, stat, " in GetDirFlags.");
- return DM_NORMAL;
- }
- info = QueueTop(elem)->q_data;
- flags = atoi(info[0]);
- FreeQueue(QueueTop(elem));
-
- sprintf(buf, "List %s in the on-line directory (y/n)", argv[1]);
- if (YesNoQuestion(buf, !(flags & DIRFLAGS_SUPPRESS)))
- flags &= ~DIRFLAGS_SUPPRESS;
- else
- flags |= DIRFLAGS_SUPPRESS;
-
- sprintf(buf, "List MIT.EDU email address even when mail is "
- "forwarded elsewhere? (y/n)");
- if (YesNoQuestion(buf, !(flags & DIRFLAGS_NONLOCAL)))
- flags &= ~DIRFLAGS_NONLOCAL;
- else
- flags |= DIRFLAGS_NONLOCAL;
-
- args[0] = argv[1];
- sprintf(buf, "%d", flags);
- args[1] = buf;
- if ((stat = do_mr_query("update_user_directory_flags", 2,
- args, NULL, NULL)))
- com_err(program_name, stat, " in SetDirFlags");
- else
- Put_message("Directory preferences set.");
-
- return DM_NORMAL;
-}