From a2d80284814d45f7f1eefd4dab699727a73ebfa5 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Fri, 29 Nov 2002 15:44:41 +0000 Subject: [PATCH] * CC->cs_inet_email is now a string buffer, not a pointer * Initialize CC->cs_inet_email with a default address, so it always contains something even when the directory doesn't * Augment CHEK command to return the user's preferred Internet e-mail addr. --- citadel/ChangeLog | 7 ++++++- citadel/msgbase.c | 2 +- citadel/serv_vcard.c | 24 ++++-------------------- citadel/server.h | 2 +- citadel/techdoc/session.txt | 1 + citadel/user_ops.c | 26 +++++++++++++++++--------- 6 files changed, 30 insertions(+), 32 deletions(-) diff --git a/citadel/ChangeLog b/citadel/ChangeLog index c758001b1..22931584b 100644 --- a/citadel/ChangeLog +++ b/citadel/ChangeLog @@ -1,4 +1,10 @@ $Log$ + Revision 601.74 2002/11/29 15:44:41 ajc + * CC->cs_inet_email is now a string buffer, not a pointer + * Initialize CC->cs_inet_email with a default address, so it always + contains something even when the directory doesn't + * Augment CHEK command to return the user's preferred Internet e-mail addr. + Revision 601.73 2002/11/27 21:05:31 nixo added dot ungoto functionality. It allows you to enter a room to ungoto, it will look @@ -4242,4 +4248,3 @@ 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 c13f74407..c78d7e345 100644 --- a/citadel/msgbase.c +++ b/citadel/msgbase.c @@ -2302,7 +2302,7 @@ struct CtdlMessage *CtdlMakeMessage( msg->cm_fields['D'] = strdoop(dest_node); } - if ( (author == &CC->usersupp) && (CC->cs_inet_email != NULL) ) { + if ( (author == &CC->usersupp) && (strlen(CC->cs_inet_email) > 0) ) { msg->cm_fields['F'] = strdoop(CC->cs_inet_email); } diff --git a/citadel/serv_vcard.c b/citadel/serv_vcard.c index 11ec58d3b..4c30c1fbf 100644 --- a/citadel/serv_vcard.c +++ b/citadel/serv_vcard.c @@ -204,14 +204,6 @@ void vcard_populate_cs_inet_email(struct vCard *v) { 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 */ @@ -224,7 +216,10 @@ void vcard_populate_cs_inet_email(struct vCard *v) { if (strlen(addr) > 0) { if (IsDirectory(addr)) { continue_searching = 0; - CC->cs_inet_email = strdoop(addr); + safestrncpy(CC->cs_inet_email, + addr, + sizeof(CC->cs_inet_email) + ); } } phree(addr); @@ -775,23 +770,12 @@ void vcard_session_login_hook(void) { } -/* - * 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 5cbcabbb9..a685c7fb5 100644 --- a/citadel/server.h +++ b/citadel/server.h @@ -112,7 +112,7 @@ struct CitContext { char cs_host[64]; /* host logged in from */ /* The Internet type of thing */ - char *cs_inet_email; /* Return address of outbound Internet mail */ + char cs_inet_email[SIZ];/* Return address of outbound Internet mail */ FILE *download_fp; /* Fields relating to file transfer */ FILE *upload_fp; diff --git a/citadel/techdoc/session.txt b/citadel/techdoc/session.txt index 94a82bb97..35e3b0484 100644 --- a/citadel/techdoc/session.txt +++ b/citadel/techdoc/session.txt @@ -1043,6 +1043,7 @@ it returns OK and the following parameters: 0: Number of new private messages in Mail> 1: Nonzero if the user needs to register 2: (Relevant to Aides only) Nonzero if new users require validation + 3: The user's preferred Internet e-mail address DELF (DELete a File) diff --git a/citadel/user_ops.c b/citadel/user_ops.c index 534a0102d..0dfad787a 100644 --- a/citadel/user_ops.c +++ b/citadel/user_ops.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -388,6 +389,8 @@ void cmd_user(char *cmdbuf) */ void session_startup(void) { + int i; + syslog(LOG_NOTICE, "session %d: user <%s> logged in", CC->cs_pid, CC->curr_user); @@ -403,6 +406,19 @@ void session_startup(void) } lputuser(&CC->usersupp); + /* + * Populate CC->cs_inet_email with a default address. This will be + * overwritten with the user's directory address, if one exists, when + * the vCard module's login hook runs. + */ + snprintf(CC->cs_inet_email, sizeof CC->cs_inet_email, "%s@%s", + CC->usersupp.fullname, config.c_fqdn); + for (i=0; ics_inet_email); ++i) { + if (isspace(CC->cs_inet_email[i])) { + CC->cs_inet_email[i] = '_'; + } + } + /* Create any personal rooms required by the system. * (Technically, MAILROOM should be there already, but just in case...) */ @@ -460,14 +476,6 @@ 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); } @@ -1287,7 +1295,7 @@ void cmd_chek(void) /* check for mail */ mail = InitialMailCheck(); - cprintf("%d %d|%d|%d\n", CIT_OK, mail, regis, vali); + cprintf("%d %d|%d|%d|%s|\n", CIT_OK, mail, regis, vali, CC->cs_inet_email); } -- 2.39.2