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.
- Download the latest OpenSSH and untar it to the desktop (Link)
- Go into this directory and open up “ssh.c”
- 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)); - Open up the terminal, and run the following commands:
cd ~/Desktop/openssh-4.7p1
./configure –exec-prefix=/usr/local –prefix=/
make
sudo make install
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
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
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
@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
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
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
hiphapisì˜ ìƒê°…
ë§¥ë¶..스스로 ì—…ë°ì´íЏ 몇번 하ë”니…… SSHê°€ 안ëœë‹¤.. í•´ê²°ì±…ì€ ì°¾ì•˜ëŠ”ë°… ì´ ë¬´ìŠ¨ 봉변ì´ëž€ ë§ì´ëƒ!…
hiphapis' me2DAY
7 Oct 08 at 8:23 pm