[issue28075] os.stat fails when access is denied

2017-03-31 Thread Donald Stufft

Changes by Donald Stufft :


--
pull_requests: +1069

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28075] os.stat fails when access is denied

2016-09-18 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 20c4ad866620 by Berker Peksag in branch '3.5':
Issue #28075: Fix test_access_denied in Python 3.5
https://hg.python.org/cpython/rev/20c4ad866620

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28075] os.stat fails when access is denied

2016-09-17 Thread Berker Peksag

Berker Peksag added the comment:

Thanks, Eryk.

--
nosy: +berker.peksag
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed
versions: +Python 3.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28075] os.stat fails when access is denied

2016-09-17 Thread Roundup Robot

Roundup Robot added the comment:

New changeset eabb86463462 by Berker Peksag in branch '3.5':
Issue #28075: Check for ERROR_ACCESS_DENIED in Windows implementation of 
os.stat()
https://hg.python.org/cpython/rev/eabb86463462

New changeset 4071a7cf6437 by Berker Peksag in branch '3.6':
Issue #28075: Merge from 3.5
https://hg.python.org/cpython/rev/4071a7cf6437

New changeset b04d5864e59a by Berker Peksag in branch 'default':
Issue #28075: Merge from 3.6
https://hg.python.org/cpython/rev/b04d5864e59a

--
nosy: +python-dev

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28075] os.stat fails when access is denied

2016-09-11 Thread Eryk Sun

Changes by Eryk Sun :


--
stage:  -> patch review

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28075] os.stat fails when access is denied

2016-09-11 Thread Eryk Sun

Eryk Sun added the comment:

I overlooked attempting to open a paging-file for any access, which is hard 
coded as a sharing violation. The attached patch checks for both cases.

--
keywords: +patch
Added file: http://bugs.python.org/file44554/issue_28075_01.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28075] os.stat fails when access is denied

2016-09-11 Thread Eryk Sun

Eryk Sun added the comment:

Python 3's os.stat tries to open a handle for the file or directory in order to 
call GetFileInformationByHandle. Opening a file handle via CreateFile requests 
at least FILE_READ_ATTRIBUTES and SYNCHRONIZE access when it calls 
NtCreateFile. If access is denied, os.stat is supposed to fall back on the 
basic WIN32_FIND_DATA information from FindFirstFile. However, it's not working 
as intended. For example:

>>> import os
>>> os.mkdir('test')
>>> os.system('icacls test /deny Users:(S,RA)')
processed file: test
Successfully processed 1 files; Failed processing 0 files
0

>>> os.stat('test')
Traceback (most recent call last):
  File "", line 1, in 
PermissionError: [WinError 5] Access is denied: 'test'

The problem is that it's mistakenly checking for ERROR_SHARING_VIOLATION 
instead of ERROR_ACCESS_DENIED. Technically, getting a sharing violation should 
be impossible here. That only applies to requesting execute (traverse), read 
(list), write (add file), append (add subdirectory), or delete access for the 
contents of the file or directory, not its metadata.

After modifying the code to instead check for ERROR_ACCESS_DENIED, os.stat 
correctly falls back on using the file attributes from the WIN32_FIND_DATA:

>>> os.stat('test')
os.stat_result(st_mode=16895, st_ino=0, st_dev=0, st_nlink=0, 
st_uid=0, st_gid=0, st_size=0, st_atime=1473589600, 
st_mtime=1473589600, st_ctime=1473589600)

--
nosy: +eryksun
title: py35 os.stat behavoir different than python 2.7 -> os.stat fails when 
access is denied
versions: +Python 3.6

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com