summaryrefslogtreecommitdiffstats
path: root/lib/libutil
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2008-01-15 15:36:23 +0000
committerjhb <jhb@FreeBSD.org>2008-01-15 15:36:23 +0000
commitc02890da0b4e1279b29fcf72906c76e4824c6037 (patch)
tree2ef3657765b0fa0ac5fa3d86db0f76bd8e1b8496 /lib/libutil
parent4c5f0cc5c49ca369ab18c4fcfe180ac666abe872 (diff)
downloadFreeBSD-src-c02890da0b4e1279b29fcf72906c76e4824c6037.zip
FreeBSD-src-c02890da0b4e1279b29fcf72906c76e4824c6037.tar.gz
Put back the openpty(3) and ptsname(3) fixes but don't disable ptsname(3)
on pts(4) devices this time. This fixes the issues while leaving pts(4) enabled on HEAD.
Diffstat (limited to 'lib/libutil')
-rw-r--r--lib/libutil/pty.c58
1 files changed, 3 insertions, 55 deletions
diff --git a/lib/libutil/pty.c b/lib/libutil/pty.c
index 1fe8be2..15f258b 100644
--- a/lib/libutil/pty.c
+++ b/lib/libutil/pty.c
@@ -49,10 +49,8 @@ static char sccsid[] = "@(#)pty.c 8.3 (Berkeley) 5/16/94";
#include <termios.h>
#include <unistd.h>
-int __use_pts(void);
-
-static int
-new_openpty(int *amaster, int *aslave, char *name, struct termios *termp,
+int
+openpty(int *amaster, int *aslave, char *name, struct termios *termp,
struct winsize *winp)
{
const char *slavename;
@@ -94,7 +92,7 @@ new_openpty(int *amaster, int *aslave, char *name, struct termios *termp,
*aslave = slave;
if (name)
- strcpy(name, ptsname(master));
+ strcpy(name, slavename);
if (termp)
tcsetattr(slave, TCSAFLUSH, termp);
if (winp)
@@ -104,56 +102,6 @@ new_openpty(int *amaster, int *aslave, char *name, struct termios *termp,
}
int
-openpty(int *amaster, int *aslave, char *name, struct termios *termp, struct winsize *winp)
-{
- char line[] = "/dev/ptyXX";
- const char *cp1, *cp2;
- int master, slave, ttygid;
- struct group *gr;
-
- if (__use_pts())
- return (new_openpty(amaster, aslave, name, termp, winp));
-
- if ((gr = getgrnam("tty")) != NULL)
- ttygid = gr->gr_gid;
- else
- ttygid = -1;
-
- for (cp1 = "pqrsPQRSlmnoLMNO"; *cp1; cp1++) {
- line[8] = *cp1;
- for (cp2 = "0123456789abcdefghijklmnopqrstuv"; *cp2; cp2++) {
- line[5] = 'p';
- line[9] = *cp2;
- if ((master = open(line, O_RDWR, 0)) == -1) {
- if (errno == ENOENT)
- break; /* try the next pty group */
- } else {
- line[5] = 't';
- (void) chown(line, getuid(), ttygid);
- (void) chmod(line, S_IRUSR|S_IWUSR|S_IWGRP);
- (void) revoke(line);
- if ((slave = open(line, O_RDWR, 0)) != -1) {
- *amaster = master;
- *aslave = slave;
- if (name)
- strcpy(name, line);
- if (termp)
- (void) tcsetattr(slave,
- TCSAFLUSH, termp);
- if (winp)
- (void) ioctl(slave, TIOCSWINSZ,
- (char *)winp);
- return (0);
- }
- (void) close(master);
- }
- }
- }
- errno = ENOENT; /* out of ptys */
- return (-1);
-}
-
-int
forkpty(int *amaster, char *name, struct termios *termp, struct winsize *winp)
{
int master, slave, pid;
OpenPOWER on IntegriCloud