Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenSSHUtils ProfilePath parsing issues #843

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion contrib/win32/openssh/OpenSSHUtils.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,9 @@ function Repair-AuthorizedKeyPermission
$userProfilePath = $properties.ProfileImagePath
}
$userProfilePath = $userProfilePath.Replace("\", "\\")
$fullPath -match "^$userProfilePath[\\|\W|\w]+authorized_keys$"
if ( $properties.PSChildName -notmatch '\.bak$') {
Copy link

@DarwinJS DarwinJS Aug 8, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bingbing8 - Windows will also create additional, profile when users move between domains or a profile is corrupt. These result it other profile folders that are orphaned (invalid for authorized_keys purposes).

Rather than the exclude, maybe the regex should just be tightened up to not match "...\userprofilepath...", but only "...\userprofilepath\..." ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DarwinJS It seems that you wrote "...\userprofilepath..." twice.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like github mistook my second slash for markup - was able to fix it. I am suggesting that the second literal slash that is found in $properties.profileimagepath be left intact so that profiles with ".something" are not picked up as they are generally not in live use.

Copy link
Author

@annulus annulus Aug 8, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is two separate thing:

  • appending a slash to the end of the filesystem path in the regex, that's against the value of the registry field ProfileImagePath is important to ignore the registry entries that are belonging to users that share the beginning of their path (this is what my other commit is about)
  • ignoring the registry ProfileList entries that end with .bak are to avoid loading old/backup reg.entries

$fullPath -match "^$userProfilePath\\[\\|\W|\w]+authorized_keys$"
}
}
if($profileItem)
{
Expand Down