]> andersk Git - moira.git/blobdiff - clients/moira/user.c
fix a cast to not generate a warning
[moira.git] / clients / moira / user.c
index a434210e91145a9767f0724d0c6a386e5cc0c166..e722b9c9a7f42c04beaa43ffb3bc37e17f2e5090 100644 (file)
@@ -1,41 +1,42 @@
-#if (!defined(lint) && !defined(SABER))
-  static char rcsid_module_c[] = "$Header$";
-#endif
-
-/*     This is the file user.c for the MOIRA Client, which allows a nieve
- *      user to quickly and easily maintain most parts of the MOIRA database.
+/* $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.
  *     It Contains: Functions for manipulating user information.
  *
  *     Created:        5/9/88
  *     By:             Chris D. Peterson
  *
- *      $Source$
- *      $Author$
- *      $Header$
- *
- *     Copyright 1988 by the Massachusetts Institute of Technology.
- *
- *     For further information on copyright and distribution
- *     see the file mit-copyright.h
+ * Copyright (C) 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
+#include <mit-copyright.h>
 #include <moira.h>
 #include <moira_site.h>
-#include <menu.h>
-#include <ctype.h>
+#include "defs.h"
+#include "f_defs.h"
+#include "globals.h"
+
 #include <sys/time.h>
-#ifdef GDSS
-#include <des.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
-#include "mit-copyright.h"
-#include "defs.h"
-#include "f_defs.h"
-#include "globals.h"
+
+RCSID("$Header$");
+
+void CorrectCapitalization(char **name);
+char **AskUserInfo(char **info, Bool name);
+struct mqelem *GetUserInfo(int type, char *name1, char *name2);
 
 #define LOGIN 0
 #define UID   1
@@ -106,7 +107,7 @@ static void PrintUserInfo(char **info)
 {
   char name[BUFSIZ], buf[BUFSIZ];
   int status;
-#ifdef GDSS
+#ifdef HAVE_GDSS
   SigInfo si;
 #endif
 
@@ -117,10 +118,11 @@ static void PrintUserInfo(char **info)
          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 */
@@ -129,11 +131,12 @@ static void PrintUserInfo(char **info)
          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]);
@@ -148,18 +151,18 @@ static void PrintUserInfo(char **info)
 
 static char **SetUserDefaults(char **info)
 {
-  info[U_NAME] = Strsave(UNIQUE_LOGIN);
-  info[U_UID] = Strsave(UNIQUE_UID);
-  info[U_SHELL] = Strsave(DEFAULT_SHELL);
-  info[U_LAST] = Strsave(DEFAULT_NONE);
-  info[U_FIRST] = Strsave(DEFAULT_NONE);
-  info[U_MIDDLE] = Strsave(DEFAULT_NONE);
-  info[U_STATE] = Strsave(DEFAULT_NO);
-  info[U_MITID] = Strsave(DEFAULT_NONE);
-  info[U_CLASS] = Strsave(DEFAULT_CLASS);
-  info[U_COMMENT] = Strsave("");
-  info[U_SIGNATURE] = Strsave("");
-  info[U_SECURE] = Strsave("0");
+  info[U_NAME] = strdup(UNIQUE_LOGIN);
+  info[U_UID] = strdup(UNIQUE_UID);
+  info[U_SHELL] = strdup(DEFAULT_SHELL);
+  info[U_LAST] = strdup(DEFAULT_NONE);
+  info[U_FIRST] = strdup(DEFAULT_NONE);
+  info[U_MIDDLE] = strdup(DEFAULT_NONE);
+  info[U_STATE] = strdup(DEFAULT_NO);
+  info[U_MITID] = strdup(DEFAULT_NONE);
+  info[U_CLASS] = strdup(DEFAULT_CLASS);
+  info[U_COMMENT] = strdup("");
+  info[U_SIGNATURE] = strdup("");
+  info[U_SECURE] = strdup("0");
   info[U_MODTIME] = info[U_MODBY] = info[U_MODWITH] = info[U_END] = NULL;
   return info;
 }
@@ -169,7 +172,7 @@ static char **SetUserDefaults(char **info)
  * offer to correct it if not.
  */
 
-int CorrectCapitalization(char **name)
+void CorrectCapitalization(char **name)
 {
   char temp_buf[BUFSIZ], fixname[BUFSIZ];
 
@@ -182,7 +185,7 @@ int CorrectCapitalization(char **name)
       if (YesNoQuestion(temp_buf, 1) == TRUE)
        {
          free(*name);
-         *name = strsave(fixname);
+         *name = strdup(fixname);
        }
     }
 }
