apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wr...@apache.org
Subject cvs commit: apr/user/win32 groupinfo.c
Date Sat, 24 Nov 2001 21:15:44 GMT
wrowe       01/11/24 13:15:44

  Modified:    user/win32 groupinfo.c
  Log:
    The missing Win32 apr_get_groupid, brings Win32 back to par with Unix.
  
  Revision  Changes    Path
  1.6       +40 -0     apr/user/win32/groupinfo.c
  
  Index: groupinfo.c
  ===================================================================
  RCS file: /home/cvs/apr/user/win32/groupinfo.c,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- groupinfo.c	2001/06/06 20:04:42	1.5
  +++ groupinfo.c	2001/11/24 21:15:43	1.6
  @@ -60,6 +60,46 @@
   #include <sys/types.h>
   #endif
   
  +APR_DECLARE(apr_status_t) apr_get_groupid(apr_gid_t *gid, 
  +                                         const char *groupname, apr_pool_t *p)
  +{
  +    SID_NAME_USE sidtype;
  +    char anydomain[256];
  +    char *domain;
  +    DWORD sidlen = 0;
  +    DWORD domlen = sizeof(anydomain);
  +    DWORD rv;
  +    char *pos;
  +
  +    if (pos = strchr(groupname, '/')) {
  +        domain = apr_pstrndup(p, groupname, pos - groupname);
  +        groupname = pos + 1;
  +    }
  +    else if (pos = strchr(groupname, '\\')) {
  +        domain = apr_pstrndup(p, groupname, pos - groupname);
  +        groupname = pos + 1;
  +    }
  +    else {
  +        domain = NULL;
  +    }
  +    /* Get nothing on the first pass ... need to size the sid buffer 
  +     */
  +    rv = LookupAccountName(domain, groupname, domain, &sidlen, 
  +                           anydomain, &domlen, &sidtype);
  +    if (sidlen) {
  +        /* Give it back on the second pass
  +         */
  +        *gid = apr_palloc(p, sidlen);
  +        domlen = sizeof(anydomain);
  +        rv = LookupAccountName(domain, groupname, *gid, &sidlen, 
  +                               anydomain, &domlen, &sidtype);
  +    }
  +    if (!sidlen || !rv) {
  +        return apr_get_os_error();
  +    }
  +    return APR_SUCCESS;
  +}
  +
   APR_DECLARE(apr_status_t) apr_get_groupname(char **groupname, apr_gid_t groupid, apr_pool_t
*p)
   {
       SID_NAME_USE type;
  
  
  

Mime
View raw message