HOWTO: Use IdentD with OSX Yosemite

If you’re an Internet Relay Chat (IRC) user like me, you’re probably familiar with or at least have heard of an identd service. IdentD is simply a service that, when accessed on port 113 of a computer, returns a simple string that identifies you as a user. If you were to watch the traffic you’d see something like this

1234,6578 : USERID : UNIX : itsmemario

Most OSX IRC clients don’t support this feature, and very few (if any) IRC servers require it any more. For those who needed this in the past, there was Identd for Mac. Which created a simple and functional icon in MacOS:

9939331-2

However in OSX Yosemite IdentD for Mac stopped working. The original author, Gallerand Sebastien, stepped up and made a new version. I’ve translated (as best as I could) his article and made a copy of his code here. So far it works great.

For those using the old IdentD

If you had previously installed identd, remove the old version:

# Clean Up !!!
sudo killall identd
sudo rm -R /Library/StartupItems/IdentD
sudo rm -R /Library/PreferencePanes/IdentD.prefPane
sudo rm -R /usr/local/identd

Now you’re ready to set up the new IdentD as a service.

Download, extract and set up IdentD

1- Download the file identd

2- Extract it to the desktop and you get a folder named identd.

Now the fun part.. installing stuff!

3- These commands will copy identd to the proper location and start it up

# Prepare
sudo mkdir -p /usr/local/identd
sudo chown root:wheel /usr/local/identd

# Install
cd ~/Desktop/identd/
sudo cp ./identd /usr/local/identd/
sudo cp ./identd.conf /usr/local/identd/
sudo cp ./org.macmax.identd.plist /Library/LaunchDaemons/
sudo chown root:wheel /usr/local/identd/identd
sudo chmod 755 /usr/local/identd/identd
sudo chown root:wheel /usr/local/identd/identd.conf
sudo chmod 644 /usr/local/identd/identd.conf
sudo chown root:wheel /Library/LaunchDaemons/org.macmax.identd.plist
sudo chmod 644 /Library/LaunchDaemons/org.macmax.identd.plist

# Load & Start
sudo launchctl load /Library/LaunchDaemons/org.macmax.identd.plist
# identd will start on boot up now.

4- Now test to see if identd is running

# Try :
ps aux | grep identd | grep root

# should report a process belonging to root
# root 1393   0.0  0.0   861896   7012   ??  Ss   Sat07PM   0:01.79 /usr/local/identd/identd

5- Now let’s send a test ident call to the service

# type this at your terminal prompt :
telnet codethought.com 113

Which should return something like this:

Trying ::1...
Connected to codethought.com.
Escape character is '^]'.
_

You can enter something like this:

# Type the following and press Enter :
1234,5678

If all went well you’ll be greeted with this response, and you’re good to go!

1234,5678 : USERID : UNIX : JohnDoe

Connection closed by foreign host.

Customizing the User name

Let’s say you want a name other than JohnDoe.. NO problem.. the following lines would take care of that nicely

# Change name to YourNameHere
sudo sh -c "echo 1:YourNameHere > /usr/local/identd/identd.conf"
sudo launchctl stop org.macmax.identd

And you’re done!

Download the file identd.zip

Link to original code and article at macmax.org (in French)

Scripts to select the default Java version on MacOS

Thanks to superuser.com I found a neat trick to make it easy to list your installed Java versions and switch between them. Just add these to your .bashrc file:

#
#
#
alias java_ls='/usr/libexec/java_home -V 2>&1 | grep -E "\d.\d.\d[,_]" | cut -d , -f 1 | colrm 1 4 | grep -v Home'

function java_use() {
    export JAVA_HOME=$(/usr/libexec/java_home -v $1)
    export PATH=$JAVA_HOME/bin:$PATH
    java -version
}

The java_ls command reduces the output of java_home -V to just return the version numbers and java_use is just a shortcut for the exports and path updates you’d normally use.

Ruby 1.9, TextMate and Segmentation fault errors

While tinkering with Ruby 1.9 in TextMate I found that Ruby was segfaulting on the TextMate Ruby Bundle output screen.

/Users/codethought/Applications/TextMate.app/Contents/SharedSupport/Bundles/Ruby.tmbundle/Support/RubyMate/catch_exception.rb:16: [BUG] Segmentation fault
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin11.4.0]

