[BACK]Return to ssh.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / ssh

Diff for /src/usr.bin/ssh/ssh.c between version 1.358 and 1.359

version 1.358, 2011/05/06 21:18:02 version 1.359, 2011/05/06 21:34:32
Line 105 
Line 105 
 /* Flag indicating whether debug mode is on.  May be set on the command line. */  /* Flag indicating whether debug mode is on.  May be set on the command line. */
 int debug_flag = 0;  int debug_flag = 0;
   
 /* Flag indicating whether a tty should be allocated */  /* Flag indicating whether a tty should be requested */
 int tty_flag = 0;  int tty_flag = 0;
 int no_tty_flag = 0;  
 int force_tty_flag = 0;  
   
 /* don't exec a shell */  /* don't exec a shell */
 int no_shell_flag = 0;  int no_shell_flag = 0;
Line 126 
Line 124 
 int need_controlpersist_detach = 0;  int need_controlpersist_detach = 0;
   
 /* Copies of flags for ControlPersist foreground slave */  /* Copies of flags for ControlPersist foreground slave */
 int ostdin_null_flag, ono_shell_flag, ono_tty_flag, otty_flag;  int ostdin_null_flag, ono_shell_flag, otty_flag, orequest_tty;
   
 /*  /*
  * Flag indicating that ssh should fork after authentication.  This is useful   * Flag indicating that ssh should fork after authentication.  This is useful
Line 377 
Line 375 
 #endif  #endif
                         break;                          break;
                 case 't':                  case 't':
                         if (tty_flag)                          if (options.request_tty == REQUEST_TTY_YES)
                                 force_tty_flag = 1;                                  options.request_tty = REQUEST_TTY_FORCE;
                         tty_flag = 1;                          else
                                   options.request_tty = REQUEST_TTY_YES;
                         break;                          break;
                 case 'v':                  case 'v':
                         if (debug_flag == 0) {                          if (debug_flag == 0) {
Line 422 
Line 421 
                                     optarg);                                      optarg);
                                 exit(255);                                  exit(255);
                         }                          }
                         no_tty_flag = 1;                          options.request_tty = REQUEST_TTY_NO;
                         no_shell_flag = 1;                          no_shell_flag = 1;
                         options.clear_forwardings = 1;                          options.clear_forwardings = 1;
                         options.exit_on_forward_failure = 1;                          options.exit_on_forward_failure = 1;
Line 531 
Line 530 
                         break;                          break;
                 case 'N':                  case 'N':
                         no_shell_flag = 1;                          no_shell_flag = 1;
                         no_tty_flag = 1;                          options.request_tty = REQUEST_TTY_NO;
                         break;                          break;
                 case 'T':                  case 'T':
                         no_tty_flag = 1;                          options.request_tty = REQUEST_TTY_NO;
                         break;                          break;
                 case 'o':                  case 'o':
                         dummy = 1;                          dummy = 1;
Line 594 
Line 593 
         /* Initialize the command to execute on remote host. */          /* Initialize the command to execute on remote host. */
         buffer_init(&command);          buffer_init(&command);
   
           if (options.request_tty == REQUEST_TTY_YES ||
               options.request_tty == REQUEST_TTY_FORCE)
                   tty_flag = 1;
   
         /*          /*
          * Save the command to execute on the remote host in a buffer. There           * Save the command to execute on the remote host in a buffer. There
          * is no limit on the length of the command, except by the maximum           * is no limit on the length of the command, except by the maximum
Line 601 
Line 604 
          */           */
         if (!ac) {          if (!ac) {
                 /* No command specified - execute shell on a tty. */                  /* No command specified - execute shell on a tty. */
                 tty_flag = 1;                  tty_flag = options.request_tty != REQUEST_TTY_NO;
                 if (subsystem_flag) {                  if (subsystem_flag) {
                         fprintf(stderr,                          fprintf(stderr,
                             "You must specify a subsystem to invoke.\n");                              "You must specify a subsystem to invoke.\n");
Line 624 
Line 627 
   
         /* Allocate a tty by default if no command specified. */          /* Allocate a tty by default if no command specified. */
         if (buffer_len(&command) == 0)          if (buffer_len(&command) == 0)
                 tty_flag = 1;                  tty_flag = options.request_tty != REQUEST_TTY_NO;
   
         /* Force no tty */          /* Force no tty */
         if (no_tty_flag || muxclient_command != 0)          if (options.request_tty == REQUEST_TTY_NO || muxclient_command != 0)
                 tty_flag = 0;                  tty_flag = 0;
         /* Do not allocate a tty if stdin is not a tty. */          /* Do not allocate a tty if stdin is not a tty. */
         if ((!isatty(fileno(stdin)) || stdin_null_flag) && !force_tty_flag) {          if ((!isatty(fileno(stdin)) || stdin_null_flag) &&
               options.request_tty != REQUEST_TTY_FORCE) {
                 if (tty_flag)                  if (tty_flag)
                         logit("Pseudo-terminal will not be allocated because "                          logit("Pseudo-terminal will not be allocated because "
                             "stdin is not a terminal.");                              "stdin is not a terminal.");
Line 912 
Line 916 
                 /* Parent: set up mux slave to connect to backgrounded master */                  /* Parent: set up mux slave to connect to backgrounded master */
                 debug2("%s: background process is %ld", __func__, (long)pid);                  debug2("%s: background process is %ld", __func__, (long)pid);
                 stdin_null_flag = ostdin_null_flag;                  stdin_null_flag = ostdin_null_flag;
                 no_shell_flag = ono_shell_flag;                  options.request_tty = orequest_tty;
                 no_tty_flag = ono_tty_flag;  
                 tty_flag = otty_flag;                  tty_flag = otty_flag;
                 close(muxserver_sock);                  close(muxserver_sock);
                 muxserver_sock = -1;                  muxserver_sock = -1;
Line 1360 
Line 1363 
         if (options.control_persist && muxserver_sock != -1) {          if (options.control_persist && muxserver_sock != -1) {
                 ostdin_null_flag = stdin_null_flag;                  ostdin_null_flag = stdin_null_flag;
                 ono_shell_flag = no_shell_flag;                  ono_shell_flag = no_shell_flag;
                 ono_tty_flag = no_tty_flag;                  orequest_tty = options.request_tty;
                 otty_flag = tty_flag;                  otty_flag = tty_flag;
                 stdin_null_flag = 1;                  stdin_null_flag = 1;
                 no_shell_flag = 1;                  no_shell_flag = 1;
                 no_tty_flag = 1;                  options.request_tty == REQUEST_TTY_NO;
                 tty_flag = 0;                  tty_flag = 0;
                 if (!fork_after_authentication_flag)                  if (!fork_after_authentication_flag)
                         need_controlpersist_detach = 1;                          need_controlpersist_detach = 1;

Legend:
Removed from v.1.358  
changed lines
  Added in v.1.359