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/cmd/zlogin/zlogin.c
          +++ new/usr/src/cmd/zlogin/zlogin.c
↓ open down ↓ 16 lines elided ↑ open up ↑
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  /*
  22   22   * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
  23   23   * Copyright 2013 DEY Storage Systems, Inc.
  24   24   * Copyright (c) 2014 Gary Mills
  25   25   * Copyright 2015 Nexenta Systems, Inc. All rights reserved.
  26   26   * Copyright 2019 Joyent, Inc.
  27      - * Copyright 2019 OmniOS Community Edition (OmniOSce) Association.
       27 + * Copyright 2020 OmniOS Community Edition (OmniOSce) Association.
  28   28   */
  29   29  
  30   30  /*
  31   31   * zlogin provides three types of login which allow users in the global
  32   32   * zone to access non-global zones.
  33   33   *
  34   34   * - "interactive login" is similar to rlogin(1); for example, the user could
  35   35   *   issue 'zlogin my-zone' or 'zlogin -e ^ -l me my-zone'.   The user is
  36   36   *   granted a new pty (which is then shoved into the zone), and an I/O
  37   37   *   loop between parent and child processes takes care of the interactive
↓ open down ↓ 70 lines elided ↑ open up ↑
 108  108  static int failsafe = 0;
 109  109  static int disconnect = 0;
 110  110  static char cmdchar = '~';
 111  111  static int quiet = 0;
 112  112  
 113  113  static int pollerr = 0;
 114  114  
 115  115  static const char *pname;
 116  116  static char *username;
 117  117  
 118      -extern int __xpg4;      /* 0 if not an xpg4/6-compiled program */
 119      -
 120  118  /*
 121  119   * When forced_login is true, the user is not prompted
 122  120   * for an authentication password in the target zone.
 123  121   */
 124  122  static boolean_t forced_login = B_FALSE;
 125  123  
 126  124  #if !defined(TEXT_DOMAIN)               /* should be defined by cc -D */
 127  125  #define TEXT_DOMAIN     "SYS_TEST"      /* Use this only if it wasn't */
 128  126  #endif
 129  127  
↓ open down ↓ 633 lines elided ↑ open up ↑
 763  761  static int
 764  762  process_output(int in_fd, int out_fd)
 765  763  {
 766  764          int wrote = 0;
 767  765          int cc;
 768  766          char ibuf[ZLOGIN_BUFSIZ];
 769  767  
 770  768          cc = read(in_fd, ibuf, ZLOGIN_BUFSIZ);
 771  769          if (cc == -1 && (errno != EINTR || dead))
 772  770                  return (-1);
 773      -        if (cc == 0) {
 774      -                /*
 775      -                 * A return value of 0 when calling read() on a terminal
 776      -                 * indicates end-of-file pre-XPG4 and no data available
 777      -                 * for XPG4 and above.
 778      -                 */
 779      -                if (__xpg4 == 0)
 780      -                        return (-1);
 781      -                return (0);
 782      -        }
      771 +        if (cc == 0)
      772 +                return (-1);    /* EOF */
 783  773          if (cc == -1)   /* The read was interrupted. */
 784  774                  return (0);
 785  775  
 786  776          do {
 787  777                  int len;
 788  778  
 789  779                  len = write(out_fd, ibuf + wrote, cc - wrote);
 790  780                  if (len == -1 && errno != EINTR)
 791  781                          return (-1);
 792  782                  if (len != -1)
↓ open down ↓ 1509 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX