Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Settings path in Lubuntu



  • Hi,

    My Qt5 Application is designed to be cross-platform Win/Mac/Linux.
    I have currently very few or no conditionals between the platforms in the settings code, I am relying on the Qt5 behaviour.

    All works as expected under Win and Mac, but there is an "anomaly" under Linux.

    The application uses a system scope setting and a user scope setting.
    When opening the application as a regular user, the system scope settings are read-only.
    The system scope settings are stored in /etc/xdg/lubuntu/Mysoft/MyApp.ini.

    To change the system scope settings, my app is executed using "sudo MyApp" and then has write access to the system scope settings.
    However, then the settings path suddenly changes to /etc/xdg/Mysoft/MyApp.ini.
    Why is this? Can I change this behaviour?

    An alternative is to use a special administrative user account and change the ownership and write access of /etc/xdg/lubuntu/Mysoft and its contents to the special admin user. To me, it feels a bit ugly an unusual.

    I need some advice on how to do this the correct way.

    BN



  • @Bengt-0 said in Settings path in Lubuntu:

    To change the system scope settings, my app is executed using "sudo MyApp" and then has write access to the system scope settings.

    Unless your whole app is intended to be some kind of administrative one --- which I doubt --- this is a really bad idea. In fact, really bad!

    The obvious question is: why would your app want to have " write access to the system scope settings"? Why can your app not work under the assumption that system settings are read-only, only write to user scope, and thereby work across all platforms, even if the others allow write access denied under Linux?


  • Lifetime Qt Champion

    Hi
    Is that a special ini file that must be placed there ?
    Else just use
    https://doc.qt.io/qt-5/qstandardpaths.html#details
    to get a writable location across platforms.



  • "why would your app want to have " write access to the system scope settings"? "
    Because someone should "set" the settings!
    If it is read-only for everyone, why have a system scope setting at all?

    The idea is that an admin user sets the application up properly, and then logs out.
    Then other users with less privs uses the application without the possibility to screw it up.



  • Unless there is a very good argument against it, I will probably use the method of admin ownership of the settings path and files. I have tested it and it works.
    Sorry for asking.



  • @mrjj
    Yes, I have considered this, but not tested it.
    However, I am not sure how I can manage the different write access for system vs. user under Linux.
    In Windows, to do the system scope settings, I do "open as Administrator", and this works fine. The "sudo " was an attempt to do something similar but it did not work for the reasons described.


Log in to reply