Commit Diff


commit - 113bd34878c17f730d8fb878157b0dbba9380326
commit + e46cf64cc1e3bf21060df1d1125502277d035170
blob - fca531d02847a6f56aaa6a5f9b7137725d38fc67
blob + f94f8d92f055f87fd4adc44c2d73527c77e97b55
--- src/ngircd/Makefile.am
+++ src/ngircd/Makefile.am
@@ -23,7 +23,7 @@ sbin_PROGRAMS = ngircd
 ngircd_SOURCES = ngircd.c array.c channel.c client.c conf.c conn.c conn-func.c \
 	conn-ssl.c conn-zip.c hash.c io.c irc.c irc-channel.c irc-info.c irc-login.c \
 	irc-mode.c irc-op.c irc-oper.c irc-server.c irc-write.c lists.c log.c \
-	match.c numeric.c parse.c rendezvous.c resolve.c
+	match.c op.c numeric.c parse.c rendezvous.c resolve.c
 
 ngircd_LDFLAGS = -L../portab -L../tool -L../ipaddr
 
@@ -32,7 +32,7 @@ ngircd_LDADD = -lngportab -lngtool -lngipaddr
 noinst_HEADERS = ngircd.h array.h channel.h client.h conf.h conf-ssl.h conn.h \
 	conn-func.h conn-ssl.h conn-zip.h hash.h io.h irc.h irc-channel.h \
 	irc-info.h irc-login.h irc-mode.h irc-op.h irc-oper.h irc-server.h \
-	irc-write.h lists.h log.h match.h numeric.h parse.h rendezvous.h \
+	irc-write.h lists.h log.h match.h numeric.h op.h parse.h rendezvous.h \
 	resolve.h defines.h messages.h
 
 clean-local:
blob - /dev/null
blob + 031bc2819bb96f6da347a392b5e73a4aec473901 (mode 644)
--- /dev/null
+++ src/ngircd/op.c
@@ -0,0 +1,82 @@
+/*
+ * ngIRCd -- The Next Generation IRC Daemon
+ * Copyright (c)2001-2008 Alexander Barton (alex@barton.de)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ * Please read the file COPYING, README and AUTHORS for more information.
+ *
+ * IRC operator functions
+ */
+
+
+#include "portab.h"
+
+#include "imp.h"
+#include <assert.h>
+#include <string.h>
+
+#include "conn.h"
+#include "client.h"
+#include "channel.h"
+#include "conf.h"
+#include "log.h"
+#include "parse.h"
+#include "messages.h"
+#include "irc-write.h"
+
+#include <exp.h>
+#include "op.h"
+
+/**
+ * Return and log a "no privileges" message.
+ */
+GLOBAL bool
+Op_NoPrivileges(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));
+	}
+} /* Op_NoPrivileges */
+
+
+/**
+ * Check that the client is an IRC operator allowed to administer this server.
+ */
+GLOBAL bool
+Op_Check(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;
+} /* Op_Check */
blob - /dev/null
blob + 544be25a8650d273492d4a3c501780dd1edc35f3 (mode 644)
--- /dev/null
+++ src/ngircd/op.h
@@ -0,0 +1,22 @@
+/*
+ * ngIRCd -- The Next Generation IRC Daemon
+ * Copyright (c)2001-2009 Alexander Barton (alex@barton.de)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ * Please read the file COPYING, README and AUTHORS for more information.
+ *
+ * Operator management (header)
+ */
+
+#ifndef __oper_h__
+#define __oper_h__
+
+GLOBAL bool Op_NoPrivileges PARAMS((CLIENT * Client, REQUEST * Req));
+GLOBAL bool Op_Check PARAMS((CLIENT * Client, REQUEST * Req));
+
+#endif
+
+/* -eof- */