#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];
* If not found, make one attempt to create it.
*/
found_user = getuserbyuid(&CC->user, pd.pw_uid);
- lprintf(CTDL_DEBUG, "found it: uid=%ld, gecos=%s here: %ld\n", (long)pd.pw_uid, pd.pw_gecos, found_user);
+ lprintf(CTDL_DEBUG, "found it: uid=%ld, gecos=%s here: %d\n",
+ (long)pd.pw_uid, pd.pw_gecos, found_user);
if (found_user != 0) {
create_user(username, 0);
found_user = getuserbyuid(&CC->user, pd.pw_uid);
{
char buf[256];
+ if (IsEmptyStr(pass)) {
+ lprintf(CTDL_DEBUG, "refusing to check empty password for uid=%d using chkpwd...\n", uid);
+ return 0;
+ }
+
lprintf(CTDL_DEBUG, "Validating password for uid=%d using chkpwd...\n", uid);
begin_critical_section(S_CHKPWD);
makeuserkey(usernamekey, pname);
+ /* If the name is empty we can't find them in the DB any way so just return */
+ if (IsEmptyStr(pname))
+ return (ERROR + NO_SUCH_USER);
+
if (getuser(&usbuf, pname) != 0) {
lprintf(CTDL_ERR, "Cannot purge user <%s> - not found\n", pname);
return (ERROR + NO_SUCH_USER);
}
+
+
/*
* create_user() - back end processing to create a new 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
*/