GetAppConfigDir.... lazarus / 32-Linux ---------------------------------------------------------------------- Mark- · 2018-09-21 03:46 Hello, I am porting my first program to Linux, a free program. Learning Linux and Lazarus has been fun. GetAppConfigDir is...confusing. "GetAppConfigDir returns the name of a directory in which the application should store its configuration files on the current OS." OK, the program settings are global (all users use the same settings) so I pass true and get back a path to "/etc/ ". Now the rub, the user does not have permission to write to that directory. Catch-22. Why return a directory/path that requires all users to have root access? Confused. If that is not the directory to create/read/modify configuration settings for all users, regardless of rights, what is the correct directory? Thanks, Mark ---------------------------------------------------------------------- balazsszekely · 2018-09-21 04:16 Hi Mark-, Lazarus uses the same technique to get the config directory: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i PrimaryConfigPath := ExtractFilePath(ChompPathDelim(GetAppConfigDirUTF8(False))) + 'lazarus';and is always writable for the current user. For example on my Linux Mint 18.2, returns the following directory: /home//.config/lazarus. PS: This was tested extensively in the past few years, so something strange is happening at your side. Please test the above example and let us know if it works or not. ---------------------------------------------------------------------- HeavyUser · 2018-09-21 04:19 Doesn't work that way on multi user systems. It doesn't work that way on windows either. A global setup is usually used for the default settings or the reset to defaults and the user's local folder is used to save user preferences. Usually on those settings are some pretty personal choices, from colors to size and types of fonts etc. As far as I know you are still able to have read only access to that folder regardless of user. ---------------------------------------------------------------------- Mark- · 2018-09-21 04:24 Thanks for the response. > /home//.config/lazarus. >GetAppConfigDirUTF8(False) Right. I do not want that. I want one file for all users, not each user with different settings. GetAppConfigDir(true) > It doesn't work that way on windows either. Yes it does. The "C:\ProgramData\\ directory is available to all users regardless of user permissions. ---------------------------------------------------------------------- balazsszekely · 2018-09-21 04:33 @Mark- QuoteYes it does. The "C:\ProgramData\\ directory is available to all users regardless of user permissions.On windows yes, but I'm almost certain there is no such thing in Linux. ---------------------------------------------------------------------- Handoko · 2018-09-21 04:47 Quote from: Mark- on September 21, 2018, 05:46:38 amOK, the program settings are global (all users use the same settings) so I pass true and get back a path to "/etc/ ". Now the rub, the user does not have permission to write to that directory. Catch-22. Why return a directory/path that requires all users to have root access? Because you're trying to save the settings that affect globally (all users) in the system, so you have to have the permission, root access or sudo. It is for security reason, it's Linux not Windows. The /etc/ folder is readable for all users with or without the special permission. I might be wrong but that's what I know. ---------------------------------------------------------------------- Mark- · 2018-09-21 04:54 OK, so where to place a file readable/writable by all users? ---------------------------------------------------------------------- Handoko · 2018-09-21 05:01 As far as I know there is no such the thing in Linux. (correct me if I'm wrong). Yeah, Linux is sometimes stupidly secure. But if you really want a read/write able folder for all users, you can try: /tmp/ I've just tested in on Ubuntu, it worked. But I'm sure you know, storing important data in temp folder is stupid too. ---------------------------------------------------------------------- Mark- · 2018-09-21 05:09 Right from what I read /tmp is cleared at each reboot. Some sources said different events can clear the /tmp directory. /var/tmp might be possible. I did not try. The name was not appealing. ---------------------------------------------------------------------- balazsszekely · 2018-09-21 05:21 Upload to the cloud.  Now seriously working against the system will fire back at some point. Linux is not windows, OSX has its own quirks. Save the config file to the same directory as your application. State in the document that the application folder must be writable and you're good to go. ---------------------------------------------------------------------- Bart · 2018-09-21 13:16 Quote from: Mark- on September 21, 2018, 06:54:55 am OK, so where to place a file readable/writable by all users? Make a folder somewhere, put the file there, then change persmissions to read/write for all users and groups. Do this when installing, you muust have root permissions (sudo) to do so anyway. Not recommended practice on *nix though.