Archive for March, 2008

Querying hosts with DirectoryService

Sunday, March 23rd, 2008

So as host, ping, nslookup, dig etc don’t use the same resolver path as the rest of the OS, we used to always use lookupd for this.

It’s not exactly the most obvious solution in the world, but since lookupd, netinfod and memberd were all rolled into DirectoryService in 10.5, we now use dscacheutil to do this.


$ dscacheutil -q host -a name www.google.com
name: www.l.google.com
alias: www.google.com
ip_address: 74.125.19.104
ip_address: 74.125.19.147
ip_address: 74.125.19.99
ip_address: 74.125.19.103

This is a much more appropriate way of debugging host problems if the *nix tools aren’t showing any problems but OS X components are.

This will fetch the result from the cache, and if it’s not there, fetch it and place it in the cache. If you want to make sure this is a fresh request, do:

dscacheutil -flushcache

and you can always do this:

dscacheutil -cachedump -entries host

to inspect the cache for hosts.

I was actually debugging a Mobile Account problem the other day where the user agreed to create a mobile account at the loginwindow, and yet it kept logging them in with the network account.

Inspecting the DirectoryService cache with:

dscacheutil -cachedump -entries user

showed that the /Local/Default entry for that user was never retrieved. Flushing the cache fixed it.

Turns out the user said no to creating a Mobile Account once, and then logged out without rebooting (and didn’t tell us they’d said no ;-) ). OS X kept the cached entry around and failed to update when creating the Mobile Account as it should have.

Need to get that one into radar….

MacPort issue when using patch…

Sunday, March 23rd, 2008

After spending a little while banging my head against the wall over this one….

root@snicko [ ~ ]
# port install git-core +svn +bash_completion
---> Applying patches to perl5.8
Error: Target org.macports.patch returned: shell command " cd "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_lang_perl5.8/work/perl-5.8.8" && patch -p0 < '/opt/local/var/macports/sources/rsync.macports.org/release/ports/lang/perl5.8/files/patch-makedepend.SH'" returned error 2
Command output: Get file makedepend.SH from Perforce with lock? [y]
Perforce client error:
Connect to server failed; check $P4PORT.
TCP connect to perforce failed.
perforce: host unknown.
patch: **** Can't get file makedepend.SH from Perforce

Error: The following dependencies failed to build: p5-error perl5.8 p5-libwww-perl p5-compress-zlib p5-compress-raw-zlib p5-io-compress-base p5-scalar-list-utils p5-io-compress-zlib p5-html-parser p5-html-tagset p5-uri p5-svn-simple subversion-perlbindings apr apr-util db44 sqlite3 gawk gmake readline neon subversion bash-completion p5-term-readkey rsync popt
Error: Status 1 encountered during processing.

I finally found Jack Palevich's post talking about exporting the POSIXLY_CORRECT environment variable as follows.


POSIXLY_CORRECT=1 port install git-core +svn +bash_completion

Of course now I’ve run into an issue with tcl…. *sigh*, but I’ve seen the patch issue above crop up a few times, and this certainly seems to be fixing it.

It’s bad enough that MacPorts and Fink can’t depend upon Apple to provide sane libraries and headers in OS X, and thus you end up with most of another whole freaking operating system in /opt/local or /sw, but I simply refuse to have both installed, no matter how frustrating it is that I can’t get all the software I need working via just one of them.