Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-118486: Switch mkdir(mode=0o700) on Windows to use OWNER RIGHTS instead of CURRENT_USER#118515

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
zooba merged 1 commit intopython:mainfromzooba:gh-118486
May 2, 2024

Conversation

zooba
Copy link
Member

@zoobazooba commentedMay 2, 2024
edited by bedevere-appbot
Loading

This ensures directories created while elevated are not accessible by the same user when non-elevated.

@@ -5616,13 +5617,25 @@ initializeMkdir700SecurityAttributes(
return GetLastError();
}

int use_alias = 0;
DWORD cbSid = sizeof(data->sid);
if (!CreateWellKnownSid(WinCreatorOwnerRightsSid, NULL, (PSID)data->sid, &cbSid)) {
Copy link
Contributor

@eryksuneryksunMay 3, 2024
edited
Loading

Choose a reason for 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 theSetEntriesInAclW() call would use a count of 2 or 3 depending on whether the current user is an elevated administrator. The latter is determined by queryingTokenElevationType. For example:

ULONGentry_count=3;TOKEN_ELEVATION_TYPEelevation_type;DWORDreturn_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.

Copy link
MemberAuthor

Choose a reason for 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 expectCreateWellKnownSid to ever fail here, but at least if it does, we're probably not doing anything too bad.

SonicField pushed a commit to SonicField/cpython that referenced this pull requestMay 8, 2024
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@eryksuneryksuneryksun left review comments

Assignees
No one assigned
Labels
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@zooba@eryksun

[8]ページ先頭

©2009-2025 Movatter.jp