Allow NickServ to ignore accounts if the user's account create ts is wrong.
authorMichael Poole <mdpoole@troilus.org>
Fri, 11 Jul 2008 02:04:41 +0000 (22:04 -0400)
committerMichael Poole <mdpoole@troilus.org>
Fri, 11 Jul 2008 02:04:41 +0000 (22:04 -0400)
src/nickserv.c (KEY_HANDLE_TS_MODE): Define.
  (enum handle_ts_mode): Define.
  (nickserv_conf): Add handle_ts_mode field.
  (nickserv_conf_read): Set it.
  (handle_account): Use it.
srvx.conf.example: Document it.

src/nickserv.c
srvx.conf.example

index 180fea8a5c3e0f48655c73f6be6dabb96de23ca6..6717a5674b900cf93cec52434da83a5ce00cbf65 100644 (file)
@@ -73,6 +73,7 @@
 #define KEY_EMAIL_SEARCH_LEVEL "email_search_level"
 #define KEY_OUNREGISTER_INACTIVE "ounregister_inactive"
 #define KEY_OUNREGISTER_FLAGS "ounregister_flags"
+#define KEY_HANDLE_TS_MODE "account_timestamp_mode"
 
 #define KEY_ID "id"
 #define KEY_PASSWD "passwd"
@@ -342,6 +343,11 @@ static void nickserv_reclaim(struct userNode *user, struct nick_info *ni, enum r
 static void nickserv_reclaim_p(void *data);
 static int nickserv_addmask(struct userNode *user, struct handle_info *hi, const char *mask);
 
+enum handle_ts_mode {
+    TS_IGNORE,
+    TS_IRCU
+};
+
 static struct {
     unsigned int disable_nicks : 1;
     unsigned int valid_handle_regex_set : 1;
@@ -378,6 +384,7 @@ static struct {
     struct policer_params *auth_policer_params;
     enum reclaim_action reclaim_action;
     enum reclaim_action auto_reclaim_action;
+    enum handle_ts_mode handle_ts_mode;
     unsigned long auto_reclaim_delay;
     unsigned char default_maxlogins;
     unsigned char hard_maxlogins;
@@ -3836,6 +3843,13 @@ nickserv_conf_read(void)
         if(pos)
             nickserv_conf.ounregister_flags |= 1 << (pos - 1);
     }
+    str = database_get_data(conf_node, KEY_HANDLE_TS_MODE, RECDB_QSTRING);
+    if (!str)
+        nickserv_conf.handle_ts_mode = TS_IGNORE;
+    else if (!irccasecmp(str, "ircu"))
+        nickserv_conf.handle_ts_mode = TS_IRCU;
+    else
+        nickserv_conf.handle_ts_mode = TS_IGNORE;
     if (!nickserv_conf.disable_nicks) {
         str = database_get_data(conf_node, "reclaim_action", RECDB_QSTRING);
         nickserv_conf.reclaim_action = str ? reclaim_action_from_string(str) : RECLAIM_NONE;
@@ -3983,6 +3997,10 @@ handle_account(struct userNode *user, const char *stamp, unsigned long timestamp
     }
 
     if (hi) {
+        if ((nickserv_conf.handle_ts_mode == TS_IRCU)
+            && (timestamp != hi->registered)) {
+            return;
+        }
         if (HANDLE_FLAGGED(hi, SUSPENDED)) {
             return;
         }
index d5ea3629cc223bcae22409fcf3441d825288ba6c..d3cac229f22565131e0efa14fa9d2b836b467144 100644 (file)
@@ -57,6 +57,8 @@
         "default_maxlogins" "2";
         // what is the absolute maxlogins value?
         "hard_maxlogins" "10";
+        // Which mode should we use for account timestamps?
+        "account_timestamp_mode" "ignore";
         // This names a file that contains easily guessed passwords.
         // It always contains "password", "<password>" and the user's
         // account name.