* dcrt0.cc (dll_crt0_0): Call malloc_init and user_shared_initialize_1
here in case we're dynamically loaded. Explain why. (dll_crt0_1): Call user_shared_initialize_1 from here. * mount.cc (is_native_path): New inline function testing for native and long Win32 path prefix. (is_unc_share): Remove long WIn32 path prefix test. (mount_info::create_root_entry): Use PATH_MAX buffer. (mount_info::init): Ditto. (mount_info::add_item): Test for is_native_path as well. * path.cc (normalize_win32_path): Simplify native path prefix code. * shared.cc (user_shared_initialize_1): New function taking user shared initialization code relying on malloc and cygtls. (user_shared_initialize): Move mountinfo initialization to user_shared_initialize_1. * shared_info.h (user_shared_initialize_1): Declare. * syscalls.cc (seteuid32): Call user_shared_initialize_1 after user changed.
This commit is contained in:
@@ -198,6 +198,24 @@ open_shared (const char *name, int n, HANDLE& shared_h, DWORD size,
|
||||
return shared;
|
||||
}
|
||||
|
||||
/* User shared initialization which requires malloc and cygtls stuff has to
|
||||
go here. */
|
||||
void
|
||||
user_shared_initialize_1 ()
|
||||
{
|
||||
if (!user_shared->cb)
|
||||
{
|
||||
cygpsid sid (cygheap->user.sid ());
|
||||
struct passwd *pw = internal_getpwsid (sid);
|
||||
/* Correct the user name with what's defined in /etc/passwd before
|
||||
loading the user fstab file. */
|
||||
if (pw)
|
||||
cygheap->user.set_name (pw->pw_name);
|
||||
user_shared->mountinfo.init (); /* Initialize the mount table. */
|
||||
user_shared->cb = sizeof (*user_shared);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
user_shared_initialize (bool reinit)
|
||||
{
|
||||
@@ -224,19 +242,8 @@ user_shared_initialize (bool reinit)
|
||||
debug_printf ("user shared version %x", user_shared->version);
|
||||
|
||||
DWORD sversion = (DWORD) InterlockedExchange ((LONG *) &user_shared->version, USER_VERSION_MAGIC);
|
||||
/* Initialize the Cygwin per-user shared, if necessary */
|
||||
if (!sversion)
|
||||
{
|
||||
cygpsid sid (cygheap->user.sid ());
|
||||
struct passwd *pw = internal_getpwsid (sid);
|
||||
/* Correct the user name with what's defined in /etc/passwd before
|
||||
loading the user fstab file. */
|
||||
if (pw)
|
||||
cygheap->user.set_name (pw->pw_name);
|
||||
user_shared->mountinfo.init (); /* Initialize the mount table. */
|
||||
user_shared->cb = sizeof (*user_shared);
|
||||
}
|
||||
else
|
||||
/* Wait for initialization of the Cygwin per-user shared, if necessary */
|
||||
if (sversion)
|
||||
{
|
||||
while (!user_shared->cb)
|
||||
low_priority_sleep (0); // Should be hit only very very rarely
|
||||
|
Reference in New Issue
Block a user