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

Allan McRae allan at archlinux.org
Mon Dec 2 05:44:07 UTC 2019


On 28/11/19 6:40 am, Ryan Gonzalez wrote:
> 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) {

AT_SYMLINK_NOFOLLOW is available on Linux and MSYS2 (which are the
largest users of pacman), but not BSD/OSX and we do have some users there.

>  		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 */
> 


More information about the pacman-dev mailing list