* cygheap.cc (cwcsdup): New function.
(cwcsdup1): New function. * cygheap.h (cygheap_user::get_windows_id): New method returning PWCHAR. (cwcsdup): Declare. (cwcsdup1): Declare. * registry.cc (get_registry_hive_path): Use WCHAR instead of char throughout. (load_registry_hive): Ditto. * registry.h (get_registry_hive_path): Change declaration accordingly. (load_registry_hive): Ditto. * sec_helper.cc (cygpsid::string): New method returning PWCHAR. * security.h (cygpsid::string): Declare. * syscalls.cc (seteuid32): Convert local name var to WCHAR. * uinfo.cc (cygheap_user::env_userprofile): Convert local name buffers to WCHAR. Call sys_wcstombs_alloc to generate puserprof buffer. * winsup.h: Fix comment. (NT_MAX_PATH): New definition for maximum internal path length. Use throughout where appropriate. * include/limits.h (PATH_MAX): Set to 4096 as on Linux.
This commit is contained in:
		
							parent
							
								
									f16db7f54e
								
							
						
					
					
						commit
						7b4b41ab3e
					
				|  | @ -1,3 +1,26 @@ | ||||||
|  | 2008-02-14  Corinna Vinschen  <corinna@vinschen.de> | ||||||
|  | 
 | ||||||
|  | 	* cygheap.cc (cwcsdup): New function. | ||||||
|  | 	(cwcsdup1): New function. | ||||||
|  | 	* cygheap.h (cygheap_user::get_windows_id): New method returning PWCHAR. | ||||||
|  | 	(cwcsdup): Declare. | ||||||
|  | 	(cwcsdup1): Declare. | ||||||
|  | 	* registry.cc (get_registry_hive_path): Use WCHAR instead of char | ||||||
|  | 	throughout. | ||||||
|  | 	(load_registry_hive): Ditto. | ||||||
|  | 	* registry.h (get_registry_hive_path): Change declaration accordingly. | ||||||
|  | 	(load_registry_hive): Ditto. | ||||||
|  | 	* sec_helper.cc (cygpsid::string): New method returning PWCHAR. | ||||||
|  | 	* security.h (cygpsid::string): Declare. | ||||||
|  | 	* syscalls.cc (seteuid32): Convert local name var to WCHAR. | ||||||
|  | 	* uinfo.cc (cygheap_user::env_userprofile): Convert local name buffers | ||||||
|  | 	to WCHAR.  Call sys_wcstombs_alloc to generate puserprof buffer. | ||||||
|  | 
 | ||||||
|  | 	* winsup.h: Fix comment. | ||||||
|  | 	(NT_MAX_PATH): New definition for maximum internal path length. | ||||||
|  | 	Use throughout where appropriate. | ||||||
|  | 	* include/limits.h (PATH_MAX): Set to 4096 as on Linux. | ||||||
|  | 
 | ||||||
| 2008-02-13  Christopher Faylor  <me+cygwin@cgf.cx> | 2008-02-13  Christopher Faylor  <me+cygwin@cgf.cx> | ||||||
| 
 | 
 | ||||||
| 	* configure.in: Remove non-working options. | 	* configure.in: Remove non-working options. | ||||||
|  |  | ||||||
|  | @ -24,6 +24,7 @@ | ||||||
| #include "sigproc.h" | #include "sigproc.h" | ||||||
| #include "pinfo.h" | #include "pinfo.h" | ||||||
| #include <unistd.h> | #include <unistd.h> | ||||||
|  | #include <wchar.h> | ||||||
| 
 | 
 | ||||||
