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 userinfo.c
Date Fri, 27 Jul 2001 07:11:07 GMT
wrowe       01/07/27 00:11:07

  Modified:    user/win32 userinfo.c
  Log:
    Here's an implementation, dunno if it's _the_ implementation we are
    looking for.
  
  Revision  Changes    Path
  1.15      +33 -0     apr/user/win32/userinfo.c
  
  Index: userinfo.c
  ===================================================================
  RCS file: /home/cvs/apr/user/win32/userinfo.c,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- userinfo.c	2001/07/26 03:33:21	1.14
  +++ userinfo.c	2001/07/27 07:11:07	1.15
  @@ -189,6 +189,39 @@
       return APR_SUCCESS;
   }
   
  +APR_DECLARE(apr_status_t) apr_current_userid(apr_uid_t *uid,
  +                                             apr_gid_t *gid,
  +                                             apr_pool_t *p)
  +{
  +    HANDLE threadtok;
  +    DWORD needed;
  +    TOKEN_USER *usr;
  +    TOKEN_PRIMARY_GROUP *grp;
  +    
  +    if(!OpenProcessToken(GetCurrentProcess(), STANDARD_RIGHTS_READ | READ_CONTROL | TOKEN_QUERY,
&threadtok)) {
  +        return apr_get_os_error();
  +    }
  +
  +    *uid = NULL;
  +    if (!GetTokenInformation(threadtok, TokenUser, NULL, 0, &needed)
  +        && (GetLastError() == ERROR_INSUFFICIENT_BUFFER) 
  +        && (usr = apr_palloc(p, needed))
  +        && GetTokenInformation(threadtok, TokenUser, usr, needed, &needed))
  +        *uid = usr->User.Sid;
  +    else
  +        return apr_get_os_error();
  +
  +    if (!GetTokenInformation(threadtok, TokenPrimaryGroup, NULL, 0, &needed)
  +        && (GetLastError() == ERROR_INSUFFICIENT_BUFFER) 
  +        && (grp = apr_palloc(p, needed))
  +        && GetTokenInformation(threadtok, TokenPrimaryGroup, grp, needed, &needed))
  +        *gid = grp->PrimaryGroup;
  +    else
  +        return apr_get_os_error();
  +
  +    return APR_SUCCESS;
  +}
  +
   APR_DECLARE(apr_status_t) apr_get_userid(apr_uid_t *uid, apr_gid_t *gid,
                                            const char *username, apr_pool_t *p)
   {
  
  
  

Mime
View raw message