GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||
GeezerVison is showing github.com — gh-118486: Switch mkdir(mode=0o700) on Windows to use OWNER RIGHTS instead of CURRENT_USER by zooba · Pull Request #118515 · python/cpython Conversation
|
|
|
||
| int use_alias = 0; | ||
| DWORD cbSid = sizeof(data->sid); | ||
| if (!CreateWellKnownSid(WinCreatorOwnerRightsSid, NULL, (PSID)data->sid, &cbSid)) { |
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
If you prefer to use "CURRENT_USER", you could just move it to the end of the array. Then the SetEntriesInAclW() call would use a count of 2 or 3 depending on whether the current user is an elevated administrator. The latter is determined by querying TokenElevationType. For example:
ULONG entry_count = 3; TOKEN_ELEVATION_TYPE elevation_type; DWORD return_length; if (GetTokenInformation(GetCurrentProcessToken(), TokenElevationType, &elevation_type, sizeof(elevation_type), &return_length) && elevation_type == TokenElevationTypeFull) { entry_count = 2; }
GetCurrentProcessToken() returns the pseudohandle (HANDLE)-4, which has been supported since Windows 8.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Thanks, but I definitely don't want to try to detect anything about the user's current state. That feels brittle (e.g. if more things are added that ought to be detected).
OWNER RIGHTS is good, and it's actually what I tried to find first. The fallback is just for completeness - I don't expect CreateWellKnownSid to ever fail here, but at least if it does, we're probably not doing anything too bad.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…HTS instead of CURRENT_USER (pythonGH-118515)
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.