This is the mail archive of the cygwin-patches 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]: cygwin_internal


The patch below uses cygpsid::get_id to implement CW_GET_UID_FROM_SID
and CW_GET_GID_FROM_SID in cygwin_internal. Thus the sid is first
compared to the user (or primary group) sid, before looking up
the passwd (or group) file.

This can make a difference when a sid appears multiple times in the
passwd or group file, e.g. when one has both 544 and 0.
This difference can cause exim (and perhaps others) to fail (it did
happen to me).

The patch also removes an obsolete member of the cygheap. 

Pierre



2005-07-01  Pierre Humblet <pierre.humblet@ieee.org>

	* cygheap.h (struct init_cygheap): Delete cygwin_regname member.
	* external.cc (cygwin_internal): Use cygpsid::get_id for 
	CW_GET_UID_FROM_SID and CW_GET_GID_FROM_SID.
	Turn CW_SET_CYGWIN_REGISTRY_NAME and CW_GET_CYGWIN_REGISTRY_NAME
	into noops.
	


Index: cygheap.h
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/cygheap.h,v
retrieving revision 1.105
diff -u -p -r1.105 cygheap.h
--- cygheap.h   1 Jun 2005 03:46:55 -0000       1.105
+++ cygheap.h   1 Jul 2005 04:38:56 -0000
@@ -278,7 +278,6 @@ struct init_cygheap
   HANDLE shared_h;
   HANDLE console_h;
   HANDLE mt_h;
-  char *cygwin_regname;
   cwdstuff cwd;
   dtable fdtab;
   LUID luid[SE_NUM_PRIVS];
Index: external.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/external.cc,v
retrieving revision 1.75
diff -u -p -r1.75 external.cc
--- external.cc 19 May 2005 01:25:19 -0000      1.75
+++ external.cc 1 Jul 2005 04:40:36 -0000
@@ -197,16 +197,8 @@ cygwin_internal (cygwin_getinfo_types t,
        }
 
       case CW_SET_CYGWIN_REGISTRY_NAME:
-       {
-         const char *cr = va_arg (arg, char *);
-         if (check_null_empty_str_errno (cr))
-           return (DWORD) NULL;
-         cygheap->cygwin_regname = (char *) crealloc (cygheap->cygwin_regname,
-                                                      strlen (cr) + 1);
-         strcpy (cygheap->cygwin_regname, cr);
-       }
       case CW_GET_CYGWIN_REGISTRY_NAME:
-         return (DWORD) cygheap->cygwin_regname;
+       return 0;
 
       case CW_STRACE_TOGGLE:
        {
@@ -280,17 +272,13 @@ cygwin_internal (cygwin_getinfo_types t,
        }
       case CW_GET_UID_FROM_SID:
        {
-         PSID psid = va_arg (arg, PSID);
-         cygsid sid (psid);
-         struct passwd *pw = internal_getpwsid (sid);
-         return pw ? pw->pw_uid : (__uid32_t)-1;
+         cygpsid psid = va_arg (arg, PSID);
+         return psid.get_id (false, NULL);
        }
       case CW_GET_GID_FROM_SID:
        {
-         PSID psid = va_arg (arg, PSID);
-         cygsid sid (psid);
-         struct __group32 *gr = internal_getgrsid (sid);
-         return gr ? gr->gr_gid : (__gid32_t)-1;
+         cygpsid psid = va_arg (arg, PSID);
+         return psid.get_id (true, NULL);
        }
       case CW_GET_BINMODE:
        {


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