Hi mich,
Can you try Marcus' patch to see if it fixes your sftp problem? I'm not sure
it will, but it seems strange that both kde and gnome implementations break
at about the same time...
If it works, can you followup to Marcus on -current?
Cheers,
Andy
---------- Forwarded Message ----------
Subject: Re: (problem found) grantpt broken on -CURRENT
Date: Wednesday 06 July 2005 07:22
From: Joe Marcus Clarke <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
On Tue, 2005-07-05 at 00:57 -0400, Joe Marcus Clarke wrote:
> 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.
I did some more research, and found that the problem was not in devfs
hiding the devices, but rather in the way ptsname() determined the tty
name for the open file descriptor. The kernel gets the minor number for
a tty from the si_drv0 member of the device cdev structure. However,
ptsname() relies on the minor number of the st_rdev member of the stat
structure to get the tty name. Devfs sets the st_rdev value to the
device's inode xor a random number. Therefore, ptsname() returns
garbage, and grantpt() subsequently fails.
I created this patch that corrects the problem, but I'm not sure if it's
the right way to go. Poul-Henning (or anyone) could you have a look and
let me know if this is okay? I'd really like to see this working again
in -CURRENT so 6.0 GNOME users will be able to use their sftp shares.
Thanks.
Oh, and it might be a good idea to make sys/types.h aware of MAXMINOR as
it still hardcodes the constant.
Joe
--
Joe Marcus Clarke
FreeBSD GNOME Team :: [EMAIL PROTECTED]
FreeNode / #freebsd-gnome
http://www.FreeBSD.org/gnome
-------------------------------------------------------
--
Andy Fawcett | [EMAIL PROTECTED]
| [EMAIL PROTECTED]
"In an open world without walls and fences, | [EMAIL PROTECTED]
we wouldn't need Windows and Gates." -- anon | [EMAIL PROTECTED]
--- src/sys/fs/devfs/devfs_vnops.c.orig Wed Jul 6 00:14:56 2005
+++ src/sys/fs/devfs/devfs_vnops.c Wed Jul 6 00:14:48 2005
@@ -520,7 +520,7 @@ devfs_getattr(ap)
fix(dev->si_ctime);
vap->va_ctime = dev->si_ctime;
- vap->va_rdev = dev->si_inode ^ devfs_random();
+ vap->va_rdev = dev->si_drv0;
}
vap->va_gen = 0;
vap->va_flags = 0;
_______________________________________________
kde-freebsd mailing list
[email protected]
http://freebsd.kde.org/mailman/listinfo/kde-freebsd