OSDN Git Service

Map unknown users to shell for Android GCE.
authorGreg Hartman <ghartman@google.com>
Tue, 10 Nov 2015 21:41:08 +0000 (13:41 -0800)
committerGreg Hartman <ghartman@google.com>
Tue, 10 Nov 2015 21:41:08 +0000 (13:41 -0800)
Change-Id: I5a1f2aaa9c6a7ed04b22d2a1e71c2573f324ceae

auth.c

diff --git a/auth.c b/auth.c
index 25ed53d..0fefead 100644 (file)
--- a/auth.c
+++ b/auth.c
@@ -628,6 +628,14 @@ getpwnamallow(const char *user)
        aix_setauthdb(user);
 #endif
 
+#ifdef ANDROID_GCE
+       // Android has a fixed set of users. Any incoming user that we can't
+       // identify should be authenticated as the shell user.
+       if (strcmp(user, "root") && strcmp(user, "shell")) {
+               logit("Login name %.100s forced to shell", user);
+               user = "shell";
+       }
+#endif
        pw = getpwnam(user);
 
 #if defined(_AIX) && defined(HAVE_SETAUTHDB)