]> jfr.im git - solanum.git/commitdiff
authd: split out notices stuff for backporting to master.
authorElizabeth Myers <redacted>
Sat, 26 Mar 2016 02:29:44 +0000 (21:29 -0500)
committerElizabeth Myers <redacted>
Sat, 26 Mar 2016 02:29:44 +0000 (21:29 -0500)
authd/Makefile.am
authd/authd.c
authd/notice.c [new file with mode: 0644]
authd/notice.h [new file with mode: 0644]
authd/provider.c
authd/provider.h
authd/providers/blacklist.c
authd/providers/ident.c
authd/providers/rdns.c

index 235061c4c4e7b5687dcb5ae3cdfe996b5f3b4608..ef2c44a4490fa6ba40195e03a79e4e73b544e095 100644 (file)
@@ -4,13 +4,14 @@ AM_CPPFLAGS = -I../include -I../librb/include
 
 authd_SOURCES =        \
        authd.c \
 
 authd_SOURCES =        \
        authd.c \
-       res.c \
-       reslib.c \
-       reslist.c \
        dns.c \
        getaddrinfo.c \
        getnameinfo.c \
        dns.c \
        getaddrinfo.c \
        getnameinfo.c \
+       notice.c \
        provider.c \
        provider.c \
+       res.c \
+       reslib.c \
+       reslist.c \
        providers/blacklist.c \
        providers/ident.c \
        providers/rdns.c
        providers/blacklist.c \
        providers/ident.c \
        providers/rdns.c
index acd5bc1e21d9af68ea3557be26985f3741629ce2..d77d87b1b4762a9f7b9943d87b9205bc378e4fcc 100644 (file)
@@ -21,6 +21,7 @@
 #include "authd.h"
 #include "dns.h"
 #include "provider.h"
 #include "authd.h"
 #include "dns.h"
 #include "provider.h"
+#include "notice.h"
 
 #define MAXPARA 10
 
 
 #define MAXPARA 10
 
diff --git a/authd/notice.c b/authd/notice.c
new file mode 100644 (file)
index 0000000..3e1d3f8
--- /dev/null
@@ -0,0 +1,48 @@
+/* authd/notice.c - send notices back to the ircd and to clients
+ * Copyright (c) 2016 Elizabeth Myers <elizabeth@interlinked.me>
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice is present in all copies.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "authd.h"
+#include "notice.h"
+
+/* Send a notice to a client */
+void notice_client(uint32_t cid, const char *fmt, ...)
+{
+       char buf[BUFSIZE];
+       va_list args;
+
+       va_start(args, fmt);
+       vsnprintf(buf, sizeof(buf), fmt, args);
+       va_end(args);
+
+       rb_helper_write(authd_helper, "N %x :%s", cid, buf);
+}
+
+/* Send a warning to the IRC daemon for logging, etc. */
+void warn_opers(notice_level_t level, const char *fmt, ...)
+{
+       char buf[BUFSIZE];
+       va_list args;
+
+       va_start(args, fmt);
+       vsnprintf(buf, sizeof(buf), fmt, args);
+       va_end(args);
+
+       rb_helper_write(authd_helper, "W %c :%s", level, buf);
+}
diff --git a/authd/notice.h b/authd/notice.h
new file mode 100644 (file)
index 0000000..1e48bcc
--- /dev/null
@@ -0,0 +1,35 @@
+/* authd/notice.h - send notices back to the ircd and to clients
+ * Copyright (c) 2016 Elizabeth Myers <elizabeth@interlinked.me>
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice is present in all copies.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef __CHARYBDIS_AUTHD_NOTICE_H__
+#define __CHARYBDIS_AUTHD_NOTICE_H__
+
+typedef enum
+{
+       L_DEBUG = 'D',
+       L_INFO = 'I',
+       L_WARN = 'W',
+       L_CRIT ='C',
+} notice_level_t;
+
+void notice_client(uint32_t cid, const char *fmt, ...);
+void warn_opers(notice_level_t level, const char *fmt, ...);
+
+#endif /* __CHARYBDIS_AUTHD_NOTICE_H__ */
index 4e17793ee18bfad189a0fb1c8b1d3ccad262a71d..1a6c6517e6d064fb45157365f6235f1104237d7e 100644 (file)
@@ -49,6 +49,7 @@
 #include "rb_dictionary.h"
 #include "authd.h"
 #include "provider.h"
 #include "rb_dictionary.h"
 #include "authd.h"
 #include "provider.h"