Turns out you can fix the error yourself… as I found at rubyflow.com

http://www.rubyflow.com/items/6795-solution-to-ruby-1-9-3-segfaulting-when-using-textmate-ruby-b

To quote here:

Edit the catch_exception.rb file in your Ruby bundle in TextMate. To get into it on my machine I had to do:

mate Applications/TextMate.app/Contents/SharedSupport/Bundles/Ruby.tmbundle/Support/RubyMate/catch_exception.rb

Then, comment out the require “cgi” line. And then remove all references to CGI::escapeHTML.

But a simpler way is to go is to download the change that someone else made from github and install it yourself.

https://gist.github.com/1354592

And put the new version catch_exception.rb in the following directory yourself:

Applications/TextMate.app/Contents/SharedSupport/Bundles/Ruby.tmbundle/Support/RubyMate/

And your problem will be resolved.

I’m writing this with tears on my eyes !!!

Does that title sound familiar? My wife and I got an email this morning from my father that read as follows:

Subject: I’m writing this with tears on my eyes !!!

Hello,

I’m sorry for this odd request and I’m writing this with tears on my eyes due to the situation of things right now, I’m stuck in London United Kingdom with my family,we came down here for vacation and we got Mugged at gunpoint, worse of it is cash cell phone and credit cards were stolen , it’s such a crazy and terrifying experience for us, we need help sort out our hotel bill and flying back home, the authorities are not being 100% helping us, but we thanks God we still have our passports, Our return flight leave today,But we still have problem in sorting out the hotel bills.Please help us i promise to refund it back.

Now I’m freaked out.

David.

There were two problems with this email:

  1. My father doesn’t write like he barely understands english. In fact he’s one of the most eloquent writers I have ever known and is a native speaker of the Queen’s English.
  2. My father lives 12 miles away and has no travel plans

Turns out this is happening to a surprising number of people. It’s a growingly common scam. It’s also happened to a friend of mine. Apparently there is a keystroke-logging trojan that’s in the wild. Virus scanners like F-Prot, and current Mal-ware scanners are not detecting it and it’s causing a lot of havoc:

  1. http://articles.cnn.com/2010-03-28/opinion/greene.email.scam_1_e-mail-first-byline-subject-line
  2. http://community.ca.com/blogs/securityadvisor/archive/2010/04/15/beware-of-scam-emails-i-m-writing-this-with-tears-in-my-eyes.aspx
  3. Google Support

If you see an email like this from any of your friends… CALL THEM before you decide to try to send money to them. Also, if you get an email like this from your friends, tell them to UNPLUG THEIR COMPUTER from the internet.. erase it completely and RE-install windows.

You could also tell them that perhaps they should consider buying a Mac… Because in 4 years of owning and using them I have yet to have them compromised by trash like this.

Open Terminal Here in Snow Leopard using Automator

A subject that has been visited plenty of times is having an “Open Terminal Here” ability from the Finder. For developers, it’s a easy way to look at files or folders and then jump quickly to a shell for the folder and execute shell commands (like mv or cp). Or to execute a build using make or ant.

I decided to make a version of that would work off the “Services” context menu. If you control-click a file and select Services | Open Terminal Here you’ll be taken to the folder containing that file. A control-click on a folder will take you to the folder you selected.

To use it, just unzip this file and put it in your ~/Library/Services folder.

Open Terminal Here.zip

The code itself is pretty straightforward:

(* 
   Workflow - Open Terminal Here 
   By David Orriss Jr - November 2010
   Another "Open Terminal Here" option.  This time as a service workflow in Automator

   For Snow Leopard
*)
on run {input, parameters}
	
	set the_path to (the POSIX path of input)
	
	set AppleScript's text item delimiters to "/"
	
	
	if the_path does not end with "/" then
		set parentPath to (items 1 thru -2 of text items of the_path) as string
		set the_path to parentPath
	end if
	
	set cmd to "cd " & quoted form of the_path & " && echo $'\ec'"
	
	tell application "System Events" to set terminalIsRunning to exists application process "Terminal"
	
	tell application "Terminal"
		activate
		if terminalIsRunning is true then
			do script with command cmd
		else
			do script with command cmd in window 1
		end if
	end tell
end run