Thursday Night

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

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

7 comments

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

7 Responses to 'Fixing “percent_expand: NULL replacement” SSH bug on OS X Leopard'

Subscribe to comments with RSS or TrackBack to 'Fixing “percent_expand: NULL replacement” SSH bug on OS X Leopard'.

  1. Use the above instructions with the following configure command:

    ./configure –exec-prefix=/opt/local –prefix=/

    To overwrite broken MacPorts version

    vulgarisoip

    29 Oct 07 at 10:18 am

  2. An even quicker fix is to rename the ’scp’ and ’ssh’ binaries in /opt/local/bin, and symlink to the working Apple versions shipped with Leopard in /usr/bin.

    That way, programs like git that explicitly look for ssh in /opt/local/bin will continue to work.

    I’ll look at submitting a macports patch if nobody else has done so already.

    Steve

    29 Oct 07 at 5:02 pm

  3. Update: I’ve submitted a patch to MacPorts, so hopefully the issue will go away soon:

    http://trac.macosforge.org/projects/macports/ticket/13046

    Steve

    30 Oct 07 at 3:40 am

  4. @vulgarisoip: Even better – when I wrote this article, I thought it was the Apple ssh that was broken, so that’s a better fix

    @steve: I didn’t want to suggest that, because I didn’t know the differences between Apple’s ssh and MacPorts’ ssh. Thanks for submitting the patch though, good work!

    Paul Betts

    30 Oct 07 at 12:12 pm

  5. An even nicer solution can be found here:

    http://www.nabble.com/ssh:-percent_expand:-NULL-replacement-t4701144.html

    Worked like a charm for me.

    Travis Vachon

    2 Nov 07 at 8:55 pm

  6. thanks for your help. I was crazy with that. I used the link provided by Travis Vachon… Easier to test first and worked fine… so far enough for me. thanks.

    fablamenas

    10 Nov 07 at 9:48 am

  7. hiphapis의 생각…

    맥북..스스로 업데이트 몇번 하더니…… SSHê°€ 안된다.. 해결책은 찾았는데… 이 무슨 봉변이란 말이냐!…

Leave a Reply