This is the mail archive of the cygwin-patches@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Patch] registry issues


This should fix the first two issues in the recent mail
to cygwin-developers.
It's currently untested (need an NT machine).

Pierre

2004-10-24  Pierre Humblet <pierre.humblet@ieee.org>

	* registry.cc (get_registry_hive_path): Simplify and add a
	debug_printf in case of failure.
	(load_registry_hive): Revert 2004-04-19 change.	


Index: registry.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/registry.cc,v
retrieving revision 1.19
diff -u -p -r1.19 registry.cc
--- registry.cc 19 Apr 2004 19:29:10 -0000      1.19
+++ registry.cc 24 Oct 2004 01:01:31 -0000
@@ -211,14 +211,15 @@ get_registry_hive_path (const PSID psid,
       char buf[256];
       DWORD type, siz;
 
-      key[0] = '\0';
+      path[0] = '\0';
       if (!RegQueryValueExA (hkey, "ProfileImagePath", 0, &type,
-                            (BYTE *)buf, (siz = 256, &siz)))
-       ExpandEnvironmentStringsA (buf, key, 256);
+                            (BYTE *)buf, (siz = sizeof (buf), &siz)))
+       ExpandEnvironmentStringsA (buf, path, CYG_MAX_PATH + 1);
       RegCloseKey (hkey);
-      if (key[0])
-       return strcpy (path, key);
+      if (path[0])
+       return path;
     }
+  debug_printf ("HKLM\\%s not found", key);
   return NULL;
 }
 
@@ -241,7 +242,8 @@ load_registry_hive (PSID psid)
       RegCloseKey (hkey);
       return;
     }
-  enable_restore_privilege ();
+  /* This is only called while deimpersonated */
+  set_process_privilege (SE_RESTORE_NAME);
   if (get_registry_hive_path (psid, path))
     {
       strcat (path, "\\NTUSER.DAT");


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]