diff options
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | session.c | 62 |
2 files changed, 20 insertions, 49 deletions
@@ -1,3 +1,8 @@ | |||
1 | 20020108 | ||
2 | - (djm) Merge Cygwin copy_environment with do_pam_environment, removing | ||
3 | fixed env var size limit in the process. Report from Corinna Vinschen | ||
4 | <vinschen@redhat.com> | ||
5 | |||
1 | 20020106 | 6 | 20020106 |
2 | - (stevesk) defines.h: determine _PATH_UNIX_X; currently "/tmp/.X11-unix/X%u" | 7 | - (stevesk) defines.h: determine _PATH_UNIX_X; currently "/tmp/.X11-unix/X%u" |
3 | for all platforms except HP-UX, which is "/usr/spool/sockets/X11/%u". | 8 | for all platforms except HP-UX, which is "/usr/spool/sockets/X11/%u". |
@@ -7126,4 +7131,4 @@ | |||
7126 | - Wrote replacements for strlcpy and mkdtemp | 7131 | - Wrote replacements for strlcpy and mkdtemp |
7127 | - Released 1.0pre1 | 7132 | - Released 1.0pre1 |
7128 | 7133 | ||
7129 | $Id: ChangeLog,v 1.1717 2002/01/06 02:32:57 stevesk Exp $ | 7134 | $Id: ChangeLog,v 1.1718 2002/01/07 23:59:32 djm Exp $ |
@@ -885,62 +885,28 @@ read_environment_file(char ***env, u_int *envsize, | |||
885 | fclose(f); | 885 | fclose(f); |
886 | } | 886 | } |
887 | 887 | ||
888 | #ifdef USE_PAM | 888 | void copy_environment(char **source, char ***env, u_int *envsize) |
889 | /* | ||
890 | * Sets any environment variables which have been specified by PAM | ||
891 | */ | ||
892 | void do_pam_environment(char ***env, u_int *envsize) | ||
893 | { | 889 | { |
894 | char *equals, var_name[512], var_val[512]; | 890 | char *var_name, *var_val; |
895 | char **pam_env; | ||
896 | int i; | 891 | int i; |
897 | 892 | ||
898 | if ((pam_env = fetch_pam_environment()) == NULL) | 893 | if (source == NULL) |
899 | return; | 894 | return; |
900 | 895 | ||
901 | for(i = 0; pam_env[i] != NULL; i++) { | 896 | for(i = 0; source[i] != NULL; i++) { |
902 | if ((equals = strstr(pam_env[i], "=")) == NULL) | 897 | var_name = xstrdup(source[i]); |
898 | if ((var_val = strstr(var_name, "=")) == NULL) { | ||
899 | xfree(var_name); | ||
903 | continue; | 900 | continue; |
904 | |||
905 | if (strlen(pam_env[i]) < (sizeof(var_name) - 1)) { | ||
906 | memset(var_name, '\0', sizeof(var_name)); | ||
907 | memset(var_val, '\0', sizeof(var_val)); | ||
908 | |||
909 | strncpy(var_name, pam_env[i], equals - pam_env[i]); | ||
910 | strcpy(var_val, equals + 1); | ||
911 | |||
912 | debug3("PAM environment: %s=%s", var_name, var_val); | ||
913 | |||
914 | child_set_env(env, envsize, var_name, var_val); | ||
915 | } | 901 | } |
916 | } | 902 | *var_val++ = '\0'; |
917 | } | ||
918 | #endif /* USE_PAM */ | ||
919 | 903 | ||
920 | #ifdef HAVE_CYGWIN | 904 | debug3("Copy environment: %s=%s", var_name, var_val); |
921 | void copy_environment(char ***env, u_int *envsize) | 905 | child_set_env(env, envsize, var_name, var_val); |
922 | { | 906 | |
923 | char *equals, var_name[512], var_val[512]; | 907 | xfree(var_name); |
924 | int i; | ||
925 | |||
926 | for(i = 0; environ[i] != NULL; i++) { | ||
927 | if ((equals = strstr(environ[i], "=")) == NULL) | ||
928 | continue; | ||
929 | |||
930 | if (strlen(environ[i]) < (sizeof(var_name) - 1)) { | ||
931 | memset(var_name, '\0', sizeof(var_name)); | ||
932 | memset(var_val, '\0', sizeof(var_val)); | ||
933 | |||
934 | strncpy(var_name, environ[i], equals - environ[i]); | ||
935 | strcpy(var_val, equals + 1); | ||
936 | |||
937 | debug3("Copy environment: %s=%s", var_name, var_val); | ||
938 | |||
939 | child_set_env(env, envsize, var_name, var_val); | ||
940 | } | ||
941 | } | 908 | } |
942 | } | 909 | } |
943 | #endif | ||
944 | 910 | ||
945 | #if defined(HAVE_GETUSERATTR) | 911 | #if defined(HAVE_GETUSERATTR) |
946 | /* | 912 | /* |
@@ -1215,7 +1181,7 @@ do_child(Session *s, const char *command) | |||
1215 | * The Windows environment contains some setting which are | 1181 | * The Windows environment contains some setting which are |
1216 | * important for a running system. They must not be dropped. | 1182 | * important for a running system. They must not be dropped. |
1217 | */ | 1183 | */ |
1218 | copy_environment(&env, &envsize); | 1184 | copy_environment(environ, &env, &envsize); |
1219 | #endif | 1185 | #endif |
1220 | 1186 | ||
1221 | if (!options.use_login) { | 1187 | if (!options.use_login) { |
@@ -1299,7 +1265,7 @@ do_child(Session *s, const char *command) | |||
1299 | #endif | 1265 | #endif |
1300 | #ifdef USE_PAM | 1266 | #ifdef USE_PAM |
1301 | /* Pull in any environment variables that may have been set by PAM. */ | 1267 | /* Pull in any environment variables that may have been set by PAM. */ |
1302 | do_pam_environment(&env, &envsize); | 1268 | copy_environment(fetch_pam_environment(), &env, &envsize); |
1303 | #endif /* USE_PAM */ | 1269 | #endif /* USE_PAM */ |
1304 | 1270 | ||
1305 | if (auth_get_socket_name() != NULL) | 1271 | if (auth_get_socket_name() != NULL) |