version 1.247, 2009/10/06 04:46:40 |
version 1.248, 2009/11/19 23:39:50 |
|
|
static int sessions_nalloc = 0; |
static int sessions_nalloc = 0; |
static Session *sessions = NULL; |
static Session *sessions = NULL; |
|
|
#define SUBSYSTEM_NONE 0 |
#define SUBSYSTEM_NONE 0 |
#define SUBSYSTEM_EXT 1 |
#define SUBSYSTEM_EXT 1 |
#define SUBSYSTEM_INT_SFTP 2 |
#define SUBSYSTEM_INT_SFTP 2 |
|
#define SUBSYSTEM_INT_SFTP_ERROR 3 |
|
|
login_cap_t *lc; |
login_cap_t *lc; |
|
|
|
|
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 (IS_INTERNAL_SFTP(command)) |
if (IS_INTERNAL_SFTP(command)) { |
s->is_subsystem = SUBSYSTEM_INT_SFTP; |
s->is_subsystem = s->is_subsystem ? |
else if (s->is_subsystem) |
SUBSYSTEM_INT_SFTP : SUBSYSTEM_INT_SFTP_ERROR; |
|
} else if (s->is_subsystem) |
s->is_subsystem = SUBSYSTEM_EXT; |
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 (IS_INTERNAL_SFTP(command)) |
if (IS_INTERNAL_SFTP(command)) { |
s->is_subsystem = SUBSYSTEM_INT_SFTP; |
s->is_subsystem = s->is_subsystem ? |
else if (s->is_subsystem) |
SUBSYSTEM_INT_SFTP : SUBSYSTEM_INT_SFTP_ERROR; |
|
} else if (s->is_subsystem) |
s->is_subsystem = SUBSYSTEM_EXT; |
s->is_subsystem = SUBSYSTEM_EXT; |
debug("Forced command (key option) '%.900s'", command); |
debug("Forced command (key option) '%.900s'", command); |
} |
} |
|
|
/* restore SIGPIPE for child */ |
/* restore SIGPIPE for child */ |
signal(SIGPIPE, SIG_DFL); |
signal(SIGPIPE, SIG_DFL); |
|
|
if (s->is_subsystem == SUBSYSTEM_INT_SFTP) { |
if (s->is_subsystem == SUBSYSTEM_INT_SFTP_ERROR) { |
|
printf("This service allows sftp connections only.\n"); |
|
fflush(NULL); |
|
exit(1); |
|
} else if (s->is_subsystem == SUBSYSTEM_INT_SFTP) { |
extern int optind, optreset; |
extern int optind, optreset; |
int i; |
int i; |
char *p, *args; |
char *p, *args; |