qt6-bb10/tests/auto/corelib/io
Thiago Macieira c94bed69b7 moveToTrash/Unix: refactor to use openat()/mkdirat()/renameat()
This ensures much better security against race conditions and attacks,
at the expense of a few more system calls.

On first run (when no trash dir is yet present):

  openat(AT_FDCWD, "/home/tjmaciei/.qttest/share/Trash", O_RDONLY|O_NOFOLLOW|O_CLOEXEC|O_DIRECTORY) = -1 ENOENT (No such file or directory)
  mkdirat(AT_FDCWD, "/home/tjmaciei/.qttest/share/Trash", 0700) = 0
  openat(AT_FDCWD, "/home/tjmaciei/.qttest/share/Trash", O_RDONLY|O_NOFOLLOW|O_CLOEXEC|O_DIRECTORY) = 5
  newfstatat(5, "", {st_mode=S_IFDIR|0700, st_size=0, ...}, AT_EMPTY_PATH) = 0
  getuid()                                = 1000
  openat(5, "files", O_RDONLY|O_NOFOLLOW|O_CLOEXEC|O_DIRECTORY) = -1 ENOENT (No such file or directory)
  mkdirat(5, "files", 0700)               = 0
  openat(5, "files", O_RDONLY|O_NOFOLLOW|O_CLOEXEC|O_DIRECTORY) = 6
  openat(5, "info", O_RDONLY|O_NOFOLLOW|O_CLOEXEC|O_DIRECTORY) = -1 ENOENT (No such file or directory)
  mkdirat(5, "info", 0700)                = 0
  openat(5, "info", O_RDONLY|O_NOFOLLOW|O_CLOEXEC|O_DIRECTORY) = 7
  close(5)                                = 0
  openat(7, "tst_qfile.moveToTrashOpenFile.fjYRxv.trashinfo", O_RDWR|O_CREAT|O_EXCL|O_CLOEXEC, 0666) = 5
  openat(AT_FDCWD, "/usr/share/zoneinfo/UTC", O_RDONLY|O_CLOEXEC) = 8
  newfstatat(8, "", {st_mode=S_IFREG|0644, st_size=114, ...}, AT_EMPTY_PATH) = 0
  newfstatat(8, "", {st_mode=S_IFREG|0644, st_size=114, ...}, AT_EMPTY_PATH) = 0
  read(8, "TZif2\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 4096) = 114
  lseek(8, -60, SEEK_CUR)                 = 54
  read(8, "TZif2\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 4096) = 60
  close(8)                                = 0
  write(5, "[Trash Info]\nPath=/home/tjmaciei"..., 103) = 103
  renameat(AT_FDCWD, "/home/tjmaciei/tst_qfile.moveToTrashOpenFile.fjYRxv", 6, "tst_qfile.moveToTrashOpenFile.fjYRxv") = 0
  close(5)                                = 0
  close(6)                                = 0
  close(7)                                = 0

On subsequent runs:

  openat(AT_FDCWD, "/home/tjmaciei/.qttest/share/Trash", O_RDONLY|O_NOFOLLOW|O_CLOEXEC|O_DIRECTORY) = 5
  newfstatat(5, "", {st_mode=S_IFDIR|0700, st_size=18, ...}, AT_EMPTY_PATH) = 0
  getuid()                                = 1000
  openat(5, "files", O_RDONLY|O_NOFOLLOW|O_CLOEXEC|O_DIRECTORY) = 6
  openat(5, "info", O_RDONLY|O_NOFOLLOW|O_CLOEXEC|O_DIRECTORY) = 7
  close(5)                                = 0
  openat(7, "tst_qfile.moveToTrashOpenFile.sPjrcA.trashinfo", O_RDWR|O_CREAT|O_EXCL|O_CLOEXEC, 0666) = 5
  openat(AT_FDCWD, "/usr/share/zoneinfo/UTC", O_RDONLY|O_CLOEXEC) = 8
  newfstatat(8, "", {st_mode=S_IFREG|0644, st_size=114, ...}, AT_EMPTY_PATH) = 0
  newfstatat(8, "", {st_mode=S_IFREG|0644, st_size=114, ...}, AT_EMPTY_PATH) = 0
  read(8, "TZif2\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 4096) = 114
  lseek(8, -60, SEEK_CUR)                 = 54
  read(8, "TZif2\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 4096) = 60
  close(8)                                = 0
  write(5, "[Trash Info]\nPath=/home/tjmaciei"..., 103) = 103
  renameat(AT_FDCWD, "/home/tjmaciei/tst_qfile.moveToTrashOpenFile.sPjrcA", 6, "tst_qfile.moveToTrashOpenFile.sPjrcA") = 0
  close(5)                                = 0
  close(6)                                = 0
  close(7)                                = 0

Change-Id: I9d43e5b91eb142d6945cfffd1787117927650dab
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2023-10-17 19:08:25 -07:00
..
largefile CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
qabstractfileengine tst_QAbstractFileEngine: compile with QT_NO_FOREACH 2023-08-19 16:28:33 +03:00
qbuffer CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
qdataurl CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
qdebug cmake: Enable Objective-C++ language for standalone test projects 2023-08-01 20:42:30 +02:00
qdir tst_QDir: compile with QT_NO_FOREACH 2023-08-19 16:28:53 +03:00
qdiriterator tst_QDirIterator: build with QT_NO_FOREACH 2023-08-19 16:29:03 +03:00
qfile moveToTrash/Unix: refactor to use openat()/mkdirat()/renameat() 2023-10-17 19:08:25 -07:00
qfileinfo tst_QFileInfo: don't trigger libstdc++ std::filesystem bug 2023-09-01 13:05:45 -07:00
qfileselector tests/auto/*: port Q_FOREACH to ranged-for 2023-08-19 16:29:09 +03:00
qfilesystementry CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
qfilesystemmetadata CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
qfilesystemwatcher tests/auto/: port Q_FOREACH to ranged-for, local const containers 2023-08-19 16:29:25 +03:00
qiodevice CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
qipaddress CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
qlockfile Mark all of Qt as free of Q_FOREACH, except where it isn't 2023-08-19 05:19:42 +00:00
qloggingcategory CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
qloggingregistry CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
qnodebug CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
qprocess QProcess: remove a XFAIL for QNX 2023-09-08 19:00:49 +02:00
qprocess-noapplication CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
qprocessenvironment CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
qresourceengine CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
qsavefile Fix undeclared identifier 'geteuid' for VxWorks 2023-09-12 02:07:04 +00:00
qsettings Main thread-proxy localStorage oprations in native WASM QSettings 2023-08-28 17:53:29 +02:00
qstandardpaths Add StateLocation & GenericStateLocation to StandardLocation 2023-09-07 01:17:13 +03:00
qstorageinfo tst_QStorageInfo: compile with QT_NO_FOREACH 2023-08-19 16:29:40 +03:00
qtemporarydir tst_QTemporaryDir/File: compile with QT_NO_FOREACH 2023-08-19 16:29:47 +03:00
qtemporaryfile QTemporaryFile: Add support for std::filesystem::path 2023-10-09 16:25:57 +02:00
qurl CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
qurlinternal CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
qurlquery CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
qurluts46 CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
qzip CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
CMakeLists.txt Move QZipReader/Writer from QtGui to QtCore 2023-04-26 12:01:05 +02:00