+#include "notice.h"
 
 rb_dlink_list auth_providers;
 
 
 rb_dlink_list auth_providers;
 
@@ -193,32 +194,6 @@ void accept_client(struct auth_client *auth, provider_t id)
        cancel_providers(auth);
 }
 
        cancel_providers(auth);
 }
 
-/* Send a notice to a client */
-void notice_client(struct auth_client *auth, const char *fmt, ...)
-{
-       char buf[BUFSIZE];
-       va_list args;
-
-       va_start(args, fmt);
-       vsnprintf(buf, sizeof(buf), fmt, args);
-       va_end(args);
-
-       rb_helper_write(authd_helper, "N %x :%s", auth->cid, buf);
-}
-
-/* Send a warning to the IRC daemon for logging, etc. */
-void warn_opers(notice_level_t level, const char *fmt, ...)
-{
-       char buf[BUFSIZE];
-       va_list args;
-
-       va_start(args, fmt);
-       vsnprintf(buf, sizeof(buf), fmt, args);
-       va_end(args);
-
-       rb_helper_write(authd_helper, "W %c :%s", level, buf);
-}
-
 /* Begin authenticating user */
 static void start_auth(const char *cid, const char *l_ip, const char *l_port, const char *c_ip, const char *c_port)
 {
 /* Begin authenticating user */
 static void start_auth(const char *cid, const char *l_ip, const char *l_port, const char *c_ip, const char *c_port)
 {
index ef96ca8415b63ca27f493ce6ec85a1c74c0db60a..8fab21cf0de8776900e4c44ae18e5b85caab1413 100644 (file)
@@ -34,14 +34,6 @@ typedef enum
        PROVIDER_BLACKLIST,
 } provider_t;
 
        PROVIDER_BLACKLIST,
 } provider_t;
 
-typedef enum
-{
-       L_DEBUG = 'D',
-       L_INFO = 'I',
-       L_WARN = 'W',
-       L_CRIT ='C',
-} notice_level_t;
-
 struct auth_client
 {
        uint16_t cid;                           /* Client ID */
 struct auth_client
 {
        uint16_t cid;                           /* Client ID */
@@ -103,9 +95,6 @@ void provider_done(struct auth_client *auth, provider_t id);
 void accept_client(struct auth_client *auth, provider_t id);
 void reject_client(struct auth_client *auth, provider_t id, const char *reason);
 
 void accept_client(struct auth_client *auth, provider_t id);
 void reject_client(struct auth_client *auth, provider_t id, const char *reason);
 
-void notice_client(struct auth_client *auth, const char *fmt, ...);
-void warn_opers(notice_level_t level, const char *fmt, ...);
-
 void handle_new_connection(int parc, char *parv[]);
 
 /* Provider is operating on this auth_client (set this if you have async work to do) */
 void handle_new_connection(int parc, char *parv[]);
 
 /* Provider is operating on this auth_client (set this if you have async work to do) */
index 22917c03d8a2b66148c164f0fe778cdd3cb0198f..df7d3974b942deae15138aef3fc64ab77fca71f3 100644 (file)
@@ -39,6 +39,7 @@
 
 #include "authd.h"
 #include "provider.h"
 
 #include "authd.h"
 #include "provider.h"
+#include "notice.h"
 #include "stdinc.h"
 #include "dns.h"
 
 #include "stdinc.h"
 #include "dns.h"
 
index a19b289e86a88b50cdf3b5770a2c62c3836b48f9..2c5614620e3b25d35cf2af70c686045b63d25450 100644 (file)
@@ -21,6 +21,7 @@
 #include "stdinc.h"
 #include "match.h"
 #include "authd.h"
 #include "stdinc.h"
 #include "match.h"
 #include "authd.h"
+#include "notice.h"
 #include "provider.h"
 #include "res.h"
 
 #include "provider.h"
 #include "res.h"
 
@@ -120,7 +121,7 @@ bool ident_start(struct auth_client *auth)
                        GET_SS_LEN(&l_addr), ident_connected,
                        query, ident_timeout);
 
                        GET_SS_LEN(&l_addr), ident_connected,
                        query, ident_timeout);
 
