Entries Tagged 'os x' ↓

Opting out of Omniture’s 192.168.112.2o7.net, the geeky way

I’ve been following the news on Daring Fireball about Omniture’s sneaky use of the 192.168.112.2o7.net domain name in phone-home functionality used by iTunes, Adobe CS3 apps and (presumably) others.

Mitcho.com notes that you can opt out of 2o7.net tracking, but only by setting a browser cookie, which won’t have any effect within apps such as iTunes and Photoshop CS3. That site suggests a third-party solution for preventing apps from connecting to Omniture’s servers. But there is a simpler (and free!) way, at least on OS X.

Like most Unix and Unix-like OSs, Mac OS X has a file that maps domain names to IP addresses, /etc/hosts. The OS looks in this file first when it needs to translate a domain name, before hitting your DNS server - so you can consider it a very crude highest-priority local DNS server. /etc/hosts is dead handy for assigning simple names to machines on your local network with static IP addresses. Mine currently looks like this:

##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1	localhost
255.255.255.255	broadcasthost
::1             localhost
fe80::1%lo0	localhost
10.0.0.11       imac
10.0.0.5        penguin
10.0.0.1	router

The format is simple:

<ip address> <domain_name> [<domain name> ...]

The essence of this trick is: we’re going to add a new domain name (192.168.112.2o7.net) that points to the localhost entry.

How to edit the hosts file is outside the scope of this article, but typically you’ll need to open a Terminal window and type:

$ sudo editor /etc/hosts

where editor is your text editor of choice. If you’ve never used a command-line text editor before and want something easy, use pico (sudo pico /etc/hosts). If you have TextMate and the mate shell command installed you can use that (sudo mate /etc/hosts). You should probably make a backup of /etc/hosts before you edit it, just in case - you can do that with:

$ sudo cp /etc/hosts /etc/hosts.backup

So I’ve changed my /etc/hosts file to resolve the domain name 192.168.112.2o7.net to 127.0.0.1 - the localhost “loopback” address, which always points to the local machine:

##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1        localhost 192.168.112.2o7.net
255.255.255.255  broadcasthost
::1              localhost
fe80::1%lo0      localhost
10.0.0.11        imac
10.0.0.5         penguin
10.0.0.1         router

Now when an app tries to phone home to 192.168.112.2o7.net, it’ll be connecting to the local host instead of Omniture’s server. This will typically result in an error response, which the app should silently ignore.

To confirm that the redirection works as expected, I saved my changes to /etc/hosts, opened a new Terminal window and used traceroute:

$ traceroute 192.168.112.2o7.net
traceroute to localhost (127.0.0.1), 64 hops max, 40 byte packets
 1  localhost (127.0.0.1)  0.387 ms  0.039 ms  0.032 ms

Problem solved!

Continue reading →

What’s your meaning, at?

A while ago I noticed that my home directory on my Macbook Pro wasn’t visible in the Finder. That is, if I opened a Finder window and browsed to /Users, there was no simon subdirectory, which was a bit odd. I could still browse to the stuff inside my home directory (Documents, Music, etc) using the shortcuts in the Finder’s left-hand panel, but my home directory itself was invisible.

Turning to the terminal, the first thing I discovered was an at symbol after the permissions string for my home directory:

$ ls -l /Users/
total 0
drwxrwxrwt   4 root   wheel   136  2 Nov 23:34 Shared
drwxr-xr-x@ 40 simon  staff  1360 23 Dec 12:05 simon

Hmm… that’s a bit weird. I couldn’t find any mention of a trailing @ in the ls manpage, and Google couldn’t help either. So my next step was to find out the hard way, by browsing Darwin’s source code. And here’s what I found, in print.c from the source for the ls command.

#ifdef __APPLE__

    // irrelevant stuff left out

    xattr = listxattr(filename, NULL, 0, XATTR_NOFOLLOW);
    if (xattr < 0)
        xattr = 0;
        str[1] = '\0';
    if (xattr > 0)
        str[0] = '@';
    else if (acl != NULL)
        str[0] = '+';
    else
        str[0] = ' ';
#endif /* __APPLE__ */

Note firstly that this stuff is in an #ifdef __APPLE__ block, which might explain why there’s no mention of it in the manpage, which appears to be the standard FreeBSD version. Anyway, according to this code, we’re appending an @ if the file has xattrs, or extended attributes.

Darwin has an xattr command that lists extended attributes for a given file, but it’s a bit cryptic:

$ xattr -l /Users/simon/
com.apple.FinderInfo:
0000   00 00 00 00 00 00 00 00 40 00 00 00 00 00 00 00    ........@.......
0010   00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................

Extended attributes are stored as key/value pairs, and in this instance the key is com.apple.FinderInfo, the value is the 32-byte blob that follows it. Presumably, byte 8 having a value of 0×40 means something to someone, but it doesn’t mean anything to me.

A regular Finder Info window doesn’t tell you much either, but fortunately Path Finder came up with the goods. Although my home directory doesn’t show up in Path Finder either, if I browse to, for example, my Music directory, again using the shortcuts in the left panel, I can then control-click on “simon” in the breadcrumb browse strip along the top of the main Path Finder window and choose Get Info, and Path Finder’s Info panel does show extended attributes. Attributes like this:

Path Finder Info panel

Invisible! Result!

No idea how that extended attribute ever got set, but that’s a different problem.

Update: MacFixIt has a good article on the invisible attribute, including how to set it at the command line.