3 * Shared routines for playing with list membership.
5 * Copyright (C) 1999 by the Massachusetts Institute of Technology
6 * For copying and distribution information, please see the file
10 #include <mit-copyright.h>
13 #include "mrclient-internal.h"
23 static char default_realm[REALM_SZ];
25 int mrcl_validate_string_member(char *str)
32 char *host = canonicalize_hostname(strdup(++p));
34 if (mailtype(host) != MAILTYPE_SMTP)
38 *strchr(str, '@') = '\0';
39 mrcl_set_message("STRING \"%s\" should be USER or LIST \"%s\" "
40 "because it is a local name.", lname, str);
46 else if (!strpbrk(str, "%!"))
48 mrcl_set_message("STRING \"%s\" is not a foreign mail address.\nAdding "
49 "it to a mailing list may cause the list to break.",
58 int mrcl_validate_kerberos_member(char *str, char **ret)
67 /* An IP address is not a Kerberos principal, but we allow it
70 if (strtoul(str, &p, 10) < 256 && (*p == '.') &&
71 strtoul(p + 1, &p, 10) < 256 && (*p == '.') &&
72 strtoul(p + 1, &p, 10) < 256 && (*p == '.') &&
73 strtoul(p + 1, &p, 10) < 256 && !*p)
80 krb_get_lrealm(default_realm, 1);
82 *ret = malloc(strlen(str) + strlen(default_realm) + 2);
83 sprintf(*ret, "%s@%s", str, default_realm);
85 mrcl_set_message("Warning: default realm \"%s\" added to principal "
86 "\"%s\"", default_realm, str);
90 /* Check capitalization. */
92 p = strchr(*ret, '@');
98 mrcl_set_message("Warning: set realm in \"%s\" to all caps.", *ret);