summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael Jennings <mej@kainx.org>2009-10-25 20:30:06 +0000
committerMichael Jennings <mej@kainx.org>2009-10-25 20:30:06 +0000
commit42a135456a75ba914291984b0c83942ac6664f75 (patch)
treeadba3ae09d57eb83d398e3553cc66a4754481041 /src
parentc6ff25f5f1391f8c7cdf0c487c284e91fdd747e9 (diff)
downloadeterm-42a135456a75ba914291984b0c83942ac6664f75.tar.gz
Sun Oct 25 12:36:01 2009 Michael Jennings (mej)
Patch for FreeBSD UNIX98 pty support from Ed Schouten <ed@80386.nl>. ---------------------------------------------------------------------- SVN revision: 43281
Diffstat (limited to 'src')
-rw-r--r--src/command.c16
-rw-r--r--src/utmp.c19
2 files changed, 20 insertions, 15 deletions
diff --git a/src/command.c b/src/command.c
index 05dca7c..65fc09f 100644
--- a/src/command.c
+++ b/src/command.c
@@ -1386,17 +1386,21 @@ sco_get_pty(void)
}
#endif
-#ifdef HAVE_DEV_PTMX
-inline int svr_get_pty(void);
+#if defined(HAVE_POSIX_OPENPT) || defined(HAVE_DEV_PTMX)
+inline int posix_get_pty(void);
inline int
-svr_get_pty(void)
+posix_get_pty(void)
{
int fd = -1;
/* open the STREAMS, clone device /dev/ptmx (master pty) */
+#if defined(HAVE_POSIX_OPENPT)
+ if ((fd = posix_openpt(O_RDWR|O_NOCTTY)) < 0) {
+#else
if ((fd = open("/dev/ptmx", O_RDWR)) < 0) {
+#endif
return (-1);
} else {
if (grantpt(fd) != 0) {
@@ -1455,12 +1459,12 @@ get_pty(void)
int fd = -1;
-#if defined(__sgi)
+#if defined(HAVE_POSIX_OPENPT) || defined(HAVE_DEV_PTMX)
+ fd = posix_get_pty();
+#elif defined(__sgi)
fd = sgi_get_pty();
#elif defined(HAVE_DEV_PTC)
fd = aix_get_pty();
-#elif defined(HAVE_DEV_PTMX)
- fd = svr_get_pty();
#elif defined(HAVE_SCO_PTYS)
fd = sco_get_pty();
#endif
diff --git a/src/utmp.c b/src/utmp.c
index 8136eb0..f946514 100644
--- a/src/utmp.c
+++ b/src/utmp.c
@@ -38,9 +38,9 @@ static const char cvs_ident[] = "$Id$";
# endif
/* don't go off end of ut_id & remember if an entry has been made */
-# if defined(USE_SYSV_UTMP) || defined(NEW_BSD_UTMP) || defined(__OpenBSD__)
+# if defined(USE_SYSV_UTMP) || defined(__OpenBSD__)
static char ut_id[5]; /* remember if entry to utmp made */
-# else
+# elif !defined(NEW_BSD_UTMP)
static int utmp_pos; /* BSD position of utmp-stamp */
# endif
@@ -340,13 +340,6 @@ add_utmp_entry(const char *pty, const char *hostname, int fd)
if (!strncmp(pty, "/dev/", 5))
pty += 5; /* skip /dev/ prefix */
- if (!strncmp(pty, "pty", 3) || !strncmp(pty, "tty", 3))
- strncpy(ut_id, (pty + 3), sizeof(ut_id)); /* bsd naming */
- else {
- libast_print_error("can't parse tty name \"%s\"\n", pty);
- ut_id[0] = '\0'; /* entry not made */
- return;
- }
# ifdef NEW_BSD_UTMP
strncpy(ut_line, pty, 31);
@@ -358,6 +351,14 @@ add_utmp_entry(const char *pty, const char *hostname, int fd)
b_login(&utmp);
# else /* NEW_BSD_UTMP */
+ if (!strncmp(pty, "pty", 3) || !strncmp(pty, "tty", 3))
+ strncpy(ut_id, (pty + 3), sizeof(ut_id)); /* bsd naming */
+ else {
+ libast_print_error("can't parse tty name \"%s\"\n", pty);
+ ut_id[0] = '\0'; /* entry not made */
+ return;
+ }
+
strncpy(utmp.ut_line, ut_id, sizeof(utmp.ut_line));
strncpy(utmp.ut_name, pwent->pw_name, sizeof(utmp.ut_name));
strncpy(utmp.ut_host, hostname, sizeof(utmp.ut_host));