X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=ngircd-alex.git;a=blobdiff_plain;f=src%2Fngircd%2Firc-info.c;h=56cae2acd973d238f01add89ed0c86fa6e2ea6da;hp=88455c74d9e85c770442aea1aa6f0c54e2e0ab9c;hb=1a628fff51fcfddde391e6c0f27686835e1b6d2e;hpb=08f9d31d60220e8a389a2d24f42625be7749f090 diff --git a/src/ngircd/irc-info.c b/src/ngircd/irc-info.c index 88455c74..56cae2ac 100644 --- a/src/ngircd/irc-info.c +++ b/src/ngircd/irc-info.c @@ -41,6 +41,7 @@ #include "irc-macros.h" #include "irc-write.h" #include "client-cap.h" +#include "op.h" #include "exp.h" #include "irc-info.h" @@ -151,8 +152,6 @@ IRC_WHO_Channel(CLIENT *Client, CHANNEL *Chan, bool OnlyOps) assert( Client != NULL ); assert( Chan != NULL ); - IRC_SetPenalty(Client, 1); - is_member = Channel_IsMemberOf(Chan, Client); /* Secret channel? */ @@ -190,7 +189,7 @@ IRC_WHO_Channel(CLIENT *Client, CHANNEL *Chan, bool OnlyOps) } } - /* If there are a lot of clients, augment penalty a bit */ + /* If there are a lot of clients, increase the penalty a bit */ if (count > MAX_RPL_WHO) IRC_SetPenalty(Client, 1); @@ -499,8 +498,6 @@ IRC_ADMIN(CLIENT *Client, REQUEST *Req ) assert( Client != NULL ); assert( Req != NULL ); - IRC_SetPenalty(Client, 1); - _IRC_GET_SENDER_OR_RETURN_(prefix, Req, Client) _IRC_GET_TARGET_SERVER_OR_RETURN_(target, Req, 0, prefix) @@ -543,8 +540,6 @@ IRC_INFO(CLIENT * Client, REQUEST * Req) assert(Client != NULL); assert(Req != NULL); - IRC_SetPenalty(Client, 2); - _IRC_GET_SENDER_OR_RETURN_(prefix, Req, Client) _IRC_GET_TARGET_SERVER_OR_RETURN_(target, Req, 0, prefix) @@ -630,8 +625,6 @@ IRC_LINKS(CLIENT *Client, REQUEST *Req) assert(Client != NULL); assert(Req != NULL); - IRC_SetPenalty(Client, 1); - _IRC_GET_SENDER_OR_RETURN_(from, Req, Client) /* Get pointer to server mask or "*", if none given */ @@ -684,8 +677,6 @@ IRC_LUSERS( CLIENT *Client, REQUEST *Req ) assert( Client != NULL ); assert( Req != NULL ); - IRC_SetPenalty(Client, 1); - _IRC_GET_SENDER_OR_RETURN_(from, Req, Client) _IRC_GET_TARGET_SERVER_OR_RETURN_(target, Req, 1, from) @@ -715,8 +706,6 @@ IRC_SERVLIST(CLIENT *Client, REQUEST *Req) assert(Client != NULL); assert(Req != NULL); - IRC_SetPenalty(Client, 1); - if (Req->argc < 2 || strcmp(Req->argv[1], "0") == 0) { for (c = Client_First(); c!= NULL; c = Client_Next(c)) { if (Client_Type(c) != CLIENT_SERVICE) @@ -752,8 +741,6 @@ IRC_MOTD( CLIENT *Client, REQUEST *Req ) assert( Client != NULL ); assert( Req != NULL ); - IRC_SetPenalty(Client, 3); - _IRC_GET_SENDER_OR_RETURN_(from, Req, Client) _IRC_GET_TARGET_SERVER_OR_RETURN_(target, Req, 0, from) @@ -784,8 +771,6 @@ IRC_NAMES( CLIENT *Client, REQUEST *Req ) assert( Client != NULL ); assert( Req != NULL ); - IRC_SetPenalty(Client, 1); - _IRC_GET_SENDER_OR_RETURN_(from, Req, Client) _IRC_GET_TARGET_SERVER_OR_RETURN_(target, Req, 1, from) @@ -865,12 +850,11 @@ IRC_STATS( CLIENT *Client, REQUEST *Req ) unsigned int days, hrs, mins; struct list_head *list; struct list_elem *list_item; + bool more_links = false; assert(Client != NULL); assert(Req != NULL); - IRC_SetPenalty(Client, 2); - _IRC_GET_SENDER_OR_RETURN_(from, Req, Client) _IRC_GET_TARGET_SERVER_OR_RETURN_(target, Req, 1, from) @@ -909,16 +893,20 @@ IRC_STATS( CLIENT *Client, REQUEST *Req ) list_item = Lists_GetNext(list_item); } break; + case 'L': /* Link status (servers and user links) */ + if (!Op_Check(from, Req)) + return Op_NoPrivileges(from, Req); + more_links = true; + case 'l': /* Link status (servers and own link) */ - case 'L': time_now = time(NULL); for (con = Conn_First(); con != NONE; con = Conn_Next(con)) { cl = Conn_GetClient(con); if (!cl) continue; - if ((Client_Type(cl) == CLIENT_SERVER) - || (cl == Client)) { - /* Server link or our own connection */ + if (Client_Type(cl) == CLIENT_SERVER || + cl == Client || + (more_links && Client_Type(cl) == CLIENT_USER)) { #ifdef ZLIB if (Conn_Options(con) & CONN_ZIP) { if (!IRC_WriteStrClient @@ -1007,8 +995,6 @@ IRC_TIME( CLIENT *Client, REQUEST *Req ) assert(Client != NULL); assert(Req != NULL); - IRC_SetPenalty(Client, 1); - _IRC_GET_SENDER_OR_RETURN_(from, Req, Client) _IRC_GET_TARGET_SERVER_OR_RETURN_(target, Req, 0, from) @@ -1042,8 +1028,6 @@ IRC_USERHOST(CLIENT *Client, REQUEST *Req) assert(Client != NULL); assert(Req != NULL); - IRC_SetPenalty(Client, 1); - if (Req->argc > 5) max = 5; else @@ -1104,8 +1088,6 @@ IRC_VERSION( CLIENT *Client, REQUEST *Req ) assert( Client != NULL ); assert( Req != NULL ); - IRC_SetPenalty(Client, 1); - _IRC_GET_SENDER_OR_RETURN_(prefix, Req, Client) _IRC_GET_TARGET_SERVER_OR_RETURN_(target, Req, 0, prefix) @@ -1139,18 +1121,17 @@ IRC_WHO(CLIENT *Client, REQUEST *Req) assert (Client != NULL); assert (Req != NULL); - IRC_SetPenalty(Client, 1); - only_ops = false; if (Req->argc == 2) { if (strcmp(Req->argv[1], "o") == 0) only_ops = true; #ifdef STRICT_RFC - else + else { return IRC_WriteErrClient(Client, ERR_NEEDMOREPARAMS_MSG, Client_ID(Client), Req->command); + } #endif } @@ -1169,7 +1150,6 @@ IRC_WHO(CLIENT *Client, REQUEST *Req) } /* No channel or (valid) mask given */ - IRC_SetPenalty(Client, 2); return IRC_WHO_Mask(Client, NULL, only_ops); } /* IRC_WHO */ @@ -1192,8 +1172,6 @@ IRC_WHOIS( CLIENT *Client, REQUEST *Req ) assert( Client != NULL ); assert( Req != NULL ); - IRC_SetPenalty(Client, 1); - /* Wrong number of parameters? */ if (Req->argc < 1) return IRC_WriteErrClient(Client, ERR_NONICKNAMEGIVEN_MSG, @@ -1255,6 +1233,7 @@ IRC_WHOIS( CLIENT *Client, REQUEST *Req ) continue; } got_wildcard = true; + /* Increase penalty for wildcard queries */ IRC_SetPenalty(Client, 3); for (c = Client_First(); c; c = Client_Next(c)) {