@@ -201,7 +204,7 @@ int CorrectCapitalization(char **name)
 char **AskUserInfo(char **info, Bool name)
 {
   int i;
-#ifdef GDSS
+#ifdef HAVE_GDSS
   SigInfo si;
 #endif
   char temp_buf[BUFSIZ], *newname;
@@ -213,7 +216,7 @@ char **AskUserInfo(char **info, Bool name)
     }
   else
     {
-      struct qelem *elem = NULL;
+      struct mqelem *elem = NULL;
       char *argv[3];
 
       if (GetValueFromUser("User's last name", &info[U_LAST]) == SUB_ERROR)
@@ -228,7 +231,7 @@ char **AskUserInfo(char **info, Bool name)
       argv[0] = info[U_FIRST];
       argv[1] = info[U_LAST];
       if (do_mr_query("get_user_account_by_name", 2, argv,
-                     StoreInfo, (char *) &elem) == MR_SUCCESS)
+                     StoreInfo, &elem) == MR_SUCCESS)
        {
          Put_message("A user by that name already exists in the database.");
          Loop(QueueTop(elem), PrintUserInfo);
@@ -240,7 +243,7 @@ char **AskUserInfo(char **info, Bool name)
     }
   if (name)
     {
-      newname = Strsave(info[U_NAME]);
+      newname = strdup(info[U_NAME]);
       if (GetValueFromUser("The new login name for this user", &newname) ==
          SUB_ERROR)
        return NULL;
@@ -249,8 +252,24 @@ char **AskUserInfo(char **info, Bool 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 (name)
@@ -289,25 +308,23 @@ char **AskUserInfo(char **info, Bool 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] = strsave("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] = strsave(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)
@@ -315,29 +332,31 @@ char **AskUserInfo(char **info, Bool 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;
            }
        }
     }
 #else /* GDSS */
-  info[U_SIGNATURE] = strsave("");
+  info[U_SIGNATURE] = strdup("");
 #endif /* GDSS */
 
   FreeAndClear(&info[U_MODTIME], TRUE);
@@ -366,18 +385,18 @@ char **AskUserInfo(char **info, Bool name)
  *
  */
 
-struct qelem *GetUserInfo(int type, char *name1, char *name2)
+struct mqelem *GetUserInfo(int type, char *name1, char *name2)
 {
   char *args[2];
-  register int status;
-  struct qelem *elem = NULL;
+  int status;
+  struct mqelem *elem = NULL;
 
   switch (type)
     {
     case LOGIN:
       args[0] = name1;
       if ((status = do_mr_query("get_user_account_by_login", 1, args,
-                               StoreInfo, (char *) &elem)))
+                               StoreInfo, &elem)))
        {
          com_err(program_name, status,
                  " when attempting to get_user_account_by_login.");
@@ -387,7 +406,7 @@ struct qelem *GetUserInfo(int type, char *name1, char *name2)
     case UID:
       args[0] = name1;
       if ((status = do_mr_query("get_user_account_by_uid", 1, args,
-                               StoreInfo, (char *) &elem)))
+                               StoreInfo, &elem)))
        {
          com_err(program_name, status,
                  " when attempting to get_user_account_by_uid.");
@@ -398,7 +417,7 @@ struct qelem *GetUserInfo(int type, char *name1, char *name2)
       args[0] = name1;
       args[1] = name2;
       if ((status = do_mr_query("get_user_account_by_name", 2, args,
-                               StoreInfo, (char *) &elem)))
+                               StoreInfo, &elem)))
        {
          com_err(program_name, status,
                  " when attempting to get_user_account_by_name.");
@@ -408,7 +427,7 @@ struct qelem *GetUserInfo(int type, char *name1, char *name2)
     case CLASS:
       args[0] = name1;
       if ((status = do_mr_query("get_user_account_by_class", 1, args,
-                               StoreInfo, (char *) &elem)))
+                               StoreInfo, &elem)))
        {
          com_err(program_name, status,
                  " when attempting to get_user_account_by_class.");
@@ -418,7 +437,7 @@ struct qelem *GetUserInfo(int type, char *name1, char *name2)
     case ID:
       args[0] = name1;
       if ((status = do_mr_query("get_user_account_by_id", 1, args,
-                               StoreInfo, (char *) &elem)))
+                               StoreInfo, &elem)))
        {
          com_err(program_name, status,
                  " when attempting to get_user_account_by_id.");
@@ -435,9 +454,9 @@ struct qelem *GetUserInfo(int type, char *name1, char *name2)
  *     Returns: DM_NORMAL.
  */
 
-int AddNewUser(void)
+int AddNewUser(int argc, char **argv)
 {
-  register int status;
+  int status;
   char **args, *info[MAX_ARGS_SIZE];
 
   if (!(args = AskUserInfo(SetUserDefaults(info), FALSE)))
@@ -446,7 +465,7 @@ int AddNewUser(void)
       return DM_NORMAL;
     }
   if ((status = do_mr_query("add_user_account", CountArgs(args),
-                           args, Scream, NULL)))
+                           args, NULL, NULL)))
     com_err(program_name, status, " in add_user_account");
   else
     Put_message("New user added to database.");
