Skip to content

Need option to set permissions on created files/dir #346

Closed

Description

@grulja

With a recent change in Qt, there is a check for correct permission on the user runtime directory (/run/user/xxxx), where when the permission is wrong, we will never get the runtime directory from QStandardPaths::RuntimeLocation. When this fails, many thing became broken. For example we are unable to identify whether a Qt app is running under Flatpak.

The error from Qt is:
QStandardPaths: wrong permissions on runtime directory /run/user/1000, 7755 instead of 7700

Qt upstream change: https://codereview.qt-project.org/c/qt/qtbase/+/256521

Activity

  1. changed the title [-]Wrong permission on user runtime directory[/-] [+]Need option to set permissions on created files/dir[/+] on Feb 6, 2020
  2. alexlarsson commented on Feb 6, 2020

    @alexlarsson
    Collaborator

    We use bwrap --directory to make the runtime directory on the root tmpfs, but there is currently no way to tell bwrap to create it with some particular permissions.

    I guess we would need to add a way to chmod the directory.

  3. Erick555 commented on Feb 28, 2020

    @Erick555

    @grulja did you tried submit revert that patch upstream considering it breaks flatpak?

  4. Erick555 commented on Feb 29, 2020

    @Erick555

    Reverting only the last chunk should suffice:

    -            qWarning("QStandardPaths: wrong permissions on runtime directory %ls, %x instead of %x",
    -                     qUtf16Printable(xdgRuntimeDir), uint(fileInfo.permissions()), uint(wantedPerms));
    -            return QString();
    +            QFile file(xdgRuntimeDir);
    +            if (!file.setPermissions(wantedPerms)) {
    +                qWarning("QStandardPaths: could not set correct permissions on runtime directory %s: %s",
    +                         qPrintable(xdgRuntimeDir), qPrintable(file.errorString()));
    +                return QString();
    +            }
    
  5. grulja commented on Mar 2, 2020

    @grulja
    Author

    @grulja did you tried submit revert that patch upstream considering it breaks flatpak?

    I did not, because to me it doesn't seem to be a Qt issue. In my opinion they are correct that they shouldn't be changing the permissions of the runtime directory.

  6. Erick555 commented on Mar 2, 2020

    @Erick555

    I did not, because to me it doesn't seem to be a Qt issue. In my opinion they are correct that they shouldn't be changing the permissions of the runtime directory.

    @grulja the problem isn't they change permissions, the problem is they stop using existing runtime dir when it has different permissions than they expect. Runtime dir isn't solely owned by Qt and they shouldn't put themselves in position to decide what is correct runtime dir and what isn't.

  7. cmollekopf commented on Mar 9, 2020

    @cmollekopf

    @grulja: I agree qt shouldn't be changing permissions but it seems to enforce the exact set of permissions, but it should IMO just check that the permissions are sufficient for Qt (which they would be I think as Qt wants 700 and bubblewrap provides 755).

    In the gpg-agent case that requires the same functionality enforcing the permissions probably makes more sense.

  8. smtalk commented on Apr 15, 2020

    @smtalk

    "--file 13 /etc/my.cnf " would also create a file with perms 666 by default, and MySQL would simply refuse reading it because of:
    "Warning: World-writable config file '/etc/my.cnf' is ignored"

    I'd suggest allowing to specify umask/chmod for created files (folders).

  9. added a commit that references this issue on Feb 16, 2021
  10. smcv commented on Feb 16, 2021

    @smcv
    Collaborator

    #406 implements options that would let you use --dir /run/user/1000 --chmod 0700 /run/user/1000 - or alternatively --perms 0700 --dir /run/user/1000, but that only works if you make sure /run/user/1000 doesn't already exist.

  11. smcv commented on Feb 16, 2021

    @smcv
    Collaborator

    "--file 13 /etc/my.cnf " would also create a file with perms 666 by default

    Workaround: use --bind-file 13 /etc/my.cnf, which defaults to 0600.

    Or, #406 would let you use --perms 0600 --bind-file 13 /etc/my.cnf.

  12. added a commit that references this issue on Apr 7, 2021
  13. added a commit that references this issue on Apr 19, 2021
  14. added a commit that references this issue on May 14, 2021
  15. added a commit that references this issue on Mar 19, 2023
  16. added a commit that references this issue on Jul 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions