Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GanneffServ: make it possible to not kill irccloud #50

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

jsoref
Copy link
Contributor

@jsoref jsoref commented Nov 15, 2021

Without this, anyone using irccloud (or a similar service) can get all other users k:lined
by tripping on a trap (J).

Goal: they should be treated like a tor user (getting themselves killed).


Background: I'm an irccloud user, and today someone managed to trip on a J trap which got my connection to oftc k:lined.

@dwfreed said that we could add some sort of pattern/mask support to enable users like me not to suffer when other irccloud users do harmless stupid things.

Implementation:

  1. This adds an extra sql table (I'm not an expert in any of this -- SQL, Ruby, Services, IRCD, so obviously my code should be carefully reviewed)
  2. This adds two commands PROTECT and UNPROTECT -- I'm not attached to the command names (or anything else really). Both take irc masks or regular expressions (the former being converted into the latter).
  3. Some extra state variables are added, and when a akill is called, after checking if the user is on tor, the code tries to check to see if the host would match a protected pattern -- if so, the kill is downgraded to the user just as for tor users.

modules/GanneffServ.rb Outdated Show resolved Hide resolved
modules/GanneffServ.rb Outdated Show resolved Hide resolved
@jsoref jsoref force-pushed the akill-downgrade-clusters branch 2 times, most recently from 01f5a1c to 08ed923 Compare November 15, 2021 00:46
Without this, anyone using irccloud (or a similar service) can get all other users k:lined
by tripping on a trap (J).

With this, they should be treated like a tor user (getting themselves killed).
@@ -326,7 +391,7 @@ def BADSERV(client, parv = [])
debug(LOG_DEBUG, "#{client.name} called BADSERV and the parms are #{parv.join(",")}")
server = parv[1].downcase

if server =~ /.*\.oftc.net$/
if server =~ /.*\.oftc\.net$/
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is unrelated, but included because I was thinking about regular expressions while working on this file. It's an outlier in this file, everything else included the \.

sql/ganneffserv-pgsql.sql Outdated Show resolved Hide resolved
Add a unique index so Postgres will enforce unique constraints

Co-authored-by: Doug Freed <[email protected]>
@jsoref jsoref changed the title Akill downgrade clusters GanneffServ: make it possible to not kill irccloud Nov 15, 2021
ret = akill_add("*@#{host}", reason, @akill_duration)
if client.host =~ /#{@protected_patterns}/i # if protected hosts
debug(LOG_DEBUG, "Using /kill instead of AKILL for protected user #{client.name}")
ret = kill_user(client, reason)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This leaks the oper reason; kills don't hide oper reasons like akills do; easy fix is to just put this section as a branch in the enclosing if

pattern = irc_pattern_to_regex(requested_pattern)
reason = parv[2]

ret = DB.execute_nonquery(@dbq['INSERT_PROTECT'], 'iiss', client.nick.account_id,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put the original pattern in the DB, rather than the regex. This is important for the listing later, as looking at IRC masks is nicer than regexes, unless we've specifically given a regex.

@dbq['DELETE_PROTECT'] = DB.prepare('DELETE FROM ganneffprotect WHERE
irc_lower(pattern) = irc_lower($1)')
@dbq['GET_PROTECTED_PATTERNS'] = DB.prepare('SELECT pattern, reason FROM ganneffprotect')
@dbq['GET_PROTECTED_PATTERNS_DETAILED'] = DB.prepare('SELECT pattern, setter, time,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

setter here will be an ID, not a name. Look at GET_ALL_CHANNELS for a simple way to get the primary nick of the setting account.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants