diff options
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | openbsd-compat/bsd-cygwin_util.c | 54 | ||||
-rw-r--r-- | openbsd-compat/bsd-cygwin_util.h | 4 | ||||
-rw-r--r-- | session.c | 8 |
4 files changed, 68 insertions, 5 deletions
@@ -1,3 +1,8 @@ | |||
1 | 20040830 | ||
2 | - (dtucker) [session.c openbsd-compat/bsd-cygwin_util.{c,h}] Bug #915: only | ||
3 | copy required environment variables on Cygwin. Patch from vinschen at | ||
4 | redhat.com, ok djm@ | ||
5 | |||
1 | 20040829 | 6 | 20040829 |
2 | - (dtucker) [openbsd-compat/getrrsetbyname.c] Prevent getrrsetbyname from | 7 | - (dtucker) [openbsd-compat/getrrsetbyname.c] Prevent getrrsetbyname from |
3 | failing with NOMEMORY if no sigs are returned and malloc(0) returns NULL. | 8 | failing with NOMEMORY if no sigs are returned and malloc(0) returns NULL. |
@@ -1707,4 +1712,4 @@ | |||
1707 | - (djm) Trim deprecated options from INSTALL. Mention UsePAM | 1712 | - (djm) Trim deprecated options from INSTALL. Mention UsePAM |
1708 | - (djm) Fix quote handling in sftp; Patch from admorten AT umich.edu | 1713 | - (djm) Fix quote handling in sftp; Patch from admorten AT umich.edu |
1709 | 1714 | ||
1710 | $Id: ChangeLog,v 1.3536 2004/08/29 11:43:33 dtucker Exp $ | 1715 | $Id: ChangeLog,v 1.3537 2004/08/30 10:42:08 dtucker Exp $ |
diff --git a/openbsd-compat/bsd-cygwin_util.c b/openbsd-compat/bsd-cygwin_util.c index 92cdba6e0..f53abb6e2 100644 --- a/openbsd-compat/bsd-cygwin_util.c +++ b/openbsd-compat/bsd-cygwin_util.c | |||
@@ -29,7 +29,7 @@ | |||
29 | 29 | ||
30 | #include "includes.h" | 30 | #include "includes.h" |
31 | 31 | ||
32 | RCSID("$Id: bsd-cygwin_util.c,v 1.12 2004/04/18 11:15:45 djm Exp $"); | 32 | RCSID("$Id: bsd-cygwin_util.c,v 1.13 2004/08/30 10:42:08 dtucker Exp $"); |
33 | 33 | ||
34 | #ifdef HAVE_CYGWIN | 34 | #ifdef HAVE_CYGWIN |
35 | 35 | ||
@@ -38,6 +38,7 @@ RCSID("$Id: bsd-cygwin_util.c,v 1.12 2004/04/18 11:15:45 djm Exp $"); | |||
38 | #include <sys/utsname.h> | 38 | #include <sys/utsname.h> |
39 | #include <sys/vfs.h> | 39 | #include <sys/vfs.h> |
40 | #include <windows.h> | 40 | #include <windows.h> |
41 | #include "xmalloc.h" | ||
41 | #define is_winnt (GetVersion() < 0x80000000) | 42 | #define is_winnt (GetVersion() < 0x80000000) |
42 | 43 | ||
43 | #define ntsec_on(c) ((c) && strstr((c),"ntsec") && !strstr((c),"nontsec")) | 44 | #define ntsec_on(c) ((c) && strstr((c),"ntsec") && !strstr((c),"nontsec")) |
@@ -96,7 +97,6 @@ has_capability(int what) | |||
96 | */ | 97 | */ |
97 | if (!inited) { | 98 | if (!inited) { |
98 | struct utsname uts; | 99 | struct utsname uts; |
99 | char *c; | ||
100 | 100 | ||
101 | if (!uname(&uts)) { | 101 | if (!uname(&uts)) { |
102 | int major_high = 0, major_low = 0, minor = 0; | 102 | int major_high = 0, major_low = 0, minor = 0; |
@@ -236,4 +236,54 @@ register_9x_service(void) | |||
236 | RegisterServiceProcess(0, 1); | 236 | RegisterServiceProcess(0, 1); |
237 | } | 237 | } |
238 | 238 | ||
239 | #define NL(x) x, (sizeof (x) - 1) | ||
240 | #define WENV_SIZ (sizeof (wenv_arr) / sizeof (wenv_arr[0])) | ||
241 | |||
242 | static struct wenv { | ||
243 | const char *name; | ||
244 | size_t namelen; | ||
245 | } wenv_arr[] = { | ||
246 | { NL("ALLUSERSPROFILE=") }, | ||
247 | { NL("COMMONPROGRAMFILES=") }, | ||
248 | { NL("COMPUTERNAME=") }, | ||
249 | { NL("COMSPEC=") }, | ||
250 | { NL("NUMBER_OF_PROCESSORS=") }, | ||
251 | { NL("OS=") }, | ||
252 | { NL("PATH=") }, | ||
253 | { NL("PATHEXT=") }, | ||
254 | { NL("PROCESSOR_ARCHITECTURE=") }, | ||
255 | { NL("PROCESSOR_IDENTIFIER=") }, | ||
256 | { NL("PROCESSOR_LEVEL=") }, | ||
257 | { NL("PROCESSOR_REVISION=") }, | ||
258 | { NL("PROGRAMFILES=") }, | ||
259 | { NL("SYSTEMDRIVE=") }, | ||
260 | { NL("SYSTEMROOT=") }, | ||
261 | { NL("TMP=") }, | ||
262 | { NL("TEMP=") }, | ||
263 | { NL("WINDIR=") }, | ||
264 | }; | ||
265 | |||
266 | char ** | ||
267 | fetch_windows_environment(void) | ||
268 | { | ||
269 | char **e, **p; | ||
270 | int i, idx = 0; | ||
271 | |||
272 | p = xmalloc(WENV_SIZ * sizeof(char *)); | ||
273 | for (e = environ; *e != NULL; ++e) { | ||
274 | for (i = 0; i < WENV_SIZ; ++i) { | ||
275 | if (!strncmp(*e, wenv_arr[i].name, wenv_arr[i].namelen)) | ||
276 | p[idx++] = *e; | ||
277 | } | ||
278 | } | ||
279 | p[idx] = NULL; | ||
280 | return p; | ||
281 | } | ||
282 | |||
283 | void | ||
284 | free_windows_environment(char **p) | ||
285 | { | ||
286 | xfree(p); | ||
287 | } | ||
288 | |||
239 | #endif /* HAVE_CYGWIN */ | 289 | #endif /* HAVE_CYGWIN */ |
diff --git a/openbsd-compat/bsd-cygwin_util.h b/openbsd-compat/bsd-cygwin_util.h index 5ccb0fba2..6719b8a49 100644 --- a/openbsd-compat/bsd-cygwin_util.h +++ b/openbsd-compat/bsd-cygwin_util.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $Id: bsd-cygwin_util.h,v 1.10 2003/08/07 06:28:16 dtucker Exp $ */ | 1 | /* $Id: bsd-cygwin_util.h,v 1.11 2004/08/30 10:42:08 dtucker Exp $ */ |
2 | 2 | ||
3 | /* | 3 | /* |
4 | * Copyright (c) 2000, 2001, Corinna Vinschen <vinschen@cygnus.com> | 4 | * Copyright (c) 2000, 2001, Corinna Vinschen <vinschen@cygnus.com> |
@@ -46,6 +46,8 @@ int binary_pipe(int fd[2]); | |||
46 | int check_nt_auth(int, struct passwd *); | 46 | int check_nt_auth(int, struct passwd *); |
47 | int check_ntsec(const char *); | 47 | int check_ntsec(const char *); |
48 | void register_9x_service(void); | 48 | void register_9x_service(void); |
49 | char **fetch_windows_environment(void); | ||
50 | void free_windows_environment(char **); | ||
49 | 51 | ||
50 | #define open binary_open | 52 | #define open binary_open |
51 | #define pipe binary_pipe | 53 | #define pipe binary_pipe |
@@ -979,7 +979,13 @@ do_setup_env(Session *s, const char *shell) | |||
979 | * The Windows environment contains some setting which are | 979 | * The Windows environment contains some setting which are |
980 | * important for a running system. They must not be dropped. | 980 | * important for a running system. They must not be dropped. |
981 | */ | 981 | */ |
982 | copy_environment(environ, &env, &envsize); | 982 | { |
983 | char **p; | ||
984 | |||
985 | p = fetch_windows_environment(); | ||
986 | copy_environment(p, &env, &envsize); | ||
987 | free_windows_environment(p); | ||
988 | } | ||
983 | #endif | 989 | #endif |
984 | 990 | ||
985 | #ifdef GSSAPI | 991 | #ifdef GSSAPI |