@@ -466,7 +485,7 @@ static char *GetLoginName(void)
 {
   char *name;
 
-  name = strsave("");
+  name = strdup("");
   if (GetValueFromUser("Login name for this user? ", &name) == SUB_ERROR)
     return NULL;
   Put_message("KERBEROS code not added, did not reserve name with kerberos.");
@@ -480,16 +499,16 @@ static char *GetLoginName(void)
  *     Returns: uid - the malloced uid of the user that was chosen.
  */
 
-static char *ChooseUser(struct qelem *elem)
+static char *ChooseUser(struct mqelem *elem)
 {
   while (elem)
     {
-      char **info = (char **) elem->q_data;
+      char **info = elem->q_data;
       PrintUserInfo(info);
       switch (YesNoQuitQuestion("Is this the user you want (y/n/q)", FALSE))
        {
        case TRUE:
-         return Strsave(info[U_UID]);
+         return strdup(info[U_UID]);
        case FALSE:
          break;
        default:                /* quit or ^C. */
@@ -509,8 +528,8 @@ static char *ChooseUser(struct qelem *elem)
 static char *GetUidNumberFromName(void)
 {
   char *args[5], *uid, first[BUFSIZ], last[BUFSIZ];
-  register int status;
-  struct qelem *top = NULL;
+  int status;
+  struct mqelem *top = NULL;
 
   if (!Prompt_input("First Name: ", first, BUFSIZ))
     return NULL;
@@ -523,7 +542,7 @@ static char *GetUidNumberFromName(void)
   args[1] = last;
 
   switch ((status = do_mr_query("get_user_account_by_name", 2, args,
-                               StoreInfo, (char *) &top)))
+                               StoreInfo, &top)))
     {
     case MR_SUCCESS:
       break;
@@ -538,13 +557,13 @@ static char *GetUidNumberFromName(void)
   top = QueueTop(top);
   if (QueueCount(top) == 1) /* This is a unique name. */
     {
-      char **info = (char **) top->q_data;
+      char **info = top->q_data;
       Put_message("User ID Number retrieved for the user: ");
       Put_message("");
       PrintUserName(info);
-      uid = Strsave(info[U_UID]);
+      uid = strdup(info[U_UID]);
       FreeQueue(top);
-      return Strsave(uid);
+      return strdup(uid);
     }
 
   Put_message("That name is not unique, choose the user that you want.");
@@ -585,12 +604,12 @@ static void GiveBackLogin(char *name)
  *     Returns: DM_NORMAL.
  */
 
-int RegisterUser(void)
+int RegisterUser(int argc, char **argv)
 {
   char *args[MAX_ARGS_SIZE];
   char *login, *fstype = NULL;
   char temp_buf[BUFSIZ];
-  register int status;
+  int status;
 
   Put_message("This function has NO kerberos support, so strange things");
   Put_message("may happen if you use it to register a user.");
@@ -599,7 +618,7 @@ int RegisterUser(void)
     {
     case TRUE:
       Prompt_input("What is the UID number of the user? ", temp_buf, BUFSIZ);
-      args[0] = Strsave(temp_buf);
+      args[0] = strdup(temp_buf);
       break;
     case FALSE:
       if (!(args[0] = GetUidNumberFromName()))
@@ -610,7 +629,7 @@ int RegisterUser(void)
     }
 
   sprintf(temp_buf, "u%s", args[0]);
-  login = strsave(temp_buf);
+  login = strdup(temp_buf);
   if ((GetValueFromUser("Login name for this user? ", &login) == SUB_ERROR) ||
       (GetFSTypes(&fstype, FALSE) == SUB_ERROR))
     {
@@ -624,7 +643,7 @@ int RegisterUser(void)
   args[3] = NULL;
 
   switch ((status = do_mr_query("register_user", CountArgs(args),
-                               args, Scream, NULL)))
+                               args, NULL, NULL)))
     {
     case MR_SUCCESS:
       sprintf(temp_buf, "User %s successfully registered.", login);
@@ -653,7 +672,7 @@ int RegisterUser(void)
 
 static void RealUpdateUser(char **info, Bool junk)
 {
-  register int status;
+  int status;
   char error_buf[BUFSIZ];
   char **args = AskUserInfo(info, TRUE);
 
@@ -663,7 +682,7 @@ static void RealUpdateUser(char **info, Bool junk)
       return;
     }
   if ((status = do_mr_query("update_user_account", CountArgs(args),
-                           args, Scream, NULL)))
+                           args, NULL, NULL)))
     {
       com_err(program_name, status, " in ModifyFields");
       sprintf(error_buf, "User %s not updated due to errors.", info[NAME]);
@@ -679,7 +698,7 @@ static void RealUpdateUser(char **info, Bool junk)
 
 int UpdateUser(int argc, char **argv)
 {
-  struct qelem *elem;
+  struct mqelem *elem;
 
   elem = GetUserInfo(LOGIN, argv[1], NULL);
   QueryLoop(elem, NullPrint, RealUpdateUser, "Update the user");
@@ -697,10 +716,10 @@ int UpdateUser(int argc, char **argv)
 
 static void RealDeactivateUser(char **info, Bool one_item)
 {
-  register int status;
+  int status;
   char txt_buf[BUFSIZ];
   char *qargs[2], **args;
-  struct qelem *elem = NULL;
+  struct mqelem *elem = NULL;
 
   if (one_item)
     {
@@ -711,7 +730,7 @@ static void RealDeactivateUser(char **info, Bool one_item)
 
   qargs[0] = info[NAME];
   qargs[1] = "3";
-  if ((status = do_mr_query("update_user_status", 2, qargs, Scream, NULL)))
+  if ((status = do_mr_query("update_user_status", 2, qargs, NULL, NULL)))
     {
       com_err(program_name, status, " in update_user_status");
       sprintf(txt_buf, "User %s not deactivated due to errors.", info[NAME]);
@@ -721,18 +740,18 @@ static void RealDeactivateUser(char **info, Bool one_item)
                         FALSE) == TRUE)
     {
       status = do_mr_query("get_list_info", 1, &(info[NAME]), StoreInfo,
-                          (char *) &elem);
+                          &elem);
       if (status == MR_SUCCESS)
        {
-         args = (char **) (QueueTop(elem)->q_data);
+         args = QueueTop(elem)->q_data;
          free(args[L_ACTIVE]);
-         args[L_ACTIVE] = strsave("0");
+         args[L_ACTIVE] = strdup("0");
          FreeAndClear(&args[L_MODTIME], TRUE);
          FreeAndClear(&args[L_MODBY], TRUE);
          FreeAndClear(&args[L_MODWITH], TRUE);
          SlipInNewName(args, args[L_NAME]);
          if ((status = do_mr_query("update_list", CountArgs(args), args,
-                                   Scream, NULL)))
+                                   NULL, NULL)))
            {
              com_err(program_name, status, " updating list, "
                      "not deactivating list or filesystem");
@@ -752,25 +771,23 @@ static void RealDeactivateUser(char **info, Bool one_item)
        }
 
       if ((status = do_mr_query("get_filesys_by_label", 1, &(info[NAME]),
-                               StoreInfo, (char *) &elem)))
+                               StoreInfo, &elem)))
        {
          com_err(program_name, status, " getting filsys info, "
                  "not deactivating filesystem");
-         FreeInfo(args);
-         FreeQueue(elem);
          return;
        }
