aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2022-02-17 08:37:10 +0000
committerRon Yorston <rmy@pobox.com>2022-02-17 08:37:10 +0000
commit67d6d366161c04ec32f2b429a2441016dfd91f2a (patch)
tree0e58054a5d7f8ae38b027680a59e2365c38bc99e
parent5ce146536f50341efd2496370af804bb348fa66e (diff)
downloadbusybox-w32-67d6d366161c04ec32f2b429a2441016dfd91f2a.tar.gz
busybox-w32-67d6d366161c04ec32f2b429a2441016dfd91f2a.tar.bz2
busybox-w32-67d6d366161c04ec32f2b429a2441016dfd91f2a.zip
win32: fake file ownership on FAT filesystems
busybox-w32 tries to display the ownership of files by comparing the security identifier (SID) of the current user with that of the file on disk. For filesystems that don't support SIDs this resulted in files being listed as owned by root. It appears that filesystems without support for file ownership return a null SID. In such cases pretend the file belongs to the current user. GitHub issue #241.
-rw-r--r--win32/mingw.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/win32/mingw.c b/win32/mingw.c
index 06da37040..f34ea1102 100644
--- a/win32/mingw.c
+++ b/win32/mingw.c
@@ -488,9 +488,14 @@ static uid_t file_owner(HANDLE fh)
488 uid_t uid = 0; 488 uid_t uid = 0;
489 DWORD *ptr; 489 DWORD *ptr;
490 unsigned char prefix[] = { 490 unsigned char prefix[] = {
491 0x01, 0x05, 0x00, 0x00, 491 0x01, 0x05, 0x00, 0x00,
492 0x00, 0x00, 0x00, 0x05, 492 0x00, 0x00, 0x00, 0x05,
493 0x15, 0x00, 0x00, 0x00 493 0x15, 0x00, 0x00, 0x00
494 };
495 unsigned char nullsid[] = {
496 0x01, 0x01, 0x00, 0x00,
497 0x00, 0x00, 0x00, 0x01,
498 0x00, 0x00, 0x00, 0x00
494 }; 499 };
495 500
496 /* get SID of current user */ 501 /* get SID of current user */
@@ -520,8 +525,9 @@ static uid_t file_owner(HANDLE fh)
520 525
521 if (EqualSid(pSidOwner, user->User.Sid)) { 526 if (EqualSid(pSidOwner, user->User.Sid)) {
522 uid = DEFAULT_UID; 527 uid = DEFAULT_UID;
523 } 528 } else if (memcmp(pSidOwner, nullsid, sizeof(nullsid)) == 0) {
524 else if (memcmp(pSidOwner, prefix, sizeof(prefix)) == 0) { 529 uid = DEFAULT_UID;
530 } else if (memcmp(pSidOwner, prefix, sizeof(prefix)) == 0) {
525 /* for local or domain users use the RID as uid */ 531 /* for local or domain users use the RID as uid */
526 ptr = (DWORD *)pSidOwner; 532 ptr = (DWORD *)pSidOwner;
527 if (ptr[6] >= 500 && ptr[6] < DEFAULT_UID) 533 if (ptr[6] >= 500 && ptr[6] < DEFAULT_UID)