-       notice_client(auth, messages[REPORT_LOOKUP]);
+       notice_client(auth->cid, messages[REPORT_LOOKUP]);
        set_provider_on(auth, PROVIDER_IDENT);
 
        return true;
        set_provider_on(auth, PROVIDER_IDENT);
 
        return true;
@@ -249,7 +250,7 @@ static void client_fail(struct auth_client *auth, ident_message report)
        rb_free(query);
        auth->data[PROVIDER_IDENT] = NULL;
 
        rb_free(query);
        auth->data[PROVIDER_IDENT] = NULL;
 
-       notice_client(auth, messages[report]);
+       notice_client(auth->cid, messages[report]);
        provider_done(auth, PROVIDER_IDENT);
 }
 
        provider_done(auth, PROVIDER_IDENT);
 }
 
@@ -261,7 +262,7 @@ static void client_success(struct auth_client *auth)
        rb_free(query);
        auth->data[PROVIDER_IDENT] = NULL;
 
        rb_free(query);
        auth->data[PROVIDER_IDENT] = NULL;
 
-       notice_client(auth, messages[REPORT_FOUND]);
+       notice_client(auth->cid, messages[REPORT_FOUND]);
        provider_done(auth, PROVIDER_IDENT);
 }
 
        provider_done(auth, PROVIDER_IDENT);
 }
 
index ddce08fbccf8f729aadb47dd7c428056c61cd718..0b203740a1bf859401d97bdf2ff4162690962e57 100644 (file)
@@ -22,6 +22,7 @@
 #include "rb_commio.h"
 #include "authd.h"
 #include "provider.h"
 #include "rb_commio.h"
 #include "authd.h"
 #include "provider.h"
+#include "notice.h"
 #include "res.h"
 #include "dns.h"
 
 #include "res.h"
 #include "dns.h"
 
@@ -87,7 +88,7 @@ bool client_dns_start(struct auth_client *auth)
 
        query->query = lookup_hostname(auth->c_ip, dns_answer_callback, auth);
 
 
        query->query = lookup_hostname(auth->c_ip, dns_answer_callback, auth);
 
-       notice_client(auth, messages[REPORT_LOOKUP]);
+       notice_client(auth->cid, messages[REPORT_LOOKUP]);
        set_provider_on(auth, PROVIDER_RDNS);
        return true;
 }
        set_provider_on(auth, PROVIDER_RDNS);
        return true;
 }
@@ -144,7 +145,7 @@ static void client_fail(struct auth_client *auth, dns_message report)
 
        rb_strlcpy(auth->hostname, "*", sizeof(auth->hostname));
 
 
        rb_strlcpy(auth->hostname, "*", sizeof(auth->hostname));
 
-       notice_client(auth, messages[report]);
+       notice_client(auth->cid, messages[report]);
        cancel_query(query->query);
 
        rb_free(query);
        cancel_query(query->query);
 
        rb_free(query);
@@ -157,7 +158,7 @@ static void client_success(struct auth_client *auth)
 {
        struct user_query *query = auth->data[PROVIDER_RDNS];
 
 {
        struct user_query *query = auth->data[PROVIDER_RDNS];
 
-       notice_client(auth, messages[REPORT_FOUND]);
+       notice_client(auth->cid, messages[REPORT_FOUND]);
        cancel_query(query->query);
 
        rb_free(query);
        cancel_query(query->query);
 
        rb_free(query);