Quality words about quality software. Maybe.

A Lack of SelfControl

March 31, 2009

Just read a Wired piece about a new mac app called SelfControl. In a nutshell, it allows you to blacklist specific domains (and IPs) for a given time, allowing you to remove the distractions that keep you from your actual work (that’s the plan at least).

It’s a fun little app, with an interesting premise. While I was skimming its website this sentence caught my eye:

“Once started, it can not be undone by the application or by restarting the computer – you must wait for the timer to run out.”

Now, I see the reasoning behind not allowing the user to renege on his/her commitment to actually get work done, but there’s no way this little app was going to tell me what to do.

Ok, ok, I admit that’s a little over the top. The app isn’t meant to be fort Knox (it’s open source), and the developer’s goal was to make the casual user keep a promise to themselves. But at the same time, my interest was piqued. (From here on, some things get a bit technical. I encourage you to keep reading, but if you just want the solution you can skip down to the bottom. I won’t tell anyone.)

I looked around on Activity Monitor, but couldn’t find a daemon that was keeping me down. Dead end.

Very suspicious. As I had no idea what ipfw was at that point, I decided to investigate. A quick man revealed that ipfw was an “IP firewall and traffic shaper control program.” Bingo.

Salient points from the man file:

An ipfw configuration, or ruleset, is made of a list of rules numbered

from 1 to 65535. Packets are passed to ipfw from a number of different

places in the protocol stack (depending on the source and destination of

the packet, it is possible that ipfw is invoked multiple times on the

same packet). The packet passed to the firewall is compared against each

of the rules in the firewall ruleset. When a match is found, the action

corresponding to the matching rule is performed.

…

Rules can be added with the add command; deleted individually or in

groups with the delete command, and globally (except those in set 31)

with the flush command; displayed, optionally with the content of the

counters, using the show and list commands. Finally, counters can be

reset with the zero and resetlog commands.

Sounds easy enough. I added YCombinator.com (174.132.225.106) to my SelfControl blacklist, and pushed the start button. My attempt to reach YC returned the expected “Safari can’t connect to the server” message. Back in Terminal, I gave sudo ipfw list(list all current ipfw rules) a shot:

02500 count ip from any to any // BEGIN SELFCONTROL BLOCK

02501 deny ip from me to 174.132.225.106

02502 count ip from any to any // END SELFCONTROL BLOCK

65535 allow ip from any to any

Looks easy enough, especially since Mr. Lambert was able to comment the block of rules that SelfControl is using (which could be helpful if you’ve got more ipfw rules than I do). I tried entering sudo ipfw delete 2501, and again attempted to connect to YCombinator.com. Success!

But was there any way to remove all of the rules? I went back into the app, and dug around in the source code a bit. Again I quickly found what I was looking for (kudos to Mr. Lambert for the clear code):

For those not completely fluent in code, the above method is the one SelfControl uses to remove the access blocks. It basically removes a set (a group of rules) from the ipfw list. Specifically, it removes the set at the index kIPFirewallRuleSetNumber.

A quick check to see what kIPFirewallRuleSetNumber was set to (19) and I was ready to go.

Without further ado, I present the simple command to resume your time-wasting ways (Note: You must enter your administrator password when you’re asked for this to work):

sudo ipfw delete set 19

Yup, it’s that easy. There goes my productivity again.

UPDATE: Uh oh. As Charlie Stigler pointed out, there’s a problem with this approach. Turns out SelfControl will reactivate the ipfw blocking after a time. Petard pointed to a better solution, which is to find the SelfControl helper and remove it. The command is thensudo /Library/PrivilegedHelperTools/org.eyebeam.SelfControl `id -u` --remove
This resets the app quite nicely.

Advertisements

Like this:

I’m Charlie Stigler. I wrote SelfControl in collaboration with Steve. This was my first application I’ve ever wrote (I’m in high school) and it’s sort of fun to see my source in an article of semi-investigative journalism.

Come to think of it, maybe I should remove the ipfw comments–it might make it harder for the user to remove. I’m just worried then users might delete all their rules trying to get to the SelfControl ones.

What’s funny though is that in all of the comments I’ve seen, nobody has mentioned the easiest way to clear blocks… and I was afraid it would make the block useless.

@petard: Yes, that should do it. Yours is actually nice and elegant. I like buttons so my solution would just be to compile in a version with an extra button in the GUI and make it call the AppController’s “removeBlock” method, which is actually the exact opposite of the method that is called when your press the Start button. Plus, I mean, look at the comment in the header:

// Gets authorization for and then immediately removes the block by calling
// SelfControl’s helper tool with the appropriate arguments. This can be used
// for testing, but should not be called at all during normal execution of the
// program.

and the one at the start of the implementation:

// Remember not to use this method, it defeats the point of SelfControl!

I’m not sure if this defeats the purpose but it seems to me there’s a lot of us having the same problem. Could you post a “generic” fix in the app webpage ? I unfortunately decided to block my email and is causing me some problems, also I’m not a big fan of posting my email in any post but I guess I must in this case. I wrote you guys to the webpage contact form too but I still got no response.

I installed self control and activated it for 12 hours, for which it worked flawlessly at not letting me access my blacklist, however the next day, i still had no access to these sites. 2 days later, I still have no access.

I tried using both the commands above to remove the block, but no cigar.

“ERROR: Not enough block information.”

oh and I used appzapper on self-control hoping that would somehow fix it, but….

Sorry you’ve been having these issues! Trying to kill the block yourself is a bad solution, it’s very difficult to do manually unless you are a computer expert. Please give me your email address and I’ll send over our one-click SelfControl Killer.

Hey Charlie– I’ve also been having the same issue. When I began the program the timer showed 00:00:00, and it didn’t appear as if I actually added any sites to the Blacklist (though I attempted to add Facebook). I deleted the app, and 24 hours later, still can’t get on the sites.

I had the same 00:00 problem until now… I added another website to the blacklist and SelfControl finally played the block expiration sound and allowed me to navigate as usual… I hope this might help someone. 🙂

Please email me via my contact form! That’s the best way to handle this issue until it is eventually eradicated for good (I’m having a hard time reproducing it, which is why it still lives, but the numbers are going down).

Charlie: can you please email me the address to uninstall self control? the timer is frozen at 00:00 and it won’t let me view the blacklist or take websites off of it. now facebook is blocked permanently and i don’t know how to unblock it. my email is: thehoint@comcast.net
thanks!

I installed selfcontrol, wasn’t able to open a few webistes (even some not blocked in the first place) after the time expired, tried the fix in the FAQs (no success), tried to uninstall the app, and now am not even able to download it (the sever denies connection)! Help!!!!! Could you please send me the killer at dichiaras@yahoo.it? Thanks!