On 05/29/2012 11:20 PM, Peter Hutterer wrote: > On Fri, May 25, 2012 at 08:22:11AM -0700, Chase Douglas wrote: >> Otherwise, the server will fail to start and it won't be obvious what >> happened. >> >> Signed-off-by: Chase Douglas <[email protected]> >> --- >> src/environment.cpp | 26 ++++++++++++++++++++++++++ >> 1 file changed, 26 insertions(+) >> >> diff --git a/src/environment.cpp b/src/environment.cpp >> index 68e05ce..a3a8ead 100644 >> --- a/src/environment.cpp >> +++ b/src/environment.cpp >> @@ -36,6 +36,7 @@ >> #include <csignal> >> #include <cstdlib> >> #include <cstring> >> +#include <fstream> >> #include <iostream> >> #include <stdexcept> >> >> @@ -114,6 +115,31 @@ void xorg::testing::Environment::SetUp() { >> throw std::runtime_error(message); >> } >> >> + /* The Xorg server won't start unless the log file and the old log file >> are >> + * writable. */ >> + std::ofstream log_test; >> + log_test.open(d_->path_to_log_file.c_str(), std::ofstream::out); >> + log_test.close(); >> + if (log_test.fail()) { >> + std::string message; >> + message += "X.org server log file "; >> + message += d_->path_to_log_file; >> + message += " is not writable."; >> + throw std::runtime_error(message); >> + } >> + >> + std::string old_log_file = d_->path_to_log_file.c_str(); >> + old_log_file += ".old"; >> + log_test.open(old_log_file.c_str(), std::ofstream::out); >> + log_test.close(); >> + if (log_test.fail()) { >> + std::string message; >> + message += "X.org old server log file "; >> + message += old_log_file; >> + message += " is not writable."; >> + throw std::runtime_error(message); >> + } >> + > > access(2) may be simpler?
At first glance, it looks like it would be simpler. However, access() doesn't use the effective uid and gid, in case someone made a test suid, and you have to check if a file exists before you can check if it is writeable. > Reviewed-by: Peter Hutterer <[email protected]> anyhow though, it > does the job Thanks, both patches are now pushed. -- Chase _______________________________________________ [email protected]: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
