summaryrefslogtreecommitdiff
path: root/session.c
diff options
context:
space:
mode:
Diffstat (limited to 'session.c')
-rw-r--r--session.c26
1 files changed, 20 insertions, 6 deletions
diff --git a/session.c b/session.c
index a2588e74b..698eaa879 100644
--- a/session.c
+++ b/session.c
@@ -984,8 +984,9 @@ read_etc_default_login(char ***env, u_int *envsize, uid_t uid)
984} 984}
985#endif /* HAVE_ETC_DEFAULT_LOGIN */ 985#endif /* HAVE_ETC_DEFAULT_LOGIN */
986 986
987void 987static void
988copy_environment(char **source, char ***env, u_int *envsize) 988copy_environment_blacklist(char **source, char ***env, u_int *envsize,
989 const char *blacklist)
989{ 990{
990 char *var_name, *var_val; 991 char *var_name, *var_val;
991 int i; 992 int i;
@@ -1001,13 +1002,22 @@ copy_environment(char **source, char ***env, u_int *envsize)
1001 } 1002 }
1002 *var_val++ = '\0'; 1003 *var_val++ = '\0';
1003 1004
1004 debug3("Copy environment: %s=%s", var_name, var_val); 1005 if (blacklist == NULL ||
1005 child_set_env(env, envsize, var_name, var_val); 1006 match_pattern_list(var_name, blacklist, 0) != 1) {
1007 debug3("Copy environment: %s=%s", var_name, var_val);
1008 child_set_env(env, envsize, var_name, var_val);
1009 }
1006 1010
1007 free(var_name); 1011 free(var_name);
1008 } 1012 }
1009} 1013}
1010 1014
1015void
1016copy_environment(char **source, char ***env, u_int *envsize)
1017{
1018 copy_environment_blacklist(source, env, envsize, NULL);
1019}
1020
1011static char ** 1021static char **
1012do_setup_env(Session *s, const char *shell) 1022do_setup_env(Session *s, const char *shell)
1013{ 1023{
@@ -1169,12 +1179,16 @@ do_setup_env(Session *s, const char *shell)
1169 if (options.use_pam) { 1179 if (options.use_pam) {
1170 char **p; 1180 char **p;
1171 1181
1182 /*
1183 * Don't allow SSH_AUTH_INFO variables posted to PAM to leak
1184 * back into the environment.
1185 */
1172 p = fetch_pam_child_environment(); 1186 p = fetch_pam_child_environment();
1173 copy_environment(p, &env, &envsize); 1187 copy_environment_blacklist(p, &env, &envsize, "SSH_AUTH_INFO*");
1174 free_pam_environment(p); 1188 free_pam_environment(p);
1175 1189
1176 p = fetch_pam_environment(); 1190 p = fetch_pam_environment();
1177 copy_environment(p, &env, &envsize); 1191 copy_environment_blacklist(p, &env, &envsize, "SSH_AUTH_INFO*");
1178 free_pam_environment(p); 1192 free_pam_environment(p);
1179 } 1193 }
1180#endif /* USE_PAM */ 1194#endif /* USE_PAM */