about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorAlexander Barton <alex@barton.de>2009-04-22 23:24:15 +0200
committerAlexander Barton <alex@barton.de>2009-09-30 16:00:06 +0200
commit9918dfc1d595a680573910d12beb337cf4a58b14 (patch)
treebbad9acf72f69b0f76578d60815f793bc7b3380b /src
parente46cf64cc1e3bf21060df1d1125502277d035170 (diff)
downloadngircd-9918dfc1d595a680573910d12beb337cf4a58b14.tar.gz
ngircd-9918dfc1d595a680573910d12beb337cf4a58b14.zip
Use functions provided by op.c "module"
Local functions Check_Oper() and No_Privileges() have been replaced by
global functions in op.c "module": Op_Check() and Op_NoPrivileges().
Diffstat (limited to 'src')
-rw-r--r--src/ngircd/irc-oper.c73
1 files changed, 11 insertions, 62 deletions
diff --git a/src/ngircd/irc-oper.c b/src/ngircd/irc-oper.c
index f67e947c..68b5eb6f 100644
--- a/src/ngircd/irc-oper.c
+++ b/src/ngircd/irc-oper.c
@@ -31,6 +31,7 @@
 #include "match.h"
 #include "messages.h"
 #include "parse.h"
+#include "op.h"
 
 #include <exp.h>
 #include "irc-oper.h"
@@ -51,58 +52,6 @@ Bad_OperPass(CLIENT *Client, char *errtoken, char *errmsg)
 } /* Bad_OperPass */
 
 
-/**
- * Check that the client is an IRC operator allowed to administer this server.
- */
-static bool
-Check_Oper(CLIENT * Client, REQUEST * Req)
-{
-	CLIENT *c;
-
-	assert(Client != NULL);
-	assert(Req != NULL);
-
-	if (Client_Type(Client) == CLIENT_SERVER && Req->prefix)
-		c = Client_Search(Req->prefix);
-	else
-		c = Client;
-	if (!c)
-		return false;
-	if (!Client_HasMode(c, 'o'))
-		return false;
-	if (!Client_OperByMe(c) && !Conf_AllowRemoteOper)
-		return false;
-	/* The client is an local IRC operator, or this server is configured
-	 * to trust remote operators. */
-	return true;
-} /* CheckOper */
-
-
-/**
- * Return and log a "no privileges" message.
- */
-static bool
-No_Privileges(CLIENT * Client, REQUEST * Req)
-{
-	CLIENT *from = NULL;
-
-	if (Req->prefix) 
-		from = Client_Search(Req->prefix);
-
-	if (from) {
-		Log(LOG_NOTICE, "No privileges: client \"%s\" (%s), command \"%s\"",
-		    Req->prefix, Client_Mask(Client), Req->command);
-		return IRC_WriteStrClient(from, ERR_NOPRIVILEGES_MSG,
-					  Client_ID(from));
-	} else {
-		Log(LOG_NOTICE, "No privileges: client \"%s\", command \"%s\"",
-		    Client_Mask(Client), Req->command);
-		return IRC_WriteStrClient(Client, ERR_NOPRIVILEGES_MSG,
-					  Client_ID(Client));
-	}
-} /* PermissionDenied */
-
-
 GLOBAL bool
 IRC_OPER( CLIENT *Client, REQUEST *Req )
 {
@@ -151,8 +100,8 @@ IRC_DIE(CLIENT * Client, REQUEST * Req)
 	assert(Client != NULL);
 	assert(Req != NULL);
 
-	if (!Check_Oper(Client, Req))
-		return No_Privileges(Client, Req);
+	if (!Op_Check(Client, Req))
+		return Op_NoPrivileges(Client, Req);
 
 	/* Bad number of parameters? */
 #ifdef STRICT_RFC
@@ -191,8 +140,8 @@ IRC_REHASH( CLIENT *Client, REQUEST *Req )
 	assert( Client != NULL );
 	assert( Req != NULL );
 
-	if (!Check_Oper(Client, Req))
-		return No_Privileges(Client, Req);
+	if (!Op_Check(Client, Req))
+		return Op_NoPrivileges(Client, Req);
 
 	/* Bad number of parameters? */
 	if( Req->argc != 0 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
@@ -212,8 +161,8 @@ IRC_RESTART( CLIENT *Client, REQUEST *Req )
 	assert( Client != NULL );
 	assert( Req != NULL );
 
-	if (!Check_Oper(Client, Req))
-		return No_Privileges(Client, Req);
+	if (!Op_Check(Client, Req))
+		return Op_NoPrivileges(Client, Req);
 
 	/* Bad number of parameters? */
 	if( Req->argc != 0 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
@@ -235,8 +184,8 @@ IRC_CONNECT(CLIENT * Client, REQUEST * Req)
 	assert(Client != NULL);
 	assert(Req != NULL);
 
-	if (!Check_Oper(Client, Req))
-		return No_Privileges(Client, Req);
+	if (!Op_Check(Client, Req))
+		return Op_NoPrivileges(Client, Req);
 
 	/* Bad number of parameters? */
 	if (Req->argc != 1 && Req->argc != 2 && Req->argc != 3 &&
@@ -329,8 +278,8 @@ IRC_DISCONNECT(CLIENT * Client, REQUEST * Req)
 	assert(Client != NULL);
 	assert(Req != NULL);
 
-	if (!Check_Oper(Client, Req))
-		return No_Privileges(Client, Req);
+	if (!Op_Check(Client, Req))
+		return Op_NoPrivileges(Client, Req);
 
 	/* Bad number of parameters? */
 	if (Req->argc != 1)