Skip to content
Snippets Groups Projects
Commit 360b2521 authored by Greg Hartman's avatar Greg Hartman Committed by android-build-merger
Browse files

Don\'t chmod /dev/ptmx when allocating a pty on Android.

am: 0199da83

* commit '0199da83':
  Don't chmod /dev/ptmx when allocating a pty on Android.
parents d7d954c2 0199da83
No related branches found
No related tags found
No related merge requests found
...@@ -73,16 +73,21 @@ pty_allocate(int *ptyfd, int *ttyfd, char *namebuf, size_t namebuflen) ...@@ -73,16 +73,21 @@ pty_allocate(int *ptyfd, int *ttyfd, char *namebuf, size_t namebuflen)
return 0; return 0;
} }
#ifdef ANDROID #ifdef ANDROID
/* Android does not have a working ttyname() */ if (ptsname_r(*ptyfd, namebuf, namebuflen)) {
name = "/dev/ptmx"; fatal("openpty ptsname failed.");
close(*ptyfd);
*ptyfd = -1;
return -1;
}
return 1;
#else #else
name = ttyname(*ttyfd); name = ttyname(*ttyfd);
if (!name) if (!name)
fatal("openpty returns device for which ttyname fails."); fatal("openpty returns device for which ttyname fails.");
#endif
strlcpy(namebuf, name, namebuflen); /* possible truncation */ strlcpy(namebuf, name, namebuflen); /* possible truncation */
return 1; return 1;
#endif
} }
/* Releases the tty. Its ownership is returned to root, and permissions to 0666. */ /* Releases the tty. Its ownership is returned to root, and permissions to 0666. */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment