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

windows: fix gem: --no-document in gemrc #398

Merged
merged 3 commits into from
Sep 18, 2024
Merged

Conversation

kenhys
Copy link
Contributor

@kenhys kenhys commented Sep 13, 2024

In the previous versions, append gem: --no-document for c:\ProgramData\gemrc, but it does not work as expected because the default gemrc content is different as we thought.

So, we should override explicitly by gem: --no-document here.

Checked with installing json gem about this behavior.

  C:\>type c:\ProgramData\gemrc
  # This is the system wide config file for Rubygems.
  # It is generated by RubyInstaller as a security measure.
  # Feel free to add any rubygems config options as described on:
  #    https://docs.ruby-lang.org/en/3.1/Gem/ConfigFile.html
  # But do not delete this file as otherwise it could be hijacked by
  # another user in a multi-user environment.
  ---
  {}
  gem: --no-document

  C:\>echo gem: --no-document > c:\ProgramData\gemrc

  C:\>type c:\ProgramData\gemrc
  gem: --no-document

  C:\>gem install json
  Fetching json-2.7.2.gem
  Temporarily enhancing PATH for MSYS/MINGW...
  Building native extensions. This could take a while...
  Successfully installed json-2.7.2
  1 gem installed

@kenhys
Copy link
Contributor Author

kenhys commented Sep 13, 2024

TIPS: c:\ProgramData\gemrc was generated by ridk install 3.

@kenhys
Copy link
Contributor Author

kenhys commented Sep 13, 2024

Before: ri documentation was installed unexpectedly

https://github.com/fluent/fluentd-docker-image/actions/runs/10843478819/job/30090722070

@kenhys
Copy link
Contributor Author

kenhys commented Sep 13, 2024

install: --no-document might be better.

@kenhys
Copy link
Contributor Author

kenhys commented Sep 13, 2024

Hmm, update: --no-document too.

@kenhys
Copy link
Contributor Author

kenhys commented Sep 13, 2024

https://github.com/fluent/fluentd-docker-image/actions/runs/10844861419/job/30094542725?pr=398

gemrcの修正で期待通りri installされなくなった
Building native extensions. This could take a while...
Successfully installed oj-3.16.5
1 gem installed
Temporarily enhancing PATH for MSYS/MINGW...
Building native extensions. This could take a while...
Successfully installed json-2.7.2
1 gem installed
Successfully installed rexml-3.3.5
1 gem installed
Temporarily enhancing PATH for MSYS/MINGW...
Building native extensions. This could take a while...
Successfully installed yajl-ruby-1.4.3
Successfully installed ffi-1.17.0-x64-mingw-ucrt
Successfully installed ffi-win32-extensions-1.0.4
Successfully installed win32-service-2.3.2
Successfully installed win32-ipc-0.7.0
Successfully installed win32-event-0.6.3
Successfully installed webrick-1.8.1
Successfully installed concurrent-ruby-1.3.4
Successfully installed tzinfo-2.0.6
Successfully installed tzinfo-data-1.2024.2
Building native extensions. This could take a while...
Successfully installed strptime-0.2.5
Successfully installed sigdump-0.2.5
Successfully installed serverengine-2.3.2
Building native extensions. This could take a while...
Successfully installed msgpack-1.7.2
Successfully installed logger-1.6.1
Building native extensions. This could take a while...
Successfully installed http_parser.rb-0.8.0
Successfully installed drb-2.2.1
Building native extensions. This could take a while...
Successfully installed cool.io-1.8.1
Building native extensions. This could take a while...
Successfully installed certstore_c-0.1.7
Successfully installed base64-0.2.0
Successfully installed fluentd-1.17.1-x64-mingw-ucrt
21 gems installed
Successfully installed win32-service-2.3.2
1 gem installed
Successfully installed win32-ipc-0.7.0
1 gem installed
Successfully installed win32-event-0.6.3
1 gem installed

@kenhys
Copy link
Contributor Author

kenhys commented Sep 13, 2024

ridk install 3が生成するgemrcの既定値が今後変わって問題になるようならそのときまた考えればいいだろう。

@kenhys kenhys requested a review from daipom September 13, 2024 07:40
@daipom
Copy link
Contributor

daipom commented Sep 13, 2024

