1 #if (!defined(lint) && !defined(SABER))
2 static char rcsid_module_c[] = "$Header$";
5 /* This is the file user.c for the Moira Client, which allows users
6 * to quickly and easily maintain most parts of the Moira database.
7 * It Contains: Functions for manipulating user information.
10 * By: Chris D. Peterson
16 * Copyright 1988 by the Massachusetts Institute of Technology.
18 * For further information on copyright and distribution
19 * see the file mit-copyright.h
26 #include <moira_site.h>
35 #include "mit-copyright.h"
47 #define DEFAULT_SHELL "/bin/athena/tcsh"
49 #define DEFAULT_SHELL "/bin/csh"
51 #define DEFAULT_CLASS "?"
54 /* Function Name: UserState
55 * Description: Convert a numeric state into a descriptive string.
56 * Arguments: state value
57 * Returns: pointer to statically allocated string.
60 static char *states[] = {
63 "Half Registered (2)",
65 "Not registerable (4)",
66 "Enrolled/Registerable (5)",
67 "Enrolled/Not Registerable (6)",
71 static char *UserState(int state)
73 static char buf[BUFSIZ];
75 if (state < 0 || state >= US_END)
77 sprintf(buf, "Unknown (%d)", state);
84 /* Function Name: PrintUserName
85 * Description: Print name of a user.
86 * Arguments: info - the information about a user.
90 static void PrintUserName(char **info)
92 char buf[BUFSIZ], print_buf[BUFSIZ];
93 sprintf(buf, "%s, %s %s", info[U_LAST], info[U_FIRST], info[U_MIDDLE]);
94 sprintf(print_buf, "%-40s User Name: %s", buf, info[U_NAME]);
95 Put_message(print_buf);
98 /* Function Name: PrintUserInfo
99 * Description: Prints Information about a user.
100 * Arguments: info - an argument list with the user information
105 static void PrintUserInfo(char **info)
107 char name[BUFSIZ], buf[BUFSIZ];
113 sprintf(name, "%s, %s %s", info[U_LAST], info[U_FIRST], info[U_MIDDLE]);
114 sprintf(buf, "Login name: %-20s Full name: %s", info[U_NAME], name);
116 sprintf(buf, "User id: %-23s Login shell %-10s Class: %s",
117 info[U_UID], info[U_SHELL], info[U_CLASS]);
121 sprintf(buf, "%s:%s", info[U_NAME], info[U_MITID]);
123 status = GDSS_Verify(buf, strlen(buf), info[U_SIGNATURE], &si);
128 sprintf(buf, "Account is: %-20s MIT ID number: %s Signed: %s",
129 UserState(atoi(info[U_STATE])), info[U_MITID],
130 *info[U_SIGNATURE] ? (status ? "Bad" : "Yes") : "No");
132 if (atoi(info[U_SECURE]))
133 sprintf(buf, "Secure password set on %s.", atot(info[U_SECURE]));
135 sprintf(buf, "No secure password set.");
137 sprintf(buf, "Comments: %s", info[U_COMMENT]);
139 sprintf(buf, MOD_FORMAT, info[U_MODBY], info[U_MODTIME], info[U_MODWITH]);
143 /* Function Name: SetUserDefaults
144 * Description: Sets the default values for add user.
145 * Arguments: info - a blank user info array of char *'s.
146 * Returns: args - the filled info structure.
149 static char **SetUserDefaults(char **info)
151 info[U_NAME] = Strsave(UNIQUE_LOGIN);
152 info[U_UID] = Strsave(UNIQUE_UID);
153 info[U_SHELL] = Strsave(DEFAULT_SHELL);
154 info[U_LAST] = Strsave(DEFAULT_NONE);
155 info[U_FIRST] = Strsave(DEFAULT_NONE);
156 info[U_MIDDLE] = Strsave(DEFAULT_NONE);
157 info[U_STATE] = Strsave(DEFAULT_NO);
158 info[U_MITID] = Strsave(DEFAULT_NONE);
159 info[U_CLASS] = Strsave(DEFAULT_CLASS);
160 info[U_COMMENT] = Strsave("");
161 info[U_SIGNATURE] = Strsave("");
162 info[U_SECURE] = Strsave("0");
163 info[U_MODTIME] = info[U_MODBY] = info[U_MODWITH] = info[U_END] = NULL;
168 /* Check that the supplied name follows the capitalization rules, and
169 * offer to correct it if not.
172 int CorrectCapitalization(char **name)
174 char temp_buf[BUFSIZ], fixname[BUFSIZ];
176 strcpy(fixname, *name);
178 if (strcmp(fixname, *name))
180 Put_message("You entered a name which does not follow the capitalization conventions.");
181 sprintf(temp_buf, "Correct it to \"%s\"", fixname);
182 if (YesNoQuestion(temp_buf, 1) == TRUE)
185 *name = strsave(fixname);
191 /* Function Name: AskUserInfo.
192 * Description: This function askes the user for information about a
193 * machine and saves it into a structure.
194 * Arguments: info - a pointer the the structure to put the info into.
195 * flags - Flags asking us which info we want.
196 * Returns: the args to pass to the query.
197 * NOTES: the return args are not necessarily in the correct order to
198 * use the #defined names (e.g args[UID] is not the uid anymore).
201 char **AskUserInfo(char **info, Bool name)
207 char temp_buf[BUFSIZ], *newname;
211 sprintf(temp_buf, "\nChanging Attributes of user %s.\n", info[U_NAME]);
212 Put_message(temp_buf);
216 struct qelem *elem = NULL;
219 if (GetValueFromUser("User's last name", &info[U_LAST]) == SUB_ERROR)
221 CorrectCapitalization(&info[U_LAST]);
222 if (GetValueFromUser("User's first name", &info[U_FIRST]) == SUB_ERROR)
224 CorrectCapitalization(&info[U_FIRST]);
225 if (GetValueFromUser("User's middle name", &info[U_MIDDLE]) == SUB_ERROR)
227 CorrectCapitalization(&info[U_MIDDLE]);
228 argv[0] = info[U_FIRST];
229 argv[1] = info[U_LAST];
230 if (do_mr_query("get_user_account_by_name", 2, argv,
231 StoreInfo, (char *) &elem) == MR_SUCCESS)
233 Put_message("A user by that name already exists in the database.");
234 Loop(QueueTop(elem), PrintUserInfo);
235 Loop(QueueTop(elem), FreeInfo);
237 if (YesNoQuestion("Add new user anyway", TRUE) != TRUE)
243 newname = Strsave(info[U_NAME]);
244 if (GetValueFromUser("The new login name for this user", &newname) ==
248 else if (GetValueFromUser("Login name for this user", &info[U_NAME]) ==
252 if (GetValueFromUser("User's UID", &info[U_UID]) == SUB_ERROR)
254 if (GetValueFromUser("User's shell", &info[U_SHELL]) == SUB_ERROR)
258 if (GetValueFromUser("User's last name", &info[U_LAST]) == SUB_ERROR)
260 CorrectCapitalization(&info[U_LAST]);
261 if (GetValueFromUser("User's first name", &info[U_FIRST]) == SUB_ERROR)
263 CorrectCapitalization(&info[U_FIRST]);
264 if (GetValueFromUser("User's middle name", &info[U_MIDDLE]) == SUB_ERROR)
266 CorrectCapitalization(&info[U_MIDDLE]);
271 if (GetValueFromUser("User's status (? for help)", &info[U_STATE]) ==
274 if (isdigit(info[U_STATE][0]))
276 Put_message("Valid status numbers:");
277 for (i = 0; i < US_END; i++)
279 sprintf(temp_buf, " %d: %s", i, states[i]);
280 Put_message(temp_buf);
283 if (GetValueFromUser("User's MIT ID number", &info[U_MITID]) == SUB_ERROR)
285 RemoveHyphens(info[U_MITID]);
286 if (GetTypeFromUser("User's MIT Year (class)", "class", &info[U_CLASS]) ==
289 if (GetValueFromUser("Comments", &info[U_COMMENT]) == SUB_ERROR)
292 if (YesNoQuestion("Secure password set",
293 atoi(info[U_SECURE]) ? TRUE : FALSE) == FALSE)
295 free(info[U_SECURE]);
296 info[U_SECURE] = strsave("0");
298 else if (!strcmp(info[U_SECURE], "0"))
303 gettimeofday(&tv, NULL);
304 sprintf(buf, "%ld", (long) tv.tv_sec);
305 free(info[U_SECURE]);
306 info[U_SECURE] = strsave(buf);
311 if (strcmp(info[U_NAME], UNIQUE_LOGIN))
314 sprintf(temp_buf, "%s:%s", newname, info[U_MITID]);
316 sprintf(temp_buf, "%s:%s", info[U_NAME], info[U_MITID]);
318 i = GDSS_Verify(temp_buf, strlen(temp_buf), info[U_SIGNATURE], &si);
319 /* If it's already signed OK, don't resign it. */
320 if (i != GDSS_SUCCESS)
322 free(info[U_SIGNATURE]);
323 info[U_SIGNATURE] = malloc(GDSS_Sig_Size() * 2);
325 i = GDSS_Sign(temp_buf, strlen(temp_buf), info[U_SIGNATURE]);
326 if (i != GDSS_SUCCESS)
327 com_err(program_name, gdss2et(i), "Failed to create signature");
330 unsigned char buf[256];
332 i = GDSS_Verify(temp_buf, strlen(temp_buf),
333 info[U_SIGNATURE], &si);
334 if (strlen(buf) > 68)
340 info[U_SIGNATURE] = strsave("");
343 FreeAndClear(&info[U_MODTIME], TRUE);
344 FreeAndClear(&info[U_MODBY], TRUE);
345 FreeAndClear(&info[U_MODWITH], TRUE);
348 * Slide the newname into the #2 slot, this screws up all future references
349 * to this list, since we slip the pointer into a info list it gets freed
350 * when the rest of the list gets freed.
353 SlipInNewName(info, newname);
358 /* Function Name: GetUserInfo
359 * Description: Stores the user information in a queue.
360 * Arguments: type - type of field given to get info, one of:
361 * LOGIN, UID, BY_NAME, CLASS.
362 * name1 - name of thing specified by type (wildcards okay)
363 * name2 - other name, only used in get user by first and last.
365 * Returns: the first element of the queue containing the user info.
369 struct qelem *GetUserInfo(int type, char *name1, char *name2)
373 struct qelem *elem = NULL;
379 if ((status = do_mr_query("get_user_account_by_login", 1, args,
380 StoreInfo, (char *) &elem)))
382 com_err(program_name, status,
383 " when attempting to get_user_account_by_login.");
389 if ((status = do_mr_query("get_user_account_by_uid", 1, args,
390 StoreInfo, (char *) &elem)))
392 com_err(program_name, status,
393 " when attempting to get_user_account_by_uid.");
400 if ((status = do_mr_query("get_user_account_by_name", 2, args,
401 StoreInfo, (char *) &elem)))
403 com_err(program_name, status,
404 " when attempting to get_user_account_by_name.");
410 if ((status = do_mr_query("get_user_account_by_class", 1, args,
411 StoreInfo, (char *) &elem)))
413 com_err(program_name, status,
414 " when attempting to get_user_account_by_class.");
420 if ((status = do_mr_query("get_user_account_by_id", 1, args,
421 StoreInfo, (char *) &elem)))
423 com_err(program_name, status,
424 " when attempting to get_user_account_by_id.");
429 return QueueTop(elem) ;
432 /* Function Name: AddNewUser
433 * Description: Adds a new user to the database.
435 * Returns: DM_NORMAL.
441 char **args, *info[MAX_ARGS_SIZE];
443 if (!(args = AskUserInfo(SetUserDefaults(info), FALSE)))
445 Put_message("Aborted.");
448 if ((status = do_mr_query("add_user_account", CountArgs(args),
449 args, Scream, NULL)))
450 com_err(program_name, status, " in add_user_account");
452 Put_message("New user added to database.");
458 /* Function Name: GetLoginName
459 * Description: Asks the user for a login name and reserves
462 * Returns: a malloced login name for the user.
465 static char *GetLoginName(void)
470 if (GetValueFromUser("Login name for this user? ", &name) == SUB_ERROR)
472 Put_message("KERBEROS code not added, did not reserve name with kerberos.");
477 /* Function Name: ChooseUser
478 * Description: Choose a user from a list and return the uid.
479 * Arguments: top - a queue of user information.
480 * Returns: uid - the malloced uid of the user that was chosen.
483 static char *ChooseUser(struct qelem *elem)
487 char **info = (char **) elem->q_data;
489 switch (YesNoQuitQuestion("Is this the user you want (y/n/q)", FALSE))
492 return Strsave(info[U_UID]);
495 default: /* quit or ^C. */
503 /* Function Name: GetUidNumberFromName
504 * Description: Gets the users uid number, from the name.
506 * Returns: uid - a malloced string containing the uid.
509 static char *GetUidNumberFromName(void)
511 char *args[5], *uid, first[BUFSIZ], last[BUFSIZ];
513 struct qelem *top = NULL;
515 if (!Prompt_input("First Name: ", first, BUFSIZ))
517 if (!Prompt_input("Last Name: ", last, BUFSIZ))
525 switch ((status = do_mr_query("get_user_account_by_name", 2, args,
526 StoreInfo, (char *) &top)))
531 Put_message("There is no user in the database with that name.");
534 com_err(program_name, status, " in get_account_user_by_name.");
539 if (QueueCount(top) == 1) /* This is a unique name. */
541 char **info = (char **) top->q_data;
542 Put_message("User ID Number retrieved for the user: ");
545 uid = Strsave(info[U_UID]);
550 Put_message("That name is not unique, choose the user that you want.");
551 uid = ChooseUser(top);
556 /* Function Name: SetUserPassword
557 * Description: Set the new kerberos password for this user.
558 * Arguments: name - kerberos principle name for this user, (login name).
562 static void SetUserPassword(char *name)
564 name = name; /* make saber happy. */
565 Put_message("Kerberos password not changed, code non-existant.");
566 /* clever message to call account_admin, if this fails. */
569 /* Function Name: GiveBackLogin
570 * Description: Gives back previously reserved kerberous principle.
571 * Arguments: name - principle to give back.
575 static void GiveBackLogin(char *name)
577 name = name; /* make saber happy. */
578 Put_message("kerberos code not implimented, name not given back.");
579 /* send mail to db maintainer if this fails. */
582 /* Function Name: RegisterUser
583 * Description: This function registers a user.
585 * Returns: DM_NORMAL.
588 int RegisterUser(void)
590 char *args[MAX_ARGS_SIZE];
591 char *login, *fstype = NULL;
592 char temp_buf[BUFSIZ];
595 Put_message("This function has NO kerberos support, so strange things");
596 Put_message("may happen if you use it to register a user.");
598 switch (YesNoQuestion("Do you know the users UID Number (y/n)", FALSE))
601 Prompt_input("What is the UID number of the user? ", temp_buf, BUFSIZ);
602 args[0] = Strsave(temp_buf);
605 if (!(args[0] = GetUidNumberFromName()))
612 sprintf(temp_buf, "u%s", args[0]);
613 login = strsave(temp_buf);
614 if ((GetValueFromUser("Login name for this user? ", &login) == SUB_ERROR) ||
615 (GetFSTypes(&fstype, FALSE) == SUB_ERROR))
618 FreeInfo(args); /* This work because the NULL temination is ok. */
621 Put_message("KERBEROS code not added, did not reserve name with kerberos.");
626 switch ((status = do_mr_query("register_user", CountArgs(args),
627 args, Scream, NULL)))
630 sprintf(temp_buf, "User %s successfully registered.", login);
631 Put_message(temp_buf);
632 SetUserPassword(login);
635 GiveBackLogin(login);
636 sprintf(temp_buf, "The username %s is already in use.", login);
637 Put_message(temp_buf);
640 com_err(program_name, status, " in register_user");
647 /* Function Name: RealUpdateUser
648 * Description: actuall updates the user information.
649 * Arguments: info - all current information for the user fields.
650 * junk - an UNUSED boolean.
654 static void RealUpdateUser(char **info, Bool junk)
657 char error_buf[BUFSIZ];
658 char **args = AskUserInfo(info, TRUE);
662 Put_message("Aborted.");
665 if ((status = do_mr_query("update_user_account", CountArgs(args),
666 args, Scream, NULL)))
668 com_err(program_name, status, " in ModifyFields");
669 sprintf(error_buf, "User %s not updated due to errors.", info[NAME]);
670 Put_message(error_buf);
674 /* Function Name: UpdateUser
675 * Description: Modify some of the information about a user.
676 * Arguments: argc, argv - login name of the user in argv[1].
677 * Returns: DM_NORMAL.
680 int UpdateUser(int argc, char **argv)
684 elem = GetUserInfo(LOGIN, argv[1], NULL);
685 QueryLoop(elem, NullPrint, RealUpdateUser, "Update the user");
691 /* Function Name: RealDeactivateUser
692 * Description: sets the user's status to 3.
693 * Arguments: info - all current information for the user fields
694 * one_item - indicates the user hasn't been queried yet
698 static void RealDeactivateUser(char **info, Bool one_item)
701 char txt_buf[BUFSIZ];
702 char *qargs[2], **args;
703 struct qelem *elem = NULL;
707 sprintf(txt_buf, "Deactivate user %s (y/n)", info[NAME]);
708 if (YesNoQuestion(txt_buf, FALSE) != TRUE)
712 qargs[0] = info[NAME];
714 if ((status = do_mr_query("update_user_status", 2, qargs, Scream, NULL)))
716 com_err(program_name, status, " in update_user_status");
717 sprintf(txt_buf, "User %s not deactivated due to errors.", info[NAME]);
718 Put_message(txt_buf);
720 else if (YesNoQuestion("Also deactivate matching list and filesystem (y/n)",
723 status = do_mr_query("get_list_info", 1, &(info[NAME]), StoreInfo,
725 if (status == MR_SUCCESS)
727 args = (char **) (QueueTop(elem)->q_data);
728 free(args[L_ACTIVE]);
729 args[L_ACTIVE] = strsave("0");
730 FreeAndClear(&args[L_MODTIME], TRUE);
731 FreeAndClear(&args[L_MODBY], TRUE);
732 FreeAndClear(&args[L_MODWITH], TRUE);
733 SlipInNewName(args, args[L_NAME]);
734 if ((status = do_mr_query("update_list", CountArgs(args), args,
737 com_err(program_name, status, " updating list, "
738 "not deactivating list or filesystem");
747 else if (status != MR_NO_MATCH)
749 com_err(program_name, status, " getting list info, "
750 "not deactivating list or filesystem");
754 if ((status = do_mr_query("get_filesys_by_label", 1, &(info[NAME]),
755 StoreInfo, (char *) &elem)))
757 com_err(program_name, status, " getting filsys info, "
758 "not deactivating filesystem");
763 args = (char **) (QueueTop(elem)->q_data);
765 args[FS_TYPE] = strsave("ERR");
766 free(args[FS_COMMENTS]);
767 args[FS_COMMENTS] = strsave("Locker disabled; call 3-1325 for help");
768 FreeAndClear(&args[FS_MODTIME], TRUE);
769 FreeAndClear(&args[FS_MODBY], TRUE);
770 FreeAndClear(&args[FS_MODWITH], TRUE);
771 SlipInNewName(args, args[FS_NAME]);
772 if ((status = do_mr_query("update_filesys", CountArgs(args), args,
775 com_err(program_name, status, " updating filesystem, "
776 "not deactivating filesystem");
787 /* Function Name: DeactivateUser
788 * Description: sets the user's status to 3.
789 * Arguments: argc, argv - login name of the user in argv[1].
790 * Returns: DM_NORMAL.
793 int DeactivateUser(int argc, char **argv)
797 elem = GetUserInfo(LOGIN, argv[1], NULL);
798 QueryLoop(elem, NullPrint, RealDeactivateUser, "Deactivate user");
805 /* ------------------------- Top Menu ------------------------- */
807 /* DeleteUser() in delete.c */
809 /* Function Name: DeleteUserByUid
810 * Description: Deletes the user given a uid number.
811 * Arguments: argc, argv - uid if user in argv[1].
812 * Returns: DM_NORMAL.
813 * NOTES: This just gets the username from the mr server
814 * and performs a DeleteUser().
817 int DeleteUserByUid(int argc, char **argv)
820 struct qelem *elem = NULL;
823 if (!ValidName(argv[1]))
826 if ((status = do_mr_query("get_user_account_by_uid", 1, argv + 1, StoreInfo,
828 com_err(program_name, status, " in get_user_account_by_uid");
830 info = (char **) elem->q_data;
831 argv[1] = info[U_NAME];
833 DeleteUser(argc, argv);
837 /* ------------------------- Show User Information ------------------------- */
839 /* Function Name: ShowUserByLogin
840 * Description: Shows user information given a login name.
841 * Arguments: argc, argv - login name in argv[1].
845 int ShowUserByLogin(int argc, char *argv[])
847 struct qelem *top, *elem;
849 elem = top = GetUserInfo(LOGIN, argv[1], NULL);
850 Loop(elem, PrintUserInfo);
856 /* Function Name: RetrieveUserByName
857 * Description: Show information on a user give fist and/or last name.
858 * Arguments: argc, argv - argv[1] - first name.
859 * argv[2] - last name.
860 * Returns: DM_NORMAL.
863 int ShowUserByName(int argc, char *argv[])
868 top = GetUserInfo(BY_NAME, argv[1], argv[2]);
870 if (!top) /* if there was an error then return. */
873 if (!PromptWithDefault("Print full information, or just the names (f/n)?",
881 Loop(top, PrintUserInfo);
885 Loop(top, PrintUserName);
893 /* Function Name: ShowUserByClass
894 * Description: Shows real and login names of all users in class.
895 * Arguments: argc, argv - argv[1] contains the class.
899 int ShowUserByClass(int argc, char **argv)
903 if (YesNoQuestion("This will take a long time. Are you sure", 0) == FALSE)
905 top = GetUserInfo(CLASS, argv[1], NULL);
906 Loop(top, PrintUserName);
913 /* Function Name: ShowUserById
914 * Description: Shows user information given an ID number.
915 * Arguments: argc, argv - ID number in argv[1].
919 int ShowUserById(int argc, char *argv[])
921 struct qelem *top, *elem;
923 elem = top = GetUserInfo(ID, argv[1], NULL);
924 Loop(elem, PrintUserInfo);
931 /* Function Name: GetKrbmap
932 * Description: Shows user <-> Kerberos mappings
933 * Arguments: argc, argv - argv[1] contains the user login name,
934 * argv[2] contains the principal
938 int GetKrbmap(int argc, char **argv)
941 struct qelem *elem = NULL, *top;
944 if ((stat = do_mr_query("get_kerberos_user_map", 2, &argv[1],
945 StoreInfo, (char *)&elem)))
947 com_err(program_name, stat, " in GetKrbMap.");
951 top = elem = QueueTop(elem);
955 char **info = (char **) elem->q_data;
956 sprintf(buf, "User: %-9s Principal: %s",
957 info[KMAP_USER], info[KMAP_PRINCIPAL]);
962 FreeQueue(QueueTop(top));
967 /* Function Name: AddKrbmap
968 * Description: Add a new user <-> Kerberos mapping
969 * Arguments: argc, argv - argv[1] contains the user login name,
970 * argv[2] contains the principal
974 int AddKrbmap(int argc, char **argv)
978 if (!strchr(argv[KMAP_PRINCIPAL + 1], '@'))
980 Put_message("Please specify a realm for the kerberos principal.");
983 if ((stat = do_mr_query("add_kerberos_user_map", 2, &argv[1],
986 com_err(program_name, stat, " in AddKrbMap.");
987 if (stat == MR_EXISTS)
988 Put_message("No user or principal may have more than one mapping.");
994 /* Function Name: DeleteKrbmap
995 * Description: Remove a user <-> Kerberos mapping
996 * Arguments: argc, argv - argv[1] contains the user login name,
997 * argv[2] contains the principal
1001 int DeleteKrbmap(int argc, char **argv)
1005 if ((stat = do_mr_query("delete_kerberos_user_map", 2, &argv[1],
1007 com_err(program_name, stat, " in DeleteKrbMap.");
1012 /* Function Name: GetDirFlags
1013 * Description: Shows MITdir listing preferences
1014 * Arguments: argc, argv - argv[1] contains the user login name
1018 int GetDirFlags(int argc, char **argv)
1021 struct qelem *elem = NULL;
1022 char buf[BUFSIZ], **info;
1024 if (!ValidName(argv[1]))
1027 if ((stat = do_mr_query("get_user_directory_flags", 1, &argv[1],
1028 StoreInfo, (char *)&elem)))
1030 com_err(program_name, stat, " in GetDirFlags.");
1034 info = (char **) QueueTop(elem)->q_data;
1035 flags = atoi(info[0]);
1036 FreeQueue(QueueTop(elem));
1039 sprintf(buf, "User: %s", argv[1]);
1041 if (flags & DIRFLAGS_SUPPRESS)
1042 Put_message("Does NOT appear in the on-line directory.");
1045 Put_message("Does appear in the on-line directory.");
1046 if (flags & DIRFLAGS_NONLOCAL)
1047 Put_message("Is listed with non-MIT.EDU email address (if known)");
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[2];
1065 struct qelem *elem = NULL;
1067 if (!ValidName(argv[1]))
1070 /* Fetch current prefs */
1071 if ((stat = do_mr_query("get_user_directory_flags", 1, &argv[1],
1072 StoreInfo, (char *) &elem)))
1074 com_err(program_name, stat, " in GetDirFlags.");
1077 info = (char **) QueueTop(elem)->q_data;
1078 flags = atoi(info[0]);
1079 FreeQueue(QueueTop(elem));
1081 sprintf(buf, "List %s in the on-line directory (y/n)", argv[1]);
1082 if (YesNoQuestion(buf, !(flags & DIRFLAGS_SUPPRESS)))
1083 flags &= ~DIRFLAGS_SUPPRESS;
1085 flags |= DIRFLAGS_SUPPRESS;
1087 sprintf(buf, "List MIT.EDU email address even when mail is "
1088 "forwarded elsewhere? (y/n)");
1089 if (YesNoQuestion(buf, !(flags & DIRFLAGS_NONLOCAL)))
1090 flags &= ~DIRFLAGS_NONLOCAL;
1092 flags |= DIRFLAGS_NONLOCAL;
1095 sprintf(buf, "%d", flags);
1097 if ((stat = do_mr_query("update_user_directory_flags", 2,
1098 args, Scream, NULL)))
1099 com_err(program_name, stat, " in SetDirFlags");
1101 Put_message("Directory preferences set.");