summaryrefslogtreecommitdiff
path: root/user
diff options
context:
space:
mode:
authorwrowe <wrowe@13f79535-47bb-0310-9956-ffa450edef68>2001-11-24 21:15:43 +0000
committerwrowe <wrowe@13f79535-47bb-0310-9956-ffa450edef68>2001-11-24 21:15:43 +0000
commitb67de35c4c8f858c4bb0e9a87234002f559c4147 (patch)
treedd67e48760d72fb5bec284e3b4dc67bd75666007 /user
parent706d9f1158348d7167ee731e6b2272dbe72b414d (diff)
downloadlibapr-b67de35c4c8f858c4bb0e9a87234002f559c4147.tar.gz
The missing Win32 apr_get_groupid, brings Win32 back to par with Unix.
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@62545 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'user')
-rw-r--r--user/win32/groupinfo.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/user/win32/groupinfo.c b/user/win32/groupinfo.c
index 6b8b74cff..3d533a19c 100644
--- a/user/win32/groupinfo.c
+++ b/user/win32/groupinfo.c
@@ -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;