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>
35 void CorrectCapitalization(char **name);
36 char **AskUserInfo(char **info, Bool name);
37 struct mqelem *GetUserInfo(int type, char *name1, char *name2);
46 #define DEFAULT_SHELL "/bin/athena/tcsh"
48 #define DEFAULT_SHELL "/bin/csh"
50 #define DEFAULT_CLASS "?"
53 /* Function Name: UserState
54 * Description: Convert a numeric state into a descriptive string.
55 * Arguments: state value
56 * Returns: pointer to statically allocated string.
59 static char *states[] = {
62 "Half Registered (2)",
64 "Not registerable (4)",
65 "Enrolled/Registerable (5)",
66 "Enrolled/Not Registerable (6)",
70 static char *UserState(int state)
72 static char buf[BUFSIZ];
74 if (state < 0 || state >= US_END)
76 sprintf(buf, "Unknown (%d)", state);
83 /* Function Name: PrintUserName
84 * Description: Print name of a user.
85 * Arguments: info - the information about a user.
89 static void PrintUserName(char **info)
91 char buf[BUFSIZ], print_buf[BUFSIZ];
92 sprintf(buf, "%s, %s %s", info[U_LAST], info[U_FIRST], info[U_MIDDLE]);
93 sprintf(print_buf, "%-40s User Name: %s", buf, info[U_NAME]);
94 Put_message(print_buf);
97 /* Function Name: PrintUserInfo
98 * Description: Prints Information about a user.
99 * Arguments: info - an argument list with the user information
104 static void PrintUserInfo(char **info)
106 char name[BUFSIZ], buf[BUFSIZ];
112 sprintf(name, "%s, %s %s", info[U_LAST], info[U_FIRST], info[U_MIDDLE]);
113 sprintf(buf, "Login name: %-20s Full name: %s", info[U_NAME], name);
115 sprintf(buf, "User id: %-23s Login shell %-10s Class: %s",
116 info[U_UID], info[U_SHELL], info[U_CLASS]);
120 sprintf(buf, "%s:%s", info[U_NAME], info[U_MITID]);
122 status = GDSS_Verify(buf, strlen(buf), info[U_SIGNATURE], &si);
127 sprintf(buf, "Account is: %-20s MIT ID number: %s Signed: %s",
128 UserState(atoi(info[U_STATE])), info[U_MITID],
129 *info[U_SIGNATURE] ? (status ? "Bad" : "Yes") : "No");
131 if (atoi(info[U_SECURE]))
132 sprintf(buf, "Secure password set on %s.", atot(info[U_SECURE]));
134 sprintf(buf, "No secure password set.");
136 sprintf(buf, "Comments: %s", info[U_COMMENT]);
138 sprintf(buf, MOD_FORMAT, info[U_MODBY], info[U_MODTIME], info[U_MODWITH]);
142 /* Function Name: SetUserDefaults
143 * Description: Sets the default values for add user.
144 * Arguments: info - a blank user info array of char *'s.
145 * Returns: args - the filled info structure.
148 static char **SetUserDefaults(char **info)
150 info[U_NAME] = strdup(UNIQUE_LOGIN);
151 info[U_UID] = strdup(UNIQUE_UID);
152 info[U_SHELL] = strdup(DEFAULT_SHELL);
153 info[U_LAST] = strdup(DEFAULT_NONE);
154 info[U_FIRST] = strdup(DEFAULT_NONE);
155 info[U_MIDDLE] = strdup(DEFAULT_NONE);
156 info[U_STATE] = strdup(DEFAULT_NO);
157 info[U_MITID] = strdup(DEFAULT_NONE);
158 info[U_CLASS] = strdup(DEFAULT_CLASS);
159 info[U_COMMENT] = strdup("");
160 info[U_SIGNATURE] = strdup("");
161 info[U_SECURE] = strdup("0");
162 info[U_MODTIME] = info[U_MODBY] = info[U_MODWITH] = info[U_END] = NULL;
167 /* Check that the supplied name follows the capitalization rules, and
168 * offer to correct it if not.
171 void CorrectCapitalization(char **name)
173 char temp_buf[BUFSIZ], fixname[BUFSIZ];
175 strcpy(fixname, *name);
177 if (strcmp(fixname, *name))
179 Put_message("You entered a name which does not follow the capitalization conventions.");
180 sprintf(temp_buf, "Correct it to \"%s\"", fixname);
181 if (YesNoQuestion(temp_buf, 1) == TRUE)
184 *name = strdup(fixname);
190 /* Function Name: AskUserInfo.
191 * Description: This function askes the user for information about a
192 * machine and saves it into a structure.
193 * Arguments: info - a pointer the the structure to put the info into.
194 * flags - Flags asking us which info we want.
195 * Returns: the args to pass to the query.
196 * NOTES: the return args are not necessarily in the correct order to
197 * use the #defined names (e.g args[UID] is not the uid anymore).
200 char **AskUserInfo(char **info, Bool name)
206 char temp_buf[BUFSIZ], *newname;
210 sprintf(temp_buf, "\nChanging Attributes of user %s.\n", info[U_NAME]);
211 Put_message(temp_buf);
215 struct mqelem *elem = NULL;
218 if (GetValueFromUser("User's last name", &info[U_LAST]) == SUB_ERROR)
220 CorrectCapitalization(&info[U_LAST]);
221 if (GetValueFromUser("User's first name", &info[U_FIRST]) == SUB_ERROR)
223 CorrectCapitalization(&info[U_FIRST]);
224 if (GetValueFromUser("User's middle name", &info[U_MIDDLE]) == SUB_ERROR)
226 CorrectCapitalization(&info[U_MIDDLE]);
227 argv[0] = info[U_FIRST];
228 argv[1] = info[U_LAST];
229 if (do_mr_query("get_user_account_by_name", 2, argv,
230 StoreInfo, &elem) == MR_SUCCESS)
232 Put_message("A user by that name already exists in the database.");
233 Loop(QueueTop(elem), PrintUserInfo);
234 Loop(QueueTop(elem), FreeInfo);
236 if (YesNoQuestion("Add new user anyway", TRUE) != TRUE)
242 newname = strdup(info[U_NAME]);
243 if (GetValueFromUser("The new login name for this user", &newname) ==
247 else if (GetValueFromUser("Login name for this user", &info[U_NAME]) ==
251 if (GetValueFromUser("User's UID", &info[U_UID]) == SUB_ERROR)
253 if (GetValueFromUser("User's shell", &info[U_SHELL]) == SUB_ERROR)
257 if (GetValueFromUser("User's last name", &info[U_LAST]) == SUB_ERROR)
259 CorrectCapitalization(&info[U_LAST]);
260 if (GetValueFromUser("User's first name", &info[U_FIRST]) == SUB_ERROR)
262 CorrectCapitalization(&info[U_FIRST]);
263 if (GetValueFromUser("User's middle name", &info[U_MIDDLE]) == SUB_ERROR)
265 CorrectCapitalization(&info[U_MIDDLE]);
270 if (GetValueFromUser("User's status (? for help)", &info[U_STATE]) ==
273 if (isdigit(info[U_STATE][0]))
275 Put_message("Valid status numbers:");
276 for (i = 0; i < US_END; i++)
278 sprintf(temp_buf, " %d: %s", i, states[i]);
279 Put_message(temp_buf);
282 if (GetValueFromUser("User's MIT ID number", &info[U_MITID]) == SUB_ERROR)
284 RemoveHyphens(info[U_MITID]);
285 if (GetTypeFromUser("User's MIT Year (class)", "class", &info[U_CLASS]) ==
288 if (GetValueFromUser("Comments", &info[U_COMMENT]) == SUB_ERROR)
291 if (YesNoQuestion("Secure password set",
292 atoi(info[U_SECURE]) ? TRUE : FALSE) == FALSE)
294 free(info[U_SECURE]);
295 info[U_SECURE] = strdup("0");
297 else if (!strcmp(info[U_SECURE], "0"))
302 gettimeofday(&tv, NULL);
303 sprintf(buf, "%ld", (long) tv.tv_sec);
304 free(info[U_SECURE]);
305 info[U_SECURE] = strdup(buf);
310 if (strcmp(info[U_NAME], UNIQUE_LOGIN))
313 sprintf(temp_buf, "%s:%s", newname, info[U_MITID]);
315 sprintf(temp_buf, "%s:%s", info[U_NAME], info[U_MITID]);
317 i = GDSS_Verify(temp_buf, strlen(temp_buf), info[U_SIGNATURE], &si);
318 /* If it's already signed OK, don't resign it. */
319 if (i != GDSS_SUCCESS)
321 free(info[U_SIGNATURE]);
322 info[U_SIGNATURE] = malloc(GDSS_Sig_Size() * 2);
324 i = GDSS_Sign(temp_buf, strlen(temp_buf), info[U_SIGNATURE]);
325 if (i != GDSS_SUCCESS)
326 com_err(program_name, gdss2et(i), "Failed to create signature");
329 unsigned char buf[256];
331 i = GDSS_Verify(temp_buf, strlen(temp_buf),
332 info[U_SIGNATURE], &si);
333 if (strlen(buf) > 68)
339 info[U_SIGNATURE] = strdup("");
342 FreeAndClear(&info[U_MODTIME], TRUE);
343 FreeAndClear(&info[U_MODBY], TRUE);
344 FreeAndClear(&info[U_MODWITH], TRUE);
347 * Slide the newname into the #2 slot, this screws up all future references
348 * to this list, since we slip the pointer into a info list it gets freed
349 * when the rest of the list gets freed.
352 SlipInNewName(info, newname);
357 /* Function Name: GetUserInfo
358 * Description: Stores the user information in a queue.
359 * Arguments: type - type of field given to get info, one of:
360 * LOGIN, UID, BY_NAME, CLASS.
361 * name1 - name of thing specified by type (wildcards okay)
362 * name2 - other name, only used in get user by first and last.
364 * Returns: the first element of the queue containing the user info.
368 struct mqelem *GetUserInfo(int type, char *name1, char *name2)
372 struct mqelem *elem = NULL;
378 if ((status = do_mr_query("get_user_account_by_login", 1, args,
381 com_err(program_name, status,
382 " when attempting to get_user_account_by_login.");
388 if ((status = do_mr_query("get_user_account_by_uid", 1, args,
391 com_err(program_name, status,
392 " when attempting to get_user_account_by_uid.");
399 if ((status = do_mr_query("get_user_account_by_name", 2, args,
402 com_err(program_name, status,
403 " when attempting to get_user_account_by_name.");
409 if ((status = do_mr_query("get_user_account_by_class", 1, args,
412 com_err(program_name, status,
413 " when attempting to get_user_account_by_class.");
419 if ((status = do_mr_query("get_user_account_by_id", 1, args,
422 com_err(program_name, status,
423 " when attempting to get_user_account_by_id.");
428 return QueueTop(elem) ;
431 /* Function Name: AddNewUser
432 * Description: Adds a new user to the database.
434 * Returns: DM_NORMAL.
437 int AddNewUser(int argc, char **argv)
440 char **args, *info[MAX_ARGS_SIZE];
442 if (!(args = AskUserInfo(SetUserDefaults(info), FALSE)))
444 Put_message("Aborted.");
447 if ((status = do_mr_query("add_user_account", CountArgs(args),
449 com_err(program_name, status, " in add_user_account");
451 Put_message("New user added to database.");
457 /* Function Name: GetLoginName
458 * Description: Asks the user for a login name and reserves
461 * Returns: a malloced login name for the user.
464 static char *GetLoginName(void)
469 if (GetValueFromUser("Login name for this user? ", &name) == SUB_ERROR)
471 Put_message("KERBEROS code not added, did not reserve name with kerberos.");
476 /* Function Name: ChooseUser
477 * Description: Choose a user from a list and return the uid.
478 * Arguments: top - a queue of user information.
479 * Returns: uid - the malloced uid of the user that was chosen.
482 static char *ChooseUser(struct mqelem *elem)
486 char **info = elem->q_data;
488 switch (YesNoQuitQuestion("Is this the user you want (y/n/q)", FALSE))
491 return strdup(info[U_UID]);
494 default: /* quit or ^C. */
502 /* Function Name: GetUidNumberFromName
503 * Description: Gets the users uid number, from the name.
505 * Returns: uid - a malloced string containing the uid.
508 static char *GetUidNumberFromName(void)
510 char *args[5], *uid, first[BUFSIZ], last[BUFSIZ];
512 struct mqelem *top = NULL;
514 if (!Prompt_input("First Name: ", first, BUFSIZ))
516 if (!Prompt_input("Last Name: ", last, BUFSIZ))
524 switch ((status = do_mr_query("get_user_account_by_name", 2, args,
530 Put_message("There is no user in the database with that name.");
533 com_err(program_name, status, " in get_account_user_by_name.");
538 if (QueueCount(top) == 1) /* This is a unique name. */
540 char **info = top->q_data;
541 Put_message("User ID Number retrieved for the user: ");
544 uid = strdup(info[U_UID]);
549 Put_message("That name is not unique, choose the user that you want.");
550 uid = ChooseUser(top);
555 /* Function Name: SetUserPassword
556 * Description: Set the new kerberos password for this user.
557 * Arguments: name - kerberos principle name for this user, (login name).
561 static void SetUserPassword(char *name)
563 name = name; /* make saber happy. */
564 Put_message("Kerberos password not changed, code non-existant.");
565 /* clever message to call account_admin, if this fails. */
568 /* Function Name: GiveBackLogin
569 * Description: Gives back previously reserved kerberous principle.
570 * Arguments: name - principle to give back.
574 static void GiveBackLogin(char *name)
576 name = name; /* make saber happy. */
577 Put_message("kerberos code not implimented, name not given back.");
578 /* send mail to db maintainer if this fails. */
581 /* Function Name: RegisterUser
582 * Description: This function registers a user.
584 * Returns: DM_NORMAL.
587 int RegisterUser(int argc, char **argv)
589 char *args[MAX_ARGS_SIZE];
590 char *login, *fstype = NULL;
591 char temp_buf[BUFSIZ];
594 Put_message("This function has NO kerberos support, so strange things");
595 Put_message("may happen if you use it to register a user.");
597 switch (YesNoQuestion("Do you know the users UID Number (y/n)", FALSE))
600 Prompt_input("What is the UID number of the user? ", temp_buf, BUFSIZ);
601 args[0] = strdup(temp_buf);
604 if (!(args[0] = GetUidNumberFromName()))
611 sprintf(temp_buf, "u%s", args[0]);
612 login = strdup(temp_buf);
613 if ((GetValueFromUser("Login name for this user? ", &login) == SUB_ERROR) ||
614 (GetFSTypes(&fstype, FALSE) == SUB_ERROR))
617 FreeInfo(args); /* This work because the NULL temination is ok. */
620 Put_message("KERBEROS code not added, did not reserve name with kerberos.");
625 switch ((status = do_mr_query("register_user", CountArgs(args),
629 sprintf(temp_buf, "User %s successfully registered.", login);
630 Put_message(temp_buf);
631 SetUserPassword(login);
634 GiveBackLogin(login);
635 sprintf(temp_buf, "The username %s is already in use.", login);
636 Put_message(temp_buf);
639 com_err(program_name, status, " in register_user");
646 /* Function Name: RealUpdateUser
647 * Description: actuall updates the user information.
648 * Arguments: info - all current information for the user fields.
649 * junk - an UNUSED boolean.
653 static void RealUpdateUser(char **info, Bool junk)
656 char error_buf[BUFSIZ];
657 char **args = AskUserInfo(info, TRUE);
661 Put_message("Aborted.");
664 if ((status = do_mr_query("update_user_account", CountArgs(args),
667 com_err(program_name, status, " in ModifyFields");
668 sprintf(error_buf, "User %s not updated due to errors.", info[NAME]);
669 Put_message(error_buf);
673 /* Function Name: UpdateUser
674 * Description: Modify some of the information about a user.
675 * Arguments: argc, argv - login name of the user in argv[1].
676 * Returns: DM_NORMAL.
679 int UpdateUser(int argc, char **argv)
683 elem = GetUserInfo(LOGIN, argv[1], NULL);
684 QueryLoop(elem, NullPrint, RealUpdateUser, "Update the user");
690 /* Function Name: RealDeactivateUser
691 * Description: sets the user's status to 3.
692 * Arguments: info - all current information for the user fields
693 * one_item - indicates the user hasn't been queried yet
697 static void RealDeactivateUser(char **info, Bool one_item)
700 char txt_buf[BUFSIZ];
701 char *qargs[2], **args;
702 struct mqelem *elem = NULL;
706 sprintf(txt_buf, "Deactivate user %s (y/n)", info[NAME]);
707 if (YesNoQuestion(txt_buf, FALSE) != TRUE)
711 qargs[0] = info[NAME];
713 if ((status = do_mr_query("update_user_status", 2, qargs, NULL, NULL)))
715 com_err(program_name, status, " in update_user_status");
716 sprintf(txt_buf, "User %s not deactivated due to errors.", info[NAME]);
717 Put_message(txt_buf);
719 else if (YesNoQuestion("Also deactivate matching list and filesystem (y/n)",
722 status = do_mr_query("get_list_info", 1, &(info[NAME]), StoreInfo,
724 if (status == MR_SUCCESS)
726 args = QueueTop(elem)->q_data;
727 free(args[L_ACTIVE]);
728 args[L_ACTIVE] = strdup("0");
729 FreeAndClear(&args[L_MODTIME], TRUE);
730 FreeAndClear(&args[L_MODBY], TRUE);
731 FreeAndClear(&args[L_MODWITH], TRUE);
732 SlipInNewName(args, args[L_NAME]);
733 if ((status = do_mr_query("update_list", CountArgs(args), args,
736 com_err(program_name, status, " updating list, "
737 "not deactivating list or filesystem");
746 else if (status != MR_NO_MATCH)
748 com_err(program_name, status, " getting list info, "
749 "not deactivating list or filesystem");
753 if ((status = do_mr_query("get_filesys_by_label", 1, &(info[NAME]),
756 com_err(program_name, status, " getting filsys info, "
757 "not deactivating filesystem");
762 args = QueueTop(elem)->q_data;
764 args[FS_TYPE] = strdup("ERR");
765 free(args[FS_COMMENTS]);
766 args[FS_COMMENTS] = strdup("Locker disabled; call 3-1325 for help");
767 FreeAndClear(&args[FS_MODTIME], TRUE);
768 FreeAndClear(&args[FS_MODBY], TRUE);
769 FreeAndClear(&args[FS_MODWITH], TRUE);
770 SlipInNewName(args, args[FS_NAME]);
771 if ((status = do_mr_query("update_filesys", CountArgs(args), args,
774 com_err(program_name, status, " updating filesystem, "
775 "not deactivating filesystem");
786 /* Function Name: DeactivateUser
787 * Description: sets the user's status to 3.
788 * Arguments: argc, argv - login name of the user in argv[1].
789 * Returns: DM_NORMAL.
792 int DeactivateUser(int argc, char **argv)
796 elem = GetUserInfo(LOGIN, argv[1], NULL);
797 QueryLoop(elem, NullPrint, RealDeactivateUser, "Deactivate user");
804 /* ------------------------- Top Menu ------------------------- */
806 /* DeleteUser() in delete.c */
808 /* Function Name: DeleteUserByUid
809 * Description: Deletes the user given a uid number.
810 * Arguments: argc, argv - uid if user in argv[1].
811 * Returns: DM_NORMAL.
812 * NOTES: This just gets the username from the mr server
813 * and performs a DeleteUser().
816 int DeleteUserByUid(int argc, char **argv)
819 struct mqelem *elem = NULL;
822 if (!ValidName(argv[1]))
825 if ((status = do_mr_query("get_user_account_by_uid", 1, argv + 1, StoreInfo,
827 com_err(program_name, status, " in get_user_account_by_uid");
830 argv[1] = info[U_NAME];
832 DeleteUser(argc, argv);
836 /* ------------------------- Show User Information ------------------------- */
838 /* Function Name: ShowUserByLogin
839 * Description: Shows user information given a login name.
840 * Arguments: argc, argv - login name in argv[1].
844 int ShowUserByLogin(int argc, char *argv[])
846 struct mqelem *top, *elem;
848 elem = top = GetUserInfo(LOGIN, argv[1], NULL);
849 Loop(elem, PrintUserInfo);
855 /* Function Name: RetrieveUserByName
856 * Description: Show information on a user give fist and/or last name.
857 * Arguments: argc, argv - argv[1] - first name.
858 * argv[2] - last name.
859 * Returns: DM_NORMAL.
862 int ShowUserByName(int argc, char *argv[])
867 top = GetUserInfo(BY_NAME, argv[1], argv[2]);
869 if (!top) /* if there was an error then return. */
872 if (!PromptWithDefault("Print full information, or just the names (f/n)?",
880 Loop(top, PrintUserInfo);
884 Loop(top, PrintUserName);
892 /* Function Name: ShowUserByClass
893 * Description: Shows real and login names of all users in class.
894 * Arguments: argc, argv - argv[1] contains the class.
898 int ShowUserByClass(int argc, char **argv)
902 if (YesNoQuestion("This will take a long time. Are you sure", 0) == FALSE)
904 top = GetUserInfo(CLASS, argv[1], NULL);
905 Loop(top, PrintUserName);
912 /* Function Name: ShowUserById
913 * Description: Shows user information given an ID number.
914 * Arguments: argc, argv - ID number in argv[1].
918 int ShowUserById(int argc, char *argv[])
920 struct mqelem *top, *elem;
922 elem = top = GetUserInfo(ID, argv[1], NULL);
923 Loop(elem, PrintUserInfo);
930 /* Function Name: GetKrbmap
931 * Description: Shows user <-> Kerberos mappings
932 * Arguments: argc, argv - argv[1] contains the user login name,
933 * argv[2] contains the principal
937 int GetKrbmap(int argc, char **argv)
940 struct mqelem *elem = NULL, *top;
943 if ((stat = do_mr_query("get_kerberos_user_map", 2, &argv[1],
946 com_err(program_name, stat, " in GetKrbMap.");
950 top = elem = QueueTop(elem);
954 char **info = elem->q_data;
955 sprintf(buf, "User: %-9s Principal: %s",
956 info[KMAP_USER], info[KMAP_PRINCIPAL]);
961 FreeQueue(QueueTop(top));
966 /* Function Name: AddKrbmap
967 * Description: Add a new user <-> Kerberos mapping
968 * Arguments: argc, argv - argv[1] contains the user login name,
969 * argv[2] contains the principal
973 int AddKrbmap(int argc, char **argv)
977 if (!strchr(argv[KMAP_PRINCIPAL + 1], '@'))
979 Put_message("Please specify a realm for the kerberos principal.");
982 if ((stat = do_mr_query("add_kerberos_user_map", 2, &argv[1],
985 com_err(program_name, stat, " in AddKrbMap.");
986 if (stat == MR_EXISTS)
987 Put_message("No user or principal may have more than one mapping.");
993 /* Function Name: DeleteKrbmap
994 * Description: Remove a user <-> Kerberos mapping
995 * Arguments: argc, argv - argv[1] contains the user login name,
996 * argv[2] contains the principal
1000 int DeleteKrbmap(int argc, char **argv)
1004 if ((stat = do_mr_query("delete_kerberos_user_map", 2, &argv[1],
1006 com_err(program_name, stat, " in DeleteKrbMap.");
1011 /* Function Name: GetDirFlags
1012 * Description: Shows MITdir listing preferences
1013 * Arguments: argc, argv - argv[1] contains the user login name
1017 int GetDirFlags(int argc, char **argv)
1020 struct mqelem *elem = NULL;
1021 char buf[BUFSIZ], **info;
1023 if (!ValidName(argv[1]))
1026 if ((stat = do_mr_query("get_user_directory_flags", 1, &argv[1],
1029 com_err(program_name, stat, " in GetDirFlags.");
1033 info = QueueTop(elem)->q_data;
1034 flags = atoi(info[0]);
1035 FreeQueue(QueueTop(elem));
1038 sprintf(buf, "User: %s", argv[1]);
1040 if (flags & DIRFLAGS_SUPPRESS)
1041 Put_message("Does NOT appear in the on-line directory.");
1044 Put_message("Does appear in the on-line directory.");
1045 if (flags & DIRFLAGS_NONLOCAL)
1046 Put_message("Is listed with non-MIT.EDU email address (if known)");
1048 Put_message("Is listed with MIT.EDU email address.");
1054 /* Function Name: SetDirFlags
1055 * Description: Update online directory preferences
1056 * Arguments: argc, argv - the login name of the user in argv[1].
1057 * Returns: DM_NORMAL.
1060 int SetDirFlags(int argc, char **argv)
1063 char **info, buf[BUFSIZ], *args[2];
1064 struct mqelem *elem = NULL;
1066 if (!ValidName(argv[1]))
1069 /* Fetch current prefs */
1070 if ((stat = do_mr_query("get_user_directory_flags", 1, &argv[1],
1073 com_err(program_name, stat, " in GetDirFlags.");
1076 info = QueueTop(elem)->q_data;
1077 flags = atoi(info[0]);
1078 FreeQueue(QueueTop(elem));
1080 sprintf(buf, "List %s in the on-line directory (y/n)", argv[1]);
1081 if (YesNoQuestion(buf, !(flags & DIRFLAGS_SUPPRESS)))
1082 flags &= ~DIRFLAGS_SUPPRESS;
1084 flags |= DIRFLAGS_SUPPRESS;
1086 sprintf(buf, "List MIT.EDU email address even when mail is "
1087 "forwarded elsewhere? (y/n)");
1088 if (YesNoQuestion(buf, !(flags & DIRFLAGS_NONLOCAL)))
1089 flags &= ~DIRFLAGS_NONLOCAL;
1091 flags |= DIRFLAGS_NONLOCAL;
1094 sprintf(buf, "%d", flags);
1096 if ((stat = do_mr_query("update_user_directory_flags", 2,
1098 com_err(program_name, stat, " in SetDirFlags");
1100 Put_message("Directory preferences set.");