Turning off NFS daemons in Mac OSX

(If you’ll ask me, I’ll deny writing down these things to remember them later, but it’s the real reason behind this. I searched in Google for an extended answer, but couldn’t find it)

I’m running 10.4.7 (other releases may be different) and I very rarely use NFS, so I don’t see any real reason to have stuff I don’t use running on my machine – moreover, with listening ports. Yes, I know ipfw blocks them, but I prefer them closed.

Short and slightly wrong answer: change

NFSLOCKS=-AUTOMATIC-
RPCSERVER=-AUTOMATIC-

to

NFSLOCKS=-NO-
RPCSERVER=-NO-

in /etc/hostconfig. This will get rid of rpc.statd,rpc.lockd, and portmapper on boot, but leaves you with many other things running (nfsd-server, mountd, nfsiod). I assume that you already got rid of automounter setting

AUTOMOUNT=-NO-

in the usual place.

Boring answer: I was hoping that I could add/modify another variable to hostconfig to disable NFS completely. If it exists, I couldn’t figure it out.
Let’s see how the system initalizes NFS: [my comments between brackets]

roadrunner:/System/Library/StartupItems/NFS root# sh -x ./NFS start
+ . /etc/rc.common

[ sources common functions and variables ]

++ set -u
++ PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/libexec:/System/Library/CoreServices
++ export PATH
++ . /etc/hostconfig

[ reads system configuration, things like: ]

+++ HOSTNAME=-AUTOMATIC-

[ and so on. then it starts ]

+ AUTOMOUNTDIR=/private/var/automount
+ RunService start
+ StartService
+ CheckForNetwork
+ local test
+ ‘[‘ -z ” ‘]’
++ ifconfig -a inet
++ sed -n -e /127.0.0.1/d -e /0.0.0.0/d -e /inet/p
++ wc -l
+ test= 1
+ ‘[‘ ‘ 1’ -gt 0 ‘]’
+ NETWORKUP=-YES-
+ ‘[‘ -YES- = -NO- ‘]’
+ lockfile -r 0 /var/run/NFS.StartupItem

[ file locking is to prevent starting up multiple instances, I suppose ]

+ echo ‘Starting network file system’
Starting network file system
+ ‘[‘ -d /private/var/automount ‘]’
+ nfsiod -n 4
++ niutil -list . /exports

[ asks NetInfo about the exported file systems… ]

++ wc -w
+ exports_ni= 2
++ grep -v ‘^[[:space:]]*\(#\|$\)’ /etc/exports

[ … and looks for the good ol’ file too! … ]

++ wc -l
+ exports_etc= 0
+ exports=2
+ ‘[‘ 2 -gt 0 ‘]’
+ ‘[‘ -AUTOMATIC- = -AUTOMATIC- ‘]’
+ NFSLOCKS=-YES-
+ ‘[‘ -YES- = -YES- ‘]’
+ rpc.statd
+ rpc.lockd
+ ‘[‘ -YES- = -AUTOMATIC- ‘]’
+ rm -f /var/db/mountdtab
+ ‘[‘ 2 -gt 0 ‘]’
+ echo ‘Starting Network File System server’
Starting Network File System server
+ mountd
++ niutil -readprop . /config/nfsd arguments
niutil: can’t open directory /config/nfsd: No such directory
+ arguments=
+ ‘[‘ ” = ” ‘]’
+ arguments=-t -u -n 6
+ nfsd -t -u -n 6
+ ‘[‘ -NO- = -YES- ‘]’
+ touch /var/run/automount.initialized

As you can see, I couldn’t find any hostconfig variables to avoid all the daemons to start. Moreover, hoping to stop everything using the “stop” argument yelds to no results: it runs the StopService() which is

StopService ()
{
return 0
}

quite useful, isn’t it? :)

I have decided for the simplest (to me) solution. Add a

return 0

at the very beginning of StartService(). This will make the script exit as soon as possible without impacting on anything else. The con is that you’ll lose that change when you’ll upgrade if Apple decides to modify the script. But you can always post the how and where on your blog and recover it at the right moment. :)

If you’re trying to harden your OsX machine, have a look at Bastille, which it seems runs (sort of) on Macs too.

Keepalive

Still not dead.
Hung into python and its available modules, trying to glue together something that amuses me.
Late night coding session with TextMate and Children of Bodom “Hate Crew DeathRoll”.
Maybe I’ll start writing good code and listening to “good” music the same day.

Literal conversation with a friend in jabber:

he: Can you have a look at [a thing]?
me: Sorry dude, I’m coding
me: :)
he: WHAT?
he: you?

me: writing code, you know? Getting a funny language to make the things you want
he: you?
me: [explaining that I’m actually able to do some of the things that usually I don’t do, and that I don’t have an army of coders waiting for my input]

:D

I’m back

Home from the trip to San Francisco and Silicon Valley: still 9 hours out of phase, with 20 hours spent between flights and airports.
Still too tired to cook me some pasta.
This is a summary on Flickr.

Would I live there? Don’t think so. Would I stay there for 6 months? Definitely yes.

Qumana

Soon I’ll be wandering California for some week, and I thought it would have been nice to be able to write down some notes to post later.
I could have used the faithful SubEthaEdit or TextWrangler (both excellent products) but I decided to look for something more… easy (yes, I’m getting lazier than ever, if possible), which could preserve timestamps, categories, etc. and push all the content online in the (short?) moments I’ll be connected to the Internet.

I’ve been testing Ecto (which is a great client, btw), but I don’t feel like I’m going to pay for it ($17.95), so I went searching for something free and good enough for what I needed — some text editing, choosing timestamp and post categories, good xml-rpc communication with WordPress.

Well, I did find Qumana: it has all of the above, plus real time spelling, wysiwyg/source editing, a smart way to create hrefs (it prefills the link content with the clipboard content), can ping and understands trackbacks.
Easy as a pie, even if I’m on 3.0beta3 for Mac.

The only drawback (if this post ever reaches the Internet, I mean) is that it’s written using Java, which makes it a bit sluggish. Go test it, it’s for Windows too.

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close