Committer : klmitch
CVSROOT : /cvsroot/undernet-ircu
Module : ircu2.10
Branch tags: u2_10_11_07
Commit time: 2004-05-14 05:48:24 UTC
Modified files:
Tag: u2_10_11_07
ChangeLog include/struct.h ircd/m_account.c ircd/s_user.c
Log message:
Author: Kev <[EMAIL PROTECTED]>
Log message:
Add an optional creation timestamp to AC messages. Currently unused by
ircu, but euworld could, for instance, use this to verify that a given X
account really does match a given euworld account. Protects against expire
and re-register attacks against euworld.
---------------------- diff included ----------------------
Index: ircu2.10/ChangeLog
diff -u ircu2.10/ChangeLog:1.290.2.130.2.6 ircu2.10/ChangeLog:1.290.2.130.2.7
--- ircu2.10/ChangeLog:1.290.2.130.2.6 Fri Mar 19 15:51:42 2004
+++ ircu2.10/ChangeLog Thu May 13 22:48:11 2004
@@ -1,3 +1,15 @@
+2004-05-14 Kevin L Mitchell <[EMAIL PROTECTED]>
+
+ * ircd/s_user.c: process account creation timestamp if present in
+ user mode portion of a N protocol message; add account creation
+ timestamp to outgoing N protocol messages if that timestamp is
+ non-zero
+
+ * ircd/m_account.c: process account creation timestamp if present
+ in AC protocol message
+
+ * include/struct.h: add account creation timestamp
+
2004-03-20 Isomer <[EMAIL PROTECTED]>
* ircd/m_invite.c: Disallow invites to non existant channels
Index: ircu2.10/include/struct.h
diff -u ircu2.10/include/struct.h:1.2.46.3 ircu2.10/include/struct.h:1.2.46.3.16.1
--- ircu2.10/include/struct.h:1.2.46.3 Fri Jun 7 08:56:36 2002
+++ ircu2.10/include/struct.h Thu May 13 22:48:12 2004
@@ -18,7 +18,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: struct.h,v 1.2.46.3 2002/06/07 15:56:36 vampire Exp $
+ * $Id: struct.h,v 1.2.46.3.16.1 2004/05/14 05:48:12 klmitch Exp $
*/
#ifndef INCLUDED_struct_h
#define INCLUDED_struct_h
@@ -76,6 +76,7 @@
char host[HOSTLEN + 1];
char realhost[HOSTLEN + 1];
char account[ACCOUNTLEN + 1];
+ time_t acc_create;
};
#endif /* INCLUDED_struct_h */
Index: ircu2.10/ircd/m_account.c
diff -u ircu2.10/ircd/m_account.c:1.1.2.4 ircu2.10/ircd/m_account.c:1.1.2.4.8.1
--- ircu2.10/ircd/m_account.c:1.1.2.4 Sat Dec 14 17:02:40 2002
+++ ircu2.10/ircd/m_account.c Thu May 13 22:48:13 2004
@@ -19,7 +19,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: m_account.c,v 1.1.2.4 2002/12/15 01:02:40 isomer Exp $
+ * $Id: m_account.c,v 1.1.2.4.8.1 2004/05/14 05:48:13 klmitch Exp $
*/
/*
@@ -86,10 +86,12 @@
#include "ircd_string.h"
#include "msg.h"
#include "numnicks.h"
+#include "s_debug.h"
#include "s_user.h"
#include "send.h"
#include <assert.h>
+#include <stdlib.h>
#include <string.h>
/*
@@ -125,11 +127,19 @@
return protocol_violation(cptr, "Received account (%s) longer than %d for %s;
ignoring.", parv[2], ACCOUNTLEN, cli_name(acptr));
}
+ if (parc > 3) {
+ cli_user(acptr)->acc_create = atoi(parv[3]);
+ Debug((DEBUG_DEBUG, "Received timestamped account: account \"%s\", "
+ "timestamp %Tu", parv[2], cli_user(acptr)->acc_create));
+ }
+
ircd_strncpy(cli_user(acptr)->account, parv[2], ACCOUNTLEN);
hide_hostmask(acptr, FLAG_ACCOUNT);
- sendcmdto_serv_butone(sptr, CMD_ACCOUNT, cptr, "%C %s", acptr,
- cli_user(acptr)->account);
+ sendcmdto_serv_butone(sptr, CMD_ACCOUNT, cptr,
+ cli_user(acptr)->acc_create ? "%C %s %Tu" : "%C %s",
+ acptr, cli_user(acptr)->account,
+ cli_user(acptr)->acc_create);
return 0;
}
Index: ircu2.10/ircd/s_user.c
diff -u ircu2.10/ircd/s_user.c:1.52.2.17 ircu2.10/ircd/s_user.c:1.52.2.17.2.1
--- ircu2.10/ircd/s_user.c:1.52.2.17 Sat Jan 10 16:23:33 2004
+++ ircu2.10/ircd/s_user.c Thu May 13 22:48:13 2004
@@ -20,7 +20,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: s_user.c,v 1.52.2.17 2004/01/11 00:23:33 isomer Exp $
+ * $Id: s_user.c,v 1.52.2.17.2.1 2004/05/14 05:48:13 klmitch Exp $
*/
#include "config.h"
@@ -705,8 +705,17 @@
ircd_strncpy(cli_user(new_client)->host, parv[5], HOSTLEN);
ircd_strncpy(cli_user(new_client)->realhost, parv[5], HOSTLEN);
ircd_strncpy(cli_info(new_client), parv[parc - 1], REALLEN);
- if (account)
- ircd_strncpy(cli_user(new_client)->account, account, ACCOUNTLEN);
+ if (account) {
+ int len = ACCOUNTLEN;
+ if ((p = strchr(account, ':'))) {
+ len = (p++) - account;
+ cli_user(new_client)->acc_create = atoi(p);
+ Debug((DEBUG_DEBUG, "Received timestamped account in user mode; "
+ "account \"%s\", timestamp %Tu", account,
+ cli_user(new_client)->acc_create));
+ }
+ ircd_strncpy(cli_user(new_client)->account, account, len);
+ }
if (HasHiddenHost(new_client))
ircd_snprintf(0, cli_user(new_client)->host, HOSTLEN, "%s.%s",
account, feature_str(FEAT_HIDDEN_HOST));
@@ -1358,6 +1367,18 @@
*m++ = ' ';
while ((*m++ = *t++))
; /* Empty loop */
+
+ if (cli_user(cptr)->acc_create) {
+ char nbuf[20];
+ Debug((DEBUG_DEBUG, "Sending timestamped account in user mode for "
+ "account \"%s\"; timestamp %Tu", cli_user(cptr)->account,
+ cli_user(cptr)->acc_create));
+ ircd_snprintf(0, t = nbuf, sizeof(nbuf), ":%Tu",
+ cli_user(cptr)->acc_create);
+ m--; /* back up over previous nul-termination */
+ while ((*m++ = *t++))
+ ; /* Empty loop */
+ }
}
*m = '\0';
----------------------- End of diff -----------------------