]> jfr.im git - solanum.git/blobdiff - modules/m_sasl.c
cap server-time: add .000 for microsecs since our clock does not support microsecs
[solanum.git] / modules / m_sasl.c
index 160c4eaf335b5cf453c54f43b2bdd22c9649b99d..3220ffe9e5b19d27e18fdd6229596365d6a5858c 100644 (file)
@@ -43,8 +43,8 @@
 #include "s_newconf.h"
 #include "s_conf.h"
 
-static int m_authenticate(struct Client *, struct Client *, int, const char **);
-static int me_sasl(struct Client *, struct Client *, int, const char **);
+static int m_authenticate(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
+static int me_sasl(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
 
 static void abort_sasl(struct Client *);
 static void abort_sasl_exit(hook_data_client_exit *);
@@ -52,12 +52,14 @@ static void abort_sasl_exit(hook_data_client_exit *);
 static void advertise_sasl(struct Client *);
 static void advertise_sasl_exit(hook_data_client_exit *);
 
+unsigned int CLICAP_SASL = 0;
+
 struct Message authenticate_msgtab = {
-       "AUTHENTICATE", 0, 0, 0, MFLG_SLOW,
+       "AUTHENTICATE", 0, 0, 0, 0,
        {{m_authenticate, 2}, {m_authenticate, 2}, mg_ignore, mg_ignore, mg_ignore, {m_authenticate, 2}}
 };
 struct Message sasl_msgtab = {
-       "SASL", 0, 0, 0, MFLG_SLOW,
+       "SASL", 0, 0, 0, 0,
        {mg_ignore, mg_ignore, mg_ignore, mg_ignore, {me_sasl, 5}, mg_ignore}
 };
 
@@ -72,10 +74,39 @@ mapi_hfn_list_av1 sasl_hfnlist[] = {
        { NULL, NULL }
 };
 
-DECLARE_MODULE_AV1(sasl, NULL, NULL, sasl_clist, NULL, sasl_hfnlist, "$Revision: 1409 $");
+static int
+sasl_visible(void)
+{
+       struct Client *agent_p = NULL;
+
+       if (ConfigFileEntry.sasl_service)
+               agent_p = find_named_client(ConfigFileEntry.sasl_service);
+
+       return agent_p != NULL && IsService(agent_p);
+}
+
+static struct ClientCapability capdata_sasl = {
+       .visible = sasl_visible,
+       .flags = CLICAP_FLAGS_STICKY,
+};
+
+static int
+_modinit(void)
+{
+       CLICAP_SASL = capability_put(cli_capindex, "sasl", &capdata_sasl);
+       return 0;
+}
+
+static void
+_moddeinit(void)
+{
+       capability_orphan(cli_capindex, "sasl");
+}
+
+DECLARE_MODULE_AV1(sasl, _modinit, _moddeinit, sasl_clist, NULL, sasl_hfnlist, "$Revision: 1409 $");
 
 static int
-m_authenticate(struct Client *client_p, struct Client *source_p,
+m_authenticate(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p,
        int parc, const char *parv[])
 {
        struct Client *agent_p = NULL;
@@ -122,23 +153,24 @@ m_authenticate(struct Client *client_p, struct Client *source_p,
 
        if(agent_p == NULL)
        {
-               sendto_server(NULL, NULL, CAP_TS6|CAP_ENCAP, NOCAPS, ":%s ENCAP * SASL %s * H %s %s", me.id,
-                                       source_p->id, source_p->host, source_p->sockhost);
+               sendto_one(saslserv_p, ":%s ENCAP %s SASL %s %s H %s %s",
+                                       me.id, saslserv_p->servptr->name, source_p->id, saslserv_p->id,
+                                       source_p->host, source_p->sockhost);
 
                if (!strcmp(parv[1], "EXTERNAL") && source_p->certfp != NULL)
-                       sendto_one(saslserv_p, ":%s ENCAP %s SASL %s %s S %s %s", me.id, saslserv_p->servptr->name,
-                                       source_p->id, saslserv_p->id,
-                                       parv[1], source_p->certfp);
+                       sendto_one(saslserv_p, ":%s ENCAP %s SASL %s %s S %s %s",
+                                               me.id, saslserv_p->servptr->name, source_p->id, saslserv_p->id,
+                                               parv[1], source_p->certfp);
                else
-                       sendto_one(saslserv_p, ":%s ENCAP %s SASL %s %s S %s", me.id, saslserv_p->servptr->name,
-                                       source_p->id, saslserv_p->id,
-                                       parv[1]);
+                       sendto_one(saslserv_p, ":%s ENCAP %s SASL %s %s S %s",
+                                               me.id, saslserv_p->servptr->name, source_p->id, saslserv_p->id,
+                                               parv[1]);
 
                rb_strlcpy(source_p->localClient->sasl_agent, saslserv_p->id, IDLEN);
        }
        else
-               sendto_one(agent_p, ":%s ENCAP %s SASL %s %s C %s", me.id, agent_p->servptr->name,
-                               source_p->id, agent_p->id,
+               sendto_one(agent_p, ":%s ENCAP %s SASL %s %s C %s",
+                               me.id, agent_p->servptr->name, source_p->id, agent_p->id,
                                parv[1]);
        source_p->localClient->sasl_out++;
 
@@ -146,7 +178,7 @@ m_authenticate(struct Client *client_p, struct Client *source_p,
 }
 
 static int
-me_sasl(struct Client *client_p, struct Client *source_p,
+me_sasl(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p,
        int parc, const char *parv[])
 {
        struct Client *target_p, *agent_p;