From: danw Date: Tue, 17 Jun 1997 20:11:20 +0000 (+0000) Subject: Warn user before letting them rename a list to someone's username. X-Git-Url: http://andersk.mit.edu/gitweb/moira.git/commitdiff_plain/6825fe398fb2ed5060e82fb9a84a17d874db4038 Warn user before letting them rename a list to someone's username. --- diff --git a/clients/moira/lists.c b/clients/moira/lists.c index 448128eb..7a7e6c4d 100644 --- a/clients/moira/lists.c +++ b/clients/moira/lists.c @@ -285,11 +285,34 @@ Bool junk; { register int stat; char ** args; + struct qelem *elem = NULL; if ((args = AskListInfo(info, TRUE)) == NULL) { Put_message("Aborted."); return; } + + /* + * If the new list name is less than 8 characters, make sure it doesn't + * collide with a username. + */ + if ((strlen(args[2]) <= 8) && + do_mr_query("get_user_account_by_login", 1, args + 1, + StoreInfo, (char *) &elem) != MR_NO_MATCH) { + char buf[256]; + + sprintf(buf, "\nA user by the name `%s' already exists in the database.", + args[1]); + Put_message(buf); + Loop(QueueTop(elem), FreeInfo); + FreeQueue(elem); + if (YesNoQuestion("Do you still want to rename this list to that name", + FALSE) != TRUE) { + Put_message("List ** NOT ** Updated."); + return; + } + } + if ( (stat = do_mr_query("update_list", CountArgs(args), args, Scream, (char *) NULL)) != MR_SUCCESS) { com_err(program_name, stat, " in UpdateList."); @@ -380,8 +403,12 @@ char **argv; */ if ((strlen(argv[1]) <= 8) && do_mr_query("get_user_account_by_login", 1, argv + 1, - StoreInfo, (char *) &elem) == 0) { - Put_message("A user by that name already exists in the database."); + StoreInfo, (char *) &elem) != MR_NO_MATCH) { + char buf[256]; + + sprintf(buf, "\nA user by the name `%s' already exists in the database.", + argv[1]); + Put_message(buf); Loop(QueueTop(elem), FreeInfo); FreeQueue(elem); if (YesNoQuestion("Crate a list with the same name",