X-Git-Url: http://git.pk910.de/?a=blobdiff_plain;f=src%2Fmodules%2FNeonServ.mod%2Fcmd_neonserv_myaccess.c;h=29f8cfdf2c289cd307568936728c497aad610b42;hb=b073db1a07d123fd422a43970e4f7caa008ff4c9;hp=7ca2334ae27bf3a2701af435d672d543ed763f99;hpb=02e797baca7f15e306d70b3b7e2b4d83ff1cf44f;p=NeonServV5.git diff --git a/src/modules/NeonServ.mod/cmd_neonserv_myaccess.c b/src/modules/NeonServ.mod/cmd_neonserv_myaccess.c index 7ca2334..29f8cfd 100644 --- a/src/modules/NeonServ.mod/cmd_neonserv_myaccess.c +++ b/src/modules/NeonServ.mod/cmd_neonserv_myaccess.c @@ -1,4 +1,4 @@ -/* cmd_neonserv_myaccess.c - NeonServ v5.5 +/* cmd_neonserv_myaccess.c - NeonServ v5.6 * Copyright (C) 2011-2012 Philipp Kreil (pk910) * * This program is free software: you can redistribute it and/or modify @@ -21,12 +21,13 @@ * 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; }; @@ -40,7 +41,7 @@ CMD_BIND(neonserv_cmd_myaccess) { if(!(user->flags & USERFLAG_ISAUTHED)) { struct neonserv_cmd_myaccess_cache *cache = malloc(sizeof(*cache)); if (!cache) { - perror("malloc() failed"); + printf_log("neonserv", LOG_ERROR, "%s:%d malloc() failed", __FILE__, __LINE__); return; } cache->client = client; @@ -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,17 +75,18 @@ 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) { - perror("malloc() failed"); + printf_log("neonserv", LOG_ERROR, "%s:%d malloc() failed", __FILE__, __LINE__); return; } cache->client = client; 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); }