* 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;
};
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;
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
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];
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);
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;
reply(textclient, user, "NS_MYACCESS_COUNT", auth, total_count, owner_count);
}
table_free(table);
+ if(event->flags & CMDFLAG_OPLOG)
+ logEvent(event);
}