From: Michael Orlitzky Date: Mon, 18 Jun 2018 00:57:24 +0000 (-0400) Subject: src/libadacl.c: add a special case for the path ".." as an argument. X-Git-Tag: v0.4.1~6 X-Git-Url: https://gitweb.michael.orlitzky.com/?a=commitdiff_plain;h=1ad6e96c6b6d1ac60ce3f5e39e674d157fae53ad;p=apply-default-acl.git src/libadacl.c: add a special case for the path ".." as an argument. In a similar vein, the path ".." needs special-case handling when opening its parent and child file descriptots. With the special-case added, the test suite once again passes. --- diff --git a/src/libadacl.c b/src/libadacl.c index a43afa5..911e69a 100644 --- a/src/libadacl.c +++ b/src/libadacl.c @@ -1016,6 +1016,9 @@ int apply_default_acl(const char* path, bool recursive) { if (strcmp(path, ".") == 0 && strcmp(parent, ".") == 0) { parent_fd = safe_open("..", O_DIRECTORY | O_NOFOLLOW); } + else if (strcmp(path, "..") == 0 && strcmp(parent, ".") == 0) { + parent_fd = safe_open("../..", O_DIRECTORY | O_NOFOLLOW); + } else { parent_fd = safe_open(parent, O_DIRECTORY | O_NOFOLLOW); } @@ -1050,6 +1053,9 @@ int apply_default_acl(const char* path, bool recursive) { if (strcmp(path, ".") == 0 && strcmp(parent, ".") == 0) { fd = open(".", O_NOFOLLOW); } + else if (strcmp(path, "..") == 0 && strcmp(parent, ".") == 0) { + fd = open("..", O_NOFOLLOW); + } else { fd = openat(parent_fd, basename(basename_path_copy), O_NOFOLLOW); }