On Sat, 14 May 2005, 15:25+0800, Tai-hwa Liang wrote: > On Sat, 14 May 2005, Daniel Eriksson wrote: > > > > Somewhere between 2005.05.12.19.00.00 and 2005.05.13.18.10.00 PAM (or > > something PAM relies on) got messed up. Installing a system with the later > > date will prevent you from logging in, both via ssh and on the console. > > Using ssh results in the following console output: > > > > sshd[530]: fatal: openpty returns device for which ttyname fails. > > sshd[530]: error: chown 0 0 failed: No such file or directory > > sshd[530]: error: chmod 0666 failed: No such file or directory > > Does backing out ttyname related changes work for you? > > http://lists.freebsd.org/pipermail/cvs-src/2005-May/046254.html Yes, it helps me. Xin LI, could you please take a loot at this? For those who already broke their sshd: o apply the patch below o rebuild and reinstall libc o restart sshd Index: include/unistd.h =================================================================== RCS file: /home/ncvs/src/include/unistd.h,v retrieving revision 1.78 diff -u -r1.78 unistd.h --- include/unistd.h 13 May 2005 16:27:30 -0000 1.78 +++ include/unistd.h 14 May 2005 12:26:25 -0000 _at__at_ -31,7 +31,7 _at__at_ * SUCH DAMAGE. * * _at_(#)unistd.h 8.12 (Berkeley) 4/27/95 - * $FreeBSD: src/include/unistd.h,v 1.78 2005/05/13 16:27:30 delphij Exp $ + * $FreeBSD: src/include/unistd.h,v 1.77 2005/05/11 14:07:25 delphij Exp $ */ #ifndef _UNISTD_H_ _at__at_ -365,7 +365,7 _at__at_ pid_t tcgetpgrp(int); int tcsetpgrp(int, pid_t); char *ttyname(int); -int ttyname_r(int, char *, size_t); +char *ttyname_r(int, char *, size_t); int unlink(const char *); ssize_t write(int, const void *, size_t); Index: lib/libc/gen/ttyname.3 =================================================================== RCS file: /home/ncvs/src/lib/libc/gen/ttyname.3,v retrieving revision 1.12 diff -u -r1.12 ttyname.3 --- lib/libc/gen/ttyname.3 13 May 2005 16:27:30 -0000 1.12 +++ lib/libc/gen/ttyname.3 14 May 2005 12:26:25 -0000 _at__at_ -30,14 +30,13 _at__at_ .\" SUCH DAMAGE. .\" .\" _at_(#)ttyname.3 8.1 (Berkeley) 6/4/93 -.\" $FreeBSD: src/lib/libc/gen/ttyname.3,v 1.12 2005/05/13 16:27:30 delphij Exp $ +.\" $FreeBSD: src/lib/libc/gen/ttyname.3,v 1.11 2005/03/08 21:35:52 phk Exp $ .\" -.Dd May 14, 2005 +.Dd June 4, 1993 .Dt TTYNAME 3 .Os .Sh NAME .Nm ttyname , -.Nm ttyname_r , .Nm isatty , .Nm ttyslot .Nd get name of associated terminal (tty) from file descriptor _at__at_ -47,7 +46,7 _at__at_ .In unistd.h .Ft char * .Fn ttyname "int fd" -.Ft int +.Ft char * .Fn ttyname_r "int fd" "char *buf" "size_t len" .Ft int .Fn isatty "int fd" _at__at_ -83,13 +82,7 _at__at_ gets the related device name of a file descriptor for which .Fn isatty -is true. -.Pp -.Fn ttyname -returns the name stored in a static buffer which will be overwritten -on subsequent calls. -.Fn ttyname_r -takes a buffer and length as arguments to avoid this problem. +is true .Pp The .Fn ttyslot _at__at_ -107,25 +100,12 _at__at_ a .Dv NULL pointer is returned. -The -.Fn ttyname_r -function returns 0 if successful. Otherwise an error number is returned. .Pp The .Fn ttyslot function returns the unit number of the device file if found; otherwise the value zero is returned. -.Sh ERRORS -.Fn ttyname_r -may return the following error codes: -.Bl -tag -width Er -.It Bq Er ENOTTY -.Fa fd -is not a valid file descriptor. -.It Bq Er ERANGE -.Fa bufsize -is smaller than the length of the string to be returned. .Sh FILES .Bl -tag -width /etc/ttys -compact .It Pa /dev/\(** _at__at_ -143,6 +123,11 _at__at_ function appeared in .At v7 . -.Fn ttyname_r -appeared in -.Fx 6.0 . +.Sh BUGS +The +.Fn ttyname +function leaves its result in an internal static object and returns +a pointer to that object. +Subsequent calls to +.Fn ttyname +will modify the same object. Index: lib/libc/gen/ttyname.c =================================================================== RCS file: /home/ncvs/src/lib/libc/gen/ttyname.c,v retrieving revision 1.18 diff -u -r1.18 ttyname.c --- lib/libc/gen/ttyname.c 13 May 2005 16:27:30 -0000 1.18 +++ lib/libc/gen/ttyname.c 14 May 2005 12:26:25 -0000 _at__at_ -35,7 +35,7 _at__at_ static char sccsid[] = "_at_(#)ttyname.c 8.2 (Berkeley) 1/27/94"; #endif /* LIBC_SCCS and not lint */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/lib/libc/gen/ttyname.c,v 1.18 2005/05/13 16:27:30 delphij Exp $"); +__FBSDID("$FreeBSD: src/lib/libc/gen/ttyname.c,v 1.17 2005/03/08 21:35:52 phk Exp $"); #include "namespace.h" #include <sys/types.h> _at__at_ -50,7 +50,6 _at__at_ #include <string.h> #include <paths.h> #include <pthread.h> -#include <errno.h> #include "un-namespace.h" #include "libc_private.h" _at__at_ -61,32 +60,34 _at__at_ static pthread_key_t ttyname_key; static int ttyname_init = 0; -int +char * ttyname_r(int fd, char *buf, size_t len) { struct stat sb; + char *rval; struct fiodgname_arg fgn; + rval = NULL; *buf = '\0'; /* Must be a terminal. */ if (!isatty(fd)) - return (ENOTTY); + return (rval); /* Must be a character device. */ if (_fstat(fd, &sb) || !S_ISCHR(sb.st_mode)) - return (ENOTTY); + return (rval); /* Must have enough room */ if (len <= sizeof(_PATH_DEV)) - return (ERANGE); + return (rval); strcpy(buf, _PATH_DEV); fgn.len = len - strlen(buf); fgn.buf = buf + strlen(buf); if (!_ioctl(fd, FIODGNAME, &fgn)) - return (EINVAL); + return(buf); devname_r(sb.st_rdev, S_IFCHR, buf + strlen(buf), sizeof(buf) - strlen(buf)); - return (0); + return (buf); } char * _at__at_ -94,12 +95,8 _at__at_ { char *buf; - if (__isthreaded == 0) { - if (ttyname_r(fd, ttyname_buf, sizeof ttyname_buf) != 0) - return (NULL); - else - return (ttyname_buf); - } + if (__isthreaded == 0) + return (ttyname_r(fd, ttyname_buf, sizeof ttyname_buf)); if (ttyname_init == 0) { _pthread_mutex_lock(&ttyname_lock); _at__at_ -124,7 +121,6 _at__at_ return (NULL); } } - ttyname_r(fd, buf, sizeof(_PATH_DEV) + MAXNAMLEN); - return (buf); + return (ttyname_r(fd, buf, sizeof(_PATH_DEV) + MAXNAMLEN)); } Index: lib/libc_r/uthread/pthread_private.h =================================================================== RCS file: /home/ncvs/src/lib/libc_r/uthread/pthread_private.h,v retrieving revision 1.86 diff -u -r1.86 pthread_private.h --- lib/libc_r/uthread/pthread_private.h 13 May 2005 16:27:30 -0000 1.86 +++ lib/libc_r/uthread/pthread_private.h 14 May 2005 12:26:25 -0000 _at__at_ -31,7 +31,7 _at__at_ * * Private thread definitions for the uthread kernel. * - * $FreeBSD: src/lib/libc_r/uthread/pthread_private.h,v 1.86 2005/05/13 16:27:30 delphij Exp $ + * $FreeBSD: src/lib/libc_r/uthread/pthread_private.h,v 1.85 2005/02/28 17:15:31 marcus Exp $ */ #ifndef _PTHREAD_PRIVATE_H _at__at_ -1212,6 +1212,8 _at__at_ */ __BEGIN_DECLS char *__ttyname_basic(int); +char *__ttyname_r_basic(int, char *, size_t); +char *ttyname_r(int, char *, size_t); void _cond_wait_backout(pthread_t); void _fd_lock_backout(pthread_t); int _find_thread(pthread_t); %%% -- Maxim KonovalovReceived on Sat May 14 2005 - 10:33:58 UTC
This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:38:34 UTC