Welcome to http://www.marssoft.de/
Sunday, 28th February 2021 08:04:36 (GMT+1) 

SSH listening on non-std port

From http://hints.macworld.com/article.php?story=20050707140439980

You can easily just add an entry to /etc/services such as ssh2, pointing to a second port (or using an existing services entry that isn't being listened too), then modify the ssh.plist file to use that entry for SockServiceName. By doing so, sshd will only listen to that port, yet leaving ssh client activity unaffected. So, in my case, I added the following to /etc/services:

  ssh2              10022/udp 
  ssh2              10022/tcp

Next I modified my /System/Library/LaunchDaemons/ssh.plist, changing the SockServiceName lines from what's shown above to this:


By default, the /home directory on MacOS Snow Leopard is owned by the auto-mounter. Therefore, it is not possible to create a symlink to the real home there. Solution: disable the auto-mounter for /home:

sudo nano /etc/auto_master

#/home                  auto_home       -nobrowse,hidefromfinder

after a reboot, you can fix the /home symlinks

cd /home/
sudo ln -s ../Users/emmenlau ./emmenlau

Fix NFS mounts

If they are broken (i.e. your Data-disk is mounted at “/Volumes/Data 1”), then you can fix the mounts like that:

sudo mv /etc/fstab /etc/fstab.bak
sudo killall -HUP autofsd
sudo killall -HUP automountd
sudo rmdir /Volumes/Data/*
sudo rmdir /Volumes/Data

sudo diskutil list|grep " Data "
#   2:                  Apple_HFS Data                    292.7 Gi   disk0s2
sudo diskutil umount /dev/disk0s2
sleep 5
sudo diskutil mount /dev/disk0s2
sleep 5

sudo cp /etc/fstab.bak /etc/fstab
sudo killall -HUP autofsd
sudo killall -HUP automountd

NFS Mounts on Locally Mounted Disk

This is the new way of doing NFS mounts on my Leopard Mac:

cat /etc/fstab

# Mario Emmenlauer, 2009.07.29
# static NFS mounts
#    /Volumes/Data/builder   nfs     rw  0 0  /Volumes/Data/gaehwiler nfs     rw  0 0      /Volumes/Data/zhang     nfs     rw  0 0

cat /etc/auto_master

# Automounter master map
#/Volumes/Test          auto_test       -nobrowse
+auto_master            # Use directory service
/home                   auto_home       -nobrowse
/net                    -hosts          -nobrowse,nosuid
/Network/Servers        -fstab
/-                      -static

For testing, you can set the automounter to more verbose, by changing the file /etc/autofs.conf:

grep TRUE /etc/autofs.conf

# If TRUE, automount(8) will print more detailed
# If TRUE, automountd(8) will log to syslogd(8) more

NFS Mounts on Locally Mounted Disk (old style)

sudo mv /usr/libexec/autofsd /usr/libexec/autofsd.real
sudo touch /usr/libexec/autofsd
sudo chmod 755 /usr/libexec/autofsd
echo "#!/bin/sh" | sudo tee -a /usr/libexec/autofsd
echo ""          | sudo tee -a /usr/libexec/autofsd
echo "sleep 60"  | sudo tee -a /usr/libexec/autofsd
echo "exec /usr/libexec/autofsd.real \"$@\"" | sudo tee /usr/libexec/autofsd
sudo chmod 555 /usr/libexec/autofsd

Static Samba (CIFS) mounts

To get static mounts of network file systems, the file /etc/fstab can be used. Entries are per share on a server, and will appear via automounter at /Network/Servers/<server>/<share>/

sudo nano /etc/fstab
# Mario Emmenlauer
#   x   url  net,automounted,url==cifs://<user>:<url-enc-pass>@ 0 0

Then restart the automounter:

sudo launchctl stop com.apple.autofsd
sleep 5
sudo launchctl start com.apple.autofsd

Finally, verify that automounter is still running:

sudo launchctl list|grep auto
-       0       com.apple.backupd-auto
-       0       com.apple.automountd
27637   -       com.apple.autofsd

NFS exports and mounting

sudo nano /etc/exports

for emmenlau, gaehwiler or xuan do:

# NFS exports
/Volumes/Data/emmenlau          -maproot=emmenlau       -network -mask
sudo nfsd checkexports
sudo nfsd update
showmount -e
## If that is not sufficient, you can force the nfsd update with 
# sudo nfsd stop
# sudo nfsd start

You should get for the current local user name:

Exports list on localhost:
mount -tnfs /Volumes/Data/emmenlau

Finally, to mount the nfs folders from a remote computer, you can use “Directory Utility” (i.e. open /Applications/Utilities/Directory\ Utility.app). There you can set up nfs mounts. Use “Advanced Options”, then “Mounts”, then add an NFS mount (using “+” add the bottom).

Remote NFS URL:  nfs://
Mount Location:  /Volumes/Data/gaehwiler
Remote NFS URL:  nfs://
Mount Location:  /Volumes/Data/zhang

When you first set up NFS exports, the needed daemons portmap and mountd are most likely not running. Thus, when running 'showmount -e', it results in the error message

# RPC: Program not registered: Can't do Exports rpc

Check if the services are running. If not, either reboot, or start them by hand:

ps aux|grep "portmap\|mountd\|nfsd"|grep -v grep
sudo launchctl list|grep "portmap\|mountd\|nfsd"
# com.apple.portmap
sudo launchctl start com.apple.portmap
sudo /usr/sbin/mountd
sudo /sbin/nfsd -t -u -n 6

Afterwards, check that the exports are available:

showmount -e
# Exports list on localhost:
# /Volumes/Data/emmenlau    

Slickedit Debugging Mac64 Applications

Debugging a 64bit Mac Application with SlickEdit

Network with DHCP and static Address

Remote logins, the way I like them

Don't start terminal on X11 start

In Leopard, xterm is run directly by X11.app which causes the server to start. Think of X11.app as something that *just* executes xterm. If you want to change this from xterm to something else, you can change the application run by doiing the following:

defaults write org.x.X11 app_to_run <whatever you want to run>

So if you want nothing to run, you can accomplish this by:

defaults write org.x.X11 app_to_run /usr/bin/true

Enable/Disable Journaling on a (mounted) hfs+ Volume

To enable or disable journaling, do from the command line:

diskutil disableJournal /Volumes/<Volume>
diskutil enableJournal /Volumes/<Volume>

(of course you would only want to disable journaling to mount the disk from Linux, like this:

mount -thfsplus /dev/sda3 /Volumes/Leopard

For more details on mounting hfsplus on linux see http://www.mjmwired.net/kernel/Documentation/filesystems/hfsplus.txt

Show Dot files

defaults write com.apple.Finder AppleShowAllFiles YES
killall Finder 

The fork problem

First, lets see what the Mac limits are:

> sysctl -n kern.maxproc
> sysctl -n kern.maxprocperuid
> ulimit -u

Then lets crank them up:

> cat /etc/sysctl.conf
# set maximum number of concurrent processes

> sudo sysctl -w kern.maxproc=2048
kern.maxproc: 532 -> 2048
> sudo sysctl -w kern.maxprocperuid=1024
kern.maxprocperuid: 100 -> 1024

> grep "limit" ~/.bashrc
# crank up Mac process limit
ulimit -u 512

Getting Apache to Start

So you enable Web Sharing in the System Preferences, and nothing happens? Having a look at syslog shows errors in the modules? After a plain new install? *WTF*

com.apple.launchd[1] (org.apache.httpd[76235]) <Warning>: Exited with exit code: 1
com.apple.launchd[1] (org.apache.httpd) <Warning>: Throttling respawn: Will start in 10 seconds
org.apache.httpd[77007] <Notice>: httpd: Syntax error on line 116 of /private/etc/apache2/httpd.conf:
 Cannot load /usr/libexec/apache2/mod_dav_svn.so into server:
 dlopen(/usr/libexec/apache2/mod_dav_svn.so, 10): no suitable image found.
 Did find:\\n\\t/usr/libexec/apache2/mod_dav_svn.so: mach-o, but wrong architecture

Checking the modules indeed revealed that not all of them are built universal:

file /usr/libexec/apache2/*|grep "so:.*Mach-O "
/usr/libexec/apache2/mod_authz_host.so:      Mach-O universal binary with 4 architectures
/usr/libexec/apache2/mod_authz_owner.so:     Mach-O universal binary with 4 architectures
/usr/libexec/apache2/mod_authz_svn.so:       Mach-O bundle ppc
/usr/libexec/apache2/mod_authz_user.so:      Mach-O universal binary with 4 architectures
/usr/libexec/apache2/mod_content_filter.so:  Mach-O universal binary with 4 architectures
/usr/libexec/apache2/mod_dav.so:             Mach-O universal binary with 4 architectures
/usr/libexec/apache2/mod_dav_fs.so:          Mach-O universal binary with 4 architectures
/usr/libexec/apache2/mod_dav_svn.so:         Mach-O bundle ppc
/usr/libexec/apache2/mod_dbd.so:             Mach-O universal binary with 4 architectures
/usr/libexec/apache2/mod_deflate.so:         Mach-O universal binary with 4 architectures

You can workaround this issue by disabling the faulty modules (which means, no svn for me :-( )

sudo nano /etc/apache2/httpd.conf

#LoadModule dav_svn_module     libexec/apache2/mod_dav_svn.so
#LoadModule authz_svn_module   libexec/apache2/mod_authz_svn.so

And it works.

GTK+ on Mac OS 10.5 (Leopard)

wget http://people.imendio.com/richard/gtk-osx-build/gtk-osx-build-setup.sh
sh gtk-osx-build-setup.sh
nano ~/.jhbuildrc-custom
 # Mario Emmenlauer:
     checkoutroot = os.path.expanduser("~/usr/src/gtk")
     prefix = os.path.expanduser("~/usr/gtk")
 # Mario Emmenlauer:
 _root = os.path.expanduser("~/usr/src/gtk")
 _path = os.path.expanduser('~/usr/bin/install-check')
jhbuild bootstrap
jhbuild build meta-gtk-osx-bootstrap
jhbuild buildone glib
jhbuild buildone gtk+
jhbuild build

Later for updates do:

jhbuild update
jhbuild build

Trying to build pidgin:

sudo perl -pi -e 's/libpixman-' /usr/X11/lib/libpixman-1.la
# dont: cp -i $HOME/usr/src/gtk/gtk+/gdk/x11/gdkx.h $HOME/usr/gtk/include/gtk-2.0/gdk/

PATH=$HOME/usr/gtk/bin:$PATH ./configure \
    MSGFMT="$HOME/usr/gtk/bin/msgfmt" \
    LIBXML_CFLAGS="-I$HOME/usr/include -I$HOME/usr/include/libxml2" \
    LIBXML_LIBS="-L$HOME/usr/lib -lxml2" \
    --prefix="$HOME/usr" \
    --disable-dependency-tracking \
    --enable-gtkui \
    --without-x \
    --disable-startup-notification \
    --disable-gtkspell \
    --disable-gstreamer \
    --disable-meanwhile \
    --disable-avahi \
    --disable-dbus \
    --disable-nm \
    --enable-gnutls=yes \
    --with-gnutls-includes="$HOME/usr/include" \
    --with-gnutls-libs="$HOME/usr/lib" \
    --enable-nss=no \
    --disable-doxygen && \
make -j2

# safety net:

And it works!

Change User ID

Urgh, what an ugly thing to do!

sudo chpass emmenlau
sudo chown -R emmenlau /Volumes/Data/emmenlau /Users/emmenlau
sudo find / -user 501 -exec chown emmenlau {} \;

other possible hints/solutions:

dscl . -change /Users/rod UniqueID 501 3308
dscl . -change /Users/rod PrimaryGroupID 501 10
chown -R 3308:10 /Users/rod

find / -user 501 -print0 | xargs -0 chown -h martin
find / -group 501 -print0 | xargs -0 chgrp -h martin
guides/mac_setup.txt · Last modified: 2014/04/02 22:39 (external edit)