added cmd_myaccess override message and blocked iohandler log through irc completely
authorpk910 <philipp@zoelle1.de>
Thu, 27 Sep 2012 23:10:57 +0000 (01:10 +0200)
committerpk910 <philipp@zoelle1.de>
Thu, 27 Sep 2012 23:12:18 +0000 (01:12 +0200)
src/log.c
src/modules/NeonServ.mod/cmd_neonserv_myaccess.c

index 6e1ba878e04dabe53776ecb35186bbd691a5dc23..9907f2b392fdc01260161c47d88a1b057e4f07f4 100644 (file)
--- a/src/log.c
+++ b/src/log.c
@@ -138,7 +138,7 @@ static void write_log(const char *module, const int section, const char *line, i
         if(!(target->section & section))
             continue;
         if(target->type == LOG_TARGET_TYPE_IRC) {
-            if(section == LOG_IRCRAW || (!stricmp(module, "iohandler") && section == LOG_DEBUG))
+            if(section == LOG_IRCRAW || !stricmp(module, "iohandler"))
                 continue; //endless loop ;)
             struct ChanNode *channel = getChanByName(target->target.channel);
             struct ClientSocket *client;
index 6fa063b2508736ce087f704068445dd6fe6d05f4..29f8cfdf2c289cd307568936728c497aad610b42 100644 (file)
 * argv[0] - nick / *auth
 */
 static USERAUTH_CALLBACK(neonserv_cmd_myaccess_nick_lookup);
-static void neonserv_cmd_myaccess_async1(struct ClientSocket *client, struct ClientSocket *textclient, struct UserNode *user, struct ChanNode *chan, char *nick, char *auth, char *chanmatch);
+static void neonserv_cmd_myaccess_async1(struct ClientSocket *client, struct ClientSocket *textclient, struct UserNode *user, struct ChanNode *chan, struct Event *event, char *nick, char *auth, char *chanmatch);
 
 struct neonserv_cmd_myaccess_cache {
     struct ClientSocket *client, *textclient;
     struct UserNode *user;
     struct ChanNode *chan;
+    struct Event *event;
     char *nick;
     char *chanmatch;
 };
@@ -51,7 +52,7 @@ CMD_BIND(neonserv_cmd_myaccess) {
             cache->chanmatch = (chanmatch ? strdup(chanmatch) : NULL);
             get_userauth(user, module_id, neonserv_cmd_myaccess_nick_lookup, cache);
         } else
-            neonserv_cmd_myaccess_async1(client, textclient, user, chan, user->nick, user->auth, chanmatch);
+            neonserv_cmd_myaccess_async1(client, textclient, user, chan, event, user->nick, user->auth, chanmatch);
     }
     else if(argv[0][0] == '*') {
         //we've got an auth
@@ -59,7 +60,7 @@ CMD_BIND(neonserv_cmd_myaccess) {
             chanmatch = argv[1];
         }
         argv[0]++;
-        neonserv_cmd_myaccess_async1(client, textclient, user, chan, NULL, argv[0], chanmatch);
+        neonserv_cmd_myaccess_async1(client, textclient, user, chan, event, NULL, argv[0], chanmatch);
     } else {
         if(argc > 1 && argv[1][0] == '#') {
             chanmatch = argv[1];
@@ -74,7 +75,7 @@ CMD_BIND(neonserv_cmd_myaccess) {
             cuser->flags |= USERFLAG_ISTMPUSER;
         }
         if(cuser->flags & USERFLAG_ISAUTHED) {
-            neonserv_cmd_myaccess_async1(client, textclient, user, chan, argv[0], cuser->auth, chanmatch);
+            neonserv_cmd_myaccess_async1(client, textclient, user, chan, event, argv[0], cuser->auth, chanmatch);
         } else {
             struct neonserv_cmd_myaccess_cache *cache = malloc(sizeof(*cache));
             if (!cache) {
@@ -85,6 +86,7 @@ CMD_BIND(neonserv_cmd_myaccess) {
             cache->textclient = textclient;
             cache->user = user;
             cache->chan = chan;
+            cache->event = event;
             cache->nick = strdup(argv[0]);
             cache->chanmatch = (chanmatch ? strdup(chanmatch) : NULL);
             get_userauth(cuser, module_id, neonserv_cmd_myaccess_nick_lookup, cache);
@@ -106,18 +108,21 @@ static USERAUTH_CALLBACK(neonserv_cmd_myaccess_nick_lookup) {
             reply(cache->textclient, cache->user, "NS_USER_NEED_AUTH", cache->nick);
     }
     else
-        neonserv_cmd_myaccess_async1(cache->client, cache->textclient, cache->user, cache->chan, user->nick, user->auth, cache->chanmatch);
+        neonserv_cmd_myaccess_async1(cache->client, cache->textclient, cache->user, cache->chan, cache->event, user->nick, user->auth, cache->chanmatch);
     if(cache->chanmatch)
         free(cache->chanmatch);
     free(cache->nick);
     free(cache);
 }
 
-static void neonserv_cmd_myaccess_async1(struct ClientSocket *client, struct ClientSocket *textclient, struct UserNode *user, struct ChanNode *chan, char *nick, char *auth, char *chanmatch) {
+static void neonserv_cmd_myaccess_async1(struct ClientSocket *client, struct ClientSocket *textclient, struct UserNode *user, struct ChanNode *chan, struct Event *event, char *nick, char *auth, char *chanmatch) {
     //we've got a valid auth now...
-    if(stricmp(user->auth, auth) && !isGodMode(user)) {
-        reply(textclient, user, "NS_MYACCESS_SELF_ONLY");
-        return;
+    if(stricmp(user->auth, auth)) {
+        if(!isGodMode(user)) {
+            reply(textclient, user, "NS_MYACCESS_SELF_ONLY");
+            return;
+        } else
+            event->flags |= CMDFLAG_OPLOG;
     }
     MYSQL_RES *res, *default_res;
     MYSQL_ROW user_row, chanuser_row, default_chan = NULL;
@@ -187,4 +192,6 @@ static void neonserv_cmd_myaccess_async1(struct ClientSocket *client, struct Cli
         reply(textclient, user, "NS_MYACCESS_COUNT", auth, total_count, owner_count);
     }
     table_free(table);
+    if(event->flags & CMDFLAG_OPLOG)
+        logEvent(event);
 }