NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.
All the Perl that's Practical to Extract and Report
Stories, comments, journals, and other submissions on use Perl; are Copyright 1998-2006, their respective owners.
Checking permissions is silly (Score:1)
How does that help? If an attacker has permission to change the contents of a config file then they may well have permission to chmod it back to 644 afterwards, surely?
Further, checking the permissions with stat() and then reading the file introduces a race condition, and so does reading it first and then statting.
Some programs like OpenSSH or Apa
-- Ed Avis ed@membled.com
Re:Checking permissions is silly (Score:1)
You can open a file, and then stat the file handle...
Reply to This
Parent
Re: (Score:1)
Doesn't help. The permissions can be changed after you stat and while you still have the file open.
-- Ed Avis ed@membled.com
Re: (Score:1)
A tighter permission check, reasonably cheap: fstat, read, fstat again and check nothing but access time has changed.