I have a world-writable file, not owned by me, that I try to touch:
-rwxrwxrwx 1 root root 0 Oct 11 10:29 /tmp/file
ruby -rfileutils -e ‘FileUtils.touch("/tmp/file")’
/usr/lib/ruby/1.8/fileutils.rb:1014:in utime': Operation not permitted - /tmp/file (Errno::EPERM) from /usr/lib/ruby/1.8/fileutils.rb:1014:intouch’
from /usr/lib/ruby/1.8/fileutils.rb:1012:in `touch’
from -e:1
but:
ruby -e ‘system(“touch /tmp/file”)’
succeeds.
The reason is that File.utime cannot be called with a NULL argument.
Linux (and I assume this is Posix) allows a utime call with NULL if
the file is writeable,
but to change the time a process must have special privileges.
With the current File.utime FileUtils cannot implement this.
At Wed, 11 Oct 2006 17:37:05 +0900,
Han H. wrote in [ruby-talk:219037]:
The reason is that File.utime cannot be called with a NULL argument.
Linux (and I assume this is Posix) allows a utime call with NULL if
the file is writeable,
but to change the time a process must have special privileges.
With the current File.utime FileUtils cannot implement this.
In mail “Re: FileUtils.touch not consistent with system(‘touch’)”
“Nobuyoshi N.” [email protected] wrote:
The reason is that File.utime cannot be called with a NULL argument.
Linux (and I assume this is Posix) allows a utime call with NULL if
the file is writeable,
but to change the time a process must have special privileges.
With the current File.utime FileUtils cannot implement this.
What about this?
Index: lib/fileutils.rb
This part seems nice, please commit it after File.utime
patch is committed.