From d5283210d4cf1c74fbeea06354d87efbac454471 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Sat, 24 Jun 2017 01:47:47 -0400 Subject: [PATCH] AGEA and ASEA server commands to get and set a user's email addresses --- citadel/internet_addressing.c | 4 +- citadel/modules/ctdlproto/serv_user.c | 91 +++++++++++++++++++++++++++ 2 files changed, 93 insertions(+), 2 deletions(-) diff --git a/citadel/internet_addressing.c b/citadel/internet_addressing.c index 8902befbd..7730e8794 100644 --- a/citadel/internet_addressing.c +++ b/citadel/internet_addressing.c @@ -702,8 +702,8 @@ recptypes *validate_recipients(const char *supplied_recipients, const char *Remo break; case MES_INTERNET: /* Yes, you're reading this correctly: if the target - * domain points back to the local system or an attached - * Citadel directory, the address is invalid. That's + * domain points back to the local system, + * the address is invalid. That's * because if the address were valid, we would have * already translated it to a local address by now. */ diff --git a/citadel/modules/ctdlproto/serv_user.c b/citadel/modules/ctdlproto/serv_user.c index 10921b48d..82a18fd14 100644 --- a/citadel/modules/ctdlproto/serv_user.c +++ b/citadel/modules/ctdlproto/serv_user.c @@ -667,6 +667,95 @@ void cmd_isme(char *argbuf) { } +/* + * Administrative Get Email Addresses + */ +void cmd_agea(char *cmdbuf) +{ + struct ctdluser usbuf; + char requested_user[128]; + int i, num_e; + char e[512]; + + if (CtdlAccessCheck(ac_aide)) { + return; + } + + extract_token(requested_user, cmdbuf, 0, '|', sizeof requested_user); + if (CtdlGetUser(&usbuf, requested_user) != 0) { + cprintf("%d No such user.\n", ERROR + NO_SUCH_USER); + return; + } + cprintf("%d internet email addresses for %s\n", LISTING_FOLLOWS, usbuf.fullname); + num_e = num_tokens(usbuf.emailaddrs, '|'); + for (i=0; i= 0 && strcmp(buf, "000")) { + if ( // addresses must be: + (!IsEmptyStr(buf)) // non-empty + && ((strlen(new_emailaddrs) + strlen(buf) + 2) < sizeof(new_emailaddrs)) // fit in the remaining buffer + && (IsDirectory(buf, 0)) // in one of our own domains + && ( // not belong to someone else + (CtdlDirectoryLookup(whodat, buf, sizeof whodat) != 0) + || (!strcasecmp(whodat, requested_user)) + ) + ) { + if (!IsEmptyStr(new_emailaddrs)) { + strcat(new_emailaddrs, "|"); + } + strcat(new_emailaddrs, buf); + } + } + + if (CtdlGetUserLock(&usbuf, requested_user) != 0) { // We are relying on the fact that the DirectoryIndex functions don't lock. + return; // Silently fail here if we can't acquire a lock on the user record. + } + + /* Delete all of the existing directory index records for the user (easier this way) */ + for (i=0; i