summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES7
-rw-r--r--include/apr_user.h28
-rw-r--r--user/win32/groupinfo.c13
-rw-r--r--user/win32/userinfo.c12
4 files changed, 57 insertions, 3 deletions
diff --git a/CHANGES b/CHANGES
index f1ef8d600..498f48b3d 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,5 +1,10 @@
Changes with APR b1
+ *) Added apr_compare_users() and apr_compare_groups() for more complex
+ apr_uid_t and apr_gid_t structures. Enabled both .user and .group
+ results from WinNT/2000 stat/getfileinfo, but expect to find that
+ .group is 'None' in most cases. [William Rowe]
+
*) Replace configure --with-optim option by using the environment
variable OPTIM instead. This is needed because configure options
do not support multiple flags separated by spaces. [Roy Fielding]
@@ -9,7 +14,7 @@ Changes with APR b1
*) Abstracted apr_get_username and apr_get_groupname for unix and win32.
Modified Win32 apr_uid_t and apr_gid_t to use PSIDs, and elimintated
- the uid_t and gid_t definitions.
+ the uid_t and gid_t definitions. [William Rowe]
*) Radically refactored apr_stat/lstat/getfileinfo/dir_read for Win32
to assure we are retrieving what we expect to retrieve, and reporting
diff --git a/include/apr_user.h b/include/apr_user.h
index 5fea54441..c650fb818 100644
--- a/include/apr_user.h
+++ b/include/apr_user.h
@@ -110,6 +110,20 @@ APR_DECLARE(apr_status_t) apr_get_username(char **username, apr_uid_t userid, ap
APR_DECLARE(apr_status_t) apr_get_home_directory(char **dirname, const char *userid, apr_pool_t *p);
/***
+ * Compare two user identifiers for equality.
+ * @param left One uid to test
+ * @param right Another uid to test
+ * @deffunc apr_status_t apr_compare_users(apr_uid_t left, apr_uid_t right)
+ * @tip Returns APR_SUCCESS if the apr_uid_t strutures identify the same user,
+ * APR_EMISMATCH if not, APR_BADARG if an apr_uid_t is invalid.
+ */
+#ifdef WIN32
+APR_DECLARE(apr_status_t) apr_compare_users(apr_uid_t left, apr_uid_t right);
+#else
+#define apr_compare_users(left,right) ((left == right) ? APR_SUCCESS : APR_EMISMATCH)
+#endif
+
+/***
* Get the group name for a specified groupid
* @param dirname Pointer to new string containing group name (on output)
* @param userid The groupid
@@ -119,6 +133,20 @@ APR_DECLARE(apr_status_t) apr_get_home_directory(char **dirname, const char *use
*/
APR_DECLARE(apr_status_t) apr_get_groupname(char **groupname, apr_gid_t groupid, apr_pool_t *p);
+/***
+ * Compare two group identifiers for equality.
+ * @param left One gid to test
+ * @param right Another gid to test
+ * @deffunc apr_status_t apr_compare_groups(apr_gid_t left, apr_gid_t right)
+ * @tip Returns APR_SUCCESS if the apr_gid_t strutures identify the same group,
+ * APR_EMISMATCH if not, APR_BADARG if an apr_gid_t is invalid.
+ */
+#ifdef WIN32
+APR_DECLARE(apr_status_t) apr_compare_groups(apr_gid_t left, apr_gid_t right);
+#else
+#define apr_compare_groups(left,right) ((left == right) ? APR_SUCCESS : APR_EMISMATCH)
+#endif
+
#endif /* ! APR_HAS_USER */
#ifdef __cplusplus
diff --git a/user/win32/groupinfo.c b/user/win32/groupinfo.c
index 49e70bd0f..1fbbcf0f6 100644
--- a/user/win32/groupinfo.c
+++ b/user/win32/groupinfo.c
@@ -72,9 +72,20 @@ APR_DECLARE(apr_status_t) apr_get_groupname(char **groupname, apr_gid_t groupid,
return APR_BADARG;
if (!LookupAccountSid(NULL, groupid, name, &cbname, domain, &cbdomain, &type))
return apr_get_os_error();
- if (type != SidTypeGroup && type != SidTypeWellKnownGroup)
+ if (type != SidTypeGroup && type != SidTypeWellKnownGroup
+ && type != SidTypeAlias)
return APR_BADARG;
*groupname = apr_pstrdup(p, name);
return APR_SUCCESS;
}
+APR_DECLARE(apr_status_t) apr_compare_groups(apr_gid_t left, apr_gid_t right)
+{
+ if (!left || !right)
+ return APR_BADARG;
+ if (!IsValidSid(left) || !IsValidSid(right))
+ return APR_BADARG;
+ if (!EqualSid(left, right))
+ return APR_EMISMATCH;
+ return APR_SUCCESS;
+}
diff --git a/user/win32/userinfo.c b/user/win32/userinfo.c
index 365703320..5d423eb1a 100644
--- a/user/win32/userinfo.c
+++ b/user/win32/userinfo.c
@@ -74,9 +74,19 @@ APR_DECLARE(apr_status_t) apr_get_username(char **username, apr_uid_t userid, ap
return APR_BADARG;
if (!LookupAccountSid(NULL, userid, name, &cbname, domain, &cbdomain, &type))
return apr_get_os_error();
- if (type != SidTypeUser)
+ if (type != SidTypeUser && type != SidTypeAlias)
return APR_BADARG;
*username = apr_pstrdup(p, name);
return APR_SUCCESS;
}
+APR_DECLARE(apr_status_t) apr_compare_users(apr_uid_t left, apr_uid_t right)
+{
+ if (!left || !right)
+ return APR_BADARG;
+ if (!IsValidSid(left) || !IsValidSid(right))
+ return APR_BADARG;
+ if (!EqualSid(left, right))
+ return APR_EMISMATCH;
+ return APR_SUCCESS;
+}