#include "citadel_dirs.h"
#include "genstamp.h"
#include "threads.h"
+#include "citadel_ldap.h"
+
+#include "ctdl_module.h"
/* These pipes are used to talk to the chkpwd daemon, which is forked during startup */
int chkpwd_write_pipe[2];
}
+#ifdef HAVE_LDAP
+ else if ((config.c_auth_mode == AUTHMODE_LDAP) || (config.c_auth_mode == AUTHMODE_LDAP_AD)) {
+
+ /* LDAP auth mode */
+
+ uid_t ldap_uid;
+ char ldap_cn[256];
+ char ldap_dn[256];
+
+ found_user = CtdlTryUserLDAP(username, ldap_dn, sizeof ldap_dn, ldap_cn, sizeof ldap_cn, &ldap_uid);
+ if (found_user != 0) {
+ return login_not_found;
+ }
+
+ found_user = getuserbyuid(&CC->user, ldap_uid);
+ if (found_user != 0) {
+ create_user(trythisname, 0);
+ found_user = getuserbyuid(&CC->user, ldap_uid);
+ }
+
+ if (found_user == 0) {
+ if (CC->ldap_dn != NULL) free(CC->ldap_dn);
+ CC->ldap_dn = strdup(ldap_dn);
+ }
+
+ }
+#endif
+
else {
/* native auth mode */
char username[256];
int a;
+ CtdlLogPrintf(CTDL_DEBUG, "cmd_user(%s)\n", cmdbuf);
extract_token(username, cmdbuf, 0, '|', sizeof username);
+ CtdlLogPrintf(CTDL_DEBUG, "username: %s\n", username);
striplt(username);
+ CtdlLogPrintf(CTDL_DEBUG, "username: %s\n", username);
a = CtdlLoginExistingUser(NULL, username);
switch (a) {
purge_user(CCC->user.fullname);
/* Free any output buffers */
- if (CCC->output_buffer != NULL) {
- unbuffer_output();
- }
+ unbuffer_output();
}
/*
}
}
+#ifdef HAVE_LDAP
+ else if ((config.c_auth_mode == AUTHMODE_LDAP) || (config.c_auth_mode == AUTHMODE_LDAP_AD)) {
+
+ /* LDAP auth mode */
+
+ if ((CC->ldap_dn) && (!CtdlTryPasswordLDAP(CC->ldap_dn, password))) {
+ code = 0;
+ }
+ else {
+ code = (-1);
+ }
+ }
+#endif
+
else {
/* native auth mode */
}
+int internal_create_user (char *username, struct ctdluser *usbuf, uid_t uid)
+{
+ if (!getuser(usbuf, username)) {
+ return (ERROR + ALREADY_EXISTS);
+ }
+
+ /* Go ahead and initialize a new user record */
+ memset(usbuf, 0, sizeof(struct ctdluser));
+ safestrncpy(usbuf->fullname, username, sizeof usbuf->fullname);
+ strcpy(usbuf->password, "");
+ usbuf->uid = uid;
+
+ /* These are the default flags on new accounts */
+ usbuf->flags = US_LASTOLD | US_DISAPPEAR | US_PAGINATOR | US_FLOORS;
+
+ usbuf->timescalled = 0;
+ usbuf->posted = 0;
+ usbuf->axlevel = config.c_initax;
+ usbuf->USscreenwidth = 80;
+ usbuf->USscreenheight = 24;
+ usbuf->lastcall = time(NULL);
+
+ /* fetch a new user number */
+ usbuf->usernum = get_new_user_number();
+
+ /* add user to the database */
+ putuser(usbuf);
+ cdb_store(CDB_USERSBYNUMBER, &usbuf->usernum, sizeof(long), usbuf->fullname, strlen(usbuf->fullname)+1);
+
+ return 0;
+}
+
+
+
/*
* create_user() - back end processing to create a new user
*
char username[256];
char mailboxname[ROOMNAMELEN];
char buf[SIZ];
+ int retval;
uid_t uid = (-1);
+
safestrncpy(username, newusername, sizeof username);
strproc(username);
+
if (config.c_auth_mode == AUTHMODE_HOST) {
/* host auth mode */
uid = pd.pw_uid;
if (IsEmptyStr (username))
{
- CtdlLogPrintf (CTDL_EMERG,
- "Can't find Realname for user %s [%d] in the Host Auth Database; giving up.\n",
- newusername, pd.pw_uid);
- snprintf(buf, SIZ,
- "Can't find Realname for user %s [%d] in the Host Auth Database; giving up.\n",
- newusername, pd.pw_uid);
- aide_message(buf, "User Creation Failure Notice");
-
+ safestrncpy(username, pd.pw_name, sizeof username);
}
}
else {
}
}
- if (!getuser(&usbuf, username)) {
- return (ERROR + ALREADY_EXISTS);
- }
-
- /* Go ahead and initialize a new user record */
- memset(&usbuf, 0, sizeof(struct ctdluser));
- safestrncpy(usbuf.fullname, username, sizeof usbuf.fullname);
- strcpy(usbuf.password, "");
- usbuf.uid = uid;
-
- /* These are the default flags on new accounts */
- usbuf.flags = US_LASTOLD | US_DISAPPEAR | US_PAGINATOR | US_FLOORS;
-
- usbuf.timescalled = 0;
- usbuf.posted = 0;
- usbuf.axlevel = config.c_initax;
- usbuf.USscreenwidth = 80;
- usbuf.USscreenheight = 24;
- usbuf.lastcall = time(NULL);
-
- /* fetch a new user number */
- usbuf.usernum = get_new_user_number();
-
- /* The very first user created on the system will always be an Aide */
- if (usbuf.usernum == 1L) {
- usbuf.axlevel = 6;
+#ifdef HAVE_LDAP
+ if ((config.c_auth_mode == AUTHMODE_LDAP) || (config.c_auth_mode == AUTHMODE_LDAP_AD)) {
+ if (CtdlTryUserLDAP(username, NULL, 0, username, sizeof username, &uid) != 0) {
+ return(ERROR + NO_SUCH_USER);
+ }
}
-
- /* add user to the database */
- putuser(&usbuf);
- cdb_store(CDB_USERSBYNUMBER, &usbuf.usernum, sizeof(long), usbuf.fullname, strlen(usbuf.fullname)+1);
-
+#endif /* HAVE_LDAP */
+
+ if ((retval = internal_create_user(username, &usbuf, uid)) != 0)
+ return retval;
+
/*
* Give the user a private mailbox and a configuration room.
* Make the latter an invisible system room.
-
/*
* cmd_newu() - create a new user account and log in as that user
*/
/*
* get user parameters
*/
-void cmd_getu(void)
+void cmd_getu(char *cmdbuf)
{
if (CtdlAccessCheck(ac_logged_in))
return;
}
+void cmd_invt(char *iuser) {cmd_invt_kick(iuser, 1);}
+void cmd_kick(char *iuser) {cmd_invt_kick(iuser, 0);}
/*
* Forget (Zap) the current room (API call)
/*
* forget (Zap) the current room
*/
-void cmd_forg(void)
+void cmd_forg(char *argbuf)
{
if (CtdlAccessCheck(ac_logged_in)) {
/*
* Get Next Unregistered User
*/
-void cmd_gnur(void)
+void cmd_gnur(char *argbuf)
{
struct cdbdata *cdbus;
struct ctdluser usbuf;
if ((CC->user.axlevel >= 6)
|| ((usbuf->flags & US_UNLISTED) == 0)
|| ((CC->internal_pgm))) {
- cprintf("%s|%d|%ld|%ld|%ld|%ld|",
+ cprintf("%s|%d|%ld|%ld|%ld|%ld||\n",
usbuf->fullname,
usbuf->axlevel,
usbuf->usernum,
(long)usbuf->lastcall,
usbuf->timescalled,
usbuf->posted);
- if (CC->user.axlevel >= 6)
- cprintf("%s", usbuf->password);
- cprintf("\n");
}
}
}
/*
* assorted info we need to check at login
*/
-void cmd_chek(void)
+void cmd_chek(char *argbuf)
{
int mail = 0;
int regis = 0;
cprintf("%d An unknown error occurred.\n", ERROR);
}
+
+
+
+/*****************************************************************************/
+/* MODULE INITIALIZATION STUFF */
+/*****************************************************************************/
+
+
+CTDL_MODULE_INIT(user_ops)
+{
+ CtdlRegisterProtoHook(cmd_user, "USER", "Autoconverted. TODO: document me.");
+ CtdlRegisterProtoHook(cmd_pass, "PASS", "Autoconverted. TODO: document me.");
+ CtdlRegisterProtoHook(cmd_creu, "CREU", "Autoconverted. TODO: document me.");
+ CtdlRegisterProtoHook(cmd_setp, "SETP", "Autoconverted. TODO: document me.");
+ CtdlRegisterProtoHook(cmd_getu, "GETU", "Autoconverted. TODO: document me.");
+ CtdlRegisterProtoHook(cmd_setu, "SETU", "Autoconverted. TODO: document me.");
+ CtdlRegisterProtoHook(cmd_slrp, "SLRP", "Autoconverted. TODO: document me.");
+ CtdlRegisterProtoHook(cmd_invt, "INVT", "Autoconverted. TODO: document me.");
+ CtdlRegisterProtoHook(cmd_kick, "KICK", "Autoconverted. TODO: document me.");
+ CtdlRegisterProtoHook(cmd_forg, "FORG", "Autoconverted. TODO: document me.");
+ CtdlRegisterProtoHook(cmd_gnur, "GNUR", "Autoconverted. TODO: document me.");
+ CtdlRegisterProtoHook(cmd_vali, "VALI", "Autoconverted. TODO: document me.");
+ CtdlRegisterProtoHook(cmd_list, "LIST", "Autoconverted. TODO: document me.");
+ CtdlRegisterProtoHook(cmd_chek, "CHEK", "Autoconverted. TODO: document me.");
+ CtdlRegisterProtoHook(cmd_qusr, "QUSR", "Autoconverted. TODO: document me.");
+ CtdlRegisterProtoHook(cmd_agup, "AGUP", "Autoconverted. TODO: document me.");
+ CtdlRegisterProtoHook(cmd_asup, "ASUP", "Autoconverted. TODO: document me.");
+ CtdlRegisterProtoHook(cmd_seen, "SEEN", "Autoconverted. TODO: document me.");
+ CtdlRegisterProtoHook(cmd_gtsn, "GTSN", "Autoconverted. TODO: document me.");
+ CtdlRegisterProtoHook(cmd_view, "VIEW", "Autoconverted. TODO: document me.");
+ CtdlRegisterProtoHook(cmd_renu, "RENU", "Autoconverted. TODO: document me.");
+ CtdlRegisterProtoHook(cmd_newu, "NEWU", "Autoconverted. TODO: document me.");
+ /* return our Subversion id for the Log */
+ return "$Id$";
+}