Print this page
14249 pseudo-terminal nomenclature should reflect POSIX
Change-Id: Ib4a3cef899ff4c71b09cb0dc6878863c5e8357bc

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/cmd-inet/usr.sbin/in.rlogind.c
          +++ new/usr/src/cmd/cmd-inet/usr.sbin/in.rlogind.c
   1    1  /*
   2    2   * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
   3    3   * Use is subject to license terms.
   4    4   */
   5    5  
   6      -/*      Copyright(c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T      */
   7      -/*        All Rights Reserved   */
        6 +/*      Copyright(c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
        7 +/*        All Rights Reserved */
   8    8  
   9    9  /*
  10   10   * Copyright (c) 1983 The Regents of the University of California.
  11   11   * All rights reserved.
  12   12   *
  13   13   * Redistribution and use in source and binary forms are permitted
  14   14   * provided that the above copyright notice and this paragraph are
  15   15   * duplicated in all such forms and that any documentation,
  16   16   * advertising materials, and other materials related to such
  17   17   * distribution and use acknowledge that the software was developed
↓ open down ↓ 1032 lines elided ↑ open up ↑
1050 1050          if (write(f, "", 1) != 1) {
1051 1051                  syslog(LOG_NOTICE,
1052 1052                      "send of the zero byte(to %s) failed:"
1053 1053                      " cannot start data transfer mode\n",
1054 1054                      (no_name ? abuf : hostname));
1055 1055                  exit(EXIT_FAILURE);
1056 1056          }
1057 1057          if ((p = open("/dev/ptmx", O_RDWR)) == -1)
1058 1058                  fatalperror(f, "cannot open /dev/ptmx");
1059 1059          if (grantpt(p) == -1)
1060      -                fatal(f, "could not grant slave pty");
     1060 +                fatal(f, "could not grant subsidiary pty");
1061 1061          if (unlockpt(p) == -1)
1062      -                fatal(f, "could not unlock slave pty");
     1062 +                fatal(f, "could not unlock subsidiary pty");
1063 1063          if ((line = ptsname(p)) == NULL)
1064      -                fatal(f, "could not enable slave pty");
     1064 +                fatal(f, "could not enable subsidiary pty");
1065 1065          if ((t = open(line, O_RDWR)) == -1)
1066      -                fatal(f, "could not open slave pty");
     1066 +                fatal(f, "could not open subsidiary pty");
1067 1067          if (ioctl(t, I_PUSH, "ptem") == -1)
1068 1068                  fatalperror(f, "ioctl I_PUSH ptem");
1069 1069          if (ioctl(t, I_PUSH, "ldterm") == -1)
1070 1070                  fatalperror(f, "ioctl I_PUSH ldterm");
1071 1071          if (ioctl(t, I_PUSH, "ttcompat") == -1)
1072 1072                  fatalperror(f, "ioctl I_PUSH ttcompat");
1073 1073          /*
1074 1074           * POP the sockmod and push the rlmod module.
1075 1075           *
1076 1076           * Note that sockmod has to be removed since readstream assumes
↓ open down ↓ 44 lines elided ↑ open up ↑
1121 1121          if (ioctl(t, TCGETS, &tp) == -1)
1122 1122                  fatalperror(f, "ioctl TCGETS");
1123 1123          tp.c_lflag &= ~(ECHO|ICANON);
1124 1124          tp.c_oflag &= ~(XTABS|OCRNL);
1125 1125          tp.c_iflag &= ~(IGNPAR|ICRNL);
1126 1126          if (ioctl(t, TCSETS, &tp) == -1)
1127 1127                  fatalperror(f, "ioctl TCSETS");
1128 1128  
1129 1129          /*
1130 1130           * System V ptys allow the TIOC{SG}WINSZ ioctl to be
1131      -         * issued on the master side of the pty.  Luckily, that's
     1131 +         * issued on the manager side of the pty.  Luckily, that's
1132 1132           * the only tty ioctl we need to do do, so we can close the
1133      -         * slave side in the parent process after the fork.
     1133 +         * subsidiary side in the parent process after the fork.
1134 1134           */
1135 1135          (void) ioctl(p, TIOCSWINSZ, &win);
1136 1136  
1137 1137          pid = fork();
1138 1138          if (pid < 0)
1139 1139                  fatalperror(f, "fork");
1140 1140          if (pid == 0) {
1141 1141                  int tt;
1142 1142                  struct utmpx ut;
1143 1143  
↓ open down ↓ 10 lines elided ↑ open up ↑
1154 1154                  ut.ut_exit.e_termination = 0;
1155 1155                  ut.ut_exit.e_exit = 0;
1156 1156                  (void) time(&ut.ut_tv.tv_sec);
1157 1157                  if (makeutx(&ut) == NULL)
1158 1158                          syslog(LOG_INFO, "in.rlogind:\tmakeutx failed");
1159 1159  
1160 1160                  /* controlling tty */
1161 1161                  if (setsid() == -1)
1162 1162                          fatalperror(f, "setsid");
1163 1163                  if ((tt = open(line, O_RDWR)) == -1)
1164      -                        fatalperror(f, "could not re-open slave pty");
     1164 +                        fatalperror(f, "could not re-open subsidiary pty");
1165 1165  
1166 1166                  if (close(p) == -1)
1167      -                        fatalperror(f, "error closing pty master");
     1167 +                        fatalperror(f, "error closing pty manager");
1168 1168                  if (close(t) == -1)
1169      -                        fatalperror(f, "error closing pty slave"
     1169 +                        fatalperror(f, "error closing pty subsidiary"
1170 1170                                      " opened before session established");
1171 1171                  /*
1172 1172                   * If this fails we may or may not be able to output an
1173 1173                   * error message.
1174 1174                   */
1175 1175                  if (close(f) == -1)
1176 1176                          fatalperror(f, "error closing deamon stdout");
1177 1177                  if (dup2(tt, STDIN_FILENO) == -1 ||
1178 1178                      dup2(tt, STDOUT_FILENO) == -1 ||
1179 1179                      dup2(tt, STDERR_FILENO) == -1)
↓ open down ↓ 22 lines elided ↑ open up ↑
1202 1202  
1203 1203                  fatalperror(STDERR_FILENO, "/bin/login");
1204 1204                  /*NOTREACHED*/
1205 1205          }
1206 1206          (void) close(t);
1207 1207          (void) ioctl(f, FIONBIO, &on);
1208 1208          (void) ioctl(p, FIONBIO, &on);
1209 1209  
1210 1210          /*
1211 1211           * Must ignore SIGTTOU, otherwise we'll stop
1212      -         * when we try and set slave pty's window shape
1213      -         * (our controlling tty is the master pty).
     1212 +         * when we try and set subsidiary pty's window shape
     1213 +         * (our controlling tty is the manager pty).
1214 1214           * Likewise, we don't want any of the tty-generated
1215 1215           * signals from chars passing through.
1216 1216           */
1217 1217          (void) sigset(SIGTSTP, SIG_IGN);
1218 1218          (void) sigset(SIGINT, SIG_IGN);
1219 1219          (void) sigset(SIGQUIT, SIG_IGN);
1220 1220          (void) sigset(SIGTTOU, SIG_IGN);
1221 1221          (void) sigset(SIGTTIN, SIG_IGN);
1222 1222          (void) sigset(SIGCHLD, cleanup);
1223 1223          (void) setpgrp();
↓ open down ↓ 101 lines elided ↑ open up ↑
1325 1325          /*NOTREACHED*/
1326 1326  }
1327 1327  
1328 1328  /*
1329 1329   * rlogin "protocol" machine.
1330 1330   */
1331 1331  static void
1332 1332  protocol(int f, int p, int encr_flag)
1333 1333  {
1334 1334          struct  stat    buf;
1335      -        struct  protocol_arg    rloginp;
     1335 +        struct  protocol_arg    rloginp;
1336 1336          struct  strioctl        rloginmod;
1337 1337          int     ptmfd;  /* fd of logindmux coneected to ptmx */
1338 1338          int     netfd;  /* fd of logindmux connected to netf */
1339 1339          static uchar_t  oobdata[] = {TIOCPKT_WINDOW};
1340 1340  
1341 1341          /* indicate new rlogin */
1342 1342          if (send_oob(f, oobdata, 1) < 0)
1343 1343                  fatalperror(f, "send_oob");
1344 1344          /*
1345 1345           * We cannot send the SECURE_MSG until after the
↓ open down ↓ 310 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX