apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject cvs commit: apr/file_io/win32 filestat.c
Date Thu, 07 Feb 2002 00:57:21 GMT
brane       02/02/06 16:57:21

  Modified:    file_io/win32 filestat.c
  Log:
  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.
  
  Revision  Changes    Path
  1.63      +23 -17    apr/file_io/win32/filestat.c
  
  Index: filestat.c
  ===================================================================
  RCS file: /home/cvs/apr/file_io/win32/filestat.c,v
  retrieving revision 1.62
  retrieving revision 1.63
  diff -u -r1.62 -r1.63
  --- filestat.c	1 Feb 2002 01:40:38 -0000	1.62
  +++ filestat.c	7 Feb 2002 00:57:21 -0000	1.63
  @@ -203,6 +203,25 @@
       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 @@
       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 @@
               /* 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);
  
  
  

Mime
View raw message