[pacman-dev] [PATCH 2/2] remove: Don't follow symlinks in checking if a file can be removed

Ryan Gonzalez rymg19 at gmail.com
Wed Nov 27 20:40:51 UTC 2019


Otherwise, symlinks to non-removable files will be logged as unable to
be removed.

Signed-off-by: Ryan Gonzalez <rymg19 at gmail.com>
---
 lib/libalpm/remove.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/libalpm/remove.c b/lib/libalpm/remove.c
index 9030bfee..bb980e7d 100644
--- a/lib/libalpm/remove.c
+++ b/lib/libalpm/remove.c
@@ -339,7 +339,7 @@ static int can_remove_file(alpm_handle_t *handle, const alpm_file_t *file)
 
 	/* If we fail write permissions due to a read-only filesystem, abort.
 	 * Assume all other possible failures are covered somewhere else */
-	if(_alpm_access(handle, NULL, filepath, W_OK) == -1) {
+	if(_alpm_access_flags(handle, NULL, filepath, W_OK, AT_SYMLINK_NOFOLLOW) == -1) {
 		if(errno != EACCES && errno != ETXTBSY && access(filepath, F_OK) == 0) {
 			/* only return failure if the file ACTUALLY exists and we can't write to
 			 * it - ignore "chmod -w" simple permission failures */
-- 
2.23.0


More information about the pacman-dev mailing list