Print this page
12306 XPG4v2 slave pty behaviour should generally be disabled
Reviewed by: Robert Mustacchi <rm@fingolfin.org>
Change-ID: I7ccd399c22866f34dd20c6bb9d28e77ba4e24c67

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/io/pts.c
          +++ new/usr/src/uts/common/io/pts.c
↓ open down ↓ 17 lines elided ↑ open up ↑
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  /*
  22   22   * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
  23   23   * Use is subject to license terms.
  24   24   */
  25   25  /*      Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
  26   26  /*        All Rights Reserved   */
  27   27  
       28 +/*
       29 + * Copyright 2020 OmniOS Community Edition (OmniOSce) Association.
       30 + */
  28   31  
  29      -
  30   32  /*
  31   33   * Pseudo Terminal Slave Driver.
  32   34   *
  33   35   * The pseudo-tty subsystem simulates a terminal connection, where the master
  34   36   * side represents the terminal and the slave represents the user process's
  35   37   * special device end point. The master device is set up as a cloned device
  36   38   * where its major device number is the major for the clone device and its minor
  37   39   * device number is the major for the ptm driver. There are no nodes in the file
  38   40   * system for master devices. The master pseudo driver is opened using the
  39   41   * open(2) system call with /dev/ptmx as the device parameter.  The clone open
↓ open down ↓ 59 lines elided ↑ open up ↑
  99  101   *
 100  102   * See ptms.h, ptm.c and ptms_conf.c fore more information.
 101  103   *
 102  104   */
 103  105  
 104  106  #include <sys/types.h>
 105  107  #include <sys/param.h>
 106  108  #include <sys/sysmacros.h>
 107  109  #include <sys/stream.h>
 108  110  #include <sys/stropts.h>
      111 +#include <sys/strsubr.h>
 109  112  #include <sys/stat.h>
 110  113  #include <sys/errno.h>
 111  114  #include <sys/debug.h>
 112  115  #include <sys/cmn_err.h>
 113  116  #include <sys/ptms.h>
 114  117  #include <sys/systm.h>
 115  118  #include <sys/modctl.h>
 116  119  #include <sys/conf.h>
 117  120  #include <sys/ddi.h>
 118  121  #include <sys/sunddi.h>
↓ open down ↓ 211 lines elided ↑ open up ↑
 330  333                  ASSERT(rqp->q_ptr == ptsp);
 331  334                  ASSERT(ptsp->pts_rdq == rqp);
 332  335                  mutex_exit(&ptsp->pt_lock);
 333  336                  mutex_exit(&ptms_lock);
 334  337                  return (0);
 335  338          }
 336  339  
 337  340          DDBGP("ptsopen: p = %p\n", (uintptr_t)ptsp);
 338  341          DDBG("ptsopen: state = %x\n", ptsp->pt_state);
 339  342  
 340      -
 341  343          ASSERT(ptsp->pt_minor == dminor);
 342  344  
 343  345          if ((ptsp->pt_state & PTLOCK) || !(ptsp->pt_state & PTMOPEN)) {
 344  346                  mutex_exit(&ptsp->pt_lock);
 345  347                  mutex_exit(&ptms_lock);
 346  348                  return (EAGAIN);
 347  349          }
 348  350  
 349  351          /*
 350      -         * if already, open simply return...
      352 +         * if already open, simply return...
 351  353           */
 352  354          if (ptsp->pt_state & PTSOPEN) {
 353  355                  ASSERT(rqp->q_ptr == ptsp);
 354  356                  ASSERT(ptsp->pts_rdq == rqp);
 355  357                  mutex_exit(&ptsp->pt_lock);
 356  358                  mutex_exit(&ptms_lock);
 357  359                  return (0);
 358  360          }
 359  361  
 360  362          /*
↓ open down ↓ 18 lines elided ↑ open up ↑
 379  381                  return (ENOMEM);
 380  382          }
 381  383  
 382  384          ptsp->pt_state |= PTSOPEN;
 383  385  
 384  386          WR(rqp)->q_ptr = rqp->q_ptr = ptsp;
 385  387  
 386  388          mutex_exit(&ptsp->pt_lock);
 387  389          mutex_exit(&ptms_lock);
 388  390  
      391 +        if (ptsp->pt_state & PTSTTY)
      392 +                STREAM(rqp)->sd_flag |= STRXPG4TTY;
      393 +
 389  394          qprocson(rqp);
 390  395  
 391  396          /*
 392  397           * After qprocson pts driver is fully plumbed into the stream and can
 393  398           * send/receive messages. Setting pts_rdq will allow master side to send
 394  399           * messages to the slave. This setting can't occur before qprocson() is
 395  400           * finished because slave is not ready to process them.
 396  401           */
 397  402          PT_ENTER_WRITE(ptsp);
 398  403          ptsp->pts_rdq = rqp;
↓ open down ↓ 10 lines elided ↑ open up ↑
 409  414          mop->b_wptr += sizeof (struct stroptions);
 410  415          sop = (struct stroptions *)mop->b_rptr;
 411  416          sop->so_flags = SO_HIWAT | SO_LOWAT | SO_ISTTY;
 412  417          sop->so_hiwat = _TTY_BUFSIZ;
 413  418          sop->so_lowat = 256;
 414  419          putnext(rqp, mop);
 415  420  
 416  421          return (0);
 417  422  }
 418  423  
 419      -
 420      -
 421  424  /*
 422  425   * Find the address to private data identifying the slave's write
 423  426   * queue. Send a 0-length msg up the slave's read queue to designate
 424  427   * the master is closing. Uattach the master from the slave by nulling
 425  428   * out master's write queue field in private data.
 426  429   */
 427  430  /*ARGSUSED1*/
 428  431  static int
 429  432  ptsclose(queue_t *rqp, int flag, cred_t *credp)
 430  433  {
↓ open down ↓ 319 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX