Skip to content

Commit

Permalink
Fix permissions on lock files on Unix
Browse files Browse the repository at this point in the history
We should create the files with 0666 and let the umask take care of adjusting
to the final permissions in the file system.

[ChangeLog][QtCore][QLockFile] Fixed permissions on lock files on Unix to
allow for adjustments via umask.

Change-Id: Iee6a6ac3920d0ffd4465f54ac6e955f7fe087173
Reviewed-by: Denis Shienkov <[email protected]>
Reviewed-by: Edward Welbourne <[email protected]>
Reviewed-by: Thiago Macieira <[email protected]>
Reviewed-by: David Faure <[email protected]>
  • Loading branch information
tronical committed Aug 5, 2016
1 parent 4e6440a commit 131b7c8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/corelib/io/qlockfile_unix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ QLockFile::LockError QLockFilePrivate::tryLock_sys()
% localHostName() % '\n';

const QByteArray lockFileName = QFile::encodeName(fileName);
const int fd = qt_safe_open(lockFileName.constData(), O_WRONLY | O_CREAT | O_EXCL, 0644);
const int fd = qt_safe_open(lockFileName.constData(), O_WRONLY | O_CREAT | O_EXCL, 0666);
if (fd < 0) {
switch (errno) {
case EEXIST:
Expand Down Expand Up @@ -217,7 +217,7 @@ QLockFile::LockError QLockFilePrivate::tryLock_sys()
bool QLockFilePrivate::removeStaleLock()
{
const QByteArray lockFileName = QFile::encodeName(fileName);
const int fd = qt_safe_open(lockFileName.constData(), O_WRONLY, 0644);
const int fd = qt_safe_open(lockFileName.constData(), O_WRONLY, 0666);
if (fd < 0) // gone already?
return false;
bool success = setNativeLocks(fileName, fd) && (::unlink(lockFileName) == 0);
Expand Down

0 comments on commit 131b7c8

Please sign in to comment.