Title: Add windows_helper module helper
Type: enhancement Stage: patch review
Components: Tests, Windows Versions: Python 3.10, Python 3.9
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Claudiu.Popa, eryksun, paul.moore, steve.dower, tim.golden, zach.ware
Priority: normal Keywords: patch

Created on 2014-07-26 12:39 by Claudiu.Popa, last changed 2021-02-24 17:11 by eryksun.

File name Uploaded Description Edit
windows_helper.patch Claudiu.Popa, 2014-07-26 12:39 review
issue22080.patch Claudiu.Popa, 2014-08-06 14:30 New version. review
issue22080_1.patch Claudiu.Popa, 2015-01-17 17:50
issue22080_2.patch Claudiu.Popa, 2015-04-19 20:22 review eryksun, 2021-02-24 17:11
Messages (6)
msg224050 - (view) Author: PCManticore (Claudiu.Popa) * (Python triager) Date: 2014-07-26 12:39
Hi. This patch adds a new test helper module, initially added in issue21518, for controlling various aspects on Windows platform, like acquiring / releasing privileges etc. At the same time, it contains a modification in, so that it tries to acquire the privilege, failing otherwise. The only downside is that acquiring SeCreateSymbolicLinkPrivilege is only possible for admins and it seems to be that they have the privilege by default. On the other hand, for SeBackupPrivilege must be explicitly acquired, so the purpose of this module isn't redundant.

The part of acquiring a privilege using ctypes is based on similar code by Jason R. Coombs.
msg224934 - (view) Author: PCManticore (Claudiu.Popa) * (Python triager) Date: 2014-08-06 14:32
The new patch fixes the issues found by Zachary. Thanks for the review!
msg229063 - (view) Author: Zachary Ware (zach.ware) * (Python committer) Date: 2014-10-11 07:11
eryksun: You commented on my review comment; does Claudiu's latest patch look good to you?
msg234179 - (view) Author: PCManticore (Claudiu.Popa) * (Python triager) Date: 2015-01-17 17:50
Here's a cleaned up version of the patch.
msg241563 - (view) Author: PCManticore (Claudiu.Popa) * (Python triager) Date: 2015-04-19 20:22
The latest patch drops the symlink check, since it can be added later.
msg387631 - (view) Author: Eryk Sun (eryksun) * (Python triager) Date: 2021-02-24 17:11
I rewrote with cleaner ctypes code, better error handling, the correct implementation of restoring the previous privilege state, and without leaking the handle for the process token. It's kind of limited as a "Windows helper" module. It's just handling privileges, at least for now. This helper was intended to help with testing bpo-21518 (add winreg.UnLoadKey), another contribution from Claudiu.
Date User Action Args
2021-02-24 17:11:36eryksunsetfiles: +

messages: + msg387631
versions: + Python 3.9, Python 3.10, - Python 3.5, Python 3.6
2015-10-02 18:05:00eryksunsetnosy: + paul.moore, tim.golden, steve.dower

components: + Windows
versions: + Python 3.6
2015-04-19 20:22:54Claudiu.Popasetfiles: + issue22080_2.patch

messages: + msg241563
2015-01-17 17:50:16Claudiu.Popasetfiles: + issue22080_1.patch

messages: + msg234179
2014-10-11 07:11:43zach.waresetnosy: + eryksun
messages: + msg229063
2014-09-26 00:18:52Claudiu.Popasetstage: patch review
2014-08-06 14:32:59Claudiu.Popasetmessages: + msg224934
2014-08-06 14:30:56Claudiu.Popasetfiles: + issue22080.patch
2014-07-26 12:42:49Claudiu.Popalinkissue21518 dependencies
2014-07-26 12:39:33Claudiu.Popacreate