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

Diff for /src/usr.bin/ssh/session.c between version 1.224 and 1.225

version 1.224, 2007/09/11 15:47:17 version 1.225, 2008/02/04 21:53:00
Line 79 
Line 79 
 #include "ssh-gss.h"  #include "ssh-gss.h"
 #endif  #endif
 #include "monitor_wrap.h"  #include "monitor_wrap.h"
   #include "sftp.h"
   
 #ifdef KRB5  #ifdef KRB5
 #include <kafs.h>  #include <kafs.h>
Line 121 
Line 122 
 #define MAX_SESSIONS 10  #define MAX_SESSIONS 10
 Session sessions[MAX_SESSIONS];  Session sessions[MAX_SESSIONS];
   
   #define SUBSYSTEM_NONE          0
   #define SUBSYSTEM_EXT           1
   #define SUBSYSTEM_INT_SFTP      2
   
 login_cap_t *lc;  login_cap_t *lc;
   
 static int is_child = 0;  static int is_child = 0;
Line 545 
Line 550 
         if (options.adm_forced_command) {          if (options.adm_forced_command) {
                 original_command = command;                  original_command = command;
                 command = options.adm_forced_command;                  command = options.adm_forced_command;
                   if (s->is_subsystem)
                           s->is_subsystem = SUBSYSTEM_EXT;
                 debug("Forced command (config) '%.900s'", command);                  debug("Forced command (config) '%.900s'", command);
         } else if (forced_command) {          } else if (forced_command) {
                 original_command = command;                  original_command = command;
                 command = forced_command;                  command = forced_command;
                   if (s->is_subsystem)
                           s->is_subsystem = SUBSYSTEM_EXT;
                 debug("Forced command (key option) '%.900s'", command);                  debug("Forced command (key option) '%.900s'", command);
         }          }
   
Line 1026 
Line 1035 
  * environment, closing extra file descriptors, setting the user and group   * environment, closing extra file descriptors, setting the user and group
  * ids, and executing the command or shell.   * ids, and executing the command or shell.
  */   */
   #define ARGV_MAX 10
 void  void
 do_child(Session *s, const char *command)  do_child(Session *s, const char *command)
 {  {
         extern char **environ;          extern char **environ;
         char **env;          char **env;
         char *argv[10];          char *argv[ARGV_MAX];
         const char *shell, *shell0, *hostname = NULL;          const char *shell, *shell0, *hostname = NULL;
         struct passwd *pw = s->pw;          struct passwd *pw = s->pw;
   
Line 1132 
Line 1142 
         /* restore SIGPIPE for child */          /* restore SIGPIPE for child */
         signal(SIGPIPE, SIG_DFL);          signal(SIGPIPE, SIG_DFL);
   
           if (s->is_subsystem == SUBSYSTEM_INT_SFTP) {
                   extern int optind, optreset;
                   int i;
                   char *p, *args;
   
                   setproctitle("%s@internal-sftp-server", s->pw->pw_name);
                   args = strdup(command ? command : "sftp-server");
                   for (i = 0, (p = strtok(args, " ")); p; (p = strtok(NULL, " ")))
                           if (i < ARGV_MAX - 1)
                                   argv[i++] = p;
                   argv[i] = NULL;
                   optind = optreset = 1;
                   __progname = argv[0];
                   exit(sftp_server_main(i, argv));
           }
   
         if (options.use_login) {          if (options.use_login) {
                 launch_login(pw, hostname);                  launch_login(pw, hostname);
                 /* NEVERREACHED */                  /* NEVERREACHED */
Line 1404 
Line 1430 
                 if (strcmp(subsys, options.subsystem_name[i]) == 0) {                  if (strcmp(subsys, options.subsystem_name[i]) == 0) {
                         prog = options.subsystem_command[i];                          prog = options.subsystem_command[i];
                         cmd = options.subsystem_args[i];                          cmd = options.subsystem_args[i];
                         if (stat(prog, &st) < 0) {                          if (!strcmp("internal-sftp", prog)) {
                                   s->is_subsystem = SUBSYSTEM_INT_SFTP;
                           } else if (stat(prog, &st) < 0) {
                                 error("subsystem: cannot stat %s: %s", prog,                                  error("subsystem: cannot stat %s: %s", prog,
                                     strerror(errno));                                      strerror(errno));
                                 break;                                  break;
                           } else {
                                   s->is_subsystem = SUBSYSTEM_EXT;
                         }                          }
                         debug("subsystem: exec() %s", cmd);                          debug("subsystem: exec() %s", cmd);
                         s->is_subsystem = 1;  
                         do_exec(s, cmd);                          do_exec(s, cmd);
                         success = 1;                          success = 1;
                         break;                          break;

Legend:
Removed from v.1.224  
changed lines
  Added in v.1.225