irctk

libircclient binding for scripts
git clone https://a3nm.net/git/irctk/
Log | Files | Refs | README

commit d87fc7da084ec3972424360d6872cc125b977864
parent a2eae69c36a497e1ebcae4caa4a4806cc64f7edd
Author: Antoine Amarilli <a3nm@a3nm.net>
Date:   Wed, 14 Nov 2012 17:51:07 +0100

do not try to join user channels (thanks louis)

Diffstat:
README | 5++++-
irctk.c | 8+++++---
test/track.sh | 2++
tests_sequential.sh | 3++-
4 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/README b/README @@ -191,7 +191,10 @@ irctk will always try to join a channel before saying something to this channel. This means that it can join entirely new channels in this fashion. To disable this behavior and prevent irctk from joining any channels except the ones given at startup, use --no-join (can be useful if irctk's stdin is -attacker-controlled). +attacker-controlled). Note that this only affects the behavior of irctk on +regular channels: even with --no-join, irctk will be able to send private +messages to anyone. If this is undesirable, you will have to prevent it +yourself. irctk will interpret some commands starting with '/' in a fashion similar to irssi. To inhibit this (can be useful if irctk's stdin is attacker-controlled), diff --git a/irctk.c b/irctk.c @@ -988,7 +988,7 @@ char* consume_word(char **from) int do_me(irc_session_t *s, char *chan, char *password, char *line) { /* TODO2 only join channels we haven't joined yet */ - if (args.join) + if (args.join && chan[0] == '#') irc_cmd_join(s, chan, password); if (args.own) { if (args.event_to == COMMAND) @@ -1010,7 +1010,7 @@ int do_me(irc_session_t *s, char *chan, char *password, char *line) { int do_say(irc_session_t *s, char *chan, char *password, char *line) { /* TODO2 only join channels we haven't joined yet */ - if (args.join) + if (args.join && chan[0] == '#') irc_cmd_join(s, chan, password); if (args.own) { mprintf("[%s] <%s%s> %s", chan, @@ -1129,7 +1129,7 @@ int do_cmd_msg(irc_session_t *s, char *chan, char* line) // with correct user tracking! } else { /* TODO2 only join channels we haven't joined yet */ - if (args.join) { + if (args.join && chan[0] == '#') { rsl = irc_cmd_join(s, chan, password); } @@ -1480,6 +1480,8 @@ void event_connect (irc_session_t *session, const char *event, const char *origi debug("Connected!\n"); for (i = 0; i < ctx->n_channels; i++) { + if (ctx->channels[i][0] != '#') + continue; // not a regular channel debug("Attempt to join %s\n", ctx->channels[i]); int pw_pos = get_password(ctx->channels[i]); irc_cmd_join (session, ctx->channels[i], ctx->channels[i] + pw_pos + 1); diff --git a/test/track.sh b/test/track.sh @@ -2,6 +2,8 @@ trap "kill 0" SIGINT SIGTERM EXIT +set -x + mkdir -p track cd track mkfifo fifo 2>/dev/null diff --git a/tests_sequential.sh b/tests_sequential.sh @@ -1,11 +1,12 @@ #!/bin/bash +set -x cd test for t in *.sh do echo -n "$t... " #./$t || { echo "FAILED!"; exit 1; } - ./$t || echo "FAILED!" + setsid ./$t || echo "FAILED!" echo "passed." done