apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wr...@apache.org
Subject cvs commit: apr/file_io/win32 open.c filestat.c
Date Sun, 29 Dec 2002 20:28:59 GMT
wrowe       2002/12/29 12:28:59

  Modified:    include/arch/win32 fileio.h
               file_io/win32 open.c filestat.c
  Log:
    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.
  
  Revision  Changes    Path
  1.71      +4 -3      apr/include/arch/win32/fileio.h
  
  Index: fileio.h
  ===================================================================
  RCS file: /home/cvs/apr/include/arch/win32/fileio.h,v
  retrieving revision 1.70
  retrieving revision 1.71
  diff -u -r1.70 -r1.71
  --- fileio.h	17 Jul 2002 03:26:29 -0000	1.70
  +++ fileio.h	29 Dec 2002 20:28:58 -0000	1.71
  @@ -133,9 +133,10 @@
   #endif
   
   /* Internal Flags for apr_file_open */
  -#define APR_OPENLINK      8192    /* Open a link itself, if supported */
  -#define APR_READCONTROL   4096    /* Read the file's owner/perms */
  -#define APR_WRITECONTROL  2048    /* Modifythe file's owner/perms */
  +#define APR_OPENINFO     0x4000    /* Open without READ or WRITE access */
  +#define APR_OPENLINK     0x2000    /* Open a link itself, if supported */
  +#define APR_READCONTROL  0x1000    /* Read the file's owner/perms */
  +#define APR_WRITECONTROL 0x0800    /* Modifythe file's owner/perms */
   
   /* Entries missing from the MSVC 5.0 Win32 SDK:
    */
  
  
  
  1.114     +20 -5     apr/file_io/win32/open.c
  
  Index: open.c
  ===================================================================
  RCS file: /home/cvs/apr/file_io/win32/open.c,v
  retrieving revision 1.113
  retrieving revision 1.114
  diff -u -r1.113 -r1.114
  --- open.c	28 Dec 2002 20:36:21 -0000	1.113
  +++ open.c	29 Dec 2002 20:28:58 -0000	1.114
  @@ -339,21 +339,36 @@
       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
       {
  
  
  
  1.74      +8 -8      apr/file_io/win32/filestat.c
  
  Index: filestat.c
  ===================================================================
  RCS file: /home/cvs/apr/file_io/win32/filestat.c,v
  retrieving revision 1.73
  retrieving revision 1.74
  diff -u -r1.73 -r1.74
  --- filestat.c	28 Dec 2002 20:39:49 -0000	1.73
  +++ filestat.c	29 Dec 2002 20:28:58 -0000	1.74
  @@ -191,11 +191,11 @@
        * 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 @@
           /* 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);
  
  
  

Mime
View raw message