Opened 5 months ago

Closed 5 months ago

#23276 closed defect (fixed)

ruby installs files owned by root in user dir

Reported by: pierre Owned by: blfs-book
Priority: normal Milestone: 13.1
Component: BOOK Version: git
Severity: medium Keywords:
Cc:

Description (last modified by pierre)

To reproduce:

  • use a terminal and cli (no graphical environment, since this one would create ~/.local/share)
  • be logged in as a user (not root)
  • rm -r ~/.local
  • build ruby with book instructions
  • after sudo -E make install, do ls -al ~/.local

Then .local is owned by root, and contains a share (empty) directory owned by root.

Change History (4)

comment:1 by pierre, 5 months ago

Description: modified (diff)

comment:2 by pierre, 5 months ago

Note that with sudo make install, the .local directory is created in /root. But HOME is passed to sudo by sudo -E. So more a problem of sudo configuration...

comment:3 by pierre, 5 months ago

I think we should recommend to use sudo -E -H instead of just sudo -E in the note for sudo configuration. But we might be concerned about creating files in /root directory...

The code creating this directory seems to be in .bundle/gems/rdoc-7.0.3/lib/rdoc.rb:

[...]
##
  # Searches and returns the directory for settings.
  #
  # 1. <tt>$HOME/.rdoc</tt> directory, if it exists.
  # 2. The +rdoc+ directory under the path specified by the
  #    +XDG_DATA_HOME+ environment variable, if it is set.
  # 3. <tt>$HOME/.local/share/rdoc</tt> directory.
  #
  # Other than the home directory, the containing directory will be
  # created automatically.

  def self.home
    rdoc_dir = begin
                File.expand_path('~/.rdoc')
              rescue ArgumentError
              end

    if File.directory?(rdoc_dir)
      rdoc_dir
    else
      require 'fileutils'
      begin
        # XDG
        xdg_data_home = ENV["XDG_DATA_HOME"] || File.join(File.expand_path("~"), '.local', 'share')
        unless File.exist?(xdg_data_home)
          FileUtils.mkdir_p xdg_data_home
        end
        File.join xdg_data_home, "rdoc"
      rescue Errno::EACCES
      end
    end
  end
[...]

(I'm not a ruby expert but the code seems to create ~/.local/share if it does not exist)

We may want to use:

XDG_DATA_HOME=/tmp make install

(with a command explanation of course)

comment:4 by pierre, 5 months ago

Resolution: → fixed
Status: new → closed

Fixed at 63cfa1c7.

Note: See TracTickets for help on using tickets.