static void finfo_equal(abts_case *tc, apr_finfo_t *f1, apr_finfo_t *f2) { /* Minimum supported flags across all platforms (APR_FINFO_MIN) */ ABTS_ASSERT(tc, "apr_stat and apr_getfileinfo must return APR_FINFO_TYPE", (f1->valid & f2->valid & APR_FINFO_TYPE)); ABTS_ASSERT(tc, "apr_stat and apr_getfileinfo differ in filetype", f1->filetype == f2->filetype); ABTS_ASSERT(tc, "apr_stat and apr_getfileinfo must return APR_FINFO_SIZE", (f1->valid & f2->valid & APR_FINFO_SIZE)); ABTS_ASSERT(tc, "apr_stat and apr_getfileinfo differ in size", f1->size == f2->size); ABTS_ASSERT(tc, "apr_stat and apr_getfileinfo must return APR_FINFO_ATIME", (f1->valid & f2->valid & APR_FINFO_ATIME)); ABTS_ASSERT(tc, "apr_stat and apr_getfileinfo differ in atime", f1->atime == f2->atime); ABTS_ASSERT(tc, "apr_stat and apr_getfileinfo must return APR_FINFO_MTIME", (f1->valid & f2->valid & APR_FINFO_MTIME)); ABTS_ASSERT(tc, "apr_stat and apr_getfileinfo differ in mtime", f1->mtime == f2->mtime); ABTS_ASSERT(tc, "apr_stat and apr_getfileinfo must return APR_FINFO_CTIME", (f1->valid & f2->valid & APR_FINFO_CTIME)); ABTS_ASSERT(tc, "apr_stat and apr_getfileinfo differ in ctime", f1->ctime == f2->ctime); if (f1->valid & f2->valid & APR_FINFO_NAME) ABTS_ASSERT(tc, "apr_stat and apr_getfileinfo differ in name", !strcmp(f1->name, f2->name)); if (f1->fname && f2->fname) ABTS_ASSERT(tc, "apr_stat and apr_getfileinfo differ in fname", !strcmp(f1->fname, f2->fname)); /* Additional supported flags not supported on all platforms */ if (f1->valid & f2->valid & APR_FINFO_USER) ABTS_ASSERT(tc, "apr_stat and apr_getfileinfo differ in user", !apr_uid_compare(f1->user, f2->user)); if (f1->valid & f2->valid & APR_FINFO_GROUP) ABTS_ASSERT(tc, "apr_stat and apr_getfileinfo differ in group", !apr_gid_compare(f1->group, f2->group)); if (f1->valid & f2->valid & APR_FINFO_INODE) ABTS_ASSERT(tc, "apr_stat and apr_getfileinfo differ in inode", f1->inode == f2->inode); if (f1->valid & f2->valid & APR_FINFO_DEV) ABTS_ASSERT(tc, "apr_stat and apr_getfileinfo differ in device", f1->device == f2->device); if (f1->valid & f2->valid & APR_FINFO_NLINK) ABTS_ASSERT(tc, "apr_stat and apr_getfileinfo differ in nlink", f1->nlink == f2->nlink); if (f1->valid & f2->valid & APR_FINFO_CSIZE) ABTS_ASSERT(tc, "apr_stat and apr_getfileinfo differ in csize", f1->csize == f2->csize); if (f1->valid & f2->valid & APR_FINFO_PROT) ABTS_ASSERT(tc, "apr_stat and apr_getfileinfo differ in protection", f1->protection == f2->protection); }
static void username(CuTest *tc) { apr_uid_t uid; apr_gid_t gid; apr_uid_t retreived_uid; apr_gid_t retreived_gid; apr_status_t rv; char *uname = NULL; rv = apr_uid_current(&uid, &gid, p); CuAssertIntEquals(tc, APR_SUCCESS, rv); rv = apr_uid_name_get(&uname, uid, p); CuAssertIntEquals(tc, APR_SUCCESS, rv); CuAssertPtrNotNull(tc, uname); rv = apr_uid_get(&retreived_uid, &retreived_gid, uname, p); CuAssertIntEquals(tc, APR_SUCCESS, rv); CuAssertIntEquals(tc, APR_SUCCESS, apr_uid_compare(uid, retreived_uid)); #ifdef WIN32 /* ### this fudge was added for Win32 but makes the test return NotImpl * on Unix if run as root, when !gid is also true. */ if (!gid || !retreived_gid) { /* The function had no way to recover the gid (this would have been * an ENOTIMPL if apr_uid_ functions didn't try to double-up and * also return apr_gid_t values, which was bogus. */ if (!gid) { CuNotImpl(tc, "Groups from apr_uid_current"); } else { CuNotImpl(tc, "Groups from apr_uid_get"); } } else { #endif CuAssertIntEquals(tc, APR_SUCCESS, apr_gid_compare(gid, retreived_gid)); #ifdef WIN32 } #endif }