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
On Windows, the vimfiles folder is owned by administrator upon install #11888
Comments
What method did you use to install Vim? If you downloaded an installer: from where? |
I've used three installers so far actually (to get python to work): the gvim90.exe download (https://ftp.nluug.nl/pub/vim/pc/gvim90.exe) and the 9.0.0000 32 bit and 64 bit installers from vim-win32-installer. Not sure if the last installer or the first installer caused the problem. I'm guessing something is going wrong with the "create plugin directory" option in the installer since it runs as admin. |
Update, after investigating what the installer code is doing, (at least what is in the vim-win32-installer project) I can't see anything obvious where its setting any security details. It looks to me like the new directories are simply inheriting the security settings from their respective parent directory. And, I think this is the correct behavior - unless I'm missing something different with your setup!? I was unable to replicate the problem you described. I could do a |
It was the admins group for me as well. I'm not sure if inheriting home is the reason here. I would more suspect it has to do with the folder being created by the installer while elevated. |
ahh, yes, I see it now;
It's an interesting issue. And, sure, it's easy enough to change security ownership back to your user account. Also, it's easy enough to add the git config as it suggests. But, I think this seems unnecessary to have to do this, and I think it would be more convenient if the $home/vimfiles directory was created with the users own account ownership. When I was looking at the source code, for example see Your bio says you are a cs major, so perhaps this is this something you'd like to have a go at doing a PR for? |
When a user selects to create $HOME/vimfiles, dosinst is called with the A possible solution is to use |
Actually is this an installer bug that should go in that repo instead? |
we can test it in the vim/vim-win32-installer repo first but if this is a change in |
@k-takata that sounds better :) nice, simple, elegant - and now I see that the ShellExecAsUser::ShellExecAsUser plugin is already used with the nsi scripts. @xsrvmy maybe :) @k-takata and @chrisbra are across both repos. @k-takata and @chrisbra How might we do a PR to the vim-win32-installer git repo, for code that is in vim git submodue? |
I would create a patch (which can reference the vim directory) and place it into the patch directory. that should then be applied during building of the installer. |
i've never done a patch file before, I don't mind having a go and trying to do it. |
If I recall correctly, you need to go with it like this: You can test it, by removing your changes in the vim worktree, going into the |
Something like this? --- a/nsis/gvim.nsi
+++ b/nsis/gvim.nsi
@@ -228,6 +228,28 @@ FunctionEnd
!insertmacro GetParent ""
!insertmacro GetParent "un."
+# Get home directory
+!macro GetHomeDir un
+Function ${un}GetHomeDir
+ Push $0
+ Push $1
+ ReadEnvStr $0 "HOME"
+ ${If} $0 == ""
+ ReadEnvStr $0 "HOMEDRIVE"
+ ReadEnvStr $1 "HOMEPATH"
+ StrCpy $0 "$0$1"
+ ${If} $0 == ""
+ ReadEnvStr $0 "USERPROFILE"
+ ${EndIf}
+ ${EndIf}
+ Pop $1
+ Exch $0 # put $0 on top of stack, restore $0 to original value
+FunctionEnd
+!macroend
+
+!insertmacro GetHomeDir ""
+!insertmacro GetHomeDir "un."
+
# Check if Vim is already installed.
# return: Installed directory. If not found, it will be empty.
Function CheckOldVim
@@ -520,7 +542,7 @@ SectionGroup $(str_group_plugin) id_grou
Section "$(str_section_plugin_home)" id_section_pluginhome
SectionIn 1 3
- StrCpy $1 "$1 -create-directories home"
+ #StrCpy $1 "$1 -create-directories home"
SectionEnd
Section "$(str_section_plugin_vim)" id_section_pluginvim
@@ -594,6 +616,13 @@ Section -call_install_exe
DetailPrint "$(str_msg_registering)"
nsExec::Exec "$0\install.exe $1"
Pop $3
+
+ ${If} ${SectionIsSelected} ${id_section_pluginhome}
+ ReadEnvStr $3 "COMSPEC"
+ Call GetHomeDir
+ Pop $4
+ ShellExecAsUser::ShellExecAsUser "" "$3" '/c mkdir "$4\vimfiles"' SW_HIDE
+ ${EndIf}
SectionEnd
##########################################################
@@ -1042,15 +1071,8 @@ SectionEnd
SectionGroup "un.$(str_ungroup_plugin)" id_ungroup_plugin
Section /o "un.$(str_unsection_plugin_home)" id_unsection_plugin_home
# get the home dir
- ReadEnvStr $0 "HOME"
- ${If} $0 == ""
- ReadEnvStr $0 "HOMEDRIVE"
- ReadEnvStr $1 "HOMEPATH"
- StrCpy $0 "$0$1"
- ${If} $0 == ""
- ReadEnvStr $0 "USERPROFILE"
- ${EndIf}
- ${EndIf}
+ Call un.GetHomeDir
+ Pop $0
${If} $0 != ""
!insertmacro RemoveVimfiles $0 Untested. Even not compiled yet. |
that looks really cool @k-takata looks like you guys have this pretty much sorted out :) I know I asked to have a go at doing it, but I've ran out of time today - and because I gotta bail now for the weekend, so I don't mind if you guys want to wrap it up. I will have a look on sunday and see if anything remaining I can do to help. |
I don't have enough time either. If you (or someone else) want to take it over, it's fine for me. |
@xsrvmy please check the artifact installer from vim/vim-win32-installer#299 |
No permission issue this time. |
Ah, that should be updated. |
Perhaps, the ShellExecAsUser line should be like this:
|
Anyone got any ideas why MSVC 2022 takes 2x longer than MSVC 2015 would take? Might be some compiler settings we could use to get it faster again? @k-takata patch for the sub-directories is now in the PR. Anyway, my earlier test results for this issue - with first patch from @k-takata ; %HOME%\vimfiles directory was correctly owned by the user account on 8.1, 10 and 11 after fresh install. However, on my Win 7.1 test, the owner still remains as Admin group. Not sure if this is just because I might have reduced all the acl settings in my Win 7.1 VM earlier when I set it up to test something else!?. I guess Win7.1 is getting old now, so this is probably a rare edge case - and as this has simple work-arounds anyway - so I don't see it as a problem that needs the installer to deal with right away. |
That was a Windows Security alert - quarantined the vim install.exe heper file.!? I'll report a separate issue. Apart from that, testing of @k-takata new patch works fine - creates the set of vimfiles\sub-dirs with correct ownership. |
okay, if this works, can someone please create a PR against this repo to change it and then to |
if no-one else does, I can do a pr when i get back home in a few days. |
Steps to reproduce
Note that this creates an error if one attempts to initialize a git repo inside vimfiles.
Expected behaviour
The vimfiles folder should be owned by the user. It is in the user folder after all.
Version of Vim
9.0
Environment
Windows 11
Logs and stack traces
No response
The text was updated successfully, but these errors were encountered: