View | Details | Raw Unified | Return to bug 1606
Collapse All | Expand All

(-)session.c (-10 / +17 lines)
Lines 131-139 static int sessions_first_unused = -1; Link Here
131
static int sessions_nalloc = 0;
131
static int sessions_nalloc = 0;
132
static Session *sessions = NULL;
132
static Session *sessions = NULL;
133
133
134
#define SUBSYSTEM_NONE		0
134
#define SUBSYSTEM_NONE			0
135
#define SUBSYSTEM_EXT		1
135
#define SUBSYSTEM_EXT			1
136
#define SUBSYSTEM_INT_SFTP	2
136
#define SUBSYSTEM_INT_SFTP		2
137
#define SUBSYSTEM_INT_SFTP_ERROR	3
137
138
138
login_cap_t *lc;
139
login_cap_t *lc;
139
140
Lines 707-723 do_exec(Session *s, const char *command) Link Here
707
	if (options.adm_forced_command) {
708
	if (options.adm_forced_command) {
708
		original_command = command;
709
		original_command = command;
709
		command = options.adm_forced_command;
710
		command = options.adm_forced_command;
710
		if (IS_INTERNAL_SFTP(command))
711
		if (IS_INTERNAL_SFTP(command)) {
711
			s->is_subsystem = SUBSYSTEM_INT_SFTP;
712
			s->is_subsystem = s->is_subsystem ?
712
		else if (s->is_subsystem)
713
			    SUBSYSTEM_INT_SFTP : SUBSYSTEM_INT_SFTP_ERROR;
714
		} else if (s->is_subsystem)
713
			s->is_subsystem = SUBSYSTEM_EXT;
715
			s->is_subsystem = SUBSYSTEM_EXT;
714
		debug("Forced command (config) '%.900s'", command);
716
		debug("Forced command (config) '%.900s'", command);
715
	} else if (forced_command) {
717
	} else if (forced_command) {
716
		original_command = command;
718
		original_command = command;
717
		command = forced_command;
719
		command = forced_command;
718
		if (IS_INTERNAL_SFTP(command))
720
		if (IS_INTERNAL_SFTP(command)) {
719
			s->is_subsystem = SUBSYSTEM_INT_SFTP;
721
			s->is_subsystem = s->is_subsystem ?
720
		else if (s->is_subsystem)
722
			    SUBSYSTEM_INT_SFTP : SUBSYSTEM_INT_SFTP_ERROR;
723
		} else if (s->is_subsystem)
721
			s->is_subsystem = SUBSYSTEM_EXT;
724
			s->is_subsystem = SUBSYSTEM_EXT;
722
		debug("Forced command (key option) '%.900s'", command);
725
		debug("Forced command (key option) '%.900s'", command);
723
	}
726
	}
Lines 1387-1393 do_child(Session *s, const char *command Link Here
1387
	/* restore SIGPIPE for child */
1390
	/* restore SIGPIPE for child */
1388
	signal(SIGPIPE, SIG_DFL);
1391
	signal(SIGPIPE, SIG_DFL);
1389
1392
1390
	if (s->is_subsystem == SUBSYSTEM_INT_SFTP) {
1393
	if (s->is_subsystem == SUBSYSTEM_INT_SFTP_ERROR) {
1394
		printf("This service allows sftp connections only.\n");
1395
		fflush(NULL);
1396
		exit(1);
1397
	} else if (s->is_subsystem == SUBSYSTEM_INT_SFTP) {
1391
		extern int optind, optreset;
1398
		extern int optind, optreset;
1392
		int i;
1399
		int i;
1393
		char *p, *args;
1400
		char *p, *args;

Return to bug 1606