瀏覽代碼

Merge branch 'upstream-KWSys' into update-kwsys

# By KWSys Upstream
* upstream-KWSys:
  KWSys 2020-04-01 (25694819)
Brad King 5 年之前
父節點
當前提交
afe8a5eb3f
共有 1 個文件被更改,包括 8 次插入1 次删除
  1. 8 1
      Source/kwsys/testSystemTools.cxx

+ 8 - 1
Source/kwsys/testSystemTools.cxx

@@ -328,7 +328,14 @@ static bool CheckFileOperations()
   }
   }
 
 
   // While we're at it, check proper TestFileAccess functionality.
   // While we're at it, check proper TestFileAccess functionality.
-  if (kwsys::SystemTools::TestFileAccess(testNewFile,
+  bool do_write_test = true;
+#if defined(__linux__)
+  // If we are running as root on linux ignore this check, as
+  // root can always write to files
+  do_write_test = (getuid() != 0);
+#endif
+  if (do_write_test &&
+      kwsys::SystemTools::TestFileAccess(testNewFile,
                                          kwsys::TEST_FILE_WRITE)) {
                                          kwsys::TEST_FILE_WRITE)) {
     std::cerr
     std::cerr
       << "TestFileAccess incorrectly indicated that this is a writable file:"
       << "TestFileAccess incorrectly indicated that this is a writable file:"