-      args = (char **) (QueueTop(elem)->q_data);
+      args = QueueTop(elem)->q_data;
       free(args[FS_TYPE]);
-      args[FS_TYPE] = strsave("ERR");
+      args[FS_TYPE] = strdup("ERR");
       free(args[FS_COMMENTS]);
-      args[FS_COMMENTS] = strsave("Locker disabled; call 3-1325 for help");
+      args[FS_COMMENTS] = strdup("Locker disabled; call 3-1325 for help");
       FreeAndClear(&args[FS_MODTIME], TRUE);
       FreeAndClear(&args[FS_MODBY], TRUE);
       FreeAndClear(&args[FS_MODWITH], TRUE);
       SlipInNewName(args, args[FS_NAME]);
       if ((status = do_mr_query("update_filesys", CountArgs(args), args,
-                               Scream, NULL)))
+                               NULL, NULL)))
        {
          com_err(program_name, status, " updating filesystem, "
                  "not deactivating filesystem");
@@ -792,7 +809,7 @@ static void RealDeactivateUser(char **info, Bool one_item)
 
 int DeactivateUser(int argc, char **argv)
 {
-  struct qelem *elem;
+  struct mqelem *elem;
 
   elem = GetUserInfo(LOGIN, argv[1], NULL);
   QueryLoop(elem, NullPrint, RealDeactivateUser, "Deactivate user");
@@ -817,17 +834,17 @@ int DeactivateUser(int argc, char **argv)
 int DeleteUserByUid(int argc, char **argv)
 {
   int status;
-  struct qelem *elem = NULL;
+  struct mqelem *elem = NULL;
   char **info;
 
   if (!ValidName(argv[1]))
     return DM_NORMAL;
 
   if ((status = do_mr_query("get_user_account_by_uid", 1, argv + 1, StoreInfo,
-                           (char *) &elem)))
+                           &elem)))
     com_err(program_name, status, " in get_user_account_by_uid");
 
