*/
#include <stdio.h>
-#include <strings.h>
+#include <string.h>
#include <moira.h>
#include <moira_site.h>
#include <menu.h>
{
static char *info[MAX_ARGS_SIZE], **add_args;
int status, ret_code = SUB_NORMAL;
+ struct qelem *elem = NULL;
if (!ValidName(argv[1]))
return(DM_NORMAL);
return(SUB_ERROR);
}
+ /*
+ * If the listname is less than 8 characters, make sure it doesn't
+ * collide with a username.
+ */
+ 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.");
+ Loop(QueueTop(elem), FreeInfo);
+ FreeQueue(elem);
+ if (YesNoQuestion("Crate a list with the same name",
+ FALSE) != TRUE)
+ return(SUB_ERROR);
+ }
+
if ((add_args = AskListInfo(SetDefaults(info,argv[1]), FALSE)) == NULL) {
Put_message("Aborted.");
return(SUB_ERROR);
int
AddMember()
{
- char *args[10], temp_buf[BUFSIZ];
+ char *args[10], temp_buf[BUFSIZ], *p;
register int status;
+ struct qelem *mailhubs, *elem, *GetTypeValues();
if ( GetMemberInfo("add", args) == SUB_ERROR )
return(DM_NORMAL);
+ if (!strcmp(args[LM_TYPE], "STRING")) {
+ if (p = strchr(args[LM_MEMBER], '@')) {
+ char *host = canonicalize_hostname(strsave(++p));
+ mailhubs = GetTypeValues("mailhub");
+ for (elem = mailhubs; elem; elem = elem->q_forw) {
+ if (!strcasecmp(host, elem->q_data)) {
+ free(host);
+ host = strsave(args[LM_MEMBER]);
+ *(--p) = 0;
+ sprintf(temp_buf, "String \"%s\" should be USER or LIST \"%s\" because it is a local name.",
+ host, args[LM_MEMBER]);
+ Put_message(temp_buf);
+ free(args[LM_TYPE]);
+ free(host);
+ return(DM_NORMAL);
+ }
+ }
+ free(host);
+ } else if (!strchr(args[LM_MEMBER], '!')) {
+ Put_message("Member which is not a foreign mail address should not be type STRING.");
+ return(DM_NORMAL);
+ }
+ }
+
if ( (status = do_mr_query("add_member_to_list", CountArgs(args), args,
Scream, NULL)) != MR_SUCCESS) {
if (status == MR_EXISTS) {
return (DM_NORMAL);
}
-/* Function Name: ListAllGroups
- * Description: This function lists all visable groups.
- * Arguments: none.
- * Returns: DM_NORMAL.
- */
-
-ListAllGroups()
-{
- register int status;
- static char * args[] = {
- "TRUE", /* active */
- "DONTCARE", /* public */
- "FALSE", /* hidden */
- "DONTCARE", /* maillist */
- "TRUE", /* group. */
- };
-
- if (YesNoQuestion("This query will take a while, Do you wish to continue?",
- TRUE) == TRUE )
- if (status = do_mr_query("qualified_get_lists", 5, args,
- Print, (char *) NULL) != 0)
- com_err(program_name, status, " in ListAllGroups");
- return (DM_NORMAL);
-}
-
-/* Function Name: ListAllMailLists
- * Description: This function lists all visable maillists.
- * Arguments: none
- * Returns: DM_NORMAL.
- */
-
-ListAllMailLists()
-{
- register int status;
- static char * args[] = {
- "TRUE", /* active */
- "DONTCARE", /* public */
- "FALSE", /* hidden */
- "TRUE", /* maillist */
- "DONTCARE", /* group. */
- };
-
- if (YesNoQuestion("This query will take a while. Do you wish to continue?",
- TRUE) == TRUE )
- if (status = do_mr_query("qualified_get_lists", 5, args,
- Print, (char *) NULL) != 0)
- com_err(program_name, status, " in ListAllGroups");
-
- return (DM_NORMAL);
-}
-
/* Function Name: ListAllPublicMailLists
* Description: This function lists all public mailing lists.
* Arguments: none