fix: permissions set by Windows programs are kept on SD cards (#2504)

* fix: keep file permissions set by Windows programs on volumes without extended attributes

Wine's server stores a file's security descriptor in an extended attribute.
Volumes that cannot hold one dropped every descriptor, so a program that
checks and repairs its install folder's permissions repeated the repair on
every start. The descriptor is now kept inside the prefix when the volume
refuses it, and follows the file when the server renames or deletes it.

* fix: a path deleted with remove() drops its kept descriptor too
This commit is contained in:
MaxsTechReview authored and GitHub committed 2026-11-11 20:45:23 -05:00
1 parent 3b6d13a8d7
commit b3c61cf0bf
5 files changed
+580 -7

No files matched your search

+4 -3
View File
@@ -12,7 +12,8 @@
#define FAT_MAGIC 0x4d44
#define EXFAT_MAGIC 0x2011bab0
static int is_wineserver(void) {
__attribute__((visibility("hidden")))
int bl_is_wineserver(void) {
static int cached = -1;
char exe[PATH_MAX];
const char *base;
@@ -43,7 +44,7 @@ void bl_storage_owner(int fd, struct stat *st) {
int saved = errno;
uid_t uid;
if (st != NULL && is_wineserver()) {
if (st != NULL && bl_is_wineserver()) {
uid = getuid();
if (st->st_uid != uid && has_no_unix_owner(fd)) st->st_uid = uid;
}
@@ -60,7 +61,7 @@ int fchmod(int fd, mode_t mode) {
return -1;
}
result = next_fchmod(fd, mode);
if (result != 0 && errno == EPERM && is_wineserver()) {
if (result != 0 && errno == EPERM && bl_is_wineserver()) {
if (has_no_unix_owner(fd)) {
errno = saved;
return 0;