git clone https://orangeshoelaces.net/git/ii.git
Author: Vasilii Kolobkov on 01/08/2019
Committer: Vasilii Kolobkov on 01/08/2019
Authenticate with SASL EXTERNAL
ii.1 | 16 ++++---
ii.c | 17 +++++++-
2 files changed, 26 insertions(+), 7 deletions(-)
diff --git a/ii.1 b/ii.1
index 2ea973e..18f346f 100644
--- a/ii.1
+++ b/ii.1
@@ -21,12 +21,13 @@ and standard output for ii messages.
.B ii
.RB < \-s
.IR servername >
-.RB [ \-k
-.IR "environment variable" ]
.RB [ \-i
.IR prefix ]
.RB [ \-n
.IR nickname ]
+.RB [ \-k
+.IR "environment variable" ]
+.RB [ \-x ]
.RB [ \-f
.IR realname ]
.SH OPTIONS
@@ -34,16 +35,19 @@ and standard output for ii messages.
.BI \-s " servername"
server name, for example: irc.freenode.net
.TP
-.BI \-k " environment variable"
-lets you specify an environment variable that contains your IRC password, e.g. IIPASS="foobar" ii -k IIPASS.
-This is done in order to prevent other users from eavesdropping the server password via the process list.
-.TP
.BI \-i " prefix"
lets you override the default irc path (~/irc)
.TP
.BI \-n " nickname"
lets you override the default nick ($USER)
.TP
+.BI \-k " environment variable"
+lets you specify an environment variable that contains your IRC password, e.g. IIPASS="foobar" ii -k IIPASS.
+This is done in order to prevent other users from eavesdropping the server password via the process list.
+.TP
+.BI \-x
+authenticate with SASL EXTERNAL
+.TP
.BI \-f " realname"
lets you specify your real name associated with your nick
.SH DIRECTORIES
diff --git a/ii.c b/ii.c
index 2345214..ab7d4bc 100644
--- a/ii.c
+++ b/ii.c
@@ -57,6 +57,7 @@ static void handle_channels_input(Channel *);
static void handle_server_output(void);
static int isnumeric(const char *);
static void loginkey(const char *);
+static void authsaslext(void);
static void loginuser(const char *, const char *);
static void proc_channels_input(Channel *, char *);
static void proc_channels_privmsg(Channel *, char *);
@@ -81,7 +82,7 @@ static void
usage(void)
{
fprintf(stderr, "usage: %s <-s host> [-i <irc dir>] "
- "[-n <nick>] [-k <password>] [-f <fullname>]\n", argv0);
+ "[-n <nick>] [-k <password>] [-x] [-f <fullname>]\n", argv0);
exit(1);
}
@@ -319,6 +320,14 @@ loginkey(const char *key)
ewritestr(msg);
}
+static void
+authsaslext()
+{
+ snprintf(msg, sizeof(msg), "CAP REQ :sasl\r\nCAP END\r\n"
+ "AUTHENTICATE EXTERNAL\r\nAUTHENTICATE +\r\n");
+ ewritestr(msg);
+}
+
static void
loginuser(const char *host, const char *fullname)
{
@@ -708,6 +717,7 @@ main(int argc, char *argv[])
Channel *c, *tmp;
struct passwd *spw;
const char *key = NULL, *fullname = NULL, *host = "";
+ int saslext = 0;
char prefix[PATH_MAX];
int r;
@@ -735,6 +745,9 @@ main(int argc, char *argv[])
case 's':
host = EARGF(usage());
break;
+ case 'x':
+ saslext = 1;
+ break;
default:
usage();
break;
@@ -761,6 +774,8 @@ main(int argc, char *argv[])
channelmaster = channel_add(""); /* master channel */
if (key)
loginkey(key);
+ else if (saslext)
+ authsaslext();
loginuser(host, fullname && *fullname ? fullname : nick);
setup();
run(host);