]> code.citadel.org Git - citadel.git/blobdiff - citadel/user_ops.c
Logging: add details to failed password attempts to make it fail2ban more easy to...
[citadel.git] / citadel / user_ops.c
index 2b66fdbe24029a51e77fd6896008977b5ebc31c1..37cbfcd6464d2c61253f9107865661a94f30021f 100644 (file)
@@ -712,40 +712,42 @@ void cmd_user(char *cmdbuf)
  */
 void do_login(void)
 {
-       CC->logged_in = 1;
-       syslog(LOG_NOTICE, "<%s> logged in\n", CC->curr_user);
+       struct CitContext *CCC = CC;
 
-       CtdlGetUserLock(&CC->user, CC->curr_user);
-       ++(CC->user.timescalled);
-       CC->previous_login = CC->user.lastcall;
-       time(&CC->user.lastcall);
+       CCC->logged_in = 1;
+       syslog(LOG_NOTICE, "<%s> logged in\n", CCC->curr_user);
+
+       CtdlGetUserLock(&CCC->user, CCC->curr_user);
+       ++(CCC->user.timescalled);
+       CCC->previous_login = CCC->user.lastcall;
+       time(&CCC->user.lastcall);
 
        /* If this user's name is the name of the system administrator
         * (as specified in setup), automatically assign access level 6.
         */
-       if (!strcasecmp(CC->user.fullname, config.c_sysadm)) {
-               CC->user.axlevel = AxAideU;
+       if (!strcasecmp(CCC->user.fullname, config.c_sysadm)) {
+               CCC->user.axlevel = AxAideU;
        }
 
        /* If we're authenticating off the host system, automatically give
         * root the highest level of access.
         */
        if (config.c_auth_mode == AUTHMODE_HOST) {
-               if (CC->user.uid == 0) {
-                       CC->user.axlevel = AxAideU;
+               if (CCC->user.uid == 0) {
+                       CCC->user.axlevel = AxAideU;
                }
        }
 
-       CtdlPutUserLock(&CC->user);
+       CtdlPutUserLock(&CCC->user);
 
        /*
-        * Populate CC->cs_inet_email with a default address.  This will be
+        * 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.
         */
-       snprintf(CC->cs_inet_email, sizeof CC->cs_inet_email, "%s@%s",
-               CC->user.fullname, config.c_fqdn);
-       convert_spaces_to_underscores(CC->cs_inet_email);
+       snprintf(CCC->cs_inet_email, sizeof CCC->cs_inet_email, "%s@%s",
+               CCC->user.fullname, config.c_fqdn);
+       convert_spaces_to_underscores(CCC->cs_inet_email);
 
        /* Create any personal rooms required by the system.
         * (Technically, MAILROOM should be there already, but just in case...)
@@ -801,7 +803,7 @@ void CtdlUserLogout(void)
         * If we were talking to a network node, we're not anymore...
         */
        if (!IsEmptyStr(CCC->net_node)) {
-               network_talking_to(CCC->net_node, NTT_REMOVE);
+               network_talking_to(CCC->net_node, strlen(CCC->net_node), NTT_REMOVE);
        }
 
        /* Run any hooks registered by modules... */
@@ -932,16 +934,17 @@ void start_chkpwd_daemon(void) {
 int CtdlTryPassword(const char *password, long len)
 {
        int code;
+       CitContext *CCC = CC;
 
-       if ((CC->logged_in)) {
+       if ((CCC->logged_in)) {
                syslog(LOG_WARNING, "CtdlTryPassword: already logged in\n");
                return pass_already_logged_in;
        }
-       if (!strcmp(CC->curr_user, NLI)) {
+       if (!strcmp(CCC->curr_user, NLI)) {
                syslog(LOG_WARNING, "CtdlTryPassword: no user selected\n");
                return pass_no_user;
        }
-       if (CtdlGetUser(&CC->user, CC->curr_user)) {
+       if (CtdlGetUser(&CCC->user, CCC->curr_user)) {
                syslog(LOG_ERR, "CtdlTryPassword: internal error\n");
                return pass_internal_error;
        }
@@ -951,7 +954,7 @@ int CtdlTryPassword(const char *password, long len)
        }
        code = (-1);
 
-       if (CC->is_master) {
+       if (CCC->is_master) {
                code = strcmp(password, config.c_master_pass);
        }
 
@@ -959,7 +962,7 @@ int CtdlTryPassword(const char *password, long len)
 
                /* host auth mode */
 
-               if (validpw(CC->user.uid, password)) {
+               if (validpw(CCC->user.uid, password)) {
                        code = 0;
 
                        /*
@@ -970,9 +973,9 @@ int CtdlTryPassword(const char *password, long len)
                         * this is a security hazard, comment it out.
                         */
 
-                       CtdlGetUserLock(&CC->user, CC->curr_user);
-                       safestrncpy(CC->user.password, password, sizeof CC->user.password);
-                       CtdlPutUserLock(&CC->user);
+                       CtdlGetUserLock(&CCC->user, CCC->curr_user);
+                       safestrncpy(CCC->user.password, password, sizeof CCC->user.password);
+                       CtdlPutUserLock(&CCC->user);
 
                        /*
                         * (sooper-seekrit hack ends here)
@@ -989,7 +992,7 @@ int CtdlTryPassword(const char *password, long len)
 
                /* LDAP auth mode */
 
-               if ((CC->ldap_dn) && (!CtdlTryPasswordLDAP(CC->ldap_dn, password))) {
+               if ((CCC->ldap_dn) && (!CtdlTryPasswordLDAP(CCC->ldap_dn, password))) {
                        code = 0;
                }
                else {
@@ -1006,11 +1009,11 @@ int CtdlTryPassword(const char *password, long len)
                pw = (char*) malloc(len + 1);
                memcpy(pw, password, len + 1);
                strproc(pw);
-               strproc(CC->user.password);
-               code = strcasecmp(CC->user.password, pw);
+               strproc(CCC->user.password);
+               code = strcasecmp(CCC->user.password, pw);
                strproc(pw);
-               strproc(CC->user.password);
-               code = strcasecmp(CC->user.password, pw);
+               strproc(CCC->user.password);
+               code = strcasecmp(CCC->user.password, pw);
                free (pw);
        }
 
@@ -1018,7 +1021,16 @@ int CtdlTryPassword(const char *password, long len)
                do_login();
                return pass_ok;
        } else {
-               syslog(LOG_WARNING, "Bad password specified for <%s>\n", CC->curr_user);
+               syslog(LOG_WARNING, "Bad password specified for <%s> Service <%s> Port <%ld> Remote <%s / %s>\n",
+                      CCC->curr_user,
+                      CCC->ServiceName,
+                      CCC->tcp_port,
+                      CCC->cs_host,
+                      CCC->cs_addr);
+
+
+//citserver[5610]: Bad password specified for <willi> Service <citadel-TCP> Remote <PotzBlitz / >
+
                return pass_wrong_password;
        }
 }
@@ -2100,18 +2112,18 @@ CTDL_MODULE_INIT(user_ops)
                CtdlRegisterProtoHook(cmd_invt, "INVT", "Invite a user to a room");
                CtdlRegisterProtoHook(cmd_kick, "KICK", "Kick a user out of a room");
                CtdlRegisterProtoHook(cmd_forg, "FORG", "Forget a room");
-               CtdlRegisterProtoHook(cmd_gnur, "GNUR", "Autoconverted. TODO: document me.");
+               CtdlRegisterProtoHook(cmd_gnur, "GNUR", "Get Next Unregistered User");
                CtdlRegisterProtoHook(cmd_vali, "VALI", "Validate new users");
                CtdlRegisterProtoHook(cmd_list, "LIST", "List users");
-               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.");
+               CtdlRegisterProtoHook(cmd_chek, "CHEK", "assorted info we need to check at login");
+               CtdlRegisterProtoHook(cmd_qusr, "QUSR", "check to see if a user exists");
+               CtdlRegisterProtoHook(cmd_agup, "AGUP", "Administratively Get User Parameters");
+               CtdlRegisterProtoHook(cmd_asup, "ASUP", "Administratively Set User Parameters");
+               CtdlRegisterProtoHook(cmd_seen, "SEEN", "Manipulate seen/unread message flags");
+               CtdlRegisterProtoHook(cmd_gtsn, "GTSN", "Fetch seen/unread message flags");
+               CtdlRegisterProtoHook(cmd_view, "VIEW", "Set preferred view for user/room combination");
+               CtdlRegisterProtoHook(cmd_renu, "RENU", "Rename a user");
+               CtdlRegisterProtoHook(cmd_newu, "NEWU", "Log in as a new user");
        }
        /* return our Subversion id for the Log */
        return "user_ops";