]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
lib/file/file.c: Handle EACCES during File_CreateDirectoryHierarchyEx
authorKruti <kpendharkar@vmware.com>
Mon, 19 Feb 2024 14:32:44 +0000 (06:32 -0800)
committerKruti <kpendharkar@vmware.com>
Mon, 19 Feb 2024 14:32:44 +0000 (06:32 -0800)
On DELL thinOS, while creating an existing dir in a path without write
permission, mkdir returns EACCES. This breaks the directory
hierarchy check.
This patch handles the EACCES by checking the file with euidaccess
after an EACCES failure.

open-vm-tools/lib/file/file.c

index 241f129e48cf86be64100662c5984334ff7e31a7..0fd2fc3bc9fd669e33f69a534da5e02f5b55c48f 100644 (file)
@@ -1,5 +1,5 @@
 /*********************************************************
- * Copyright (C) 1998-2022 VMware, Inc. All rights reserved.
+ * Copyright (C) 1998-2023 VMware, Inc. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Lesser General Public License as published
@@ -1785,6 +1785,16 @@ File_CreateDirectoryHierarchyEx(const char *pathName,   // IN:
             temp = NULL;
          }
       } else {
+         /*
+          * For DELL thinOS, calling `mkdir' for an existing directory in a
+          * path which we do not have write permission will return with EACCES
+          * instead of EEXIST. Here we test again using `euidaccess' to work
+          * around this.
+          */
+         if (err == EACCES && Posix_EuidAccess(temp, F_OK) == 0) {
+            err = EEXIST;
+         }
+
          if (err == EEXIST) {
             FileData fileData;