summaryrefslogtreecommitdiff
path: root/user
diff options
context:
space:
mode:
authorwrowe <wrowe@13f79535-47bb-0310-9956-ffa450edef68>2001-02-21 23:38:47 +0000
committerwrowe <wrowe@13f79535-47bb-0310-9956-ffa450edef68>2001-02-21 23:38:47 +0000
commitce4be7b763ba28728e4b6aec97ac871e14071efd (patch)
tree1eb30232fd0e4240bc0e2a68ba996260c9b25f88 /user
parentadc5b77f4f3b56421d55fe50553a925942dd3abd (diff)
downloadlibapr-ce4be7b763ba28728e4b6aec97ac871e14071efd.tar.gz
Missing the apr_pool_t arg required for more complex queries of uid/gid
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@61278 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'user')
-rw-r--r--user/unix/userinfo.c2
-rw-r--r--user/win32/userinfo.c34
2 files changed, 32 insertions, 4 deletions
diff --git a/user/unix/userinfo.c b/user/unix/userinfo.c
index cc2e98cfd..2987153f5 100644
--- a/user/unix/userinfo.c
+++ b/user/unix/userinfo.c
@@ -99,7 +99,7 @@ APR_DECLARE(apr_status_t) apr_get_home_directory(char **dirname,
}
APR_DECLARE(apr_status_t) apr_get_userid(apr_uid_t *uid, apr_gid_t *gid,
- const char *username)
+ const char *username, apr_pool_t *p)
{
struct passwd *pw;
apr_status_t rv;
diff --git a/user/win32/userinfo.c b/user/win32/userinfo.c
index de1794d19..4ba7699dd 100644
--- a/user/win32/userinfo.c
+++ b/user/win32/userinfo.c
@@ -66,10 +66,38 @@ APR_DECLARE(apr_status_t) apr_get_home_directory(char **dirname, const char *use
}
APR_DECLARE(apr_status_t) apr_get_userid(apr_uid_t *uid, apr_gid_t *gid,
- const char *username)
+ const char *username, apr_pool_t *p)
{
- /* XXX: could someone please implement this for me? */
- return APR_ENOTIMPL;
+ SID_NAME_USE sidtype;
+ char *domain = NULL;
+ DWORD sidlen, rv;
+
+ if (strchr(username, '/')) {
+ domain = apr_pstrndup(p, username, strchr(username, '/') - username);
+ username += strlen(domain) + 1;
+ }
+ else if (strchr(username, '\\')) {
+ domain = apr_pstrndup(p, username, strchr(username, '/') - username);
+ username += strlen(domain) + 1;
+ }
+ /* Get nothing on the first pass ... need to size the sid buffer
+ */
+ sidlen = LookupAccountName(domain, username, NULL, NULL,
+ NULL, NULL, &sidtype);
+ if (sidlen) {
+ /* Give it back on the second pass
+ */
+ *uid = apr_palloc(p, sidlen);
+ rv = LookupAccountName(domain, username, *uid, &sidlen,
+ NULL, NULL, &sidtype);
+ }
+ if (!sidlen || !rv) {
+ return apr_get_os_error();
+ }
+ /* There doesn't seem to be a simple way to retrieve the primary group sid
+ */
+ *gid = NULL;
+ return APR_SUCCESS;
}
APR_DECLARE(apr_status_t) apr_get_username(char **username, apr_uid_t userid, apr_pool_t *p)