From: Greg Hartman Date: Wed, 29 Jul 2015 22:38:15 +0000 (-0700) Subject: Don't chmod /dev/ptmx when allocating a pty on Android. X-Git-Tag: android-x86-8.1-r1~29 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=0199da83f61c7a951b6e05ec844dabc0d3e04cd7;p=android-x86%2Fexternal-openssh.git Don't chmod /dev/ptmx when allocating a pty on Android. This resolves an incompatibility with non-root adb. BUG=22803455 Change-Id: I908923e9ddc04e0ec8de0122eb79486c8b1ae03e --- 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. */