Chapter 26. Banning Users

The LiveJournalsysban” mechanism provides the means for generic bans on site functionality given a block type and value. The type is what is being checked (IP address, e-mail address, etc.), and the value is the value which causes the block to activate (10.0.0.10, for example).

The $LJHOME/bin/ljsysban.pl tool lets you create and modify bans, and list existing ones.

There are two statushistory types tied to the sysban tool:

sysban_add
Logs the creation of new bans
sysban_mod
Logs the modification of bans

The data each type logs varies depending on the type of ban and the information available when it was triggered. If a userid is available, it will be logged and the notes column will contain a short description of what caused the trigger along with a number of variables that may be useful in investigation of the situation.

Below are the current ban types. More can be added as necessary.

General

ip

Blocked from site if IP address matches.

e-mail

Blocked if e-mail matches. Return a fake “503 Service Unavailable” message to a user who tries to create a new account with the given e-mail address.

uniq

Blocked if value of unique cookie (from /admin/userlog.bml) matches.

contentflag

Blocked if value (username) matches.

Ban management tool usage: 

ljsysban.pl [ --list {(1) args} | add {(2) args} | modify {(3) args} ]

(1) --banid=id | --what=bantype | --status=value | --bandate=datetime | --banuntil=datetime | --value=value | --note=string

(2) { --what=bantype | --value=value } | --status=value | --bandate=datetime | { --banuntil=datetime | --banlength=duration } | --note=string

(3) --banid=id | --status=value | --bandate=datetime | { --banuntil=datetime | --banlength=duration } | --value=value | --note=string

Datetime format is “YYYY-MM-DD HH:MM:SS”.
The note string can be changed to be blank.
Status can be “active” or “expired”.
Duration format is “N[dhms]” e.g. “5d” or “3h”.

Example 26.1. Using ljsysban.pl

ljsysban.pl --list --what=ip --value=127.0.0.1

ljsysban.pl --add --what=email --value=test@example.com --banuntil='2007-12-12 00:05:00' --note='test'

ljsysban.pl --add --what=uniq --value=jd57kdnes6jd6jdr --banlength=3d --note='3 day ban'