From a982238ee97ca7aa4e9345f4dd2ed143f05031ca Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Sat, 2 Feb 2002 21:44:04 +0000 Subject: [PATCH] * If a user has at least one valid Internet directory address, stamp it onto any outgoing messages. --- citadel/ChangeLog | 5 +++ citadel/msgbase.c | 12 +++++-- citadel/serv_vcard.c | 75 ++++++++++++++++++++++++++++++++++++++++++++ citadel/server.h | 11 ++++--- citadel/user_ops.c | 8 +++++ 5 files changed, 104 insertions(+), 7 deletions(-) diff --git a/citadel/ChangeLog b/citadel/ChangeLog index a6fb24357..4ef55bd59 100644 --- a/citadel/ChangeLog +++ b/citadel/ChangeLog @@ -1,4 +1,8 @@ $Log$ + Revision 590.98 2002/02/02 21:44:04 ajc + * If a user has at least one valid Internet directory address, stamp it onto + any outgoing messages. + Revision 590.97 2002/02/01 05:11:26 ajc * Added a QDIR protocol command to do quick-and-dirty queries of the directory * In the client, check the directory for conflicts when selecting email addr. @@ -3282,3 +3286,4 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant Fri Jul 10 1998 Art Cancro * Initial CVS import + diff --git a/citadel/msgbase.c b/citadel/msgbase.c index 468b70795..4c162d2b2 100644 --- a/citadel/msgbase.c +++ b/citadel/msgbase.c @@ -1123,14 +1123,16 @@ int CtdlOutputPreLoadedMsg(struct CtdlMessage *TheMessage, else if (i == 'U') cprintf("Subject: %s%s", mptr, nl); else if (i == 'I') - strcpy(mid, mptr); + safestrncpy(mid, mptr, sizeof mid); else if (i == 'H') - strcpy(lnode, mptr); + safestrncpy(lnode, mptr, sizeof lnode); + else if (i == 'F') + safestrncpy(fuser, mptr, sizeof fuser); else if (i == 'O') cprintf("X-Citadel-Room: %s%s", mptr, nl); else if (i == 'N') - strcpy(snode, mptr); + safestrncpy(snode, mptr, sizeof snode); else if (i == 'R') cprintf("To: %s%s", mptr, nl); else if (i == 'T') { @@ -2121,6 +2123,10 @@ static struct CtdlMessage *make_message( msg->cm_fields['D'] = strdoop(dest_node); } + if (author == &CC->usersupp) { + msg->cm_fields['F'] = strdoop(CC->cs_inet_email); + } + msg->cm_fields['M'] = CtdlReadMessageBody("000", config.c_maxmsglen, NULL); diff --git a/citadel/serv_vcard.c b/citadel/serv_vcard.c index eeb9e1921..275b4a8d0 100644 --- a/citadel/serv_vcard.c +++ b/citadel/serv_vcard.c @@ -163,6 +163,49 @@ void cmd_igab(char *argbuf) { + +/* + * See if there is a valid Internet address in a vCard to use for outbound + * Interet messages. If there is, stick it in CC->cs_inet_email. + */ +void vcard_populate_cs_inet_email(struct vCard *v) { + char *s, *addr; + int continue_searching = 1; + int instance = 0; + + /* + * Clear whatever was in there previously. + */ + if (CC->cs_inet_email != NULL) { + phree(CC->cs_inet_email); + CC->cs_inet_email = NULL; + } + + /* Go through the vCard searching for *all* instances of + * the "email;internet" key + */ + do { + s = vcard_get_prop(v, "email;internet", 0, instance++); + if (s != NULL) { + continue_searching = 1; + addr = strdoop(s); + striplt(addr); + if (strlen(addr) > 0) { + if (IsDirectory(addr)) { + continue_searching = 0; + CC->cs_inet_email = strdoop(addr); + } + } + phree(addr); + } + else { + continue_searching = 0; + } + } while(continue_searching); +} + + + /* * This handler detects whether the user is attempting to save a new * vCard as part of his/her personal configuration, and handles the replace @@ -242,6 +285,7 @@ int vcard_upload_aftersave(struct CtdlMessage *msg) { char *ptr; int linelen; long I; + struct vCard *v; if (!CC->logged_in) return(0); /* Only do this if logged in. */ @@ -274,6 +318,11 @@ int vcard_upload_aftersave(struct CtdlMessage *msg) { /* ...and also in the directory database. */ vcard_add_to_directory(I, NULL); + /* Store our Internet return address in memory */ + v = vcard_load(msg->cm_fields['M']); + vcard_populate_cs_inet_email(v); + vcard_free(v); + return(0); } @@ -639,10 +688,36 @@ void vcard_session_startup_hook(void) { } +/* + * When a user logs in... + */ +void vcard_session_login_hook(void) { + struct vCard *v; + + v = vcard_get_user(&CC->usersupp); + vcard_populate_cs_inet_email(v); + + vcard_free(v); +} + + +/* + * When a user logs out... + */ +void vcard_session_logout_hook(void) { + if (CC->cs_inet_email != NULL) { + phree(CC->cs_inet_email); + CC->cs_inet_email = NULL; + } +} + + char *Dynamic_Module_Init(void) { SYM_VCARD = CtdlGetDynamicSymbol(); CtdlRegisterSessionHook(vcard_session_startup_hook, EVT_START); + CtdlRegisterSessionHook(vcard_session_login_hook, EVT_LOGIN); + CtdlRegisterSessionHook(vcard_session_logout_hook, EVT_LOGOUT); CtdlRegisterMessageHook(vcard_upload_beforesave, EVT_BEFORESAVE); CtdlRegisterMessageHook(vcard_upload_aftersave, EVT_AFTERSAVE); CtdlRegisterDeleteHook(vcard_delete_remove); diff --git a/citadel/server.h b/citadel/server.h index d1df87682..583f55a2c 100644 --- a/citadel/server.h +++ b/citadel/server.h @@ -111,8 +111,8 @@ struct CitContext { char cs_clientname[32]; /* name of client software */ char cs_host[64]; /* host logged in from */ - /* Beginning of cryptography - session nonce */ - char cs_nonce[NONCE_SIZE]; /* The nonce for this session's next auth transaction */ + /* The Internet type of thing */ + char *cs_inet_email; /* Return address of outbound Internet mail */ FILE *download_fp; /* Fields relating to file transfer */ FILE *upload_fp; @@ -123,6 +123,9 @@ struct CitContext { char dl_is_net; char upload_type; + /* Beginning of cryptography - session nonce */ + char cs_nonce[NONCE_SIZE]; /* The nonce for this session's next auth transaction */ + /* Redirect this session's output to somewhere else? */ FILE *redirect_fp; int redirect_sock; @@ -138,7 +141,7 @@ struct CitContext { /* Masquerade... */ char fake_username[USERNAME_SIZE]; /* Fake username */ char fake_postname[USERNAME_SIZE]; /* Fake postname */ - char fake_hostname[25]; /* Fake hostname */ + char fake_hostname[64]; /* Fake hostname */ char fake_roomname[ROOMNAMELEN]; /* Fake roomname */ /* Dynamically allocated session data */ @@ -353,7 +356,7 @@ extern DLEXP struct NetprocFunctionHook *NetprocHookTable; */ struct DeleteFunctionHook { struct DeleteFunctionHook *next; - int (*h_function_pointer) (char *target_room, long msgnum); + void (*h_function_pointer) (char *target_room, long msgnum); }; extern DLEXP struct DeleteFunctionHook *DeleteHookTable; diff --git a/citadel/user_ops.c b/citadel/user_ops.c index f8aefce0d..5930c71ad 100644 --- a/citadel/user_ops.c +++ b/citadel/user_ops.c @@ -454,6 +454,14 @@ void logout(struct CitContext *who) network_talking_to(who->net_node, NTT_REMOVE); } + /* + * Yes, we really need to free EVERY LAST BYTE we allocated. + */ + if (who->cs_inet_email != NULL) { + phree(who->cs_inet_email); + who->cs_inet_email = NULL; + } + /* Do modular stuff... */ PerformSessionHooks(EVT_LOGOUT); } -- 2.39.2