*/
int CtdlGetUserLen(struct ctdluser *usbuf, const char *name, long len)
{
-
char usernamekey[USERNAME_SIZE];
struct cdbdata *cdbus;
return CtdlGetUserLen(usbuf, name, cutuserkey(name));
}
+
int CtdlLockGetCurrentUser(void)
{
CitContext *CCC = CC;
-
return CtdlGetUserLen(&CCC->user, CCC->curr_user, cutuserkey(CCC->curr_user));
}
+
/*
* CtdlGetUserLock() - same as getuser() but locks the record
*/
{
char usernamekey[USERNAME_SIZE];
- makeuserkey(usernamekey,
- usbuf->fullname,
- cutuserkey(usbuf->fullname));
-
+ makeuserkey(usernamekey, usbuf->fullname, cutuserkey(usbuf->fullname));
usbuf->version = REV_LEVEL;
- cdb_store(CDB_USERS,
- usernamekey, strlen(usernamekey),
- usbuf, sizeof(struct ctdluser));
-
+ cdb_store(CDB_USERS, usernamekey, strlen(usernamekey), usbuf, sizeof(struct ctdluser));
}
+
void CtdlPutCurrentUserLock()
{
CtdlPutUser(&CC->user);
}
-
/*
* rename_user() - this is tricky because the user's display name is the database key
*
syslog(LOG_DEBUG, "user_ops: can not rename user \"Citadel\".");
retcode = RENAMEUSER_NOT_FOUND;
} else {
- syslog(LOG_DEBUG, "user_ops: renaming <%s> to <%s>\n", oldname, newname);
+ syslog(LOG_DEBUG, "user_ops: renaming <%s> to <%s>", oldname, newname);
cdb_delete(CDB_USERS, oldnamekey, strlen(oldnamekey));
safestrncpy(usbuf.fullname, newname, sizeof usbuf.fullname);
CtdlPutUser(&usbuf);
}
-
/*
* Index-generating function used by Ctdl[Get|Set]Relationship
*/
struct ctdluser *rel_user,
struct ctdlroom *rel_room)
{
-
-
/* We don't use these in Citadel because they're implicit by the
* index, but they must be present if the database is exported.
*/
put_visit(newvisit);
}
+
/*
* Locate a relationship between a user and a room
*/
struct ctdluser *rel_user,
struct ctdlroom *rel_room)
{
-
char IndexBuf[32];
int IndexLen;
struct cdbdata *cdbvisit;
return(0);
}
+
/*
* Convenience function.
*/
{
if (CC->internal_pgm) return(0);
if (required_level >= ac_internal) {
- cprintf("%d This is not a user-level command.\n",
- ERROR + HIGHER_ACCESS_REQUIRED);
+ cprintf("%d This is not a user-level command.\n", ERROR + HIGHER_ACCESS_REQUIRED);
return(-1);
}
}
-
/*
* Is the user currently logged in an Admin?
*/
if (((CC->nologin)) && (CC->user.axlevel < AxAideU)) {
return login_too_many_users;
} else {
- safestrncpy(CC->curr_user, CC->user.fullname,
- sizeof CC->curr_user);
+ safestrncpy(CC->curr_user, CC->user.fullname, sizeof CC->curr_user);
return login_ok;
}
}
CtdlPutUserLock(&CCC->user);
+
+ // PUT THE EMAIL EXTRACT HERE AJC FIXME
+ //#ifdef HAVE_LDAP
+ //if ((CtdlGetConfigInt("c_auth_mode") == AUTHMODE_LDAP) || (CtdlGetConfigInt("c_auth_mode") == AUTHMODE_LDAP_AD)) {
+ //int extract_email_addresses_from_ldap(char *ldap_dn, char *emailaddrs)
+ //#endif
+
/*
- * Populate CCC->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.
+ * No email address for user? Make one up.
*/
- snprintf(CCC->cs_inet_email, sizeof CCC->cs_inet_email, "%s@%s",
- CCC->user.fullname, CtdlGetConfigStr("c_fqdn"));
- convert_spaces_to_underscores(CCC->cs_inet_email);
+ if (IsEmptyStr(CCC->user.emailaddrs)) {
+ sprintf(CCC->user.emailaddrs, "cit%ld@%s", CCC->user.usernum, CtdlGetConfigStr("c_fqdn"));
+ }
+
+ /*
+ * Populate cs_inet_email and cs_inet_other_emails with valid email addresses from the user record
+ */
+ strcpy(CCC->cs_inet_email, CCC->user.emailaddrs);
+ char *firstsep = strstr(CCC->cs_inet_email, "|");
+ if (firstsep) {
+ strcpy(CCC->cs_inet_other_emails, firstsep+1);
+ *firstsep = 0;
+ }
+ else {
+ CCC->cs_inet_other_emails[0] = 0;
+ }
/* Create any personal rooms required by the system.
* (Technically, MAILROOM should be there already, but just in case...)
begin_critical_section(S_CHKPWD);
rv = write(chkpwd_write_pipe[1], &uid, sizeof(uid_t));
if (rv == -1) {
- syslog(LOG_EMERG, "user_ops: communication with chkpwd broken: %s", strerror(errno));
+ syslog(LOG_ERR, "user_ops: communication with chkpwd broken: %m");
end_critical_section(S_CHKPWD);
return 0;
}
rv = write(chkpwd_write_pipe[1], pass, 256);
if (rv == -1) {
- syslog(LOG_EMERG, "user_ops: communication with chkpwd broken: %s", strerror(errno));
+ syslog(LOG_ERR, "user_ops: communication with chkpwd broken: %m");
end_critical_section(S_CHKPWD);
return 0;
}
rv = read(chkpwd_read_pipe[0], buf, 4);
if (rv == -1) {
- syslog(LOG_EMERG, "user_ops: ommunication with chkpwd broken: %s", strerror(errno));
+ syslog(LOG_ERR, "user_ops: ommunication with chkpwd broken: %m");
end_critical_section(S_CHKPWD);
return 0;
}
syslog(LOG_DEBUG, "user_ops: starting chkpwd daemon for host authentication mode");
if ((stat(file_chkpwd, &filestats)==-1) || (filestats.st_size==0)) {
- printf("didn't find chkpwd daemon in %s: %s\n", file_chkpwd, strerror(errno));
+ syslog(LOG_ERR, "user_ops: %s: %m", file_chkpwd);
abort();
}
if (pipe(chkpwd_write_pipe) != 0) {
- syslog(LOG_ERR, "user_ops: unable to create pipe for chkpwd daemon: %s", strerror(errno));
+ syslog(LOG_ERR, "user_ops: unable to create pipe for chkpwd daemon: %m");
abort();
}
if (pipe(chkpwd_read_pipe) != 0) {
- syslog(LOG_ERR, "user_ops: unable to create pipe for chkpwd daemon: %s", strerror(errno));
+ syslog(LOG_ERR, "user_ops: unable to create pipe for chkpwd daemon: %m");
abort();
}
chkpwd_pid = fork();
if (chkpwd_pid < 0) {
- syslog(LOG_ERR, "user_ops: unable to fork chkpwd daemon: %s", strerror(errno));
+ syslog(LOG_ERR, "user_ops: unable to fork chkpwd daemon: %m");
abort();
}
if (chkpwd_pid == 0) {
dup2(chkpwd_read_pipe[1], 1);
for (i=2; i<256; ++i) close(i);
execl(file_chkpwd, file_chkpwd, NULL);
- syslog(LOG_ERR, "user_ops: unable to exec chkpwd daemon: %s", strerror(errno));
+ syslog(LOG_ERR, "user_ops: unable to exec chkpwd daemon: %m");
abort();
exit(errno);
}
char buf[SIZ];
int retval;
uid_t uid = (-1);
-
safestrncpy(username, newusername, sizeof username);
strproc(username);
-
if (CtdlGetConfigInt("c_auth_mode") == AUTHMODE_HOST) {