Commit 718abcb6 authored by Harald Sitter's avatar Harald Sitter 🌈
Browse files

smb: disable mode bits getting forwarded to KIO

Summary:
mode bits in libsmb_stat are fairly cheaply constructed. file and directory
qualification is alright, beyond that it is a bit of a shambles.
specifically +W is set iff the DOS attribute READONLY isn't set, but
that attribute doesn't mean what we think it means, at least not on
NT+ systems. see exhaustive comment.

long story short: we cannot represent mode bits accurately because NT's
access controls simply do not map to posix mode bits. therefore I'm
removing the mode setting for the udsentry, making all entries effectively
writable.

whether an entry truly is writable is hard to say anyway. specifically
because SMB+NTFS have independent ACLs. so, the SMB ACL may allow a
given user or group to do something, that doesn't mean they'll also
have permissions on a file system level.

BUG: 414482
FIXED-IN: 19.12.3

Test Plan:
previously not writable shares as described in the bug report are now writable.
permission dialog looks a bit meh now, it wasn't really designed around not knowing
what the access situation is. gnome simply shows a "dunno what permissions we have" label
instead of everything, that seems like a reasonable approach

Reviewers: ngraham

Reviewed By: ngraham

Subscribers: dfaure, kde-frameworks-devel, kfm-devel

Tags: #dolphin, #frameworks

Differential Revision: https://phabricator.kde.org/D27372
parent 2075e763
......@@ -92,15 +92,36 @@ int SMBSlave::browse_stat_path(const SMBUrl& _url, UDSEntry& udsentry)
}
}
udsentry.fastInsert(KIO::UDSEntry::UDS_FILE_TYPE, st.st_mode & S_IFMT);
udsentry.fastInsert(KIO::UDSEntry::UDS_SIZE, st.st_size);
// UID and GID **must** not be mapped. The values returned by libsmbclient are
// simply the getuid/getgid of the process. They mean absolutely nothing.
// Also see libsmb_stat.c.
// Related: https://bugs.kde.org/show_bug.cgi?id=212801
udsentry.fastInsert(KIO::UDSEntry::UDS_ACCESS, st.st_mode & 07777);
// POSIX Access mode must not be mapped either!
// It's meaningless for smb shares and downright disadvantagous.
// The mode attributes outside the ones used and document above are
// useless. The only one actively set is readonlyness.
//
// BUT the READONLY attribute does nothing on NT systems:
// https://support.microsoft.com/en-us/help/326549/you-cannot-view-or-change-the-read-only-or-the-system-attributes-of-fo
// The Read-only and System attributes is only used by Windows Explorer to determine
// whether the folder is a special folder, such as a system folder that has its view
// customized by Windows (for example, My Documents, Favorites, Fonts, Downloaded Program Files),
// or a folder that you customized by using the Customize tab of the folder's Properties dialog box.
//
// As such respecting it on a KIO level is actually wrong as it doesn't indicate actual
// readonlyness since the 90s and causes us to show readonly UI states when in fact
// the directory is perfectly writable.
// https://bugs.kde.org/show_bug.cgi?id=414482
//
// Should we ever want to parse desktop.ini like we do .directory we'd only want to when a
// dir is readonly as per the above microsoft support article.
// Also see:
// https://docs.microsoft.com/en-us/windows/win32/shell/how-to-customize-folders-with-desktop-ini
udsentry.fastInsert(KIO::UDSEntry::UDS_ACCESS, -1);
udsentry.fastInsert(KIO::UDSEntry::UDS_FILE_TYPE, st.st_mode & S_IFMT);
udsentry.fastInsert(KIO::UDSEntry::UDS_SIZE, st.st_size);
udsentry.fastInsert(KIO::UDSEntry::UDS_MODIFICATION_TIME, st.st_mtime);
udsentry.fastInsert(KIO::UDSEntry::UDS_ACCESS_TIME, st.st_atime);
// No, st_ctime is not UDS_CREATION_TIME...
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment