1
0
mirror of https://github.com/moparisthebest/socat synced 2024-11-10 19:15:03 -05:00

port to Android

This commit is contained in:
Gerhard Rieger 2011-11-22 10:58:15 +01:00
parent 0b472d59d2
commit 26801266f2
11 changed files with 84 additions and 0 deletions

View File

@ -53,6 +53,10 @@ corrections:
Fixed by providing temporary DH parameters. Thanks to Philip Rowlands
for drawing my attention to this issue.
porting:
Cedril Priscal ported socat to Android (using Googles cross compiler).
The port includes the socat_buildscript_for_android.sh script
####################### V 1.7.1.3:
security:

View File

@ -477,6 +477,10 @@
/* Define if you have the /proc/$$/fd directories */
#undef HAVE_PROC_DIR_FD
#undef HAVE_SETGRENT
#undef HAVE_GETGRENT
#undef HAVE_ENDGRENT
#undef WITH_HELP
#undef WITH_STDIO
#undef WITH_FDNUM

View File

@ -80,6 +80,8 @@ AC_CHECK_HEADERS(sys/utsname.h sys/select.h sys/file.h)
AC_CHECK_HEADERS(util.h libutil.h sys/stropts.h regex.h)
AC_CHECK_HEADERS(linux/fs.h linux/ext2_fs.h)
dnl Checks for setgrent, getgrent and endgrent.
AC_CHECK_FUNCS(setgrent getgrent endgrent)
dnl Link libresolv if necessary (for Mac OS X)
AC_SEARCH_LIBS([res_9_init], [resolv])

View File

@ -0,0 +1,56 @@
#!/bin/sh
# Customize these parameters according to your environment
ANDROID_NDK="${HOME}/bin/android-ndk-r6b"
# Check for parameters
if [ ! -d "${ANDROID_NDK}" ]; then
echo "Android NDK not found in ${ANDROID_NDK}, please edit $0 to fix it."
exit 1
fi
if [ ! -e "${ANDROID_NDK}/build/tools/make-standalone-toolchain.sh" ]; then
echo "Your Android NDK is not compatible (make-standalone-toolchain.sh not found)."
echo "Android NDK r6b is known to work."
exit 1
fi
# Extract the Android toolchain from NDK
ANDROID_PLATFORM="android-3"
ROOT="`pwd`"
OUT="${ROOT}/out"
${ANDROID_NDK}/build/tools/make-standalone-toolchain.sh \
--ndk-dir="${ANDROID_NDK}" \
--platform="${ANDROID_PLATFORM}" \
--install-dir="${OUT}/toolchain" \
|| exit 1
# Remove resolv.h because it is quite unusable as is
rm ${OUT}/toolchain/sysroot/usr/include/resolv.h
# Create configure script
cd ${ROOT}
autoconf || exit 1
# Create config.h and Makefile
cd ${OUT}
${ROOT}/configure \
--host \
--disable-openssl \
--disable-unix \
CC="${OUT}/toolchain/bin/arm-linux-androideabi-gcc" \
|| exit 1
# Replace misconfigured values in config.h
mv config.h config.old
cat config.old \
| sed 's/CRDLY_SHIFT/CRDLY_SHIFT 9/' \
| sed 's/TABDLY_SHIFT/TABDLY_SHIFT 11/' \
| sed 's/CSIZE_SHIFT/CSIZE_SHIFT 4/' \
> config.h
# Compile
make socat || exit 1
# Done
echo "Build finished, socat has been generated successfuly in out/socat"

View File