-  info = (char **) elem->q_data;
+  info = elem->q_data;
   argv[1] = info[U_NAME];
 
   DeleteUser(argc, argv);
@@ -844,7 +861,7 @@ int DeleteUserByUid(int argc, char **argv)
 
 int ShowUserByLogin(int argc, char *argv[])
 {
-  struct qelem *top, *elem;
+  struct mqelem *top, *elem;
 
   elem = top = GetUserInfo(LOGIN, argv[1], NULL);
   Loop(elem, PrintUserInfo);
@@ -862,7 +879,7 @@ int ShowUserByLogin(int argc, char *argv[])
 
 int ShowUserByName(int argc, char *argv[])
 {
-  struct qelem *top;
+  struct mqelem *top;
   char buf[BUFSIZ];
 
   top = GetUserInfo(BY_NAME, argv[1], argv[2]);
@@ -898,7 +915,7 @@ int ShowUserByName(int argc, char *argv[])
 
 int ShowUserByClass(int argc, char **argv)
 {
-  struct qelem *top;
+  struct mqelem *top;
 
   if (YesNoQuestion("This will take a long time.  Are you sure", 0) == FALSE)
     return DM_NORMAL;
@@ -918,7 +935,7 @@ int ShowUserByClass(int argc, char **argv)
 
 int ShowUserById(int argc, char *argv[])
 {
-  struct qelem *top, *elem;
+  struct mqelem *top, *elem;
 
   elem = top = GetUserInfo(ID, argv[1], NULL);
   Loop(elem, PrintUserInfo);
@@ -938,11 +955,11 @@ int ShowUserById(int argc, char *argv[])
 int GetKrbmap(int argc, char **argv)
 {
   int stat;
-  struct qelem *elem = NULL, *top;
+  struct mqelem *elem = NULL, *top;
   char buf[BUFSIZ];
 
   if ((stat = do_mr_query("get_kerberos_user_map", 2, &argv[1],
-                         StoreInfo, (char *)&elem)))
+                         StoreInfo, &elem)))
     {
       com_err(program_name, stat, " in GetKrbMap.");
       return DM_NORMAL;
@@ -952,7 +969,7 @@ int GetKrbmap(int argc, char **argv)
   Put_message("");
   while (elem)
     {
-      char **info = (char **) elem->q_data;
+      char **info = elem->q_data;
       sprintf(buf, "User: %-9s Principal: %s",
              info[KMAP_USER], info[KMAP_PRINCIPAL]);
       Put_message(buf);
@@ -981,7 +998,7 @@ int AddKrbmap(int argc, char **argv)
       return DM_NORMAL;
     }
   if ((stat = do_mr_query("add_kerberos_user_map", 2, &argv[1],
-                         Scream, NULL)))
+                         NULL, NULL)))
     {
       com_err(program_name, stat, " in AddKrbMap.");
       if (stat == MR_EXISTS)
@@ -1003,102 +1020,7 @@ int DeleteKrbmap(int argc, char **argv)
   int stat;
 
   if ((stat = do_mr_query("delete_kerberos_user_map", 2, &argv[1],
-                         Scream, NULL)))
+                         NULL, NULL)))
     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 qelem *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, (char *)&elem)))
-    {
-      com_err(program_name, stat, " in GetDirFlags.");
-      return DM_NORMAL;
-    }
-
-  info = (char **) 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 qelem *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, (char *) &elem)))
-    {
-      com_err(program_name, stat, " in GetDirFlags.");
-      return DM_NORMAL;
-    }
-  info = (char **) 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, Scream, NULL)))
-    com_err(program_name, stat, " in SetDirFlags");
-  else
-    Put_message("Directory preferences set.");
-
-  return DM_NORMAL;
-}
This page took 0.089479 seconds and 4 git commands to generate.