Forward port account timestamp feature from 2.10.11.
authorMichael Poole <mdpoole@troilus.org>
Sun, 16 May 2004 17:59:40 +0000 (17:59 +0000)
committerMichael Poole <mdpoole@troilus.org>
Sun, 16 May 2004 17:59:40 +0000 (17:59 +0000)
git-svn-id: file:///home/klmitch/undernet-ircu/undernet-ircu-svn/ircu2/trunk@1069 c9e4aea6-c8fd-4c43-8297-357d70d61c8c

ChangeLog
include/struct.h
ircd/m_account.c
ircd/s_user.c

index 6086aed9e9f825c215d8dda9e7d28057b0d7b739..6e209def4bee96bfe139552f4cb2c17bd6d61bff 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2004-05-14  Kevin L Mitchell  <klmitch@mit.edu>
+
+       * 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-05-16  Michael Poole <mdpoole@troilus.org>
 
        * doc/example.conf: Document operator privilege settings.
index b173c3024aa123ebd8fa8045d94b53422d72011d..015ae0f744418cebc953c3c1dc1aca301f6fa823 100644 (file)
@@ -76,6 +76,7 @@ struct User {
   char               host[HOSTLEN + 1];
   char               realhost[HOSTLEN + 1];
   char               account[ACCOUNTLEN + 1];
+  time_t            acc_create;
 };
 
 #endif /* INCLUDED_struct_h */
index 9a7cfe817e76977af5a9b7dc91467df76594a520..3b00133aef6eae64adca85be42f12e43de44ecf9 100644 (file)
 #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>
 
 /*
@@ -126,11 +128,20 @@ int ms_account(struct Client* cptr, struct Client* sptr, int parc,
                               "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 34e341a7606718b7871b183f9bd34b62e1226522..ed641eb27f1ea32daa063c1aae4cb60c54202b8a 100644 (file)
@@ -710,8 +710,17 @@ int set_nick_name(struct Client* cptr, struct Client* sptr,
     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));
@@ -1384,6 +1393,18 @@ char *umode_str(struct Client *cptr)
     *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';