wrowe 01/02/21 15:38:49
Modified: . CHANGES
user/unix userinfo.c
user/win32 userinfo.c
include apr_user.h
Log:
Missing the apr_pool_t arg required for more complex queries of uid/gid
Revision Changes Path
1.67 +3 -0 apr/CHANGES
Index: CHANGES
===================================================================
RCS file: /home/cvs/apr/CHANGES,v
retrieving revision 1.66
retrieving revision 1.67
diff -u -r1.66 -r1.67
--- CHANGES 2001/02/20 20:08:13 1.66
+++ CHANGES 2001/02/21 23:38:41 1.67
@@ -1,5 +1,8 @@
Changes with APR b1
+ *) Introduce apr_get_userid to return a named user's apr_uid_t and
+ apr_gid_t across platforms [cliff Woolley, William Rowe]
+
*) In apr_shm_init(), check the retcode from mm_malloc(). Previously,
we segfaulted here if mm_malloc() failed to get a lock. An example
error scenario is when the lock file lives on a filesystem which
1.9 +1 -1 apr/user/unix/userinfo.c
Index: userinfo.c
===================================================================
RCS file: /home/cvs/apr/user/unix/userinfo.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- userinfo.c 2001/02/21 18:41:24 1.8
+++ userinfo.c 2001/02/21 23:38:43 1.9
@@ -99,7 +99,7 @@
}
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;
1.5 +31 -3 apr/user/win32/userinfo.c
Index: userinfo.c
===================================================================
RCS file: /home/cvs/apr/user/win32/userinfo.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- userinfo.c 2001/02/21 18:41:27 1.4
+++ userinfo.c 2001/02/21 23:38:45 1.5
@@ -66,10 +66,38 @@
}
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)
1.11 +4 -2 apr/include/apr_user.h
Index: apr_user.h
===================================================================
RCS file: /home/cvs/apr/include/apr_user.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- apr_user.h 2001/02/21 18:41:29 1.10
+++ apr_user.h 2001/02/21 23:38:47 1.11
@@ -104,10 +104,12 @@
* @param userid Returns the user id
* @param groupid Returns the user's group id
* @param username The username to lookup
+ * @param p The pool from which to allocate working space
* @tip This function is available only if APR_HAS_USER is defined.
- * @deffunc apr_status_t apr_get_userid(apr_uid_t *userid, apr_gid_t
*groupid, const char *username)
+ * @deffunc apr_status_t apr_get_userid(apr_uid_t *userid, apr_gid_t
*groupid, const char *username, apr_pool_t *p)
*/
-APR_DECLARE(apr_status_t) apr_get_userid(apr_uid_t *userid, apr_gid_t
*groupid, const char *username);
+APR_DECLARE(apr_status_t) apr_get_userid(apr_uid_t *userid, apr_gid_t
*groupid,
+ const char *username, apr_pool_t
*p);
/***
* Get the home directory for the named user