From 0199da83f61c7a951b6e05ec844dabc0d3e04cd7 Mon Sep 17 00:00:00 2001 From: Greg Hartman Date: Wed, 29 Jul 2015 15:38:15 -0700 Subject: [PATCH] Don't chmod /dev/ptmx when allocating a pty on Android. This resolves an incompatibility with non-root adb. BUG=22803455 Change-Id: I908923e9ddc04e0ec8de0122eb79486c8b1ae03e --- sshpty.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/sshpty.c b/sshpty.c index af85259..5816922 100644 --- a/sshpty.c +++ b/sshpty.c @@ -73,16 +73,21 @@ pty_allocate(int *ptyfd, int *ttyfd, char *namebuf, size_t namebuflen) return 0; } #ifdef ANDROID - /* Android does not have a working ttyname() */ - name = "/dev/ptmx"; + if (ptsname_r(*ptyfd, namebuf, namebuflen)) { + fatal("openpty ptsname failed."); + close(*ptyfd); + *ptyfd = -1; + return -1; + } + return 1; #else name = ttyname(*ttyfd); if (!name) fatal("openpty returns device for which ttyname fails."); -#endif strlcpy(namebuf, name, namebuflen); /* possible truncation */ return 1; +#endif } /* Releases the tty. Its ownership is returned to root, and permissions to 0666. */ -- 2.11.0