From: Kruti Date: Mon, 19 Feb 2024 14:32:44 +0000 (-0800) Subject: lib/file/file.c: Handle EACCES during File_CreateDirectoryHierarchyEx X-Git-Tag: stable-12.4.0~25 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=60094472f75aefbbc957574faa8c1663ee0625d4;p=thirdparty%2Fopen-vm-tools.git lib/file/file.c: Handle EACCES during File_CreateDirectoryHierarchyEx 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. --- diff --git a/open-vm-tools/lib/file/file.c b/open-vm-tools/lib/file/file.c index 241f129e4..0fd2fc3bc 100644 --- a/open-vm-tools/lib/file/file.c +++ b/open-vm-tools/lib/file/file.c @@ -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;