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

Incorrect ownership when creating files using MSYS2 commands as Administrator #250

Open
1 task done
fgimian opened this issue Dec 24, 2024 · 2 comments
Open
1 task done
Labels
bug Something isn't working

Comments

@fgimian
Copy link

fgimian commented Dec 24, 2024

Description / Steps to reproduce the issue

  1. Install MSYS2
  2. Search for MSYS2 in your start menu, right-click and start any of the environments as Administrator
  3. Create a file in your home directory with touch example.txt
  4. Open the location in Windows Explorer, select example.txt, hit Alt+Enter, select the Security tab and then click Advanced, notice the owner of the file is your username and not the Administrators group

When using any suitable tool to create a file in Command Prompt and PowerShell as Administrator, the owner of the file is the Administrators group as expected.

This problem also goes for any command executed through the bash shell built as part of MSYS2 as well and can result in unexpected behaviour when CLI tools expect that creation of files in an elevated context will be owned by the Administrators group.

Expected behavior

Any file created in a privileged window would be owned by the Administrators group, matching Command Prompt, PowerShell and Windows Explorer.

Actual behavior

Files created using any tools compiled for MSYS2 in a privileged window are owned by the user account, not the Administrators group.

Verification

Windows Version

MSYS_NT-10.0-26100

Are you willing to submit a PR?

I'm unaware how to rectify this issue I'm afraid.

@fgimian fgimian added the bug Something isn't working label Dec 24, 2024
@fgimian
Copy link
Author

fgimian commented Dec 24, 2024

Here's a demonstration using PowerShell running as Administrator. Even without being in the MSYS2 Bash shell, executing touch results in incorrect permissions.

PS C:\Users\Fots\Downloads\example> New-Item file-powershell.txt


    Directory: C:\Users\Fots\Downloads\example


Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a----        24/12/2024   8:58 PM              0 file-powershell.txt


PS C:\Users\Fots\Downloads\example> C:\msys64\usr\bin\touch.exe file-msys2.txt
PS C:\Users\Fots\Downloads\example> Get-Acl -Path .\file-powershell.txt


    Directory: C:\Users\Fots\Downloads\example


Path                Owner                  Access
----                -----                  ------
file-powershell.txt BUILTIN\Administrators NT AUTHORITY\SYSTEM Allow  FullControl...


PS C:\Users\Fots\Downloads\example> Get-Acl -Path .\file-msys2.txt


    Directory: C:\Users\Fots\Downloads\example


Path           Owner           Access
----           -----           ------
file-msys2.txt FOTSIES-PC\Fots NT AUTHORITY\SYSTEM Allow  FullControl...

Kindly let me know if I can provide any further information or if I'm missing something 😄

Thanks heaps!
Fotis

@jeremyd2019 jeremyd2019 transferred this issue from msys2/MSYS2-packages Dec 24, 2024
@jeremyd2019
Copy link
Member

I'm guessing Cygwin does this on purpose, to act more like POSIX.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants