Skip to content

Commit

Permalink
[nemo-filemanager] FileModel: use euidaccess() instead of access() to…
Browse files Browse the repository at this point in the history
… check read permissions. JB#47766

access() returns a result based on the real uid/gid rather than
the effective uid/gid. If the calling process has gid=nemo but
egid=privileged then it is still able to read the listing of a
privileged directory.
  • Loading branch information
Bea Lam committed Apr 16, 2020
1 parent 1084494 commit 1d03d36
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/plugin/filemodel.cpp
Expand Up @@ -59,11 +59,11 @@ enum {
BaseNameRole
};

int access(QString fileName, int how)
int euidaccess(QString fileName, int how)
{
QByteArray fab = fileName.toUtf8();
char *fn = fab.data();
return ::access(fn, how);
return ::euidaccess(fn, how);
}

QVector<StatFileInfo> directoryEntries(const QDir &dir)
Expand Down Expand Up @@ -461,7 +461,7 @@ void FileModel::readAllEntries()
return;
}

if (access(dir.path(), R_OK) == -1) {
if (euidaccess(dir.path(), R_OK) == -1) {
qmlInfo(this) << "No permissions to access " << dir.path();
emit error(ErrorReadNoPermissions, dir.path());
return;
Expand All @@ -488,7 +488,7 @@ void FileModel::refreshEntries()
return;
}

if (access(dir.path(), R_OK) == -1) {
if (euidaccess(dir.path(), R_OK) == -1) {
clearModel();
qmlInfo(this) << "No permissions to access " << dir.path();
emit error(ErrorReadNoPermissions, dir.path());
Expand Down

0 comments on commit 1d03d36

Please sign in to comment.