Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-57165

On macOS QDir::tempPath() falls back to a hardcoded /tmp path if $TMPDIR is empty

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: P3: Somewhat important P3: Somewhat important
    • 5.6.3
    • 5.5.1, 5.6.2, 5.7.0
    • Core: I/O
    • None
    • macOS
    • e2b856d56290e9b3eaaf889b3e0a08badbaa6046

      On macOS, if a process is launched via sudo with an empty $TMPDIR environment variable, QDir::tempPath() falls back to a hardcoded "/tmp" path, which might not be writable.

      Correct writable temporary directory can be obtained via call to NSTemporaryDirectory()

      Sample program is attached. It's output is below:
      1. Normal execution
      Qt tempPath: /var/folders/3z/jqb49r_56xz_ky8fqb55ccnh0000gn/T
      Cocoa tempPath: /var/folders/3z/jqb49r_56xz_ky8fqb55ccnh0000gn/T/

      2. sudo execution
      Qt tempPath: /tmp
      Cocoa tempPath: /var/folders/zz/zyxvpxvq6csfxvn_n0000000000000/T/

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            tpochep Timur Pocheptsov
            ikorobov Ivan Korobov
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes