Class: OsCtld::Commands::User::SubUGIds

Inherits:
Base
  • Object
show all
Defined in:
lib/osctld/commands/user/subugids.rb

Constant Summary collapse

@@mutex =
Mutex.new

Instance Attribute Summary

Attributes inherited from Base

#client, #client_handler, #id, #opts

Instance Method Summary collapse

Methods inherited from Base

#base_execute, #call_cmd, #call_cmd!, #error, #error!, handle, #handled, #indirect?, #initialize, #manipulate, #manipulation_holder, #ok, #progress, #request_stop, run, run!

Constructor Details

This class inherits a constructor from OsCtld::Commands::Base

Instance Method Details

#executeObject



9
10
11
12
13
14
15
# File 'lib/osctld/commands/user/subugids.rb', line 9

def execute
  @@mutex.synchronize do
    generate
  end

  ok
end

#generateObject (protected)



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/osctld/commands/user/subugids.rb', line 19

def generate
  DB::Users.get do |users|
    %w[u g].each do |v|
      File.open("/etc/sub#{v}id.new", 'w') do |f|
        users.each do |u|
          u.send("#{v}id_map").each do |entry|
            f.write("#{u.ugid}:#{entry.host_id}:#{entry.id_count}\n")
          end
        end
      end

      File.rename("/etc/sub#{v}id.new", "/etc/sub#{v}id")
    end
  end
end