- (djm) Merge Cygwin copy_environment with do_pam_environment, removing
fixed env var size limit in the process. Report from Corinna Vinschen <vinschen@redhat.com>
This commit is contained in:
parent
f49a1191c7
commit
bb9ffc18ca
|
@ -1,3 +1,8 @@
|
||||||
|
20020108
|
||||||
|
- (djm) Merge Cygwin copy_environment with do_pam_environment, removing
|
||||||
|
fixed env var size limit in the process. Report from Corinna Vinschen
|
||||||
|
<vinschen@redhat.com>
|
||||||
|
|
||||||
20020106
|
20020106
|
||||||
- (stevesk) defines.h: determine _PATH_UNIX_X; currently "/tmp/.X11-unix/X%u"
|
- (stevesk) defines.h: determine _PATH_UNIX_X; currently "/tmp/.X11-unix/X%u"
|
||||||
for all platforms except HP-UX, which is "/usr/spool/sockets/X11/%u".
|
for all platforms except HP-UX, which is "/usr/spool/sockets/X11/%u".
|
||||||
|
@ -7126,4 +7131,4 @@
|
||||||
- Wrote replacements for strlcpy and mkdtemp
|
- Wrote replacements for strlcpy and mkdtemp
|
||||||
- Released 1.0pre1
|
- Released 1.0pre1
|
||||||
|
|
||||||
$Id: ChangeLog,v 1.1717 2002/01/06 02:32:57 stevesk Exp $
|
$Id: ChangeLog,v 1.1718 2002/01/07 23:59:32 djm Exp $
|
||||||
|
|
64
session.c
64
session.c
|
@ -885,62 +885,28 @@ read_environment_file(char ***env, u_int *envsize,
|
||||||
fclose(f);
|
fclose(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_PAM
|
void copy_environment(char **source, char ***env, u_int *envsize)
|
||||||
/*
|
|
||||||
* Sets any environment variables which have been specified by PAM
|
|
||||||
*/
|
|
||||||
void do_pam_environment(char ***env, u_int *envsize)
|
|
||||||
{
|
{
|
||||||
char *equals, var_name[512], var_val[512];
|
char *var_name, *var_val;
|
||||||
char **pam_env;
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if ((pam_env = fetch_pam_environment()) == NULL)
|
if (source == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for(i = 0; pam_env[i] != NULL; i++) {
|
for(i = 0; source[i] != NULL; i++) {
|
||||||
if ((equals = strstr(pam_env[i], "=")) == NULL)
|
var_name = xstrdup(source[i]);
|
||||||
|
if ((var_val = strstr(var_name, "=")) == NULL) {
|
||||||
|
xfree(var_name);
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (strlen(pam_env[i]) < (sizeof(var_name) - 1)) {
|
|
||||||
memset(var_name, '\0', sizeof(var_name));
|
|
||||||
memset(var_val, '\0', sizeof(var_val));
|
|
||||||
|
|
||||||
strncpy(var_name, pam_env[i], equals - pam_env[i]);
|
|
||||||
strcpy(var_val, equals + 1);
|
|
||||||
|
|
||||||
debug3("PAM environment: %s=%s", var_name, var_val);
|
|
||||||
|
|
||||||
child_set_env(env, envsize, var_name, var_val);
|
|
||||||
}
|
}
|
||||||
|
*var_val++ = '\0';
|
||||||
|
|
||||||
|
debug3("Copy environment: %s=%s", var_name, var_val);
|
||||||
|
child_set_env(env, envsize, var_name, var_val);
|
||||||
|
|
||||||
|
xfree(var_name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* USE_PAM */
|
|
||||||
|
|
||||||
#ifdef HAVE_CYGWIN
|
|
||||||
void copy_environment(char ***env, u_int *envsize)
|
|
||||||
{
|
|
||||||
char *equals, var_name[512], var_val[512];
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for(i = 0; environ[i] != NULL; i++) {
|
|
||||||
if ((equals = strstr(environ[i], "=")) == NULL)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (strlen(environ[i]) < (sizeof(var_name) - 1)) {
|
|
||||||
memset(var_name, '\0', sizeof(var_name));
|
|
||||||
memset(var_val, '\0', sizeof(var_val));
|
|
||||||
|
|
||||||
strncpy(var_name, environ[i], equals - environ[i]);
|
|
||||||
strcpy(var_val, equals + 1);
|
|
||||||
|
|
||||||
debug3("Copy environment: %s=%s", var_name, var_val);
|
|
||||||
|
|
||||||
child_set_env(env, envsize, var_name, var_val);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(HAVE_GETUSERATTR)
|
#if defined(HAVE_GETUSERATTR)
|
||||||
/*
|
/*
|
||||||
|
@ -1215,7 +1181,7 @@ do_child(Session *s, const char *command)
|
||||||
* The Windows environment contains some setting which are
|
* The Windows environment contains some setting which are
|
||||||
* important for a running system. They must not be dropped.
|
* important for a running system. They must not be dropped.
|
||||||
*/
|
*/
|
||||||
copy_environment(&env, &envsize);
|
copy_environment(environ, &env, &envsize);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!options.use_login) {
|
if (!options.use_login) {
|
||||||
|
@ -1299,7 +1265,7 @@ do_child(Session *s, const char *command)
|
||||||
#endif
|
#endif
|
||||||
#ifdef USE_PAM
|
#ifdef USE_PAM
|
||||||
/* Pull in any environment variables that may have been set by PAM. */
|
/* Pull in any environment variables that may have been set by PAM. */
|
||||||
do_pam_environment(&env, &envsize);
|
copy_environment(fetch_pam_environment(), &env, &envsize);
|
||||||
#endif /* USE_PAM */
|
#endif /* USE_PAM */
|
||||||
|
|
||||||
if (auth_get_socket_name() != NULL)
|
if (auth_get_socket_name() != NULL)
|
||||||
|
|
Loading…
Reference in New Issue