#include <fcntl.h>
#include <signal.h>
#include <pwd.h>
+#include <ctype.h>
#include <sys/types.h>
#include <sys/wait.h>
#include "server.h"
#include "database.h"
#include "user_ops.h"
-#include "dynloader.h"
+#include "serv_extensions.h"
#include "sysdep_decls.h"
#include "support.h"
#include "room_ops.h"
struct cdbdata *cdbus;
memset(usbuf, 0, sizeof(struct usersupp));
- for (a = 0; a <= strlen(name); ++a) {
- if (a < sizeof(lowercase_name))
- lowercase_name[a] = tolower(name[a]);
+
+ if (CtdlAssociateSystemUser(lowercase_name, name) == 0) {
+ for (a = 0; a <= strlen(lowercase_name); ++a) {
+ lowercase_name[a] = tolower(lowercase_name[a]);
+ }
+ }
+ else {
+ for (a = 0; a <= strlen(name); ++a) {
+ if (a < sizeof(lowercase_name))
+ lowercase_name[a] = tolower(name[a]);
+ }
}
lowercase_name[sizeof(lowercase_name) - 1] = 0;
}
+/*
+ * See if we can translate a system login name (i.e. from /etc/passwd)
+ * to a Citadel screen name. Returns 0 if one is found.
+ */
+int CtdlAssociateSystemUser(char *screenname, char *loginname) {
+ struct passwd *p;
+ int a;
+
+ p = (struct passwd *) getpwnam(loginname);
+ if (p != NULL) {
+ strcpy(screenname, p->pw_gecos);
+ for (a = 0; a < strlen(screenname); ++a) {
+ if (screenname[a] == ',') {
+ screenname[a] = 0;
+ }
+ }
+ return(0);
+ }
+ return(1);
+}
+
+
+
/*
* Back end for cmd_user() and its ilk
*/
int CtdlLoginExistingUser(char *trythisname)
{
char username[SIZ];
- char autoname[SIZ];
- int found_user = 0;
- struct passwd *p;
- int a;
+ int found_user;
if (trythisname == NULL) return login_not_found;
safestrncpy(username, trythisname, sizeof username);
if ((CC->logged_in)) {
return login_already_logged_in;
}
+
found_user = getuser(&CC->usersupp, username);
- if (found_user != 0) {
- p = (struct passwd *) getpwnam(username);
- if (p != NULL) {
- strcpy(autoname, p->pw_gecos);
- for (a = 0; a < strlen(autoname); ++a)
- if (autoname[a] == ',')
- autoname[a] = 0;
- found_user = getuser(&CC->usersupp, autoname);
- }
- }
+
if (found_user == 0) {
if (((CC->nologin)) && (CC->usersupp.axlevel < 6)) {
return login_too_many_users;
*/
void session_startup(void)
{
+ int i;
+
syslog(LOG_NOTICE, "session %d: user <%s> logged in",
CC->cs_pid, CC->curr_user);
}
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; i<strlen(CC->cs_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...)
*/
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);
}
/* 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);
}