From 60094472f75aefbbc957574faa8c1663ee0625d4 Mon Sep 17 00:00:00 2001 From: Kruti Date: Mon, 19 Feb 2024 06:32:44 -0800 Subject: [PATCH] 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. --- open-vm-tools/lib/file/file.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) 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; -- 2.47.3