Bug 279165 - Qt's QFile::isWritable is broken by kde4
Summary: Qt's QFile::isWritable is broken by kde4
Status: RESOLVED UNMAINTAINED
Alias: None
Product: kde
Classification: I don't know
Component: general (show other bugs)
Version: 4.6
Platform: Debian unstable Linux
: NOR normal
Target Milestone: ---
Assignee: Unassigned bugs mailing-list
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-08-02 11:59 UTC by Simon
Modified: 2018-02-23 21:16 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Simon 2011-08-02 11:59:51 UTC
Version:           4.6 (using KDE 4.6.2) 
OS:                Linux

File permissions are reported incorrectly to Qt.

Reproducible: Always

Steps to Reproduce:
This code always says that the file (or directory) is writable. filename was /tmp/ro/someFile which did not exist yet, /tmp/ro was r-xr-xr-x. QFile::open returned true as well.

    QFile outFile(filename);
    if (QFileInfo(outFile).isWritable()) {
        qDebug() << "Can write file.";
    } else {
        qDebug() << "Cannot write file.";
    }
    if (QFileInfo(QFileInfo(outFile).absolutePath()).isWritable()) {
        qDebug() << "Can write directory.";
    } else {
        qDebug() << "Cannot write directory.";
    }
    qDebug() << "File permissions: " << outFile.permissions();
    qDebug() << "Directory permissions: " << QFile(QFileInfo(outFile).absolutePath()).permissions();
    if (QFile(QFileInfo(outFile).absolutePath()).permissions() & QFile::WriteUser) {
        qDebug() << "Can write directory.";
    } else {
        qDebug() << "Cannot write directory.";
    }
    if (!outFile.open(QIODevice::WriteOnly)) {
        qDebug() << "Cannot write file " << filename;
        Q_ASSERT(false);
    }

#qt on freenode also suspected that this is the problem for file dialogs to not switch into directories with QFileDialog::setDirectory() but changing into the parent directory and selecting the directory it is assumed to change into.

Actual Results:  
r-xr-xr-x directory is reported as writable.

Expected Results:  
There is no w in r-xr-xr-x, so it is NOT writable! Really!

strace output when opening a file save dialog and trying to save to /tmp/ro/myfile.svproj:

