summaryrefslogtreecommitdiff
path: root/session.c
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2000-09-29 12:12:36 +1100
committerDamien Miller <djm@mindrot.org>2000-09-29 12:12:36 +1100
commitcb5e44a440c1b310a9dc5b8b5abe32fe11ed479b (patch)
treee71546529e0058787f555ebf3c2fc03ad826bb89 /session.c
parent280e71bcb631d205fec33b1dd695263e2696a3f1 (diff)
- (djm) Clean up. Strip some unnecessary differences with OpenBSD's code,
tidy necessary differences. Use Markus' new debugN() in entropy.c
Diffstat (limited to 'session.c')
-rw-r--r--session.c66
1 files changed, 37 insertions, 29 deletions
diff --git a/session.c b/session.c
index ca12a4f73..f5bbf19d4 100644
--- a/session.c
+++ b/session.c
@@ -867,7 +867,7 @@ void do_pam_environment(char ***env, int *envsize)
867 strncpy(var_name, pam_env[i], equals - pam_env[i]); 867 strncpy(var_name, pam_env[i], equals - pam_env[i]);
868 strcpy(var_val, equals + 1); 868 strcpy(var_val, equals + 1);
869 869
870 debug("PAM environment: %s=%s", var_name, var_val); 870 debug3("PAM environment: %s=%s", var_name, var_val);
871 871
872 child_set_env(env, envsize, var_name, var_val); 872 child_set_env(env, envsize, var_name, var_val);
873 } 873 }
@@ -875,6 +875,32 @@ void do_pam_environment(char ***env, int *envsize)
875} 875}
876#endif /* USE_PAM */ 876#endif /* USE_PAM */
877 877
878
879#ifdef HAVE_CYGWIN
880void copy_environment(char ***env, int *envsize)
881{
882 char *equals, var_name[512], var_val[512];
883 int i;
884
885 for(i = 0; environ[i] != NULL; i++) {
886 if ((equals = strstr(environ[i], "=")) == NULL)
887 continue;
888
889 if (strlen(environ[i]) < (sizeof(var_name) - 1)) {
890 memset(var_name, '\0', sizeof(var_name));
891 memset(var_val, '\0', sizeof(var_val));
892
893 strncpy(var_name, environ[i], equals - environ[i]);
894 strcpy(var_val, equals + 1);
895
896 debug3("Copy environment: %s=%s", var_name, var_val);
897
898 child_set_env(env, envsize, var_name, var_val);
899 }
900 }
901}
902#endif
903
878#if defined(HAVE_GETUSERATTR) 904#if defined(HAVE_GETUSERATTR)
879/* 905/*
880 * AIX-specific login initialisation 906 * AIX-specific login initialisation
@@ -1107,15 +1133,7 @@ do_child(const char *command, struct passwd * pw, const char *term,
1107 * The Windows environment contains some setting which are 1133 * The Windows environment contains some setting which are
1108 * important for a running system. They must not be dropped. 1134 * important for a running system. They must not be dropped.
1109 */ 1135 */
1110 { 1136 copy_environment(&env, &envsize);
1111 char **ep;
1112 for (ep = environ; *ep; ++ep) {
1113 char *esp = strchr(*ep, '=');
1114 *esp = '\0';
1115 child_set_env(&env, &envsize, *ep, esp + 1);
1116 *esp = '=';
1117 }
1118 }
1119#endif 1137#endif
1120 1138
1121 if (!options.use_login) { 1139 if (!options.use_login) {
@@ -1126,8 +1144,8 @@ do_child(const char *command, struct passwd * pw, const char *term,
1126#ifdef HAVE_LOGIN_CAP 1144#ifdef HAVE_LOGIN_CAP
1127 (void) setusercontext(lc, pw, pw->pw_uid, LOGIN_SETPATH); 1145 (void) setusercontext(lc, pw, pw->pw_uid, LOGIN_SETPATH);
1128 child_set_env(&env, &envsize, "PATH", getenv("PATH")); 1146 child_set_env(&env, &envsize, "PATH", getenv("PATH"));
1129#else 1147#else /* HAVE_LOGIN_CAP */
1130#ifndef HAVE_CYGWIN 1148# ifndef HAVE_CYGWIN
1131 /* 1149 /*
1132 * There's no standard path on Windows. The path contains 1150 * There's no standard path on Windows. The path contains
1133 * important components pointing to the system directories, 1151 * important components pointing to the system directories,
@@ -1135,8 +1153,8 @@ do_child(const char *command, struct passwd * pw, const char *term,
1135 * remains intact here. 1153 * remains intact here.
1136 */ 1154 */
1137 child_set_env(&env, &envsize, "PATH", _PATH_STDPATH); 1155 child_set_env(&env, &envsize, "PATH", _PATH_STDPATH);
1138#endif 1156# endif /* HAVE_CYGWIN */
1139#endif 1157#endif /* HAVE_LOGIN_CAP */
1140 1158
1141 snprintf(buf, sizeof buf, "%.200s/%.50s", 1159 snprintf(buf, sizeof buf, "%.200s/%.50s",
1142 _PATH_MAILDIR, pw->pw_name); 1160 _PATH_MAILDIR, pw->pw_name);
@@ -1178,15 +1196,11 @@ do_child(const char *command, struct passwd * pw, const char *term,
1178 original_command); 1196 original_command);
1179 1197
1180#ifdef _AIX 1198#ifdef _AIX
1181 { 1199 if ((cp = getenv("AUTHSTATE")) != NULL)
1182 char *authstate,*krb5cc; 1200 child_set_env(&env, &envsize, "AUTHSTATE", cp);
1183 1201 if ((cp = getenv("KRB5CCNAME")) != NULL)
1184 if ((authstate = getenv("AUTHSTATE")) != NULL) 1202 child_set_env(&env, &envsize, "KRB5CCNAME", cp);
1185 child_set_env(&env,&envsize,"AUTHSTATE",authstate); 1203 read_environment_file(&env, &envsize, "/etc/environment");
1186
1187 if ((krb5cc = getenv("KRB5CCNAME")) != NULL)
1188 child_set_env(&env,&envsize,"KRB5CCNAME",krb5cc);
1189 }
1190#endif 1204#endif
1191 1205
1192#ifdef KRB4 1206#ifdef KRB4
@@ -1203,8 +1217,6 @@ do_child(const char *command, struct passwd * pw, const char *term,
1203 do_pam_environment(&env, &envsize); 1217 do_pam_environment(&env, &envsize);
1204#endif /* USE_PAM */ 1218#endif /* USE_PAM */
1205 1219
1206 read_environment_file(&env,&envsize,"/etc/environment");
1207
1208 if (xauthfile) 1220 if (xauthfile)
1209 child_set_env(&env, &envsize, "XAUTHORITY", xauthfile); 1221 child_set_env(&env, &envsize, "XAUTHORITY", xauthfile);
1210 if (auth_get_socket_name() != NULL) 1222 if (auth_get_socket_name() != NULL)
@@ -1313,13 +1325,11 @@ do_child(const char *command, struct passwd * pw, const char *term,
1313 "Running %.100s add %.100s %.100s %.100s\n", 1325 "Running %.100s add %.100s %.100s %.100s\n",
1314 options.xauth_location, display, 1326 options.xauth_location, display,
1315 auth_proto, auth_data); 1327 auth_proto, auth_data);
1316#ifndef HAVE_CYGWIN
1317 if (screen != NULL) 1328 if (screen != NULL)
1318 fprintf(stderr, 1329 fprintf(stderr,
1319 "Adding %.*s/unix%s %s %s\n", 1330 "Adding %.*s/unix%s %s %s\n",
1320 (int)(screen-display), display, 1331 (int)(screen-display), display,
1321 screen, auth_proto, auth_data); 1332 screen, auth_proto, auth_data);
1322#endif
1323 } 1333 }
1324 snprintf(cmd, sizeof cmd, "%s -q -", 1334 snprintf(cmd, sizeof cmd, "%s -q -",
1325 options.xauth_location); 1335 options.xauth_location);
@@ -1327,12 +1337,10 @@ do_child(const char *command, struct passwd * pw, const char *term,
1327 if (f) { 1337 if (f) {
1328 fprintf(f, "add %s %s %s\n", display, 1338 fprintf(f, "add %s %s %s\n", display,
1329 auth_proto, auth_data); 1339 auth_proto, auth_data);
1330#ifndef HAVE_CYGWIN
1331 if (screen != NULL) 1340 if (screen != NULL)
1332 fprintf(f, "add %.*s/unix%s %s %s\n", 1341 fprintf(f, "add %.*s/unix%s %s %s\n",
1333 (int)(screen-display), display, 1342 (int)(screen-display), display,
1334 screen, auth_proto, auth_data); 1343 screen, auth_proto, auth_data);
1335#endif
1336 pclose(f); 1344 pclose(f);
1337 } else { 1345 } else {
1338 fprintf(stderr, "Could not run %s\n", 1346 fprintf(stderr, "Could not run %s\n",