From c885e5aaf9ebc6690f145ab6152e2bd76e6b0ac7 Mon Sep 17 00:00:00 2001 From: Dave West Date: Wed, 13 Feb 2008 22:47:42 +0000 Subject: [PATCH] When using host auth mode the user is given a default email address based on the gecos field from the passwd file which is usually "firstname_lastname" this results in the user not being able to receive mail to their default username address. To rememdy this when the user logs in for the first time we now create the users vCard as normal and then add an alias to the vCard. The alias is username@domain as opposed to firstname_lastname@domain. We only add the alias if it would differ from the original address. We only do this in host auth mode. --- citadel/modules/vcard/serv_vcard.c | 19 +++++++++++++++++++ citadel/serv_vcard.h | 1 + citadel/user_ops.c | 20 ++++++++++++++++++++ 3 files changed, 40 insertions(+) diff --git a/citadel/modules/vcard/serv_vcard.c b/citadel/modules/vcard/serv_vcard.c index d4ab858b9..a3b0fc46c 100644 --- a/citadel/modules/vcard/serv_vcard.c +++ b/citadel/modules/vcard/serv_vcard.c @@ -968,6 +968,25 @@ void cmd_greg(char *argbuf) + + +/* + * Add an email alias to a users vcard + */ + +void vcard_add_alias(struct ctdluser *usbuf, char *addr) +{ + struct vCard *v; + + v = vcard_get_user(usbuf); + vcard_add_prop(v, "email;internet", addr); + vcard_write_user(usbuf, v); + vcard_free(v); +} + + + + /* * When a user is being created, create his/her vCard. */ diff --git a/citadel/serv_vcard.h b/citadel/serv_vcard.h index 003b8d3d7..22077653e 100644 --- a/citadel/serv_vcard.h +++ b/citadel/serv_vcard.h @@ -9,3 +9,4 @@ enum { V2L_DELETE }; +void vcard_add_alias(struct ctdluser *usbuf, char *addr); diff --git a/citadel/user_ops.c b/citadel/user_ops.c index 7f84fa21e..79bbb9a07 100644 --- a/citadel/user_ops.c +++ b/citadel/user_ops.c @@ -50,6 +50,7 @@ #include "citadel_dirs.h" #include "genstamp.h" #include "threads.h" +#include "serv_vcard.h" /* FIXME: Get this dependancy out. Needed for vcard_add_alias */ /* These pipes are used to talk to the chkpwd daemon, which is forked during startup */ int chkpwd_write_pipe[2]; @@ -873,6 +874,8 @@ int purge_user(char pname[]) } + + /* * create_user() - back end processing to create a new user * @@ -977,6 +980,23 @@ int create_user(char *newusername, int become_user) /* Perform any create functions registered by server extensions */ PerformUserHooks(&usbuf, EVT_NEWUSER); + /* In host auth mode the user was created with an email address of the users + * full name from the passwd gecos field. + * Not sure what would have happened if that wasn't set to something + * but thats another story + * We need to add an email alias to the users vCard for the proper username + */ + if (config.c_auth_mode == AUTHMODE_HOST) + { + char user_alias[SIZ]; + + if (strcmp(username, newusername)) + { + sprintf(user_alias, "%s@%s", newusername, config.c_fqdn); + vcard_add_alias(&usbuf, user_alias); + } + } + /* Everything below this line can be bypassed if administratively * creating a user, instead of doing self-service account creation */ -- 2.30.2