Akira Shirai, thanks for the info about grantpt and its internal setuid program; that made the problem obvious. I installed the attached patch into the Emacs master sources and am (perhaps optimistically) marking this bug as done.