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

Qt takes wrong XDG_RUNTIME_DIR when running program with su -c

    XMLWordPrintable

Details

    • Bug
    • Resolution: Out of scope
    • P3: Somewhat important
    • None
    • 5.8.0, 5.9.1
    • Core: I/O
    • None

    Description

      Following is a modified snippet from src/corelib/io/qstandardpaths_unix.cpp

       

      const uint myUid = uint(geteuid());

      qDebug() << "myUid" << myUid; 

      QFileInfo fileInfo; QString xdgRuntimeDir = QFile::decodeName(qgetenv("XDG_RUNTIME_DIR"));

      qDebug() << "xdgRuntimeDir" << xdgRuntimeDir;  fileInfo.setFile(xdgRuntimeDir); 

      qDebug() << "fileowner:" << fileInfo.ownerId();

      // "The directory MUST be owned by the user"

      if (fileInfo.ownerId() != myUid) {

        qWarning("QStandardPaths: wrong ownership on runtime directory %s, %d instead of %d", qPrintable(xdgRuntimeDir), fileInfo.ownerId(), myUid);

      }

      If I build and run this as normal user on Linux, the output is:

      $ ./test

      myUid 1000
      xdgRuntimeDir "/tmp/xdg-runtime-guest/"
      fileowner: 1000

      However, if I run it with su:

      $ su -c ./test

      myUid 0
      xdgRuntimeDir "/tmp/xdg-runtime-guest/"
      fileowner: 1000
      QStandardPaths: wrong ownership on runtime directory /tmp/xdg-runtime-guest/, 1000 instead of 0

       

       

      Attachments

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

        Activity

          People

            thiago Thiago Macieira
            jssouza jssouza
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes