summaryrefslogtreecommitdiff
path: root/file_io
diff options
context:
space:
mode:
authorwrowe <wrowe@13f79535-47bb-0310-9956-ffa450edef68>2002-12-29 20:28:58 +0000
committerwrowe <wrowe@13f79535-47bb-0310-9956-ffa450edef68>2002-12-29 20:28:58 +0000
commit114aa1159cc9b299d6ecb1c80817628a84e1bf1b (patch)
treed9d649525a537b68920b5c12a8f45d6237821990 /file_io
parenta57aa4ef4b0cc9b02e86f601b02755f57d84c9e3 (diff)
downloadlibapr-114aa1159cc9b299d6ecb1c80817628a84e1bf1b.tar.gz
Add an internal Win32 apr_file_open flag APR_OPENINFO to allow APR itself
to access a Win32 file or directory without READ/WRITE access, for various GetFileInformationEx() and security descriptor access. Now the testfile suite passes on Win32. git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@64227 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'file_io')
-rw-r--r--file_io/win32/filestat.c16
-rw-r--r--file_io/win32/open.c25
2 files changed, 28 insertions, 13 deletions
diff --git a/file_io/win32/filestat.c b/file_io/win32/filestat.c
index 429d26e72..cd4f6c2ac 100644
--- a/file_io/win32/filestat.c
+++ b/file_io/win32/filestat.c
@@ -191,11 +191,11 @@ static apr_status_t resolve_ident(apr_finfo_t *finfo, const char *fname,
* user, group or permissions.
*/
- if ((rv = apr_file_open(&thefile, fname,
- ((wanted & APR_FINFO_LINK) ? APR_OPENLINK : 0)
- | ((wanted & (APR_FINFO_PROT | APR_FINFO_OWNER))
- ? APR_READCONTROL : 0),
- APR_OS_DEFAULT, pool)) == APR_SUCCESS) {
+ if ((rv = apr_file_open(&thefile, fname, APR_OPENINFO
+ | ((wanted & APR_FINFO_LINK) ? APR_OPENLINK : 0)
+ | ((wanted & (APR_FINFO_PROT | APR_FINFO_OWNER))
+ ? APR_READCONTROL : 0),
+ APR_OS_DEFAULT, pool)) == APR_SUCCESS) {
rv = apr_file_info_get(finfo, wanted, thefile);
finfo->filehand = NULL;
apr_file_close(thefile);
@@ -205,9 +205,9 @@ static apr_status_t resolve_ident(apr_finfo_t *finfo, const char *fname,
/* We have a backup plan. Perhaps we couldn't grab READ_CONTROL?
* proceed without asking for that permission...
*/
- if ((rv = apr_file_open(&thefile, fname,
- ((wanted & APR_FINFO_LINK) ? APR_OPENLINK : 0),
- APR_OS_DEFAULT, pool)) == APR_SUCCESS) {
+ if ((rv = apr_file_open(&thefile, fname, APR_OPENINFO
+ | ((wanted & APR_FINFO_LINK) ? APR_OPENLINK : 0),
+ APR_OS_DEFAULT, pool)) == APR_SUCCESS) {
rv = apr_file_info_get(finfo, wanted & ~(APR_FINFO_PROT
| APR_FINFO_OWNER),
thefile);
diff --git a/file_io/win32/open.c b/file_io/win32/open.c
index ae15ed9a3..b0bb7da04 100644
--- a/file_io/win32/open.c
+++ b/file_io/win32/open.c
@@ -339,21 +339,36 @@ APR_DECLARE(apr_status_t) apr_file_open(apr_file_t **new, const char *fname,
if (flag & APR_DELONCLOSE) {
attributes |= FILE_FLAG_DELETE_ON_CLOSE;
}
+
if (flag & APR_OPENLINK) {
attributes |= FILE_FLAG_OPEN_REPARSE_POINT;
}
- if (!(flag & (APR_READ | APR_WRITE)) && (apr_os_level >= APR_WIN_NT)) {
- /* We once failed here, but this is how one opens
- * a directory as a file under winnt
- */
- attributes |= FILE_FLAG_BACKUP_SEMANTICS;
+
+ /* Without READ or WRITE, we fail unless apr called apr_file_open
+ * internally with the private APR_OPENINFO flag.
+ *
+ * With the APR_OPENINFO flag on NT, use the option flag
+ * FILE_FLAG_BACKUP_SEMANTICS to allow us to open directories.
+ * See the static resolve_ident() fn in file_io/win32/filestat.c
+ */
+ if (!(flag & (APR_READ | APR_WRITE))) {
+ if (flag & APR_OPENINFO) {
+ if (apr_os_level >= APR_WIN_NT) {
+ attributes |= FILE_FLAG_BACKUP_SEMANTICS;
+ }
+ }
+ else {
+ return APR_EACCES;
+ }
}
+
if (flag & APR_XTHREAD) {
/* This win32 specific feature is required
* to allow multiple threads to work with the file.
*/
attributes |= FILE_FLAG_OVERLAPPED;
}
+
#if APR_HAS_UNICODE_FS
IF_WIN_OS_IS_UNICODE
{