Thursday Night

Paul Betts’s personal website / blog / what-have-you

Fixing “percent_expand: NULL replacement” SSH bug on OS X Leopard

Apple decided to fix up some of their UNIX functions to operate more like the standard, but they didn’t test very thoroughly because they broke the SSH client Update: Actually, this is a problem with MacPorts, Apple’s SSH still works (if you see “percent_expand: NULL replacement”, you’ve hit the bug). They’ll probably fix this, but if you need a quicker solution, here it is.

  1. Download the latest OpenSSH and untar it to the desktop (Link)
  2. Go into this directory and open up “ssh.c”
  3. Make the following patch near line 1252 (Leave out the ‘+’):
    #endif /* SMARTCARD */
           if ((pw = getpwuid(original_real_uid)) == NULL)
                   fatal("load_public_identity_files: getpwuid failed");
    +        pw = pwcopy(pw);
           if (gethostname(thishost, sizeof(thishost)) == -1)
                   fatal("load_public_identity_files: gethostname: %s",
                       strerror(errno));

  4. Open up the terminal, and run the following commands:
    cd ~/Desktop/openssh-4.7p1
    ./configure –exec-prefix=/usr/local  –prefix=/
    make
    sudo make install

Written by Paul Betts

October 27th, 2007 at 8:25 pm

Posted in Apple