3 * This is the file user.c for the Moira Client, which allows users
4 * to quickly and easily maintain most parts of the Moira database.
5 * It Contains: Functions for manipulating user information.
8 * By: Chris D. Peterson
10 * Copyright (C) 1988-1998 by the Massachusetts Institute of Technology.
11 * For copying and distribution information, please see the file
15 #include <mit-copyright.h>
17 #include <moira_site.h>
37 void CorrectCapitalization(char **name);
38 char **AskUserInfo(char **info, Bool name);
39 struct mqelem *GetUserInfo(int type, char *name1, char *name2);
48 #define DEFAULT_SHELL "/bin/athena/tcsh"
50 #define DEFAULT_SHELL "/bin/csh"
52 #define DEFAULT_CLASS "?"
55 /* Function Name: UserState
56 * Description: Convert a numeric state into a descriptive string.
57 * Arguments: state value
58 * Returns: pointer to statically allocated string.
61 static char *states[] = {
64 "Half Registered (2)",
66 "Not registerable (4)",
67 "Enrolled/Registerable (5)",
68 "Enrolled/Not Registerable (6)",
72 static char *UserState(int state)
74 static char buf[BUFSIZ];
76 if (state < 0 || state >= US_END)
78 sprintf(buf, "Unknown (%d)", state);
85 /* Function Name: PrintUserName
86 * Description: Print name of a user.
87 * Arguments: info - the information about a user.
91 static void PrintUserName(char **info)
93 char buf[BUFSIZ], print_buf[BUFSIZ];
94 sprintf(buf, "%s, %s %s", info[U_LAST], info[U_FIRST], info[U_MIDDLE]);
95 sprintf(print_buf, "%-40s User Name: %s", buf, info[U_NAME]);
96 Put_message(print_buf);
99 /* Function Name: PrintUserInfo
100 * Description: Prints Information about a user.
101 * Arguments: info - an argument list with the user information
106 static void PrintUserInfo(char **info)
108 char name[BUFSIZ], buf[BUFSIZ];
114 sprintf(name, "%s, %s %s", info[U_LAST], info[U_FIRST], info[U_MIDDLE]);
115 sprintf(buf, "Login name: %-20s Full name: %s", info[U_NAME], name);
117 sprintf(buf, "User id: %-23s Login shell %-10s Class: %s",
118 info[U_UID], info[U_SHELL], info[U_CLASS]);
122 sprintf(buf, "%s:%s", info[U_NAME], info[U_MITID]);
124 status = GDSS_Verify(buf, strlen(buf), info[U_SIGNATURE], &si);
129 sprintf(buf, "Account is: %-20s MIT ID number: %s Signed: %s",
130 UserState(atoi(info[U_STATE])), info[U_MITID],
131 *info[U_SIGNATURE] ? (status ? "Bad" : "Yes") : "No");
133 if (atoi(info[U_SECURE]))
134 sprintf(buf, "Secure password set on %s.", atot(info[U_SECURE]));
136 sprintf(buf, "No secure password set.");
138 sprintf(buf, "Comments: %s", info[U_COMMENT]);
140 sprintf(buf, MOD_FORMAT, info[U_MODBY], info[U_MODTIME], info[U_MODWITH]);
144 /* Function Name: SetUserDefaults
145 * Description: Sets the default values for add user.
146 * Arguments: info - a blank user info array of char *'s.
147 * Returns: args - the filled info structure.
150 static char **SetUserDefaults(char **info)
152 info[U_NAME] = strdup(UNIQUE_LOGIN);
153 info[U_UID] = strdup(UNIQUE_UID);
154 info[U_SHELL] = strdup(DEFAULT_SHELL);
155 info[U_LAST] = strdup(DEFAULT_NONE);
156 info[U_FIRST] = strdup(DEFAULT_NONE);
157 info[U_MIDDLE] = strdup(DEFAULT_NONE);
158 info[U_STATE] = strdup(DEFAULT_NO);
159 info[U_MITID] = strdup(DEFAULT_NONE);
160 info[U_CLASS] = strdup(DEFAULT_CLASS);
161 info[U_COMMENT] = strdup("");
162 info[U_SIGNATURE] = strdup("");
163 info[U_SECURE] = strdup("0");
164 info[U_MODTIME] = info[U_MODBY] = info[U_MODWITH] = info[U_END] = NULL;
169 /* Check that the supplied name follows the capitalization rules, and
170 * offer to correct it if not.
173 void CorrectCapitalization(char **name)
175 char temp_buf[BUFSIZ], fixname[BUFSIZ];
177 strcpy(fixname, *name);
179 if (strcmp(fixname, *name))
181 Put_message("You entered a name which does not follow the capitalization conventions.");
182 sprintf(temp_buf, "Correct it to \"%s\"", fixname);
183 if (YesNoQuestion(temp_buf, 1) == TRUE)
186 *name = strdup(fixname);
192 /* Function Name: AskUserInfo.
193 * Description: This function askes the user for information about a
194 * machine and saves it into a structure.
195 * Arguments: info - a pointer the the structure to put the info into.
196 * flags - Flags asking us which info we want.
197 * Returns: the args to pass to the query.
198 * NOTES: the return args are not necessarily in the correct order to
199 * use the #defined names (e.g args[UID] is not the uid anymore).
202 char **AskUserInfo(char **info, Bool name)
208 char temp_buf[BUFSIZ], *newname;
212 sprintf(temp_buf, "\nChanging Attributes of user %s.\n", info[U_NAME]);
213 Put_message(temp_buf);
217 struct mqelem *elem = NULL;
220 if (GetValueFromUser("User's last name", &info[U_LAST]) == SUB_ERROR)
222 CorrectCapitalization(&info[U_LAST]);
223 if (GetValueFromUser("User's first name", &info[U_FIRST]) == SUB_ERROR)
225 CorrectCapitalization(&info[U_FIRST]);
226 if (GetValueFromUser("User's middle name", &info[U_MIDDLE]) == SUB_ERROR)
228 CorrectCapitalization(&info[U_MIDDLE]);
229 argv[0] = info[U_FIRST];
230 argv[1] = info[U_LAST];
231 if (do_mr_query("get_user_account_by_name", 2, argv,
232 StoreInfo, &elem) == MR_SUCCESS)
234 Put_message("A user by that name already exists in the database.");
235 Loop(QueueTop(elem), PrintUserInfo);
236 Loop(QueueTop(elem), FreeInfo);
238 if (YesNoQuestion("Add new user anyway", TRUE) != TRUE)
244 newname = strdup(info[U_NAME]);
245 if (GetValueFromUser("The new login name for this user", &newname) ==
249 else if (GetValueFromUser("Login name for this user", &info[U_NAME]) ==
253 if (GetValueFromUser("User's UID", &info[U_UID]) == SUB_ERROR)
255 if (GetValueFromUser("User's shell", &info[U_SHELL]) == SUB_ERROR)
259 if (GetValueFromUser("User's last name", &info[U_LAST]) == SUB_ERROR)
261 CorrectCapitalization(&info[U_LAST]);
262 if (GetValueFromUser("User's first name", &info[U_FIRST]) == SUB_ERROR)
264 CorrectCapitalization(&info[U_FIRST]);
265 if (GetValueFromUser("User's middle name", &info[U_MIDDLE]) == SUB_ERROR)
267 CorrectCapitalization(&info[U_MIDDLE]);
272 if (GetValueFromUser("User's status (? for help)", &info[U_STATE]) ==
275 if (isdigit(info[U_STATE][0]))
277 Put_message("Valid status numbers:");
278 for (i = 0; i < US_END; i++)
280 sprintf(temp_buf, " %d: %s", i, states[i]);
281 Put_message(temp_buf);
284 if (GetValueFromUser("User's MIT ID number", &info[U_MITID]) == SUB_ERROR)
286 RemoveHyphens(info[U_MITID]);
287 if (GetTypeFromUser("User's MIT Year (class)", "class", &info[U_CLASS]) ==
290 if (GetValueFromUser("Comments", &info[U_COMMENT]) == SUB_ERROR)
293 if (YesNoQuestion("Secure password set",
294 atoi(info[U_SECURE]) ? TRUE : FALSE) == FALSE)
296 free(info[U_SECURE]);
297 info[U_SECURE] = strdup("0");
299 else if (!strcmp(info[U_SECURE], "0"))
304 gettimeofday(&tv, NULL);
305 sprintf(buf, "%ld", (long) tv.tv_sec);
306 free(info[U_SECURE]);
307 info[U_SECURE] = strdup(buf);
312 if (strcmp(info[U_NAME], UNIQUE_LOGIN))
315 sprintf(temp_buf, "%s:%s", newname, info[U_MITID]);
317 sprintf(temp_buf, "%s:%s", info[U_NAME], info[U_MITID]);
319 i = GDSS_Verify(temp_buf, strlen(temp_buf), info[U_SIGNATURE], &si);
320 /* If it's already signed OK, don't resign it. */
321 if (i != GDSS_SUCCESS)
323 free(info[U_SIGNATURE]);
324 info[U_SIGNATURE] = malloc(GDSS_Sig_Size() * 2);
326 i = GDSS_Sign(temp_buf, strlen(temp_buf), info[U_SIGNATURE]);
327 if (i != GDSS_SUCCESS)
328 com_err(program_name, gdss2et(i), "Failed to create signature");
331 unsigned char buf[256];
333 i = GDSS_Verify(temp_buf, strlen(temp_buf),
334 info[U_SIGNATURE], &si);
335 if (strlen(buf) > 68)
341 info[U_SIGNATURE] = strdup("");
344 FreeAndClear(&info[U_MODTIME], TRUE);
345 FreeAndClear(&info[U_MODBY], TRUE);
346 FreeAndClear(&info[U_MODWITH], TRUE);
349 * Slide the newname into the #2 slot, this screws up all future references
350 * to this list, since we slip the pointer into a info list it gets freed
351 * when the rest of the list gets freed.
354 SlipInNewName(info, newname);
359 /* Function Name: GetUserInfo
360 * Description: Stores the user information in a queue.
361 * Arguments: type - type of field given to get info, one of:
362 * LOGIN, UID, BY_NAME, CLASS.
363 * name1 - name of thing specified by type (wildcards okay)
364 * name2 - other name, only used in get user by first and last.
366 * Returns: the first element of the queue containing the user info.
370 struct mqelem *GetUserInfo(int type, char *name1, char *name2)
374 struct mqelem *elem = NULL;
380 if ((status = do_mr_query("get_user_account_by_login", 1, args,
383 com_err(program_name, status,
384 " when attempting to get_user_account_by_login.");
390 if ((status = do_mr_query("get_user_account_by_uid", 1, args,
393 com_err(program_name, status,
394 " when attempting to get_user_account_by_uid.");
401 if ((status = do_mr_query("get_user_account_by_name", 2, args,
404 com_err(program_name, status,
405 " when attempting to get_user_account_by_name.");
411 if ((status = do_mr_query("get_user_account_by_class", 1, args,
414 com_err(program_name, status,
415 " when attempting to get_user_account_by_class.");
421 if ((status = do_mr_query("get_user_account_by_id", 1, args,
424 com_err(program_name, status,
425 " when attempting to get_user_account_by_id.");
430 return QueueTop(elem) ;
433 /* Function Name: AddNewUser
434 * Description: Adds a new user to the database.
436 * Returns: DM_NORMAL.
439 int AddNewUser(int argc, char **argv)
442 char **args, *info[MAX_ARGS_SIZE];
444 if (!(args = AskUserInfo(SetUserDefaults(info), FALSE)))
446 Put_message("Aborted.");
449 if ((status = do_mr_query("add_user_account", CountArgs(args),
451 com_err(program_name, status, " in add_user_account");
453 Put_message("New user added to database.");
459 /* Function Name: GetLoginName
460 * Description: Asks the user for a login name and reserves
463 * Returns: a malloced login name for the user.
466 static char *GetLoginName(void)
471 if (GetValueFromUser("Login name for this user? ", &name) == SUB_ERROR)
473 Put_message("KERBEROS code not added, did not reserve name with kerberos.");
478 /* Function Name: ChooseUser
479 * Description: Choose a user from a list and return the uid.
480 * Arguments: top - a queue of user information.
481 * Returns: uid - the malloced uid of the user that was chosen.
484 static char *ChooseUser(struct mqelem *elem)
488 char **info = elem->q_data;
490 switch (YesNoQuitQuestion("Is this the user you want (y/n/q)", FALSE))
493 return strdup(info[U_UID]);
496 default: /* quit or ^C. */
504 /* Function Name: GetUidNumberFromName
505 * Description: Gets the users uid number, from the name.
507 * Returns: uid - a malloced string containing the uid.
510 static char *GetUidNumberFromName(void)
512 char *args[5], *uid, first[BUFSIZ], last[BUFSIZ];
514 struct mqelem *top = NULL;
516 if (!Prompt_input("First Name: ", first, BUFSIZ))
518 if (!Prompt_input("Last Name: ", last, BUFSIZ))
526 switch ((status = do_mr_query("get_user_account_by_name", 2, args,
532 Put_message("There is no user in the database with that name.");
535 com_err(program_name, status, " in get_account_user_by_name.");
540 if (QueueCount(top) == 1) /* This is a unique name. */
542 char **info = top->q_data;
543 Put_message("User ID Number retrieved for the user: ");
546 uid = strdup(info[U_UID]);
551 Put_message("That name is not unique, choose the user that you want.");
552 uid = ChooseUser(top);
557 /* Function Name: SetUserPassword
558 * Description: Set the new kerberos password for this user.
559 * Arguments: name - kerberos principle name for this user, (login name).
563 static void SetUserPassword(char *name)
565 name = name; /* make saber happy. */
566 Put_message("Kerberos password not changed, code non-existant.");
567 /* clever message to call account_admin, if this fails. */
570 /* Function Name: GiveBackLogin
571 * Description: Gives back previously reserved kerberous principle.
572 * Arguments: name - principle to give back.
576 static void GiveBackLogin(char *name)
578 name = name; /* make saber happy. */
579 Put_message("kerberos code not implimented, name not given back.");
580 /* send mail to db maintainer if this fails. */
583 /* Function Name: RegisterUser
584 * Description: This function registers a user.
586 * Returns: DM_NORMAL.
589 int RegisterUser(int argc, char **argv)
591 char *args[MAX_ARGS_SIZE];
592 char *login, *fstype = NULL;
593 char temp_buf[BUFSIZ];
596 Put_message("This function has NO kerberos support, so strange things");
597 Put_message("may happen if you use it to register a user.");
599 switch (YesNoQuestion("Do you know the users UID Number (y/n)", FALSE))
602 Prompt_input("What is the UID number of the user? ", temp_buf, BUFSIZ);
603 args[0] = strdup(temp_buf);
606 if (!(args[0] = GetUidNumberFromName()))
613 sprintf(temp_buf, "u%s", args[0]);
614 login = strdup(temp_buf);
615 if ((GetValueFromUser("Login name for this user? ", &login) == SUB_ERROR) ||
616 (GetFSTypes(&fstype, FALSE) == SUB_ERROR))
619 FreeInfo(args); /* This work because the NULL temination is ok. */
622 Put_message("KERBEROS code not added, did not reserve name with kerberos.");
627 switch ((status = do_mr_query("register_user", CountArgs(args),
631 sprintf(temp_buf, "User %s successfully registered.", login);
632 Put_message(temp_buf);
633 SetUserPassword(login);
636 GiveBackLogin(login);
637 sprintf(temp_buf, "The username %s is already in use.", login);
638 Put_message(temp_buf);
641 com_err(program_name, status, " in register_user");
648 /* Function Name: RealUpdateUser
649 * Description: actuall updates the user information.
650 * Arguments: info - all current information for the user fields.
651 * junk - an UNUSED boolean.
655 static void RealUpdateUser(char **info, Bool junk)
658 char error_buf[BUFSIZ];
659 char **args = AskUserInfo(info, TRUE);
663 Put_message("Aborted.");
666 if ((status = do_mr_query("update_user_account", CountArgs(args),
669 com_err(program_name, status, " in ModifyFields");
670 sprintf(error_buf, "User %s not updated due to errors.", info[NAME]);
671 Put_message(error_buf);
675 /* Function Name: UpdateUser
676 * Description: Modify some of the information about a user.
677 * Arguments: argc, argv - login name of the user in argv[1].
678 * Returns: DM_NORMAL.
681 int UpdateUser(int argc, char **argv)
685 elem = GetUserInfo(LOGIN, argv[1], NULL);
686 QueryLoop(elem, NullPrint, RealUpdateUser, "Update the user");
692 /* Function Name: RealDeactivateUser
693 * Description: sets the user's status to 3.
694 * Arguments: info - all current information for the user fields
695 * one_item - indicates the user hasn't been queried yet
699 static void RealDeactivateUser(char **info, Bool one_item)
702 char txt_buf[BUFSIZ];
703 char *qargs[2], **args;
704 struct mqelem *elem = NULL;
708 sprintf(txt_buf, "Deactivate user %s (y/n)", info[NAME]);
709 if (YesNoQuestion(txt_buf, FALSE) != TRUE)
713 qargs[0] = info[NAME];
715 if ((status = do_mr_query("update_user_status", 2, qargs, NULL, NULL)))
717 com_err(program_name, status, " in update_user_status");
718 sprintf(txt_buf, "User %s not deactivated due to errors.", info[NAME]);
719 Put_message(txt_buf);
721 else if (YesNoQuestion("Also deactivate matching list and filesystem (y/n)",
724 status = do_mr_query("get_list_info", 1, &(info[NAME]), StoreInfo,
726 if (status == MR_SUCCESS)
728 args = QueueTop(elem)->q_data;
729 free(args[L_ACTIVE]);
730 args[L_ACTIVE] = strdup("0");
731 FreeAndClear(&args[L_MODTIME], TRUE);
732 FreeAndClear(&args[L_MODBY], TRUE);
733 FreeAndClear(&args[L_MODWITH], TRUE);
734 SlipInNewName(args, args[L_NAME]);
735 if ((status = do_mr_query("update_list", CountArgs(args), args,
738 com_err(program_name, status, " updating list, "
739 "not deactivating list or filesystem");
748 else if (status != MR_NO_MATCH)
750 com_err(program_name, status, " getting list info, "
751 "not deactivating list or filesystem");
755 if ((status = do_mr_query("get_filesys_by_label", 1, &(info[NAME]),
758 com_err(program_name, status, " getting filsys info, "
759 "not deactivating filesystem");
764 args = QueueTop(elem)->q_data;
766 args[FS_TYPE] = strdup("ERR");
767 free(args[FS_COMMENTS]);
768 args[FS_COMMENTS] = strdup("Locker disabled; call 3-1325 for help");
769 FreeAndClear(&args[FS_MODTIME], TRUE);
770 FreeAndClear(&args[FS_MODBY], TRUE);
771 FreeAndClear(&args[FS_MODWITH], TRUE);
772 SlipInNewName(args, args[FS_NAME]);
773 if ((status = do_mr_query("update_filesys", CountArgs(args), args,
776 com_err(program_name, status, " updating filesystem, "
777 "not deactivating filesystem");
788 /* Function Name: DeactivateUser
789 * Description: sets the user's status to 3.
790 * Arguments: argc, argv - login name of the user in argv[1].
791 * Returns: DM_NORMAL.
794 int DeactivateUser(int argc, char **argv)
798 elem = GetUserInfo(LOGIN, argv[1], NULL);
799 QueryLoop(elem, NullPrint, RealDeactivateUser, "Deactivate user");
806 /* ------------------------- Top Menu ------------------------- */
808 /* DeleteUser() in delete.c */
810 /* Function Name: DeleteUserByUid
811 * Description: Deletes the user given a uid number.
812 * Arguments: argc, argv - uid if user in argv[1].
813 * Returns: DM_NORMAL.
814 * NOTES: This just gets the username from the mr server
815 * and performs a DeleteUser().
818 int DeleteUserByUid(int argc, char **argv)
821 struct mqelem *elem = NULL;
824 if (!ValidName(argv[1]))
827 if ((status = do_mr_query("get_user_account_by_uid", 1, argv + 1, StoreInfo,
829 com_err(program_name, status, " in get_user_account_by_uid");
832 argv[1] = info[U_NAME];
834 DeleteUser(argc, argv);
838 /* ------------------------- Show User Information ------------------------- */
840 /* Function Name: ShowUserByLogin
841 * Description: Shows user information given a login name.
842 * Arguments: argc, argv - login name in argv[1].
846 int ShowUserByLogin(int argc, char *argv[])
848 struct mqelem *top, *elem;
850 elem = top = GetUserInfo(LOGIN, argv[1], NULL);
851 Loop(elem, PrintUserInfo);
857 /* Function Name: RetrieveUserByName
858 * Description: Show information on a user give fist and/or last name.
859 * Arguments: argc, argv - argv[1] - first name.
860 * argv[2] - last name.
861 * Returns: DM_NORMAL.
864 int ShowUserByName(int argc, char *argv[])
869 top = GetUserInfo(BY_NAME, argv[1], argv[2]);
871 if (!top) /* if there was an error then return. */
874 if (!PromptWithDefault("Print full information, or just the names (f/n)?",
882 Loop(top, PrintUserInfo);
886 Loop(top, PrintUserName);
894 /* Function Name: ShowUserByClass
895 * Description: Shows real and login names of all users in class.
896 * Arguments: argc, argv - argv[1] contains the class.
900 int ShowUserByClass(int argc, char **argv)
904 if (YesNoQuestion("This will take a long time. Are you sure", 0) == FALSE)
906 top = GetUserInfo(CLASS, argv[1], NULL);
907 Loop(top, PrintUserName);
914 /* Function Name: ShowUserById
915 * Description: Shows user information given an ID number.
916 * Arguments: argc, argv - ID number in argv[1].
920 int ShowUserById(int argc, char *argv[])
922 struct mqelem *top, *elem;
924 elem = top = GetUserInfo(ID, argv[1], NULL);
925 Loop(elem, PrintUserInfo);
932 /* Function Name: GetKrbmap
933 * Description: Shows user <-> Kerberos mappings
934 * Arguments: argc, argv - argv[1] contains the user login name,
935 * argv[2] contains the principal
939 int GetKrbmap(int argc, char **argv)
942 struct mqelem *elem = NULL, *top;
945 if ((stat = do_mr_query("get_kerberos_user_map", 2, &argv[1],
948 com_err(program_name, stat, " in GetKrbMap.");
952 top = elem = QueueTop(elem);
956 char **info = elem->q_data;
957 sprintf(buf, "User: %-9s Principal: %s",
958 info[KMAP_USER], info[KMAP_PRINCIPAL]);
963 FreeQueue(QueueTop(top));
968 /* Function Name: AddKrbmap
969 * Description: Add a new user <-> Kerberos mapping
970 * Arguments: argc, argv - argv[1] contains the user login name,
971 * argv[2] contains the principal
975 int AddKrbmap(int argc, char **argv)
979 if (!strchr(argv[KMAP_PRINCIPAL + 1], '@'))
981 Put_message("Please specify a realm for the kerberos principal.");
984 if ((stat = do_mr_query("add_kerberos_user_map", 2, &argv[1],
987 com_err(program_name, stat, " in AddKrbMap.");
988 if (stat == MR_EXISTS)
989 Put_message("No user or principal may have more than one mapping.");
995 /* Function Name: DeleteKrbmap
996 * Description: Remove a user <-> Kerberos mapping
997 * Arguments: argc, argv - argv[1] contains the user login name,
998 * argv[2] contains the principal
1002 int DeleteKrbmap(int argc, char **argv)
1006 if ((stat = do_mr_query("delete_kerberos_user_map", 2, &argv[1],
1008 com_err(program_name, stat, " in DeleteKrbMap.");
1013 /* Function Name: GetDirFlags
1014 * Description: Shows MITdir listing preferences
1015 * Arguments: argc, argv - argv[1] contains the user login name
1019 int GetDirFlags(int argc, char **argv)
1022 struct mqelem *elem = NULL;
1023 char buf[BUFSIZ], **info;
1025 if (!ValidName(argv[1]))
1028 if ((stat = do_mr_query("get_user_directory_flags", 1, &argv[1],
1031 com_err(program_name, stat, " in GetDirFlags.");
1035 info = QueueTop(elem)->q_data;
1036 FreeQueue(QueueTop(elem));
1039 sprintf(buf, "User: %s", argv[1]);
1041 if (atoi(info[0]) == 0)
1042 Put_message("Does NOT appear in the on-line directory.");
1045 Put_message("Does appear in the on-line directory.");
1046 if (atoi(info[1]) == 0)
1047 Put_message("Is listed with non-MIT.EDU email address (if any)");
1049 Put_message("Is listed with MIT.EDU email address.");
1055 /* Function Name: SetDirFlags
1056 * Description: Update online directory preferences
1057 * Arguments: argc, argv - the login name of the user in argv[1].
1058 * Returns: DM_NORMAL.
1061 int SetDirFlags(int argc, char **argv)
1064 char **info, buf[BUFSIZ], *args[3];
1065 struct mqelem *elem = NULL;
1067 if (!ValidName(argv[1]))
1070 /* Fetch current prefs */
1071 if ((stat = do_mr_query("get_user_directory_flags", 1, &argv[1],
1074 com_err(program_name, stat, " in GetDirFlags.");
1077 info = QueueTop(elem)->q_data;
1078 FreeQueue(QueueTop(elem));
1080 sprintf(buf, "List %s in the on-line directory (y/n)", argv[1]);
1081 if (YesNoQuestion(buf, !atoi(info[0])))
1086 sprintf(buf, "List MIT.EDU email address even when mail is "
1087 "forwarded elsewhere? (y/n)");
1088 if (YesNoQuestion(buf, !atoi(info[1])))
1094 if ((stat = do_mr_query("update_user_directory_flags", 3,
1096 com_err(program_name, stat, " in SetDirFlags");
1098 Put_message("Directory preferences set.");