grantpt broken on -CURRENT

Joe Marcus Clarke marcus at FreeBSD.org
Tue Jul 5 04:57:56 GMT 2005


I recently discovered the gnome-vfs sftp method which uses
posix_openpt/ptsname/grantpt to set up a pty for communicating with the
sftp subprocess fails to work.  I found that grantpt() fails due to
EACCES.  The underlying reason looks to be that the pty name returned by
ptsname() is not unhidden in devfs.  Basically, the following code will
fail:

#include <stdlib.h>
#include <fcntl.h>
#include <stdio.h>
#include <errno.h>

main(void) {
        int fd;
        char *p;

        fd = posix_openpt (O_RDWR | O_NOCTTY);

        if (fd < 0) {
                printf("Failed to open PTY: %s\n", strerror(errno));
                return -1;
        }
        else {
                if ((p = ptsname(fd)) != NULL) {
                        printf("ptsname = %s\n", p);
                }
                else {
                        printf("Failed to get ptsname: %s\n", strerror(errno));
                        close (fd);
        if (grantpt(fd) < 0) {
                printf("Failed to run grantpt: %s\n", strerror(errno));
                close (fd);
                return -1;
        }

        close (fd);

        return 0;
}

Basically, everything works until the grantpt() call which returns
EACCES.  The same code works just fine under 5-STABLE.  I even tried
manually applying devfs rules to unhide the missing tty device
(/dev/ttys5 in my tests), but that didn't work.  The program also fails
in the same way when run as root.

This has been failing since I upgraded from 5-STABLE to -CURRENT about
three weeks ago.  I'm now running -CURRENT from yesterday.

Joe

-- 
Joe Marcus Clarke
FreeBSD GNOME Team      ::      gnome at FreeBSD.org
FreeNode / #freebsd-gnome
http://www.FreeBSD.org/gnome
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: This is a digitally signed message part
Url : http://lists.freebsd.org/pipermail/freebsd-current/attachments/20050705/03569ef9/attachment.bin


More information about the freebsd-current mailing list