]> jfr.im git - solanum.git/blobdiff - modules/m_starttls.c
ircd/packet.c: make function definition consistent with declaration (#301)
[solanum.git] / modules / m_starttls.c
index f49abb46dc15712f02387e8914f0a0bf75ad1961..bc25e9cc457ce83ad884d1197001f8893bd2ce42 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012 William Pitcock <nenolod@dereferenced.org>.
+ * Copyright (c) 2012 Ariadne Conill <ariadne@dereferenced.org>.
  *
  * Permission to use, copy, modify, and/or distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above
@@ -45,23 +45,20 @@ mapi_clist_av1 starttls_clist[] = { &starttls_msgtab, NULL };
 
 unsigned int CLICAP_TLS = 0;
 
-#ifdef HAVE_LIBCRYPTO
+static struct ClientCapability capdata_tls = {
+       .flags = CLICAP_FLAGS_PRIORITY,
+};
+
 mapi_cap_list_av2 starttls_cap_list[] = {
-       { MAPI_CAP_CLIENT, "tls", NULL, &CLICAP_TLS },
+       { MAPI_CAP_CLIENT, "tls", &capdata_tls, &CLICAP_TLS },
        { 0, NULL, NULL, NULL }
 };
-#else /* HAVE_LIBCRYPTO */
-
-mapi_cap_list_av2 starttls_cap_list[] = { { 0, NULL, NULL, NULL } };
-
-#endif /* HAVE_LIBCRYPTO */
 
 DECLARE_MODULE_AV2(starttls, NULL, NULL, starttls_clist, NULL, NULL, starttls_cap_list, NULL, starttls_desc);
 
 static void
 mr_starttls(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
 {
-#ifdef HAVE_LIBCRYPTO
        ssl_ctl_t *ctl;
        rb_fde_t *F[2];
 
@@ -95,14 +92,14 @@ mr_starttls(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *sou
        sendto_one_numeric(client_p, RPL_STARTTLS, form_str(RPL_STARTTLS));
        send_queued(client_p);
 
-       ctl = start_ssld_accept(client_p->localClient->F, F[1], client_p->localClient->connid);
+       /* TODO: set localClient->ssl_callback and handle success/failure */
+
+       ctl = start_ssld_accept(client_p->localClient->F, F[1], connid_get(client_p));
        if (ctl != NULL)
        {
                client_p->localClient->F = F[0];
                client_p->localClient->ssl_ctl = ctl;
                SetSSL(client_p);
+               SetSecure(client_p);
        }
-#else /* HAVE_LIBCRYPTO */
-       sendto_one_numeric(client_p, ERR_STARTTLS, form_str(ERR_STARTTLS), "TLS is not configured");
-#endif /* HAVE_LIBCRYPTO */
 }