I see.
I am concerned about whether it is safe to overwrite it.
This file should not be editable except for a specific user.
Can overwriting this file change the permissions?

I asked rubyinstaller2 about this point.

@kenhys
Copy link
Contributor Author

kenhys commented Sep 17, 2024

I'll fix it a bit.

In the previous versions, append gem: --no-document
for c:\ProgramData\gemrc, but it does not work as expected
because the default gemrc content is different as we thought.

So, we should override explicitly by gem: --no-document here.

  C:\>type c:\ProgramData\gemrc
  # This is the system wide config file for Rubygems.
  # It is generated by RubyInstaller as a security measure.
  # Feel free to add any rubygems config options as described on:
  #    https://docs.ruby-lang.org/en/3.1/Gem/ConfigFile.html
  # But do not delete this file as otherwise it could be hijacked by
  # another user in a multi-user environment.
  ---
  {}
  gem: --no-document

  C:\>echo gem: --no-document > c:\ProgramData\gemrc

  C:\>type c:\ProgramData\gemrc
  gem: --no-document

  C:\>gem install json
  Fetching json-2.7.2.gem
  Temporarily enhancing PATH for MSYS/MINGW...
  Building native extensions. This could take a while...
  Successfully installed json-2.7.2
  1 gem installed

Signed-off-by: Kentaro Hayashi <[email protected]>
@kenhys
Copy link
Contributor Author

kenhys commented Sep 17, 2024

ridk install 3が生成するgemrcの既定値が今後変わって問題になるようならそのときまた考えればいいだろう。

changed to use ruby's one-liner script to replace it.

It will be safe even though the default gemrc was changed by ridk.

@daipom
Copy link
Contributor

daipom commented Sep 17, 2024

I see. I am concerned about whether it is safe to overwrite it. This file should not be editable except for a specific user. Can overwriting this file change the permissions?

I asked rubyinstaller2 about this point.

* [Questions about automatic "system gemrc" file creation oneclick/rubyinstaller2#388](https://github.com/oneclick/rubyinstaller2/issues/388)

Just to be sure, I have confirmed that overwriting the file doesn't change the ACL.

Powershell with administrative privilege

> cp C:\ProgramData\gemrc C:\ProgramData\gemrc.cp
> Set-Acl C:\ProgramData\gemrc.cp -AclObject (Get-Acl C:\ProgramData\gemrc)
> Get-Acl .\gemrc.cp | Format-List Owner,Group,AccessToString


Owner          : NT AUTHORITY\SYSTEM
Group          : NT AUTHORITY\SYSTEM
AccessToString : NT AUTHORITY\SYSTEM Allow  FullControl
                 BUILTIN\Administrators Allow  FullControl
                 BUILTIN\Users Allow  ReadAndExecute, Synchronize

Command Prompt with administrative privilege

echo gem: --no-document > \ProgramData\gemrc.cp

Powershell with administrative privilege

> Get-Acl .\gemrc.cp | Format-List Owner,Group,AccessToString


Owner          : NT AUTHORITY\SYSTEM
Group          : NT AUTHORITY\SYSTEM
AccessToString : NT AUTHORITY\SYSTEM Allow  FullControl
                 BUILTIN\Administrators Allow  FullControl
                 BUILTIN\Users Allow  ReadAndExecute, Synchronize

Dockerfile.template.erb Outdated Show resolved Hide resolved
@daipom
Copy link
Contributor

daipom commented Sep 17, 2024

Just to be sure, I have confirmed that overwriting the file doesn't change the ACL.

I have confirmed it is the same when using Ruby.

Copy link
Contributor

@daipom daipom left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks for this!
Please regenerate Dockerfiles.

kenhys and others added 2 commits September 18, 2024 10:24
Co-authored-by: Daijiro Fukuda <[email protected]>
Signed-off-by: Kentaro Hayashi <[email protected]>
Signed-off-by: Kentaro Hayashi <[email protected]>
@kenhys
Copy link
Contributor Author

kenhys commented Sep 18, 2024

Please regenerate Dockerfiles.

I've forgot it to do so....

@kenhys kenhys merged commit a528078 into fluent:master Sep 18, 2024
5 checks passed
@kenhys kenhys deleted the drop-ri branch September 18, 2024 02:19
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.

2 participants