Hello,
I don't know if any of you ever tried to compile
against the Android NDK, but attached is the changes
I made to get something slightly useful.
These are really 3 completely independent changes.
1) common-session.c: Android may return NULL as
the account password instead of "".
Since the current code crashes that might be
a good idea.
Possibly it might even make sense to change
m_strdup to return strdup("") when the input
is NULL.
2) loginrec.c: Android defines USER_PROCESS but not
DEAD_PROCESS. No idea what a sensible solution is.
3) sshpty.c: The /dev/ptmx code actually works fine
on Android (as far as I can tell), as long as you disable
the I_PUSH stuff which doesn't compile.
Since the USE_DEV_PTMX auto-detection is quite conservative
checking whether I_PUSH is defined seemed quite reasonable
to me.
4) svr-auth.c: Allow disabling the valid shell check.
It just prints a lot of warnings that the related
libc functions are only stubs and always fails on
Android.
Hope parts of it are acceptable for inclusion,
would be nice if all those Android-dropbox forks
would have fewer custom changes.
Kind regards,
Reimar Döffinger
diff -r d392f5a61a48 common-session.c
--- a/common-session.c Thu Feb 23 21:46:02 2012 +0800
+++ b/common-session.c Tue Mar 06 00:00:04 2012 +0100
@@ -453,6 +453,7 @@
ses.authstate.pw_name = m_strdup(pw->pw_name);
ses.authstate.pw_dir = m_strdup(pw->pw_dir);
ses.authstate.pw_shell = m_strdup(pw->pw_shell);
- ses.authstate.pw_passwd = m_strdup(pw->pw_passwd);
+ // Android returns NULL as password
+ ses.authstate.pw_passwd = m_strdup(pw->pw_passwd ? pw->pw_passwd : "");
}
diff -r d392f5a61a48 loginrec.c
--- a/loginrec.c Thu Feb 23 21:46:02 2012 +0800
+++ b/loginrec.c Tue Mar 06 00:00:04 2012 +0100
@@ -158,6 +158,10 @@
#include "dbutil.h"
#include "atomicio.h"
+#ifndef DEAD_PROCESS
+#define DEAD_PROCESS 8
+#endif
+
/**
** prototypes for helper functions in this file
**/
diff -r d392f5a61a48 sshpty.c
--- a/sshpty.c Thu Feb 23 21:46:02 2012 +0800
+++ b/sshpty.c Tue Mar 06 00:00:04 2012 +0100
@@ -133,7 +133,7 @@
close(*ptyfd);
return 0;
}
-#ifndef HAVE_CYGWIN
+#if !defined(HAVE_CYGWIN) && defined(I_PUSH)
/*
* Push the appropriate streams modules, as described in Solaris pts(7).
* HP-UX pts(7) doesn't have ttcompat module.
diff -r d392f5a61a48 svr-auth.c
--- a/svr-auth.c Thu Feb 23 21:46:02 2012 +0800
+++ b/svr-auth.c Tue Mar 06 00:00:04 2012 +0100
@@ -258,6 +258,7 @@
usershell = "/bin/sh";
}
+#ifdef DISABLE_SHELL_CHECK
/* check the shell is valid. If /etc/shells doesn't exist, getusershell()
* should return some standard shells like "/bin/sh" and "/bin/csh" (this
* is platform-specific) */
@@ -280,6 +281,7 @@
goodshell:
endusershell();
TRACE(("matching shell"))
+#endif
TRACE(("uid = %d", ses.authstate.pw_uid))
TRACE(("leave checkusername"))