OSDN Git Service

Allow root login if ro.debuggable is set (userdebug and eng builds)
authorMike Lockwood <lockwood@google.com>
Thu, 29 Dec 2011 20:30:07 +0000 (15:30 -0500)
committerMike Lockwood <lockwood@google.com>
Wed, 8 Feb 2012 18:13:10 +0000 (10:13 -0800)
Change-Id: I4aed01758ca5589a6bf1642e9f2f2894221c82b9
Signed-off-by: Mike Lockwood <lockwood@google.com>
Android.mk
auth.c
servconf.c

index 868ca6a..c2e190b 100644 (file)
@@ -128,7 +128,7 @@ LOCAL_MODULE := sshd
 LOCAL_C_INCLUDES := external/openssl/include external/zlib
 PRIVATE_C_INCLUDES := external/openssl/openbsd-compat
 
-LOCAL_SHARED_LIBRARIES += libssh libssl libcrypto libdl libz
+LOCAL_SHARED_LIBRARIES += libssh libssl libcrypto libdl libz libcutils
 
 include $(BUILD_EXECUTABLE)
 
diff --git a/auth.c b/auth.c
index 6623e0f..a15b306 100644 (file)
--- a/auth.c
+++ b/auth.c
@@ -443,9 +443,15 @@ secure_filename(FILE *f, const char *file, struct passwd *pw,
        if (fstat(fileno(f), &st) < 0 ||
            (st.st_uid != 0 && st.st_uid != uid) ||
            (st.st_mode & 022) != 0) {
-               snprintf(err, errlen, "bad ownership or modes for file %s",
-                   buf);
-               return -1;
+#ifdef ANDROID
+               /* needed to allow root login on android */
+               if (getuid() != 0)
+#endif
+           {
+                       snprintf(err, errlen, "bad ownership or modes for file %s",
+                               buf);
+                       return -1;
+               }
        }
 
        /* for each component of the canonical path, walking upwards */
index 91986e5..fb293f5 100644 (file)
 #include "channels.h"
 #include "groupaccess.h"
 
+#ifdef ANDROID
+#include <cutils/properties.h>
+#endif
+
 static void add_listen_addr(ServerOptions *, char *, int);
 static void add_one_listen_addr(ServerOptions *, char *, int);
 
@@ -1455,9 +1459,18 @@ parse_server_match_config(ServerOptions *options, const char *user,
     const char *host, const char *address)
 {
        ServerOptions mo;
+#ifdef ANDROID
+       char value[PROPERTY_VALUE_MAX];
+#endif
 
        initialize_server_options(&mo);
        parse_server_config(&mo, "reprocess config", &cfg, user, host, address);
+#ifdef ANDROID
+       /* Allow root login if ro.debuggable is set */
+       property_get("ro.debuggable", value, "");
+       if (strcmp(value, "1") == 0)
+               mo.permit_root_login = PERMIT_YES;
+#endif
        copy_set_server_options(options, &mo, 0);
 }