@ -412,6 +412,7 @@ char *sockaddr_inet6_info(const struct sockaddr_in6 *sa, char *buff, size_t blen
}
#endif /* WITH_IP6 */
#if defined(HAVE_SETGRENT) && defined(HAVE_GETGRENT) && defined(HAVE_ENDGRENT)
/* fill the list with the supplementary group ids of user.
caller passes size of list in ngroups, function returns number of groups in
ngroups.
@ -438,6 +439,7 @@ int getusergroups(const char *user, gid_t *list, size_t *ngroups) {
*ngroups = i;
return 0;
}
#endif
#if !HAVE_HSTRERROR
const char *hstrerror(int err) {

View File

@ -73,7 +73,9 @@ extern const char *inet_ntop(int pf, const void *binaddr,
char *addrtext, socklen_t textlen);
#endif
#if defined(HAVE_SETGRENT) && defined(HAVE_GETGRENT) && defined(HAVE_ENDGRENT)
extern int getusergroups(const char *user, gid_t *list, size_t *ngroups);
#endif
#if !HAVE_HSTRERROR
extern const char *hstrerror(int err);

View File

@ -16,7 +16,9 @@ const struct optdesc opt_setuid_early= { "setuid-early",NULL, OPT_SETUID_EARLY,
const struct optdesc opt_setuid = { "setuid", NULL, OPT_SETUID, GROUP_PROCESS, PH_LATE2, TYPE_UIDT, OFUNC_SPEC };
const struct optdesc opt_substuser_early = { "substuser-early", "su-e", OPT_SUBSTUSER_EARLY, GROUP_PROCESS, PH_EARLY, TYPE_UIDT, OFUNC_SPEC };
const struct optdesc opt_substuser = { "substuser", "su", OPT_SUBSTUSER, GROUP_PROCESS, PH_LATE2, TYPE_UIDT, OFUNC_SPEC };
#if defined(HAVE_SETGRENT) && defined(HAVE_GETGRENT) && defined(HAVE_ENDGRENT)
const struct optdesc opt_substuser_delayed = { "substuser-delayed", "su-d", OPT_SUBSTUSER_DELAYED, GROUP_PROCESS, PH_INIT, TYPE_UIDT, OFUNC_SPEC };
#endif
const struct optdesc opt_chroot_early = { "chroot-early", NULL, OPT_CHROOT_EARLY, GROUP_PROCESS, PH_EARLY, TYPE_STRING, OFUNC_SPEC };
const struct optdesc opt_chroot = { "chroot", NULL, OPT_CHROOT, GROUP_PROCESS, PH_LATE, TYPE_STRING, OFUNC_SPEC };
const struct optdesc opt_setsid = { "setsid", "sid", OPT_SETSID, GROUP_PROCESS, PH_LATE, TYPE_BOOL, OFUNC_SPEC };

View File

@ -11,7 +11,9 @@ extern const struct optdesc opt_setuid_early;
extern const struct optdesc opt_setuid;
extern const struct optdesc opt_substuser_early;
extern const struct optdesc opt_substuser;
#if defined(HAVE_SETGRENT) && defined(HAVE_GETGRENT) && defined(HAVE_ENDGRENT)
extern const struct optdesc opt_substuser_delayed;
#endif
extern const struct optdesc opt_chroot_early;
extern const struct optdesc opt_chroot;
extern const struct optdesc opt_setsid;

View File

@ -78,7 +78,9 @@ static int xioopen_pty(int argc, const char *argv[], struct opt *opts, int xiofl
useptmx = true;
# endif /* !HAVE_OPENPTY */
#else
# if HAVE_OPENPTY
useopenpty = true;
# endif /* HAVE_OPENPTY */
#endif /* ! (defined(HAVE_DEV_PTMX) || defined(HAVE_DEV_PTC)) */
#if HAVE_POLL

View File

@ -1458,10 +1458,14 @@ const struct optname optionnames[] = {
IF_ANY ("streams-i-push", &opt_streams_i_push)
#endif
IF_ANY ("su", &opt_substuser)
#if defined(HAVE_SETGRENT) && defined(HAVE_GETGRENT) && defined(HAVE_ENDGRENT)
IF_ANY ("su-d", &opt_substuser_delayed)
#endif
IF_ANY ("su-e", &opt_substuser_early)
IF_ANY ("substuser", &opt_substuser)
#if defined(HAVE_SETGRENT) && defined(HAVE_GETGRENT) && defined(HAVE_ENDGRENT)
IF_ANY ("substuser-delayed", &opt_substuser_delayed)
#endif
IF_ANY ("substuser-early", &opt_substuser_early)
IF_TERMIOS("susp", &opt_vsusp)
#ifdef VSWTC
@ -3330,6 +3334,7 @@ int applyopts(int fd, struct opt *opts, enum e_phase phase) {
#endif
}
break;
#if defined(HAVE_SETGRENT) && defined(HAVE_GETGRENT) && defined(HAVE_ENDGRENT)
case OPT_SUBSTUSER_DELAYED:
{
struct passwd *pwd;
@ -3363,6 +3368,7 @@ int applyopts(int fd, struct opt *opts, enum e_phase phase) {
delayeduser = true;
}
break;
#endif
case OPT_CHROOT_EARLY:
case OPT_CHROOT:
if (Chroot(opt->value.u_string) < 0) {

View File

@ -703,7 +703,9 @@ enum e_optcode {
# undef ENABLE_OPTCODE
OPT_SUBSTUSER_EARLY,
OPT_SUBSTUSER,
#if defined(HAVE_SETGRENT) && defined(HAVE_GETGRENT) && defined(HAVE_ENDGRENT)
OPT_SUBSTUSER_DELAYED,
#endif
OPT_SYMBOLIC_LINK, /* with pty */
#ifdef TABDLY
# ifdef TAB0