From: "Iñaki Baz Castillo" Date: 2009-12-13T02:06:43+09:00 Subject: Re: How to make a ruby program tu run unser other user:group different than root El Sábado, 12 de Diciembre de 2009, Iñaki Baz Castillo escribió: > > Maybe you like to copy that: > > > > http://bertram-scharpf.homelinux.com:8808/doc_root/bs-ruby-3.0/rdoc/class > >e s/Kernel.src/M000100.html > > Really annoying. however I've found an issue with group permissions when > doing Kernel#su. I must to investigate it a bit more. Let me explain it: - My home "/home/ibc" has these owner/group and permissions: drwxr-x--- ibc ibc_grp /home/ibc/ - Other user "alice" belongs to group "ibc_grp" group so "alice" user can read into /home/ibc: ~# whoami alice ~# cd /home/ibc ~# echo $? 0 - Now I start a irb session with root user, load "fileutils" and your "kernel#su" Ruby file. - I do "su" to become "alice:alice" and try to enter in /home/ibc, but it fails: irb> su "alice", "alice" do Dir.chdir("/home/ibc") ; end (irb):9:in `chdir': Permission denied - /home/ibc (Errno::EACCES) from (irb):9:in `block in irb_binding' from /PATH_TO/kernel.rb:7:in `block in su' - It also doesn't work even setting "root" as group (same error). kernel.rb: ------------- module Kernel def su u, g = nil if block_given? then pid = fork { su u, g yield <--- line 7 } _, status = Process.waitpid2 pid return status end uid = case u when Fixnum then [...] ------------- Is it an issue in your code or in fileutils gem? Thanks a lot. -- Iñaki Baz Castillo