$ strace ./slowmoUI 2>&1 |grep '/tmp/ro'
stat("/tmp/ro/Lego.svproj", 0x226a748)  = -1 ENOENT (No such file or directory)
lstat("/tmp/ro/Lego.svproj", 0x7fffe0daf850) = -1 ENOENT (No such file or directory)
write(2, "kfilemodule(5320)/kurifilter (pl"..., 77kfilemodule(5320)/kurifilter (plugins) KShortUriFilter::filterUri: "/tmp/ro"
stat("/tmp/ro", {st_mode=S_IFDIR|0555, st_size=4096, ...}) = 0
write(2, "kfilemodule(5320)/kurifilter KUr"..., 103kfilemodule(5320)/kurifilter KUriFilterPlugin::setFilteredUri: Got filtered to: KUrl("file:///tmp/ro")
write(2, "kfilemodule(5320)/kurifilter (pl"..., 78kfilemodule(5320)/kurifilter (plugins) KUriSearchFilter::filterUri: "/tmp/ro"
stat("/tmp/ro", {st_mode=S_IFDIR|0555, st_size=4096, ...}) = 0
stat("/tmp/ro/", {st_mode=S_IFDIR|0555, st_size=4096, ...}) = 0
open("/tmp/ro/", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 26
stat("/tmp/ro/", {st_mode=S_IFDIR|0555, st_size=4096, ...}) = 0
open("/tmp/ro/", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 26
stat("/tmp/ro", {st_mode=S_IFDIR|0555, st_size=4096, ...}) = 0
lstat("/tmp/ro", {st_mode=S_IFDIR|0555, st_size=4096, ...}) = 0
stat("/tmp/ro", {st_mode=S_IFDIR|0555, st_size=4096, ...}) = 0
lstat("/tmp/ro", {st_mode=S_IFDIR|0555, st_size=4096, ...}) = 0
stat("/tmp/ro", {st_mode=S_IFDIR|0555, st_size=4096, ...}) = 0
inotify_add_watch(17, "/tmp/ro", IN_ATTRIB|IN_MOVED_FROM|IN_MOVED_TO|IN_CREATE|IN_DELETE|IN_DELETE_SELF) = 10
sendmsg(8, {msg_name(0)=NULL, msg_iov(2)=[{"l\4\1\1\23\0\0\0}\0\0\0W\0\0\0\1\1o\0\1\0\0\0/\0\0\0\0\0\0\0"..., 104}, {"\16\0\0\0file:///tmp/ro\0", 19}], msg_controllen=0, msg_flags=0}, MSG_NOSIGNAL) = 123
write(25, "    12_47_\0\0\0\16file:///tmp/ro", 28) = 28
write(25, "    19_45_\0\0\0\25file:///tmp/ro/myf"..., 35) = 35
write(2, "kfilemodule(5320)/kio (KIOJob) K"..., 92kfilemodule(5320)/kio (KIOJob) KIO::SlaveInterface::dispatch: error  111   "/tmp/ro/myfile"
write(25, "    20_45_\0\0\0\34file:///tmp/ro/myf"..., 42) = 42
write(2, "kfilemodule(5320)/kio (KIOJob) K"..., 99kfilemodule(5320)/kio (KIOJob) KIO::SlaveInterface::dispatch: error  111   "/tmp/ro/myfile.svproj"
write(25, "    20_45_\0\0\0\34file:///tmp/ro/myf"..., 42) = 42
write(2, "kfilemodule(5320)/kio (KIOJob) K"..., 99kfilemodule(5320)/kio (KIOJob) KIO::SlaveInterface::dispatch: error  111   "/tmp/ro/myfile.svproj"
lstat("/tmp/ro", {st_mode=S_IFDIR|0555, st_size=4096, ...}) = 0
lstat("/tmp/ro/myfile.svproj", 0x7fffe0dad410) = -1 ENOENT (No such file or directory)
stat("/tmp/ro/myfile.svproj", 0x7fffe0dae0e0) = -1 ENOENT (No such file or directory)
open("/tmp/ro/myfile.svproj", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/tmp/ro/myfile.svproj", 0x2aea1c8) = -1 ENOENT (No such file or directory)
lstat("/tmp/ro/myfile.svproj", 0x7fffe0dae000) = -1 ENOENT (No such file or directory)
stat("/tmp/ro/myfile.svproj", 0x2aea1c8) = -1 ENOENT (No such file or directory)
lstat("/tmp/ro/myfile.svproj", 0x7fffe0db09a0) = -1 ENOENT (No such file or directory)
write(2, "Saving project as  \"/tmp/ro/myfi"..., 44Saving project as  "/tmp/ro/myfile.svproj" 
lstat("/tmp/ro", {st_mode=S_IFDIR|0555, st_size=4096, ...}) = 0
sendmsg(8, {msg_name(0)=NULL, msg_iov(2)=[{"l\4\1\1\23\0\0\0\204\0\0\0O\0\0\0\1\1o\0\1\0\0\0/\0\0\0\0\0\0\0"..., 96}, {"\16\0\0\0file:///tmp/ro\0", 19}], msg_controllen=0, msg_flags=0}, MSG_NOSIGNAL) = 115
Comment 1 Simon 2011-08-02 12:12:24 UTC
PS: I was wrong -- actually saved to a different file. Permissions work. The problem with the file dialog exists though. Is this the right place for its report?
Comment 2 Christoph Feck 2011-08-04 02:36:43 UTC
"QFileDialog::setFileMode(QFileDialog::ExistingFile)" should work as a workaround, until we find the bug.
Comment 3 Simon 2011-08-04 07:26:44 UTC
Okay. Would strace output help finding it?
Comment 4 Ben Creasy 2018-02-23 21:16:55 UTC
If this is happening with KDE, please leave a comment.