summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrane <brane@13f79535-47bb-0310-9956-ffa450edef68>2002-02-07 00:57:21 +0000
committerbrane <brane@13f79535-47bb-0310-9956-ffa450edef68>2002-02-07 00:57:21 +0000
commit4c61e7dedd537925d8a9882b3e19e269449d4f37 (patch)
treed7e0628cfec4da3b74f195e0e4b1b10c6e54fbe9
parent2cf79136de9ba99ca5458911e39709a0fe1f6f03 (diff)
downloadlibapr-4c61e7dedd537925d8a9882b3e19e269449d4f37.tar.gz
Even on NT, a file can be without a DACL -- for example, if it's in a
FAT volume. In that case, the access rights are effectively 0777, modulo the readonly bit -- just like they're computed for Win9x. Before this change, apr_file_info_get would return APR_INCOMPLETE if APR_FILE_PROT was requested for such files. git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@62925 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--file_io/win32/filestat.c40
1 files changed, 23 insertions, 17 deletions
diff --git a/file_io/win32/filestat.c b/file_io/win32/filestat.c
index a50d534b3..fca7e1b46 100644
--- a/file_io/win32/filestat.c
+++ b/file_io/win32/filestat.c
@@ -203,6 +203,25 @@ static apr_status_t resolve_ident(apr_finfo_t *finfo, const char *fname,
return rv;
}
+static void guess_protection_bits(apr_finfo_t *finfo)
+{
+ /* Read, write execute for owner. In the Win9x environment, any
+ * readable file is executable (well, not entirely 100% true, but
+ * still looking for some cheap logic that would help us here.)
+ * The same holds on NT if a file doesn't have a DACL (e.g., on FAT)
+ */
+ if (finfo->protection & APR_FREADONLY) {
+ finfo->protection |= APR_WREAD | APR_WEXECUTE;
+ }
+ else {
+ finfo->protection |= APR_WREAD | APR_WEXECUTE | APR_WWRITE;
+ }
+ finfo->protection |= (finfo->protection << prot_scope_group)
+ | (finfo->protection << prot_scope_user);
+
+ finfo->valid |= APR_FINFO_UPROT | APR_FINFO_GPROT | APR_FINFO_WPROT;
+}
+
apr_status_t more_finfo(apr_finfo_t *finfo, const void *ufile,
apr_int32_t wanted, int whatfile)
{
@@ -210,23 +229,8 @@ apr_status_t more_finfo(apr_finfo_t *finfo, const void *ufile,
PACL dacl = NULL;
apr_status_t rv;
- if (apr_os_level < APR_WIN_NT)
- {
- /* Read, write execute for owner. In the Win9x environment, any
- * readable file is executable (well, not entirely 100% true, but
- * still looking for some cheap logic that would help us here.)
- */
- if (finfo->protection & APR_FREADONLY) {
- finfo->protection |= APR_WREAD | APR_WEXECUTE;
- }
- else {
- finfo->protection |= APR_WREAD | APR_WEXECUTE | APR_WWRITE;
- }
- finfo->protection |= (finfo->protection << prot_scope_group)
- | (finfo->protection << prot_scope_user);
-
- finfo->valid |= APR_FINFO_UPROT | APR_FINFO_GPROT | APR_FINFO_WPROT;
- }
+ if (apr_os_level < APR_WIN_NT)
+ guess_protection_bits(finfo);
else if (wanted & (APR_FINFO_PROT | APR_FINFO_OWNER))
{
/* On NT this request is incredibly expensive, but accurate.
@@ -296,6 +300,8 @@ apr_status_t more_finfo(apr_finfo_t *finfo, const void *ufile,
/* Retrieved the discresionary access list */
resolve_prot(finfo, wanted, dacl);
}
+ else if (wanted & APR_FINFO_PROT)
+ guess_protection_bits(finfo);
}
return ((wanted & ~finfo->valid) ? APR_INCOMPLETE : APR_SUCCESS);