View | Details | Raw Unified | Return to bug 1352 | Differences between
and this patch

Collapse All | Expand All

(-)servconf.c (-1 / +8 lines)
Lines 115-120 initialize_server_options(ServerOptions Link Here
115
	options->permit_tun = -1;
115
	options->permit_tun = -1;
116
	options->num_permitted_opens = -1;
116
	options->num_permitted_opens = -1;
117
	options->adm_forced_command = NULL;
117
	options->adm_forced_command = NULL;
118
	options->chroot_directory = NULL;
118
}
119
}
119
120
120
void
121
void
Lines 266-272 typedef enum { Link Here
266
	sHostbasedUsesNameFromPacketOnly, sClientAliveInterval,
267
	sHostbasedUsesNameFromPacketOnly, sClientAliveInterval,
267
	sClientAliveCountMax, sAuthorizedKeysFile, sAuthorizedKeysFile2,
268
	sClientAliveCountMax, sAuthorizedKeysFile, sAuthorizedKeysFile2,
268
	sGssAuthentication, sGssCleanupCreds, sAcceptEnv, sPermitTunnel,
269
	sGssAuthentication, sGssCleanupCreds, sAcceptEnv, sPermitTunnel,
269
	sMatch, sPermitOpen, sForceCommand,
270
	sMatch, sPermitOpen, sForceCommand, sChrootDirectory,
270
	sUsePrivilegeSeparation,
271
	sUsePrivilegeSeparation,
271
	sDeprecated, sUnsupported
272
	sDeprecated, sUnsupported
272
} ServerOpCodes;
273
} ServerOpCodes;
Lines 366-371 static struct { Link Here
366
	{ "match", sMatch, SSHCFG_ALL },
367
	{ "match", sMatch, SSHCFG_ALL },
367
	{ "permitopen", sPermitOpen, SSHCFG_ALL },
368
	{ "permitopen", sPermitOpen, SSHCFG_ALL },
368
	{ "forcecommand", sForceCommand, SSHCFG_ALL },
369
	{ "forcecommand", sForceCommand, SSHCFG_ALL },
370
	{ "chrootdirectory", sChrootDirectory, SSHCFG_ALL },
369
	{ NULL, sBadOption, 0 }
371
	{ NULL, sBadOption, 0 }
370
};
372
};
371
373
Lines 1210-1215 parse_flag: Link Here
1210
			options->adm_forced_command = xstrdup(cp + len);
1212
			options->adm_forced_command = xstrdup(cp + len);
1211
		return 0;
1213
		return 0;
1212
1214
1215
	case sChrootDirectory:
1216
		charptr = &options->chroot_directory;
1217
		goto parse_filename;
1218
1213
	case sDeprecated:
1219
	case sDeprecated:
1214
		logit("%s line %d: Deprecated option %s",
1220
		logit("%s line %d: Deprecated option %s",
1215
		    filename, linenum, arg);
1221
		    filename, linenum, arg);
Lines 1317-1322 copy_set_server_options(ServerOptions *d Link Here
1317
	if (preauth)
1323
	if (preauth)
1318
		return;
1324
		return;
1319
	M_CP_STROPT(adm_forced_command);
1325
	M_CP_STROPT(adm_forced_command);
1326
	M_CP_STROPT(chroot_directory);
1320
}
1327
}
1321
1328
1322
#undef M_CP_INTOPT
1329
#undef M_CP_INTOPT
(-)servconf.h (+2 lines)
Lines 139-144 typedef struct { Link Here
139
	int	permit_tun;
139
	int	permit_tun;
140
140
141
	int	num_permitted_opens;
141
	int	num_permitted_opens;
142
143
	char   *chroot_directory;
142
}       ServerOptions;
144
}       ServerOptions;
143
145
144
void	 initialize_server_options(ServerOptions *);
146
void	 initialize_server_options(ServerOptions *);
(-)session.c (-3 / +27 lines)
Lines 73-78 Link Here
73
#include "sshlogin.h"
73
#include "sshlogin.h"
74
#include "serverloop.h"
74
#include "serverloop.h"
75
#include "canohost.h"
75
#include "canohost.h"
76
#include "misc.h"
76
#include "session.h"
77
#include "session.h"
77
#ifdef GSSAPI
78
#ifdef GSSAPI
78
#include "ssh-gss.h"
79
#include "ssh-gss.h"
Lines 117-123 extern Buffer loginmsg; Link Here
117
const char *original_command = NULL;
118
const char *original_command = NULL;
118
119
119
/* data */
120
/* data */
120
#define MAX_SESSIONS 10
121
#define MAX_SESSIONS 20
121
Session	sessions[MAX_SESSIONS];
122
Session	sessions[MAX_SESSIONS];
122
123
123
#ifdef HAVE_LOGIN_CAP
124
#ifdef HAVE_LOGIN_CAP
Lines 560-566 do_exec(Session *s, const char *command) Link Here
560
		restore_uid();
561
		restore_uid();
561
	}
562
	}
562
#endif
563
#endif
563
564
	if (s->ttyfd != -1)
564
	if (s->ttyfd != -1)
565
		do_exec_pty(s, command);
565
		do_exec_pty(s, command);
566
	else
566
	else
Lines 964-972 void Link Here
964
do_setusercontext(struct passwd *pw)
964
do_setusercontext(struct passwd *pw)
965
{
965
{
966
	if (getuid() == 0 || geteuid() == 0) {
966
	if (getuid() == 0 || geteuid() == 0) {
967
		/* Prepare groups */
967
#ifdef HAVE_LOGIN_CAP
968
#ifdef HAVE_LOGIN_CAP
968
		if (setusercontext(lc, pw, pw->pw_uid,
969
		if (setusercontext(lc, pw, pw->pw_uid,
969
		    (LOGIN_SETALL & ~LOGIN_SETPATH)) < 0) {
970
		    (LOGIN_SETALL & ~(LOGIN_SETPATH|LOGIN_SETUSER))) < 0) {
970
			perror("unable to set user context");
971
			perror("unable to set user context");
971
			exit(1);
972
			exit(1);
972
		}
973
		}
Lines 983-989 do_setusercontext(struct passwd *pw) Link Here
983
			exit(1);
984
			exit(1);
984
		}
985
		}
985
		endgrent();
986
		endgrent();
987
#endif
988
989
		if (options.chroot_directory != NULL) {
990
			char *chroot_path;
991
992
			chroot_path = percent_expand(options.chroot_directory,
993
			    "h", pw->pw_dir, "u", pw->pw_name, (char *)NULL);
994
			if (chdir(chroot_path) == -1)
995
				fatal("Unable to chdir to chroot path \"%s\": "
996
				    "%s", chroot_path, strerror(errno));
997
			if (chroot(chroot_path) == -1)
998
				fatal("chroot(\"%s\"): %s", chroot_path,
999
				    strerror(errno));
1000
			verbose("Changed root to \"%s\"", chroot_path);
1001
			free(chroot_path);
1002
		}
986
1003
1004
		/* Set UID */
1005
#ifdef HAVE_LOGIN_CAP
1006
		if (setusercontext(lc, pw, pw->pw_uid, LOGIN_SETUSER) < 0) {
1007
			perror("unable to set user context (setuser)");
1008
			exit(1);
1009
		}
1010
#else
987
		/* Permanently switch to the desired uid. */
1011
		/* Permanently switch to the desired uid. */
988
		permanently_set_uid(pw);
1012
		permanently_set_uid(pw);
989
#endif
1013
#endif

Return to bug 1352