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

fix for Issue648 #136

Merged
merged 8 commits into from
May 18, 2017
Merged

fix for Issue648 #136

merged 8 commits into from
May 18, 2017

Conversation

bingbing8
Copy link

@bingbing8 bingbing8 commented May 11, 2017

path_start = path + 2;
else
path_start = path;
if ((*path_start == L'\0') || ((*path_start == L'\\' || *path_start == L'/' ) && path_start[1] == L'\0'))

Choose a reason for hiding this comment

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

could you provide a scenario when we run into this logic?

Copy link
Author

@bingbing8 bingbing8 May 16, 2017

Choose a reason for hiding this comment

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

*path_start == L'\0' means the path is empty, or path like c:\ (for this case, path_start is from index 2)
(*path_start == L'\' || *path_start == L'/' ) && path_start[1] == L'\0' means the path is root directory. your can try "dir \"

Copy link
Author

Choose a reason for hiding this comment

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

I added one line comment for the sample path

last_dot = wcsrchr(path, L'.');
if (!last_dot)
return FALSE;
if (_wcsnicmp(last_dot, L".exe", 4) != 0 && _wcsnicmp(last_dot, L".cmd", 4) != 0 &&

Choose a reason for hiding this comment

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

You might need to retrieve the executable extension from %PATHEXT% environment variable..
http://environmentvariables.org/PathExt

If you fail to find / retrieve the environment variable then you can fall back on to the standard ones
.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC (This is not an exhaustive list)

Copy link
Author

Choose a reason for hiding this comment

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

I compared the results for other extension, the current implementation mirror the functionality of _wstat64 except it doesn't require permission to access the file. I will keep it for now until three is a need to consider other file extension.

}

int
file_attr_to_st_mode(wchar_t * path, DWORD attributes)

Choose a reason for hiding this comment

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

Copy link
Author

Choose a reason for hiding this comment

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

The change is to replace the usage of stat because stat require some (read) permission. When the user doesn't have the permission, stat return file_not_found. that is the reason we don't want to use stat.

r = _wstat64(wpath, buf);

/*
* If we doesn't have sufficient permissions then _wstat64() is returning "file not found"

Choose a reason for hiding this comment

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

I would suggest to remove all this code and have _wstat64() but before making that attempt call GetFileAttributesExW() since we are just worried about the wrong error message.. we shouldn't be re-writing _wstat64() implementation again? If GetFileAttributesExW() success then call _wstat64

Copy link
Author

Choose a reason for hiding this comment

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

No, with GetFileAttributesExW, we don't need to have that permission. GetFileAttributesExW success does not mean you can call _wstat64.

@bingbing8
Copy link
Author

@bagajjal please review my response to your feedback and let me know your think. Thanks!

@@ -542,18 +542,22 @@ function UnInstall-OpenSSH
[string]$OpenSSHDir = "$env:SystemDrive\OpenSSH"
)

if (-not (Test-Path $OpenSSHDir))

Choose a reason for hiding this comment

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

this should be independent of stopping the ssh-agent.. can you have this check down?

Copy link
Author

Choose a reason for hiding this comment

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

this check is needed. if the folder does not exists, there is no need to do any of the below steps. The purpose of stopping ssh-agent is to run uninstall script. If the folder does not exists, there is no need to stop ssh-agent either.

@manojampalam manojampalam merged commit afc6ca9 into latestw_all May 18, 2017
@manojampalam manojampalam deleted the issue648 branch May 18, 2017 19:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants