summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2012-02-10 20:56:22 +0000
committerCorinna Vinschen <corinna@vinschen.de>2012-02-10 20:56:22 +0000
commit793371f584d847db11cfbd9a900cb4bae0f234cf (patch)
tree2bdd36f2bd3dd43d4a0bfc5eb159dff4fd0af38b
parentc38a2d83730311cad68d3c2d4759dfc18a3c64f3 (diff)
downloadcygnal-793371f584d847db11cfbd9a900cb4bae0f234cf.tar.gz
cygnal-793371f584d847db11cfbd9a900cb4bae0f234cf.tar.bz2
cygnal-793371f584d847db11cfbd9a900cb4bae0f234cf.zip
* miscfuncs.cc (DEFAULT_STACKSIZE): Set to 1 Megs. Drop comment about
RLIMIT_STACK. * registry.cc (get_registry_hive_path): Expect the user hive path to be never longer than MAX_PATH. Don't prepend native NT path prefix here. Add comment. (load_registry_hive): Prepend native NT path prefix here. Additionally try to load user's classes hive. * uinfo.cc (cygheap_user::env_userprofile): Reduce size of userprofile_env_buf to MAX_PATH. Add comment.
-rw-r--r--winsup/cygwin/ChangeLog13
-rw-r--r--winsup/cygwin/miscfuncs.cc3
-rw-r--r--winsup/cygwin/registry.cc44
-rw-r--r--winsup/cygwin/uinfo.cc5
4 files changed, 51 insertions, 14 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 1c4c486c6..1b84e7cf4 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,16 @@
+2012-02-10 Corinna Vinschen <corinna@vinschen.de>
+
+ * miscfuncs.cc (DEFAULT_STACKSIZE): Set to 1 Megs. Drop comment about
+ RLIMIT_STACK.
+
+ * registry.cc (get_registry_hive_path): Expect the user hive path to
+ be never longer than MAX_PATH. Don't prepend native NT path prefix
+ here. Add comment.
+ (load_registry_hive): Prepend native NT path prefix here. Additionally
+ try to load user's classes hive.
+ * uinfo.cc (cygheap_user::env_userprofile): Reduce size of
+ userprofile_env_buf to MAX_PATH. Add comment.
+
2012-02-10 Christopher Faylor <me.cygwin2012@cgf.cx>
* syscalls.cc (setsid): On second thought, in the spirit of keeping
diff --git a/winsup/cygwin/miscfuncs.cc b/winsup/cygwin/miscfuncs.cc
index c6e37942d..85507da04 100644
--- a/winsup/cygwin/miscfuncs.cc
+++ b/winsup/cygwin/miscfuncs.cc
@@ -549,8 +549,7 @@ thread_wrapper (VOID *arg)
ExitThread (0);
}
-/* FIXME: This should be settable via setrlimit (RLIMIT_STACK). */
-#define DEFAULT_STACKSIZE (512 * 1024)
+#define DEFAULT_STACKSIZE (1024 * 1024)
HANDLE WINAPI
CygwinCreateThread (LPTHREAD_START_ROUTINE thread_func, PVOID thread_arg,
diff --git a/winsup/cygwin/registry.cc b/winsup/cygwin/registry.cc
index 2923cbe86..3047e269c 100644
--- a/winsup/cygwin/registry.cc
+++ b/winsup/cygwin/registry.cc
@@ -1,7 +1,7 @@
/* registry.cc: registry interface
Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
- 2005, 2006, 2007, 2008, 2009, 2010, 2011 Red Hat, Inc.
+ 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Red Hat, Inc.
This file is part of Cygwin.
@@ -214,6 +214,7 @@ reg_key::~reg_key ()
key_is_invalid = 1;
}
+/* The buffer path points to should be at least MAX_PATH bytes. */
PWCHAR
get_registry_hive_path (PCWSTR name, PWCHAR path)
{
@@ -241,8 +242,7 @@ get_registry_hive_path (PCWSTR name, PWCHAR path)
status);
return NULL;
}
- wcpcpy (path, L"\\??\\");
- ExpandEnvironmentStringsW (buf.Buffer, path + 4, NT_MAX_PATH - 4);
+ ExpandEnvironmentStringsW (buf.Buffer, path, MAX_PATH);
debug_printf ("ProfileImagePath for %W: %W", name, path);
return path;
}
@@ -253,32 +253,56 @@ load_registry_hive (PCWSTR name)
if (!name)
return;
- /* Fetch the path. */
+ /* Fetch the path. Prepend native NT path prefix. */
tmp_pathbuf tp;
PWCHAR path = tp.w_get ();
- if (!get_registry_hive_path (name, path))
+ if (!get_registry_hive_path (name, wcpcpy (path, L"\\??\\")))
return;
WCHAR key[256];
+ PWCHAR path_comp;
UNICODE_STRING ukey, upath;
OBJECT_ATTRIBUTES key_attr, path_attr;
NTSTATUS status;
- /* Create the object attributes for key and path. */
+ /* Create keyname and path strings and object attributes. */
wcpcpy (wcpcpy (key, L"\\Registry\\User\\"), name);
RtlInitUnicodeString (&ukey, key);
InitializeObjectAttributes (&key_attr, &ukey, OBJ_CASE_INSENSITIVE,
NULL, NULL);
- wcscat (path, L"\\NTUSER.DAT");
+ /* First try to load the "normal" registry hive, which is what the user
+ is supposed to see under HKEY_CURRENT_USER. */
+ path_comp = wcschr (path, L'\0');
+ wcpcpy (path_comp, L"\\ntuser.dat");
RtlInitUnicodeString (&upath, path);
InitializeObjectAttributes (&path_attr, &upath, OBJ_CASE_INSENSITIVE,
NULL, NULL);
- /* Load file into key. */
status = NtLoadKey (&key_attr, &path_attr);
if (!NT_SUCCESS (status))
- debug_printf ("Loading user registry hive %S into %S failed: %p",
+ {
+ debug_printf ("Loading user registry hive %S into %S failed: %p",
+ &upath, &ukey, status);
+ return;
+ }
+ debug_printf ("Loading user registry hive %S into %S SUCCEEDED: %p",
+ &upath, &ukey, status);
+ /* If loading the normal hive worked, try to load the classes hive into
+ the sibling *_Classes subkey, which is what the user is supposed to
+ see under HKEY_CLASSES_ROOT, merged with the machine-wide classes. */
+ wcscat (key, L"_Classes");
+ RtlInitUnicodeString (&ukey, key);
+ /* Path to UsrClass.dat changed in Vista to
+ \\AppData\\Local\\Microsoft\\Windows\\UsrClass.dat
+ but old path is still available via symlinks. */
+ wcpcpy (path_comp, L"\\Local Settings\\Application Data\\Microsoft\\"
+ "Windows\\UsrClass.dat");
+ RtlInitUnicodeString (&upath, path);
+ /* Load UsrClass.dat file into key. */
+ status = NtLoadKey (&key_attr, &path_attr);
+ if (!NT_SUCCESS (status))
+ debug_printf ("Loading user classes hive %S into %S failed: %p",
&upath, &ukey, status);
else
- debug_printf ("Loading user registry hive %S into %S SUCCEEDED: %p",
+ debug_printf ("Loading user classes hive %S into %S SUCCEEDED: %p",
&upath, &ukey, status);
}
diff --git a/winsup/cygwin/uinfo.cc b/winsup/cygwin/uinfo.cc
index c1a30c5b0..e0f6e910d 100644
--- a/winsup/cygwin/uinfo.cc
+++ b/winsup/cygwin/uinfo.cc
@@ -435,12 +435,13 @@ cygheap_user::env_userprofile (const char *name, size_t namelen)
if (test_uid (puserprof, name, namelen))
return puserprof;
- WCHAR userprofile_env_buf[NT_MAX_PATH];
+ /* User hive path is never longer than MAX_PATH. */
+ WCHAR userprofile_env_buf[MAX_PATH];
WCHAR win_id[UNLEN + 1]; /* Large enough for SID */
cfree_and_set (puserprof, almost_null);
if (get_registry_hive_path (get_windows_id (win_id), userprofile_env_buf))
- sys_wcstombs_alloc (&puserprof, HEAP_STR, userprofile_env_buf + 4);
+ sys_wcstombs_alloc (&puserprof, HEAP_STR, userprofile_env_buf);
return puserprof;
}