views:

908

answers:

3

I'm trying to (cross-)compile obfuscated-openssh for the iPhone, and I'm running into some problems. I'm using this to configure the build:

./configure --host=arm-apple-darwin CC=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/arm-apple-darwin9-gcc-4.0.1 \
CFLAGS="-arch armv6 -pipe -std=c99 -I/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.0.sdk/usr/include \
-L/Users/ben/iphonelib -Wno-trigraphs -fpascal-strings -fasm-blocks -O0 -Wreturn-type \
-Wunused-variable -fmessage-length=0 -fvisibility=hidden \
-miphoneos-version-min=2.0 -gdwarf-2 -mthumb \
-isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.0.sdk" \
CPP=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/cpp \
AR=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/ar

This doesn't work, though, complaining about not being able to find many header files, including netinet/in_systm.h and openssl/bn.h. Does anyone have any ideas as to how to make the build finish?

+7  A: 

in_systm.h isn't available on iPhone. It only defines a few types, and the other pieces it includes are available. So you may be able to just copy the Mac version of the header into the build tree and point to it. ("locate in_systm.h" is a good way to find these kinds of things.)

You may very well run into many more problems like this, but that's how to address in_systm.h.

Rob Napier
I suppose this might work, but there are in fact many header files missing, and I'm looking for a clean way to resolve all of the problems at once.
Ben Alpert
You are unlikely to find a one step solution in general. Not all OSX APIs are available on iPhone. Porting a complex framework to the iPhone is often difficult (though generally possible). Your best bet is to search for "openssh iphone" and see how others have attacked the problem before. Most of the work has been in creating servers (which generally means jailbreaking the phone). I assume you're making a client in this case? The underlying porting issues should be similar, however. But I can't promise there's any "set this flag and it will work" solution. For code like openssh, it's unlikely.
Rob Napier
I did extensive Googling, but was unable to find configuration options that others have used. (And you're right, I'm attempting to compile the client.)
Ben Alpert
I'm suggesting that you look at how the Gus who portted the server did it and use that as the basis of your work, since the client and server sides will likely have similar code, and particular have to work around the same missing network functions. I am not suggesting you will find a simple set of config options that will make it work. Much of the work will look like my original answer: look at what the code is using, find it for Mac, and see if it's something you can bring over. may take several days to work it all out, but you'll learn a lot. Good luck, and post your success for others.
Rob Napier
Which Gus is this? I can't find him.
Ben Alpert
"Gus" was iPhone helping me spell "guys." There is no Gus. Just google for people who have ported the server to iPhone and follow their lead.
Rob Napier
+1  A: 

Openssh depends on the openssl libraries. You'll probably need to build that first.

I recently had to add ssh support to an embedded system and used Dropbear. It was a lot easier to get up and running than openssh. It gave us scp, ssh, and sshd support with a 300k executable. Supposedly, for ssh only you can get it down to ~110K.

Devon_C_Miller
+1  A: 

There's a repository available with Cydia (and with apt) where OpenSSH is available: Telesphoreo. know the team ported OpenSSH server, which means they've modified source code in order to make it compile on the target platform.

o_O Tync