xaizek / vifm (License: GPLv2+) (since 2018-12-07)
Vifm is a file manager with curses interface, which provides Vi[m]-like environment for managing objects within file systems, extended with some useful ideas from mutt.
Commit 09e976d017599e6be3639b395efed4891f07ddde

Fix rooted trashes and read-only file-systems
Fix treating a failure to create a trash directory on a read-only
file-system in a Unix environment as a success.

The issue was introduced in commit
dc63ea0c6e26a36431afa971bb9eb624cffc7ec8 which did not differentiate
between two uses of try_create_trash_dir(), that commit was:

Ignore read-only trash directory error

The issue became apparent on MacOS after commit
4ed5d79ed1a0f3c11fa2f3ad2c1b8b4831f872d1:

Fix 'trashdir' with "%r" on BSD-like systems

Thanks to feekApp.

Fixes #1079 on GitHub.
Author: xaizek
Author date (UTC): 2025-05-05 14:43
Committer name: xaizek
Committer date (UTC): 2025-05-05 20:48
Parent(s): eafe9ba8be5e73eb50d1ccaeb21e5ed020422ce0
Signing key: 99DC5E4DB05F6BE2
Tree: ca1dd3f62ae7b6daf43b9c560ee8216017b27337
File Lines added Lines deleted
ChangeLog 3 0
THANKS 1 0
src/trash.c 11 9
File ChangeLog changed (mode: 100644) (index d231da65e..5c682cddd)
79 79 Fixed user-specific trash directory (absolute path, `%u` and no `%r`) Fixed user-specific trash directory (absolute path, `%u` and no `%r`)
80 80 created on setting 'trashdir' not having reduced set of permissions. created on setting 'trashdir' not having reduced set of permissions.
81 81
82 Fixed treating a failure to create a trash directory on a read-only
83 file-system in a Unix environment as a success. Thanks to feekApp.
84
82 85 0.14-beta to 0.14 (2025-02-08) 0.14-beta to 0.14 (2025-02-08)
83 86
84 87 Improved documentation on zh/zl menu keys a bit. Improved documentation on zh/zl menu keys a bit.
File THANKS changed (mode: 100644) (index a741ab9fa..03c713ce5)
... ... emorozov
100 100 Evgeniy (iron-udjin) Evgeniy (iron-udjin)
101 101 Factorial Prime Factorial Prime
102 102 Fang (peromage) Fang (peromage)
103 feekApp
103 104 Flaviu Tamas (flaviut) Flaviu Tamas (flaviut)
104 105 Florian Baumann (derflob) Florian Baumann (derflob)
105 106 flux242 flux242
File src/trash.c changed (mode: 100644) (index d5016db29..3746e5ed7)
... ... get_list_of_trashes_traverser_state;
92 92
93 93 static int validate_spec(const char spec[]); static int validate_spec(const char spec[]);
94 94 static int create_trash_dir(const char trash_dir[], int user_specific); static int create_trash_dir(const char trash_dir[], int user_specific);
95 static int try_create_trash_dir(const char trash_dir[], int user_specific);
95 static int try_create_trash_dir(const char trash_dir[], int user_specific,
96 int interactive);
96 97 static void empty_trash_dirs(void); static void empty_trash_dirs(void);
97 98 static void empty_trash_dir(const char trash_dir[], int can_delete); static void empty_trash_dir(const char trash_dir[], int can_delete);
98 99 static void empty_trash_in_bg(bg_op_t *bg_op, void *arg); static void empty_trash_in_bg(bg_op_t *bg_op, void *arg);
 
... ... create_trash_dir(const char trash_dir[], int user_specific)
220 221 { {
221 222 LOG_FUNC_ENTER; LOG_FUNC_ENTER;
222 223
223 if(try_create_trash_dir(trash_dir, user_specific) != 0)
224 if(try_create_trash_dir(trash_dir, user_specific, /*interactive=*/1) != 0)
224 225 { {
225 226 show_error_msgf("Error Setting Trash Directory", show_error_msgf("Error Setting Trash Directory",
226 227 "Could not set trash directory to %s: %s", trash_dir, strerror(errno)); "Could not set trash directory to %s: %s", trash_dir, strerror(errno));
 
... ... create_trash_dir(const char trash_dir[], int user_specific)
233 234 /* Tries to create trash directory. Returns zero on success, otherwise non-zero /* Tries to create trash directory. Returns zero on success, otherwise non-zero
234 235 * value is returned. */ * value is returned. */
235 236 static int static int
236 try_create_trash_dir(const char trash_dir[], int user_specific)
237 try_create_trash_dir(const char trash_dir[], int user_specific, int interactive)
237 238 { {
238 239 LOG_FUNC_ENTER; LOG_FUNC_ENTER;
239 240
 
... ... try_create_trash_dir(const char trash_dir[], int user_specific)
242 243 if(make_path(trash_dir, 0777) != 0) if(make_path(trash_dir, 0777) != 0)
243 244 { {
244 245 #ifndef _WIN32 #ifndef _WIN32
245 /* Do not treat it as an error if trash is not writable because
246 * file-system is mounted read-only. User should be aware of it. */
247 return (errno != EROFS);
248 #else
249 return 1;
246 if(interactive)
247 {
248 /* Do not treat it as an error if the trash is not writable because
249 * file-system is mounted read-only. User should be aware of it. */
250 return (errno != EROFS);
251 }
250 252 #endif #endif
251 253 } }
252 254 } }
 
... ... static int
684 686 pick_trash_dir_traverser(const char base_path[], const char trash_dir[], pick_trash_dir_traverser(const char base_path[], const char trash_dir[],
685 687 int user_specific, void *arg) int user_specific, void *arg)
686 688 { {
687 if(try_create_trash_dir(trash_dir, user_specific) == 0)
689 if(try_create_trash_dir(trash_dir, user_specific, /*interactive=*/0) == 0)
688 690 { {
689 691 char **const result = arg; char **const result = arg;
690 692 *result = strdup(trash_dir); *result = strdup(trash_dir);
Hints

Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://code.reversed.top/user/xaizek/vifm

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@code.reversed.top/user/xaizek/vifm

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a pull request:
... clone the repository ...
... make some changes and some commits ...
git push origin master