]> jfr.im git - irc/evilnet/x3.git/blobdiff - src/nickserv.c
Added missing PRIV_* flags
[irc/evilnet/x3.git] / src / nickserv.c
index b0aeb784180ec588caf811844d519428f539c43b..4e0d1bd41bbac69d559ea18825f310de10f9119f 100644 (file)
 #define KEY_LDAP_FIELD_EMAIL "ldap_field_email"
 #define KEY_LDAP_OBJECT_CLASSES "ldap_object_classes"
 #define KEY_LDAP_OPER_GROUP_DN "ldap_oper_group_dn"
+#define KEY_LDAP_OPER_GROUP_LEVEL "ldap_oper_group_level"
 #define KEY_LDAP_FIELD_GROUP_MEMBER "ldap_field_group_member"
 #define KEY_LDAP_TIMEOUT "ldap_timeout"
 #endif
@@ -1944,7 +1945,6 @@ struct handle_info *loc_auth(char *handle, char *password, char *userhost)
 #ifdef WITH_LDAP
     int ldap_result = LDAP_SUCCESS;
     char *email = NULL;
-
 #endif
 
     hi = dict_find(nickserv_handle_dict, handle, NULL);
@@ -1957,7 +1957,6 @@ struct handle_info *loc_auth(char *handle, char *password, char *userhost)
            return NULL;
         }
     }
-//    else           
 #else
     if (!hi) {
         return NULL;
@@ -1968,7 +1967,16 @@ struct handle_info *loc_auth(char *handle, char *password, char *userhost)
     }
 #endif
 #ifdef WITH_LDAP
-    if( (!hi) && nickserv_conf.ldap_enable && ldap_result == LDAP_SUCCESS && nickserv_conf.ldap_autocreate) {
+    /* ldap libs are present but we are not using them... */
+    if( !nickserv_conf.ldap_enable ) {
+       if (!hi) {
+          return NULL;
+       }
+       if (!checkpass(password, hi->passwd)) {
+         return NULL;
+       }
+    }
+    else if( (!hi) && ldap_result == LDAP_SUCCESS && nickserv_conf.ldap_autocreate) {
          /* user not found, but authed to ldap successfully..
           * create the account.
           */
@@ -3102,7 +3110,7 @@ static OPTION_FUNC(opt_announcements)
 static OPTION_FUNC(opt_password)
 {
     char crypted[MD5_CRYPT_LENGTH+1];
-    if(argc < 1) {
+    if(argc < 2) {
        return 0;
     }
     if (!override) {
@@ -3258,7 +3266,7 @@ oper_try_set_access(struct userNode *user, struct userNode *bot, struct handle_i
 #ifdef WITH_LDAP
     if(nickserv_conf.ldap_enable && nickserv_conf.ldap_oper_group_dn && nickserv_conf.ldap_admin_dn) {
         int rc;
-        if(new_level > 0)
+        if(new_level > nickserv_conf.ldap_oper_group_level)
           rc = ldap_add2group(target->handle, nickserv_conf.ldap_oper_group_dn);
         else
           rc = ldap_delfromgroup(target->handle, nickserv_conf.ldap_oper_group_dn);
@@ -4794,6 +4802,9 @@ nickserv_conf_read(void)
     str = database_get_data(conf_node, KEY_LDAP_OPER_GROUP_DN, RECDB_QSTRING);
     nickserv_conf.ldap_oper_group_dn = str ? str : "";
 
+    str = database_get_data(conf_node, KEY_LDAP_OPER_GROUP_LEVEL, RECDB_QSTRING);
+    nickserv_conf.ldap_oper_group_level = str ? strtoul(str, NULL, 0) : 99;
+
     str = database_get_data(conf_node, KEY_LDAP_FIELD_GROUP_MEMBER, RECDB_QSTRING);
     nickserv_conf.ldap_field_group_member = str ? str : "";