| init_cygheap NO_COPY *cygheap; | init_cygheap NO_COPY *cygheap; | ||||||
| void NO_COPY *cygheap_max; | void NO_COPY *cygheap_max; | ||||||
|  | @ -354,6 +355,30 @@ ccalloc_abort (cygheap_types x, DWORD n, DWORD size) | ||||||
|   return ccalloc (x, n, size, "ccalloc"); |   return ccalloc (x, n, size, "ccalloc"); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | extern "C" PWCHAR __stdcall | ||||||
|  | cwcsdup (const PWCHAR s) | ||||||
|  | { | ||||||
|  |   MALLOC_CHECK; | ||||||
|  |   PWCHAR p = (PWCHAR) cmalloc (HEAP_STR, wcslen (s) + 1); | ||||||
|  |   if (!p) | ||||||
|  |     return NULL; | ||||||
|  |   wcpcpy (p, s); | ||||||
|  |   MALLOC_CHECK; | ||||||
|  |   return p; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | extern "C" PWCHAR __stdcall | ||||||
|  | cwcsdup1 (const PWCHAR s) | ||||||
|  | { | ||||||
|  |   MALLOC_CHECK; | ||||||
|  |   PWCHAR p = (PWCHAR) cmalloc (HEAP_1_STR, wcslen (s) + 1); | ||||||
|  |   if (!p) | ||||||
|  |     return NULL; | ||||||
|  |   wcpcpy (p, s); | ||||||
|  |   MALLOC_CHECK; | ||||||
|  |   return p; | ||||||
|  | } | ||||||
|  | 
 | ||||||
| extern "C" char *__stdcall | extern "C" char *__stdcall | ||||||
| cstrdup (const char *s) | cstrdup (const char *s) | ||||||
| { | { | ||||||
|  |  | ||||||
|  | @ -206,7 +206,11 @@ public: | ||||||
|     if (internal_token != NO_IMPERSONATION) |     if (internal_token != NO_IMPERSONATION) | ||||||
|       CloseHandle (internal_token); |       CloseHandle (internal_token); | ||||||
|   } |   } | ||||||
|   char * get_windows_id (char * buf) |   PWCHAR get_windows_id (PWCHAR buf) | ||||||
|  |   { | ||||||
|  |     return effec_cygsid.string (buf); | ||||||
|  |   } | ||||||
|  |   char *get_windows_id (char *buf) | ||||||
|   { |   { | ||||||
|     return effec_cygsid.string (buf); |     return effec_cygsid.string (buf); | ||||||
|   } |   } | ||||||
|  | @ -231,7 +235,7 @@ struct cwdstuff | ||||||
|   DWORD get_drive (char * dst) |   DWORD get_drive (char * dst) | ||||||
|   { |   { | ||||||
|     cwd_lock.acquire (); |     cwd_lock.acquire (); | ||||||
|     DWORD ret = sys_wcstombs (dst, PATH_MAX, win32.Buffer, drive_length); |     DWORD ret = sys_wcstombs (dst, NT_MAX_PATH, win32.Buffer, drive_length); | ||||||
|     cwd_lock.release (); |     cwd_lock.release (); | ||||||
|     return ret; |     return ret; | ||||||
|   } |   } | ||||||
|  | @ -423,6 +427,8 @@ void *__stdcall ccalloc (cygheap_types, DWORD, DWORD) __attribute__ ((regparm(3) | ||||||
| void *__stdcall cmalloc_abort (cygheap_types, DWORD) __attribute__ ((regparm(2))); | void *__stdcall cmalloc_abort (cygheap_types, DWORD) __attribute__ ((regparm(2))); | ||||||
| void *__stdcall crealloc_abort (void *, DWORD) __attribute__ ((regparm(2))); | void *__stdcall crealloc_abort (void *, DWORD) __attribute__ ((regparm(2))); | ||||||
| void *__stdcall ccalloc_abort (cygheap_types, DWORD, DWORD) __attribute__ ((regparm(3))); | void *__stdcall ccalloc_abort (cygheap_types, DWORD, DWORD) __attribute__ ((regparm(3))); | ||||||
|  | PWCHAR __stdcall cwcsdup (const PWCHAR) __attribute__ ((regparm(1))); | ||||||
|  | PWCHAR __stdcall cwcsdup1 (const PWCHAR) __attribute__ ((regparm(1))); | ||||||
| char *__stdcall cstrdup (const char *) __attribute__ ((regparm(1))); | char *__stdcall cstrdup (const char *) __attribute__ ((regparm(1))); | ||||||
| char *__stdcall cstrdup1 (const char *) __attribute__ ((regparm(1))); | char *__stdcall cstrdup1 (const char *) __attribute__ ((regparm(1))); | ||||||
| void __stdcall cfree_and_set (char *&, char * = NULL) __attribute__ ((regparm(2))); | void __stdcall cfree_and_set (char *&, char * = NULL) __attribute__ ((regparm(2))); | ||||||
|  |  | ||||||
|  | @ -544,7 +544,7 @@ break_here () | ||||||
| static void | static void | ||||||
| initial_env () | initial_env () | ||||||
| { | { | ||||||
|   char buf[PATH_MAX]; |   char buf[NT_MAX_PATH]; | ||||||
|   if (GetEnvironmentVariable ("CYGWIN_TESTING", buf, sizeof (buf) - 1)) |   if (GetEnvironmentVariable ("CYGWIN_TESTING", buf, sizeof (buf) - 1)) | ||||||
|     _cygwin_testing = 1; |     _cygwin_testing = 1; | ||||||
| 
 | 
 | ||||||
|  | @ -561,8 +561,8 @@ initial_env () | ||||||
|     } |     } | ||||||
|   if (GetEnvironmentVariable ("CYGWIN_DEBUG", buf, sizeof (buf) - 1)) |   if (GetEnvironmentVariable ("CYGWIN_DEBUG", buf, sizeof (buf) - 1)) | ||||||
|     { |     { | ||||||
|       char buf1[PATH_MAX]; |       char buf1[NT_MAX_PATH]; | ||||||
|       len = GetModuleFileName (NULL, buf1, PATH_MAX); |       len = GetModuleFileName (NULL, buf1, NT_MAX_PATH); | ||||||
|       strlwr (buf1); |       strlwr (buf1); | ||||||
|       strlwr (buf); |       strlwr (buf); | ||||||
|       char *p = strpbrk (buf, ":="); |       char *p = strpbrk (buf, ":="); | ||||||
|  | @ -870,7 +870,7 @@ dll_crt0_1 (void *) | ||||||
| 	 win32 style. */ | 	 win32 style. */ | ||||||
|       if ((strchr (__argv[0], ':')) || (strchr (__argv[0], '\\'))) |       if ((strchr (__argv[0], ':')) || (strchr (__argv[0], '\\'))) | ||||||
| 	{ | 	{ | ||||||
| 	  char *new_argv0 = (char *) malloc (PATH_MAX); | 	  char *new_argv0 = (char *) malloc (NT_MAX_PATH); | ||||||
| 	  cygwin_conv_to_posix_path (__argv[0], new_argv0); | 	  cygwin_conv_to_posix_path (__argv[0], new_argv0); | ||||||
| 	  __argv[0] = (char *) realloc (new_argv0, strlen (new_argv0) + 1); | 	  __argv[0] = (char *) realloc (new_argv0, strlen (new_argv0) + 1); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | @ -106,7 +106,7 @@ dll_list::operator[] (const char *name) | ||||||
| dll * | dll * | ||||||
| dll_list::alloc (HINSTANCE h, per_process *p, dll_type type) | dll_list::alloc (HINSTANCE h, per_process *p, dll_type type) | ||||||
| { | { | ||||||
|   char name[PATH_MAX]; |   char name[NT_MAX_PATH]; | ||||||
|   DWORD namelen = GetModuleFileName (h, name, sizeof (name)); |   DWORD namelen = GetModuleFileName (h, name, sizeof (name)); | ||||||
| 
 | 
 | ||||||
|   /* Already loaded? */ |   /* Already loaded? */ | ||||||
|  |  | ||||||
|  | @ -51,7 +51,7 @@ struct dll | ||||||
|   int count; |   int count; | ||||||
|   dll_type type; |   dll_type type; | ||||||
|   int namelen; |   int namelen; | ||||||
|   char name[PATH_MAX]; |   char name[NT_MAX_PATH]; | ||||||
|   void detach (); |   void detach (); | ||||||
|   int init (); |   int init (); | ||||||
| }; | }; | ||||||
|  |  | ||||||
|  | @ -116,7 +116,7 @@ win_env::add_cache (const char *in_posix, const char *in_native) | ||||||
|     } |     } | ||||||
|   else |   else | ||||||
|     { |     { | ||||||
|       char buf[PATH_MAX]; |       char buf[NT_MAX_PATH]; | ||||||
|       strcpy (buf, name + namelen); |       strcpy (buf, name + namelen); | ||||||
|       towin32 (in_posix, buf); |       towin32 (in_posix, buf); | ||||||
|       native = (char *) realloc (native, namelen + 1 + strlen (buf)); |       native = (char *) realloc (native, namelen + 1 + strlen (buf)); | ||||||
|  | @ -185,7 +185,7 @@ posify (char **here, const char *value) | ||||||
|   /* Turn all the items from c:<foo>;<bar> into their
 |   /* Turn all the items from c:<foo>;<bar> into their
 | ||||||
|      mounted equivalents - if there is one.  */ |      mounted equivalents - if there is one.  */ | ||||||
| 
 | 
 | ||||||
|   char outenv[1 + len + PATH_MAX]; |   char outenv[1 + len + NT_MAX_PATH]; | ||||||
|   memcpy (outenv, src, len); |   memcpy (outenv, src, len); | ||||||
|   char *newvalue = outenv + len; |   char *newvalue = outenv + len; | ||||||
|   if (!conv->toposix (value, newvalue) || _impure_ptr->_errno != EIDRM) |   if (!conv->toposix (value, newvalue) || _impure_ptr->_errno != EIDRM) | ||||||
|  |  | ||||||
|  | @ -35,7 +35,7 @@ details. */ | ||||||
| 
 | 
 | ||||||
| #define CALL_HANDLER_RETRY 20 | #define CALL_HANDLER_RETRY 20 | ||||||
| 
 | 
 | ||||||
| char debugger_command[2 * PATH_MAX + 20]; | char debugger_command[2 * NT_MAX_PATH + 20]; | ||||||
| 
 | 
 | ||||||
| extern "C" { | extern "C" { | ||||||
| extern void sigdelayed (); | extern void sigdelayed (); | ||||||
|  | @ -118,8 +118,8 @@ error_start_init (const char *buf) | ||||||
|       return; |       return; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|   char pgm[PATH_MAX]; |   char pgm[NT_MAX_PATH]; | ||||||
|   if (!GetModuleFileName (NULL, pgm, PATH_MAX)) |   if (!GetModuleFileName (NULL, pgm, NT_MAX_PATH)) | ||||||
|     strcpy (pgm, "cygwin1.dll"); |     strcpy (pgm, "cygwin1.dll"); | ||||||
|   for (char *p = strchr (pgm, '\\'); p; p = strchr (p, '\\')) |   for (char *p = strchr (pgm, '\\'); p; p = strchr (p, '\\')) | ||||||
|     *p = '/'; |     *p = '/'; | ||||||
|  |  | ||||||
|  | @ -442,7 +442,7 @@ fhandler_process::fill_filebuf () | ||||||
|     case PROCESS_EXENAME: |     case PROCESS_EXENAME: | ||||||
|     case PROCESS_EXE: |     case PROCESS_EXE: | ||||||
|       { |       { | ||||||
| 	filebuf = (char *) crealloc_abort (filebuf, bufalloc = PATH_MAX); | 	filebuf = (char *) crealloc_abort (filebuf, bufalloc = NT_MAX_PATH); | ||||||
| 	if (p->process_state & PID_EXITED) | 	if (p->process_state & PID_EXITED) | ||||||
| 	  strcpy (filebuf, "<defunct>"); | 	  strcpy (filebuf, "<defunct>"); | ||||||
| 	else | 	else | ||||||
|  | @ -524,8 +524,8 @@ format_process_maps (_pinfo *p, char *&destbuf, size_t maxsize) | ||||||
|   DWORD_PTR wset_size; |   DWORD_PTR wset_size; | ||||||
|   DWORD_PTR *workingset = NULL; |   DWORD_PTR *workingset = NULL; | ||||||
|   MODULEINFO info; |   MODULEINFO info; | ||||||
|   WCHAR modname[PATH_MAX]; |   WCHAR modname[NT_MAX_PATH]; | ||||||
|   char posix_modname[PATH_MAX]; |   char posix_modname[NT_MAX_PATH]; | ||||||
| 
 | 
 | ||||||
|   if (!EnumProcessModules (proc, NULL, 0, &needed)) |   if (!EnumProcessModules (proc, NULL, 0, &needed)) | ||||||
|     { |     { | ||||||
|  | @ -557,7 +557,7 @@ format_process_maps (_pinfo *p, char *&destbuf, size_t maxsize) | ||||||
| 	strcpy (access, "r--p"); | 	strcpy (access, "r--p"); | ||||||
| 	struct __stat64 st; | 	struct __stat64 st; | ||||||
| 	if (mount_table->conv_to_posix_path (modname, posix_modname, 0)) | 	if (mount_table->conv_to_posix_path (modname, posix_modname, 0)) | ||||||
| 	  sys_wcstombs (posix_modname, PATH_MAX, modname); | 	  sys_wcstombs (posix_modname, NT_MAX_PATH, modname); | ||||||
| 	if (stat64 (posix_modname, &st)) | 	if (stat64 (posix_modname, &st)) | ||||||
| 	  { | 	  { | ||||||
| 	    st.st_dev = 0; | 	    st.st_dev = 0; | ||||||
|  |  | ||||||
|  | @ -321,10 +321,11 @@ details. */ | ||||||
| #undef NAME_MAX | #undef NAME_MAX | ||||||
| #define NAME_MAX 255 | #define NAME_MAX 255 | ||||||
| 
 | 
 | ||||||
| /* Maximum length of a path including trailing NUL.
 | /* Maximum length of a path given to API functions including trailing NUL.
 | ||||||
|    (32767 - max. native NT path prefix) */ |    Deliberately set to the same default value as on Linux.  Internal paths | ||||||
|  |    may be longer. */ | ||||||
| #undef PATH_MAX | #undef PATH_MAX | ||||||
| #define PATH_MAX 32760 | #define PATH_MAX 4096 | ||||||
| 
 | 
 | ||||||
| /* # of bytes in a pipe buf. This is the max # of bytes which can be
 | /* # of bytes in a pipe buf. This is the max # of bytes which can be
 | ||||||
|    written to a pipe in one atomic operation. */ |    written to a pipe in one atomic operation. */ | ||||||
|  |  | ||||||
|  | @ -266,7 +266,7 @@ struct external_pinfo | ||||||
|   __gid32_t gid32; |   __gid32_t gid32; | ||||||
| 
 | 
 | ||||||
|   /* Only available if version >= EXTERNAL_PINFO_VERSION_32_LP */ |   /* Only available if version >= EXTERNAL_PINFO_VERSION_32_LP */ | ||||||
|   char progname_long[PATH_MAX]; |   char progname_long[NT_MAX_PATH]; | ||||||
| }; | }; | ||||||
| #endif /*__CYGWIN__*/ | #endif /*__CYGWIN__*/ | ||||||
| #endif /*WINVER*/ | #endif /*WINVER*/ | ||||||
|  |  | ||||||
|  | @ -2002,8 +2002,8 @@ mount_info::conv_to_posix_path (PWCHAR src_path, char *posix_path, | ||||||
| 	  changed = true; | 	  changed = true; | ||||||
| 	} | 	} | ||||||
|     } |     } | ||||||
|   char buf[PATH_MAX]; |   char buf[NT_MAX_PATH]; | ||||||
|   sys_wcstombs (buf, PATH_MAX, src_path); |   sys_wcstombs (buf, NT_MAX_PATH, src_path); | ||||||
|   int ret = conv_to_posix_path (buf, posix_path, keep_rel_p); |   int ret = conv_to_posix_path (buf, posix_path, keep_rel_p); | ||||||
|   if (changed) |   if (changed) | ||||||
|     src_path[0] = L'C'; |     src_path[0] = L'C'; | ||||||
|  | @ -4565,7 +4565,7 @@ cwdstuff::set (PUNICODE_STRING nat_cwd, const char *posix_cwd, bool doit) | ||||||
| 
 | 
 | ||||||
|       if (!posix_cwd) |       if (!posix_cwd) | ||||||
| 	{ | 	{ | ||||||
| 	  posix_cwd = (const char *) alloca (PATH_MAX); | 	  posix_cwd = (const char *) alloca (NT_MAX_PATH); | ||||||
| 	  mount_table->conv_to_posix_path (win32.Buffer, (char *) posix_cwd, 0); | 	  mount_table->conv_to_posix_path (win32.Buffer, (char *) posix_cwd, 0); | ||||||
| 	} | 	} | ||||||
|       posix = (char *) crealloc_abort (posix, strlen (posix_cwd) + 1); |       posix = (char *) crealloc_abort (posix, strlen (posix_cwd) + 1); | ||||||
|  | @ -4598,8 +4598,8 @@ cwdstuff::get (char *buf, int need_posix, int with_chroot, unsigned ulen) | ||||||
|   char *tocopy; |   char *tocopy; | ||||||
|   if (!need_posix) |   if (!need_posix) | ||||||
|     { |     { | ||||||
|       tocopy = (char *) alloca (PATH_MAX); |       tocopy = (char *) alloca (NT_MAX_PATH); | ||||||
|       sys_wcstombs (tocopy, PATH_MAX, win32.Buffer, win32.Length); |       sys_wcstombs (tocopy, NT_MAX_PATH, win32.Buffer, win32.Length); | ||||||
|     } |     } | ||||||
|   else |   else | ||||||
|     tocopy = posix; |     tocopy = posix; | ||||||
|  |  | ||||||
|  | @ -392,7 +392,7 @@ DWORD WINAPI | ||||||
| commune_process (void *arg) | commune_process (void *arg) | ||||||
| { | { | ||||||
|   siginfo_t& si = *((siginfo_t *) arg); |   siginfo_t& si = *((siginfo_t *) arg); | ||||||
|   char path[PATH_MAX]; |   char path[NT_MAX_PATH]; | ||||||
|   DWORD nr; |   DWORD nr; | ||||||
|   HANDLE& tothem = si._si_commune._si_write_handle; |   HANDLE& tothem = si._si_commune._si_write_handle; | ||||||
|   HANDLE process_sync = |   HANDLE process_sync = | ||||||
|  | @ -439,7 +439,7 @@ commune_process (void *arg) | ||||||
|     case PICOM_CWD: |     case PICOM_CWD: | ||||||
|       { |       { | ||||||
| 	sigproc_printf ("processing PICOM_CWD"); | 	sigproc_printf ("processing PICOM_CWD"); | ||||||
| 	unsigned int n = strlen (cygheap->cwd.get (path, 1, 1, PATH_MAX)) + 1; | 	unsigned int n = strlen (cygheap->cwd.get (path, 1, 1, NT_MAX_PATH)) + 1; | ||||||
| 	if (!WriteFile (tothem, &n, sizeof n, &nr, NULL)) | 	if (!WriteFile (tothem, &n, sizeof n, &nr, NULL)) | ||||||
| 	  sigproc_printf ("WriteFile sizeof cwd failed, %E"); | 	  sigproc_printf ("WriteFile sizeof cwd failed, %E"); | ||||||
| 	else if (!WriteFile (tothem, path, n, &nr, NULL)) | 	else if (!WriteFile (tothem, path, n, &nr, NULL)) | ||||||
|  | @ -665,7 +665,7 @@ _pinfo::fd (int fd, size_t &n) | ||||||
|       if (cfd < 0) |       if (cfd < 0) | ||||||
| 	s = cstrdup (""); | 	s = cstrdup (""); | ||||||
|       else |       else | ||||||
| 	s = cfd->get_proc_fd_name ((char *) cmalloc_abort (HEAP_COMMUNE, PATH_MAX)); | 	s = cfd->get_proc_fd_name ((char *) cmalloc_abort (HEAP_COMMUNE, NT_MAX_PATH)); | ||||||
|       n = strlen (s) + 1; |       n = strlen (s) + 1; | ||||||
|     } |     } | ||||||
|   return s; |   return s; | ||||||
|  | @ -736,8 +736,8 @@ _pinfo::cwd (size_t& n) | ||||||
|     } |     } | ||||||
|   else |   else | ||||||
|     { |     { | ||||||
|       s = (char *) cmalloc_abort (HEAP_COMMUNE, PATH_MAX); |       s = (char *) cmalloc_abort (HEAP_COMMUNE, NT_MAX_PATH); | ||||||
|       cygheap->cwd.get (s, 1, 1, PATH_MAX); |       cygheap->cwd.get (s, 1, 1, NT_MAX_PATH); | ||||||
|       n = strlen (s) + 1; |       n = strlen (s) + 1; | ||||||
|     } |     } | ||||||
|   return s; |   return s; | ||||||
|  |  | ||||||
|  | @ -64,7 +64,7 @@ public: | ||||||
|   DWORD dwProcessId; |   DWORD dwProcessId; | ||||||
| 
 | 
 | ||||||
|   /* Used to spawn a child for fork(), among other things. */ |   /* Used to spawn a child for fork(), among other things. */ | ||||||
|   char progname[PATH_MAX]; |   char progname[NT_MAX_PATH]; | ||||||
| 
 | 
 | ||||||
|   /* User information.
 |   /* User information.
 | ||||||
|      The information is derived from the GetUserName system call, |      The information is derived from the GetUserName system call, | ||||||
|  |  | ||||||
|  | @ -19,6 +19,7 @@ details. */ | ||||||
| #include "fhandler.h" | #include "fhandler.h" | ||||||
| #include "dtable.h" | #include "dtable.h" | ||||||
| #include "cygheap.h" | #include "cygheap.h" | ||||||
|  | #include <wchar.h> | ||||||
| static const char cygnus_class[] = "cygnus"; | static const char cygnus_class[] = "cygnus"; | ||||||
| 
 | 
 | ||||||
| reg_key::reg_key (HKEY top, REGSAM access, ...): _disposition (0) | reg_key::reg_key (HKEY top, REGSAM access, ...): _disposition (0) | ||||||
|  | @ -207,54 +208,55 @@ reg_key::~reg_key () | ||||||
|   key_is_invalid = 1; |   key_is_invalid = 1; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| char * | PWCHAR | ||||||
| get_registry_hive_path (const char *name, char *path) | get_registry_hive_path (const PWCHAR name, PWCHAR path) | ||||||
| { | { | ||||||
|   char key[256]; |   WCHAR key[256], *kend; | ||||||
|   HKEY hkey; |   HKEY hkey; | ||||||
| 
 | 
 | ||||||
|   if (!name || !path) |   if (!name || !path) | ||||||
|     return NULL; |     return NULL; | ||||||
|   __small_sprintf (key, "SOFTWARE\\Microsoft\\WindowsNT\\CurrentVersion\\" |   kend = wcpcpy (key, L"SOFTWARE\\Microsoft\\WindowsNT\\CurrentVersion\\ProfileList\\"); | ||||||
|   			"ProfileList\\%s", name); |   wcpcpy (kend, name); | ||||||
|   if (!RegOpenKeyExA (HKEY_LOCAL_MACHINE, key, 0, KEY_READ, &hkey)) |   if (!RegOpenKeyExW (HKEY_LOCAL_MACHINE, key, 0, KEY_READ, &hkey)) | ||||||
|     { |     { | ||||||
|       char buf[PATH_MAX]; |       WCHAR buf[NT_MAX_PATH]; | ||||||
|  |       WCHAR tmp[NT_MAX_PATH]; | ||||||
|       DWORD type, siz; |       DWORD type, siz; | ||||||
| 
 | 
 | ||||||
|       path[0] = '\0'; |       path[0] = L'\0'; | ||||||
|       if (!RegQueryValueExA (hkey, "ProfileImagePath", 0, &type, |       if (!RegQueryValueExW (hkey, L"ProfileImagePath", 0, &type, | ||||||
| 			     (BYTE *)buf, (siz = sizeof (buf), &siz))) | 			     (BYTE *)buf, (siz = sizeof (buf), &siz))) | ||||||
| 	ExpandEnvironmentStringsA (buf, path, PATH_MAX); | 	ExpandEnvironmentStringsW (buf, path, NT_MAX_PATH); | ||||||
|       RegCloseKey (hkey); |       RegCloseKey (hkey); | ||||||
|       if (path[0]) |       if (path[0]) | ||||||
| 	return path; | 	return path; | ||||||
|     } |     } | ||||||
|   debug_printf ("HKLM\\%s not found", key); |   debug_printf ("HKLM\\%W not found", key); | ||||||
|   return NULL; |   return NULL; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void | void | ||||||
| load_registry_hive (const char * name) | load_registry_hive (const PWCHAR name) | ||||||
| { | { | ||||||
|   char path[PATH_MAX]; |   WCHAR path[NT_MAX_PATH]; | ||||||
|   HKEY hkey; |   HKEY hkey; | ||||||
|   LONG ret; |   LONG ret; | ||||||
| 
 | 
 | ||||||
|   if (!name) |   if (!name) | ||||||
|     return; |     return; | ||||||
|   /* Check if user hive is already loaded. */ |   /* Check if user hive is already loaded. */ | ||||||
|   if (!RegOpenKeyExA (HKEY_USERS, name, 0, KEY_READ, &hkey)) |   if (!RegOpenKeyExW (HKEY_USERS, name, 0, KEY_READ, &hkey)) | ||||||
|     { |     { | ||||||
|       debug_printf ("User registry hive for %s already exists", name); |       debug_printf ("User registry hive for %W already exists", name); | ||||||
|       RegCloseKey (hkey); |       RegCloseKey (hkey); | ||||||
|       return; |       return; | ||||||
|     } |     } | ||||||
|   if (get_registry_hive_path (name, path)) |   if (get_registry_hive_path (name, path)) | ||||||
|     { |     { | ||||||
|       strcat (path, "\\NTUSER.DAT"); |       wcscat (path, L"\\NTUSER.DAT"); | ||||||
|       if ((ret = RegLoadKeyA (HKEY_USERS, name, path)) != ERROR_SUCCESS) |       if ((ret = RegLoadKeyW (HKEY_USERS, name, path)) != ERROR_SUCCESS) | ||||||
| 	debug_printf ("Loading user registry hive for %s failed: %d", name, ret); | 	debug_printf ("Loading user registry hive for %W failed: %d", name, ret); | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -40,5 +40,5 @@ public: | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| /* Evaluates path to the directory of the local user registry hive */ | /* Evaluates path to the directory of the local user registry hive */ | ||||||
| char *__stdcall get_registry_hive_path (const char *name, char *path); | PWCHAR __stdcall get_registry_hive_path (const PWCHAR name, PWCHAR path); | ||||||
| void __stdcall load_registry_hive (const char *name); | void __stdcall load_registry_hive (const PWCHAR name); | ||||||
|  |  | ||||||
|  | @ -101,6 +101,17 @@ cygpsid::get_id (BOOL search_grp, int *type) | ||||||
|   return id; |   return id; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | PWCHAR | ||||||
|  | cygpsid::string (PWCHAR nsidstr) const | ||||||
|  | { | ||||||
|  |   UNICODE_STRING sid; | ||||||
|  | 
 | ||||||
|  |   if (!psid || !nsidstr)  | ||||||
|  |     return NULL; | ||||||
|  |   RtlInitEmptyUnicodeString (&sid, nsidstr, 256); | ||||||
|  |   RtlConvertSidToUnicodeString (&sid, psid, FALSE); | ||||||
|  |   return nsidstr; | ||||||
|  | } | ||||||
| 
 | 
 | ||||||
| char * | char * | ||||||
| cygpsid::string (char *nsidstr) const | cygpsid::string (char *nsidstr) const | ||||||
|  |  | ||||||
|  | @ -100,6 +100,7 @@ public: | ||||||
|   int get_uid () { return get_id (FALSE); } |   int get_uid () { return get_id (FALSE); } | ||||||
|   int get_gid () { return get_id (TRUE); } |   int get_gid () { return get_id (TRUE); } | ||||||
| 
 | 
 | ||||||
|  |   PWCHAR string (PWCHAR nsidstr) const; | ||||||
|   char *string (char *nsidstr) const; |   char *string (char *nsidstr) const; | ||||||
| 
 | 
 | ||||||
|   bool operator== (const PSID nsid) const |   bool operator== (const PSID nsid) const | ||||||
|  |  | ||||||
|  | @ -64,7 +64,7 @@ __rn (char *dst, int base, int dosign, long long val, int len, int pad, unsigned | ||||||
| extern "C" int | extern "C" int | ||||||
| __small_vsprintf (char *dst, const char *fmt, va_list ap) | __small_vsprintf (char *dst, const char *fmt, va_list ap) | ||||||
| { | { | ||||||
|   char tmp[PATH_MAX]; |   char tmp[NT_MAX_PATH]; | ||||||
|   char *orig = dst; |   char *orig = dst; | ||||||
|   const char *s; |   const char *s; | ||||||
|   PWCHAR w; |   PWCHAR w; | ||||||
|  | @ -169,7 +169,7 @@ __small_vsprintf (char *dst, const char *fmt, va_list ap) | ||||||
| 		  dst = rnargLL (dst, 16, 0, len, pad); | 		  dst = rnargLL (dst, 16, 0, len, pad); | ||||||
| 		  break; | 		  break; | ||||||
| 		case 'P': | 		case 'P': | ||||||
| 		  if (!GetModuleFileName (NULL, tmp, PATH_MAX)) | 		  if (!GetModuleFileName (NULL, tmp, NT_MAX_PATH)) | ||||||
| 		    s = "cygwin program"; | 		    s = "cygwin program"; | ||||||
| 		  else | 		  else | ||||||
| 		    s = tmp; | 		    s = tmp; | ||||||
|  |  | ||||||
|  | @ -154,7 +154,7 @@ strace::vsprntf (char *buf, const char *func, const char *infmt, va_list ap) | ||||||
| 	pn = NULL; | 	pn = NULL; | ||||||
| 
 | 
 | ||||||
|       char *p; |       char *p; | ||||||
|       char progname[PATH_MAX]; |       char progname[NT_MAX_PATH]; | ||||||
|       if (!pn) |       if (!pn) | ||||||
| 	GetModuleFileName (NULL, pn = progname, sizeof (progname)); | 	GetModuleFileName (NULL, pn = progname, sizeof (progname)); | ||||||
|       if (!pn) |       if (!pn) | ||||||
|  |  | ||||||
|  | @ -2483,7 +2483,7 @@ seteuid32 (__uid32_t uid) | ||||||
|   if (new_token != hProcToken) |   if (new_token != hProcToken) | ||||||
|     { |     { | ||||||
|       /* Avoid having HKCU use default user */ |       /* Avoid having HKCU use default user */ | ||||||
|       char name[128]; |       WCHAR name[128]; | ||||||
|       load_registry_hive (usersid.string (name)); |       load_registry_hive (usersid.string (name)); | ||||||
| 
 | 
 | ||||||
|       /* Try setting owner to same value as user. */ |       /* Try setting owner to same value as user. */ | ||||||
|  |  | ||||||
|  | @ -408,12 +408,12 @@ cygheap_user::env_userprofile (const char *name, size_t namelen) | ||||||
|   if (test_uid (puserprof, name, namelen)) |   if (test_uid (puserprof, name, namelen)) | ||||||
|     return puserprof; |     return puserprof; | ||||||
| 
 | 
 | ||||||
|   char userprofile_env_buf[PATH_MAX]; |   WCHAR userprofile_env_buf[NT_MAX_PATH]; | ||||||
|   char win_id[UNLEN + 1]; /* Large enough for SID */ |   WCHAR win_id[UNLEN + 1]; /* Large enough for SID */ | ||||||
| 
 | 
 | ||||||
|   cfree_and_set (puserprof, almost_null); |   cfree_and_set (puserprof, almost_null); | ||||||
|   if (get_registry_hive_path (get_windows_id (win_id), userprofile_env_buf)) |   if (get_registry_hive_path (get_windows_id (win_id), userprofile_env_buf)) | ||||||
|     puserprof = cstrdup (userprofile_env_buf); |     sys_wcstombs_alloc (&puserprof, HEAP_STR, userprofile_env_buf); | ||||||
| 
 | 
 | ||||||
|   return puserprof; |   return puserprof; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -61,7 +61,7 @@ extern unsigned long cygwin_inet_addr (const char *cp); | ||||||
| 
 | 
 | ||||||
| /* Note that MAX_PATH is defined in the windows headers */ | /* Note that MAX_PATH is defined in the windows headers */ | ||||||
| /* There is also PATH_MAX and MAXPATHLEN.
 | /* There is also PATH_MAX and MAXPATHLEN.
 | ||||||
|    PATH_MAX is from Posix and does *not* include the trailing NUL. |    PATH_MAX is from Posix and does include the trailing NUL. | ||||||
|    MAXPATHLEN is from Unix. |    MAXPATHLEN is from Unix. | ||||||
| 
 | 
 | ||||||
|    Thou shalt use CYG_MAX_PATH throughout.  It avoids the NUL vs no-NUL |    Thou shalt use CYG_MAX_PATH throughout.  It avoids the NUL vs no-NUL | ||||||
|  | @ -76,6 +76,15 @@ extern unsigned long cygwin_inet_addr (const char *cp); | ||||||
| 
 | 
 | ||||||
| #define CYG_MAX_PATH (MAX_PATH) | #define CYG_MAX_PATH (MAX_PATH) | ||||||
| 
 | 
 | ||||||
|  | /* There's no define for the maximum path length the NT kernel can handle.
 | ||||||
|  |    That's why we define our own to use in path length test and for path | ||||||
|  |    buffer sizes.  As MAX_PATH and PATH_MAX, this is defined including the | ||||||
|  |    trailing 0.  Internal buffers and internal path routines should use | ||||||
|  |    NT_MAX_PATH.  PATH_MAX as defined in limits.h is the maximum length of | ||||||
|  |    application provided path strings we handle.  */ | ||||||
|  | /* FIXME: The name is preliminary and TBD. */ | ||||||
|  | #define NT_MAX_PATH 32768 | ||||||
|  | 
 | ||||||
| #ifdef __cplusplus | #ifdef __cplusplus | ||||||
| 
 | 
 | ||||||
| extern const char case_folded_lower[]; | extern const char case_folded_lower[]; | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue