Ruby/Threads/Process

Материал из Wiki.crossplatform.ru

Перейти к: навигация, поиск

Check to see what you can do

def what_can_i_do?
  sys = Process::Sys
  puts "UID=#{sys.getuid}, GID=#{sys.getgid}"
  puts "Effective UID=#{sys.geteuid}, Effective GID=#{sys.getegid}"
  file = "/bin/ls"
  can_do = [:readable?, :writable?, :executable?].inject([]) do |arr, method|
    arr << method if File.send(method, file); arr
  end
  puts "To you, #{file} is: #{can_do.join(", ")}"
end
what_can_i_do?
 
Process.uid = 1000
what_can_i_do?