diff options
Diffstat (limited to 'file_io/unix/filestat.c')
-rw-r--r-- | file_io/unix/filestat.c | 46 |
1 files changed, 35 insertions, 11 deletions
diff --git a/file_io/unix/filestat.c b/file_io/unix/filestat.c index 29bf16e50..d46640e40 100644 --- a/file_io/unix/filestat.c +++ b/file_io/unix/filestat.c @@ -138,6 +138,7 @@ APR_DECLARE(apr_status_t) apr_file_perms_set(const char *fname, APR_DECLARE(apr_status_t) apr_file_attrs_set(const char *fname, apr_fileattrs_t attributes, + apr_fileattrs_t attr_mask, apr_pool_t *cont) { apr_status_t status; @@ -147,21 +148,44 @@ APR_DECLARE(apr_status_t) apr_file_attrs_set(const char *fname, if (!APR_STATUS_IS_SUCCESS(status)) return status; - if (attributes & APR_FILE_ATTR_READONLY) { - finfo.protection &= ~APR_UWRITE; - finfo.protection &= ~APR_GWRITE; - finfo.protection &= ~APR_WWRITE; + /* ### TODO: should added bits be umask'd? */ + if (attr_mask & APR_FILE_ATTR_READONLY) + { + if (attributes & APR_FILE_ATTR_READONLY) + { + finfo.protection &= ~APR_UWRITE; + finfo.protection &= ~APR_GWRITE; + finfo.protection &= ~APR_WWRITE; + } + else + { + /* ### umask this! */ + finfo.protection |= APR_UWRITE; + finfo.protection |= APR_GWRITE; + finfo.protection |= APR_WWRITE; + } } - if (attributes & APR_FILE_ATTR_EXECUTABLE) { - /* ### TODO: should this be umask'd? */ - finfo.protection |= APR_UEXECUTE; - finfo.protection |= APR_GEXECUTE; - finfo.protection |= APR_WEXECUTE; + + if (attr_mask & APR_FILE_ATTR_EXECUTABLE) + { + if (attributes & APR_FILE_ATTR_EXECUTABLE) + { + /* ### umask this! */ + finfo.protection |= APR_UEXECUTE; + finfo.protection |= APR_GEXECUTE; + finfo.protection |= APR_WEXECUTE; + } + else + { + finfo.protection &= ~APR_UEXECUTE; + finfo.protection &= ~APR_GEXECUTE; + finfo.protection &= ~APR_WEXECUTE; + } } - return apr_file_perms_set(fname, finfo.protection); + return apr_file_perms_set(fname, finfo.protection); } - + APR_DECLARE(apr_status_t) apr_stat(apr_finfo_t *finfo, const char *fname, apr_int32_t wanted, apr_pool_t *cont) |