f-koehler / KTailctl

A GUI to monitor and manage Tailscale on your Linux desktop.
GNU General Public License v3.0
97 stars 3 forks source link

Flatpak version is not saving config. Is it a permissions issue? #270

Open mlongval opened 1 month ago

mlongval commented 1 month ago

Hello,

I am running Kubuntu24.04 with Plasma 5.27.11

I have installed the the Flatpak version of KTailctl (About reports version 0.17.1)

Issue: Settings made inside KTailctl are not saved between launches. (ie: Start minimized, Tray Icon Theme etc)

I checked who it is running as: (turns out that is ok doc is me)

doc@DellL5400:~/.var/app/org.fkoehler.KTailctl/data/fkoehler.org/KTailctl$ ps aux | grep KTail doc 10419 0.0 0.0 9292 2432 pts/3 S+ 14:11 0:00 grep --color=auto org.fkoehler.KTailctl doc 10726 0.0 0.0 9148 2176 pts/2 S+ 14:17 0:00 grep --color=auto KTail

I then got the logs from "journalctl --user -f | grep org.fkoehler.KTailctl"

Jul 14 14:27:29 DellL5400 systemd[1836]: app-flatpak-org.fkoehler.KTailctl-11060.scope: Consumed 12.392s CPU time. Jul 14 14:27:36 DellL5400 plasmashell[4404]: QString::arg: 2 argument(s) missing in org.fkoehler.KTailctl Jul 14 14:27:36 DellL5400 systemd[1836]: Started app-org.fkoehler.KTailctl-aeb68df8de074bfd8256154bc9351100.scope - KTailctl. Jul 14 14:27:36 DellL5400 systemd[1836]: Started app-flatpak-org.fkoehler.KTailctl-11269.scope. Jul 14 14:27:36 DellL5400 plasmashell[11280]: [2024-07-14T14:27:36][warning][/run/build-runtime/kconfig/src/core/kconfigini.cpp:503] Couldn't write "/home/doc/.var/app/org.fkoehler.KTailctl/config/KTailctlrc" . Disk full? Jul 14 14:27:38 DellL5400 plasmashell[11280]: [2024-07-14T14:27:38][warning][/run/build-runtime/kconfig/src/core/kconfigini.cpp:503] Couldn't write "/home/doc/.var/app/org.fkoehler.KTailctl/data/fkoehler.org/KTailctl/data" . Disk full? Jul 14 14:27:40 DellL5400 plasmashell[11280]: [2024-07-14T14:27:40][warning][/run/build-runtime/kconfig/src/core/kconfigini.cpp:503] Couldn't write "/home/doc/.var/app/org.fkoehler.KTailctl/data/fkoehler.org/KTailctl/data" . Disk full?

The disk is not full.

doc@DellL5400:~/.var/app/org.fkoehler.KTailctl/data/fkoehler.org/KTailctl$ df -h /home Filesystem Size Used Avail Use% Mounted on /dev/mapper/luks-a3a3421d-4bee-4ef3-8c55-a84fdc620833 820G 4.4G 774G 1% /home

Is it a permissions issue? ... so I modified the

/home/doc/.var/app/org.fkoehler.KTailctl/data/fkoehler.org/KTailctl/data

file to be world-writable (and I modified all the parent directories to be 775

doc@DellL5400:~/.var/app/org.fkoehler.KTailctl/data/fkoehler.org/KTailctl$ ls -la total 8 drwxrwxr-x 2 doc doc 4096 Jul 14 14:27 . drwxrwxr-x 3 doc doc 4096 Jul 14 00:16 .. -rwxrwxrwx 1 doc doc 0 Jul 14 14:09 data

But I still get the same issue with KTailctl not being able to write the settings.

Any help would be appreciated. I really like KTailctl otherwise. I am just nitpicking here.... :smiley:

Thanks.

FYI: ChatGPT suggested:

doc@DellL5400:~$ flatpak -u override --filesystem=home org.fkoehler.KTailctl

but that did not change anything.

Cheers from Canada!

f-koehler commented 1 month ago

Hi @mlongval,

thanks for the detailed report! I would love to resolve this issue!

What you are reporting is a bit strange. The flatpak override you mentioned should not be necessary at all as it would give the flatpak access to your actual home directory. The path /home/doc/.var/app/org.fkoehler.KTailctl/data/fkoehler.org/KTailctl/data should be available for the flatpak by default, it is the dedicated config directory for this app.

I just tested the flatpak on my machine (NixOS with Plasma 6) and it saves/loads the config options just fine. Would you mind sharing the output of flatpak permission-show org.fkoehler.KTailctl with me? The output is empty for me...

And just to make sure: did you install the flatpak in user mode (flatpak install --user ...) or system-wide?

Greetings from Singapore!

mlongval commented 1 month ago

Hi,

Thanks for the quick reply!

The initial installation was via the KDE Plasma Software Installer thingamajig: "Discover"

I uninstalled it and the tried to install it 2 ways (with and without the --user flag) Here is my output:

doc@DellL5400:~$ flatpak install org.fkoehler.KTailctl
Looking for matches…

org.fkoehler.KTailctl permissions:
ipc      fallback-x11      wayland      x11      dri      file access [1]      dbus access [2]

[1] /run/tailscale:ro, xdg-config/kdeglobals:ro
[2] com.canonical.AppMenu.Registrar, org.kde.KGlobalSettings, org.kde.StatusNotifierWatcher, org.kde.kconfig.notify

ID                                     Branch           Op          Remote           Download
1.     org.fkoehler.KTailctl.Locale           stable           i           flathub          < 147.1 kB (partial)
2.     org.fkoehler.KTailctl                  stable           i           flathub           < 17.4 MB

 Proceed with these changes to the system installation? [Y/n]: n

This is with the -u option:

doc@DellL5400:~$ flatpak install --user org.fkoehler.KTailctl
Looking for matches…
error: No remote refs found for ‘org.fkoehler.KTailctl’
doc@DellL5400:~$ 

So the only way to install it is systemwide. Which I did.

The output of

doc@DellL5400:~$ flatpak permission-show org.fkoehler.KTailctl

doc@DellL5400:~$

The output of journalctl:

doc@DellL5400:~$ journalctl --user -f | grep org.fkoehler.KTailctl
Jul 14 23:23:15 DellL5400 plasmashell[27514]: [2024-07-14T23:23:15][warning][/run/build-runtime/kconfig/src/core/kconfigini.cpp:503] Couldn't write "/home/doc/.var/app/org.fkoehler.KTailctl/data/fkoehler.org/KTailctl/data" . Disk full?
Jul 14 23:23:24 DellL5400 plasmashell[27514]: [2024-07-14T23:23:24][warning][/run/build-runtime/kconfig/src/core/kconfigini.cpp:503] Couldn't write "/home/doc/.var/app/org.fkoehler.KTailctl/config/KTailctlrc" . Disk full?
Jul 14 23:23:31 DellL5400 plasmashell[27514]: [2024-07-14T23:23:31][warning][/run/build-runtime/kconfig/src/core/kconfigini.cpp:503] Couldn't write "/home/doc/.var/app/org.fkoehler.KTailctl/config/KTailctlrc" . Disk full?
Jul 14 23:23:34 DellL5400 plasmashell[27514]: [2024-07-14T23:23:34][warning][/run/build-runtime/kconfig/src/core/kconfigini.cpp:503] Couldn't write "/home/doc/.var/app/org.fkoehler.KTailctl/data/fkoehler.org/KTailctl/data" . Disk full?
Jul 14 23:27:32 DellL5400 systemd[1836]: app-flatpak-org.fkoehler.KTailctl-27500.scope: Consumed 15.100s CPU time.
Jul 14 23:27:39 DellL5400 plasmashell[4404]: QString::arg: 2 argument(s) missing in org.fkoehler.KTailctl
Jul 14 23:27:39 DellL5400 systemd[1836]: Started app-org.fkoehler.KTailctl-defbf494cc034cadb70e7e3da5f7975b.scope - KTailctl.
Jul 14 23:27:39 DellL5400 systemd[1836]: Started app-flatpak-org.fkoehler.KTailctl-27697.scope.
Jul 14 23:27:40 DellL5400 plasmashell[27708]: [2024-07-14T23:27:40][warning][/run/build-runtime/kconfig/src/core/kconfigini.cpp:503] Couldn't write "/home/doc/.var/app/org.fkoehler.KTailctl/config/KTailctlrc" . Disk full?
Jul 14 23:27:42 DellL5400 plasmashell[27708]: [2024-07-14T23:27:42][warning][/run/build-runtime/kconfig/src/core/kconfigini.cpp:503] Couldn't write "/home/doc/.var/app/org.fkoehler.KTailctl/data/fkoehler.org/KTailctl/data" . Disk full?
Jul 14 23:27:46 DellL5400 plasmashell[27708]: [2024-07-14T23:27:46][warning][/run/build-runtime/kconfig/src/core/kconfigini.cpp:503] Couldn't write "/home/doc/.var/app/org.fkoehler.KTailctl/config/KTailctlrc" . Disk full?
Jul 14 23:27:49 DellL5400 plasmashell[27708]: [2024-07-14T23:27:49][warning][/run/build-runtime/kconfig/src/core/kconfigini.cpp:503] Couldn't write "/home/doc/.var/app/org.fkoehler.KTailctl/config/KTailctlrc" . Disk full?
Jul 14 23:27:57 DellL5400 plasmashell[27708]: [2024-07-14T23:27:57][warning][/run/build-runtime/kconfig/src/core/kconfigini.cpp:503] Couldn't write "/home/doc/.var/app/org.fkoehler.KTailctl/data/fkoehler.org/KTailctl/data" . Disk full?

The .../KTailctl/data file:

doc@DellL5400:~/.var/app/org.fkoehler.KTailctl/data/fkoehler.org/KTailctl$ ls -la
total 8
drwxrwxr-x 2 doc doc 4096 Jul 14 23:23 .
drwxrwxr-x 3 doc doc 4096 Jul 14 00:16 ..
-rwxrwxrwx 1 doc doc    0 Jul 14 14:09 data
doc@DellL5400:~/.var/app/org.fkoehler.KTailctl/data/fkoehler.org/KTailctl$

It's got me stumped.

Thanks for your help!

mlongval commented 1 month ago

I even tried symlinking the 2 files in question: (see output from journalctl:

Jul 14 23:43:35 DellL5400 plasmashell[4404]: QString::arg: 2 argument(s) missing in org.fkoehler.KTailctl
Jul 14 23:43:35 DellL5400 systemd[1836]: Started app-org.fkoehler.KTailctl-09db2005921049e1b3b61f6467d0c21f.scope - KTailctl.
Jul 14 23:43:35 DellL5400 systemd[1836]: Started app-flatpak-org.fkoehler.KTailctl-28423.scope.
Jul 14 23:43:36 DellL5400 plasmashell[28434]: [2024-07-14T23:43:36][warning][/run/build-runtime/kconfig/src/core/kconfigini.cpp:503] Couldn't write "/home/doc/.var/app/org.fkoehler.KTailctl/config/KTailctlrc" . Disk full?
Jul 14 23:43:39 DellL5400 plasmashell[28434]: [2024-07-14T23:43:39][warning][/run/build-runtime/kconfig/src/core/kconfigini.cpp:503] Couldn't write "/home/doc/.var/app/org.fkoehler.KTailctl/data/fkoehler.org/KTailctl/data" . Disk full?
Jul 14 23:43:42 DellL5400 plasmashell[28434]: [2024-07-14T23:43:42][warning][/run/build-runtime/kconfig/src/core/kconfigini.cpp:503] Couldn't write "/home/doc/.var/app/org.fkoehler.KTailctl/data/fkoehler.org/KTailctl/data" . Disk full?
Jul 14 23:51:11 DellL5400 systemd[1836]: app-flatpak-org.fkoehler.KTailctl-28423.scope: Consumed 16.713s CPU time.
Jul 14 23:51:20 DellL5400 plasmashell[4404]: QString::arg: 2 argument(s) missing in org.fkoehler.KTailctl
Jul 14 23:51:20 DellL5400 systemd[1836]: Started app-org.fkoehler.KTailctl-7b1c8ca634094aa09836ec6cb0e1f854.scope - KTailctl.
Jul 14 23:51:20 DellL5400 systemd[1836]: Started app-flatpak-org.fkoehler.KTailctl-28683.scope.
Jul 14 23:51:21 DellL5400 plasmashell[28694]: [2024-07-14T23:51:21][warning][/run/build-runtime/kconfig/src/core/kconfigini.cpp:503] Couldn't write "/home/doc/.config/org.fkoehler.KTailctl/config/KTailctlrc" . Disk full?
Jul 14 23:51:24 DellL5400 plasmashell[28694]: [2024-07-14T23:51:24][warning][/run/build-runtime/kconfig/src/core/kconfigini.cpp:503] Couldn't write "/home/doc/.config/org.fkoehler.KTailctl/data/fkoehler.org/KTailctl/data" . Disk full?
Jul 14 23:51:26 DellL5400 plasmashell[28694]: [2024-07-14T23:51:26][warning][/run/build-runtime/kconfig/src/core/kconfigini.cpp:503] Couldn't write "/home/doc/.config/org.fkoehler.KTailctl/data/fkoehler.org/KTailctl/data" . Disk full?

Thanks again!

mlongval commented 1 month ago

I checked and it really seems like a permissions issue. The error:

[/run/build-runtime/kconfig/src/core/kconfigini.cpp:503]

references here:

https://github.com/KDE/kconfig/blob/master/src/core/kconfigini.cpp

Around line 503, shows:

        writeEntries(locale, file, writeMap);

        if (!file.size() && (fileMode == (QFile::ReadUser | QFile::WriteUser))) {
            // File is empty and doesn't have special permissions: delete it.
            file.cancelWriting();

            if (fi.exists()) {
                // also remove the old file in case it existed. this can happen
                // when we delete all the entries in an existing config file.
                // if we don't do this, then deletions and revertToDefault's
                // will mysteriously fail
                QFile::remove(filePath());
            }
        } else {
            // Normal case: Close the file
            if (file.commit()) {
                QFile::setPermissions(filePath(), fileMode);
                return true;
            }
            // Couldn't write. Disk full?
            qCWarning(KCONFIG_CORE_LOG) << "Couldn't write" << filePath() << ". Disk full?";
            return false;
        }

Thanks again.

f-koehler commented 1 month ago

Hi,

Thanks for the quick reply!

The initial installation was via the KDE Plasma Software Installer thingamajig: "Discover"

I uninstalled it and the tried to install it 2 ways (with and without the --user flag) Here is my output:

doc@DellL5400:~$ flatpak install org.fkoehler.KTailctl
Looking for matches…

org.fkoehler.KTailctl permissions:
ipc      fallback-x11      wayland      x11      dri      file access [1]      dbus access [2]

[1] /run/tailscale:ro, xdg-config/kdeglobals:ro
[2] com.canonical.AppMenu.Registrar, org.kde.KGlobalSettings, org.kde.StatusNotifierWatcher, org.kde.kconfig.notify

ID                                     Branch           Op          Remote           Download
1.     org.fkoehler.KTailctl.Locale           stable           i           flathub          < 147.1 kB (partial)
2.     org.fkoehler.KTailctl                  stable           i           flathub           < 17.4 MB

 Proceed with these changes to the system installation? [Y/n]: n

This is with the -u option:

doc@DellL5400:~$ flatpak install --user org.fkoehler.KTailctl
Looking for matches…
error: No remote refs found for ‘org.fkoehler.KTailctl’
doc@DellL5400:~$ 

So the only way to install it is systemwide. Which I did.

The output of

doc@DellL5400:~$ flatpak permission-show org.fkoehler.KTailctl

doc@DellL5400:~$

The output of journalctl:

doc@DellL5400:~$ journalctl --user -f | grep org.fkoehler.KTailctl
Jul 14 23:23:15 DellL5400 plasmashell[27514]: [2024-07-14T23:23:15][warning][/run/build-runtime/kconfig/src/core/kconfigini.cpp:503] Couldn't write "/home/doc/.var/app/org.fkoehler.KTailctl/data/fkoehler.org/KTailctl/data" . Disk full?
Jul 14 23:23:24 DellL5400 plasmashell[27514]: [2024-07-14T23:23:24][warning][/run/build-runtime/kconfig/src/core/kconfigini.cpp:503] Couldn't write "/home/doc/.var/app/org.fkoehler.KTailctl/config/KTailctlrc" . Disk full?
Jul 14 23:23:31 DellL5400 plasmashell[27514]: [2024-07-14T23:23:31][warning][/run/build-runtime/kconfig/src/core/kconfigini.cpp:503] Couldn't write "/home/doc/.var/app/org.fkoehler.KTailctl/config/KTailctlrc" . Disk full?
Jul 14 23:23:34 DellL5400 plasmashell[27514]: [2024-07-14T23:23:34][warning][/run/build-runtime/kconfig/src/core/kconfigini.cpp:503] Couldn't write "/home/doc/.var/app/org.fkoehler.KTailctl/data/fkoehler.org/KTailctl/data" . Disk full?
Jul 14 23:27:32 DellL5400 systemd[1836]: app-flatpak-org.fkoehler.KTailctl-27500.scope: Consumed 15.100s CPU time.
Jul 14 23:27:39 DellL5400 plasmashell[4404]: QString::arg: 2 argument(s) missing in org.fkoehler.KTailctl
Jul 14 23:27:39 DellL5400 systemd[1836]: Started app-org.fkoehler.KTailctl-defbf494cc034cadb70e7e3da5f7975b.scope - KTailctl.
Jul 14 23:27:39 DellL5400 systemd[1836]: Started app-flatpak-org.fkoehler.KTailctl-27697.scope.
Jul 14 23:27:40 DellL5400 plasmashell[27708]: [2024-07-14T23:27:40][warning][/run/build-runtime/kconfig/src/core/kconfigini.cpp:503] Couldn't write "/home/doc/.var/app/org.fkoehler.KTailctl/config/KTailctlrc" . Disk full?
Jul 14 23:27:42 DellL5400 plasmashell[27708]: [2024-07-14T23:27:42][warning][/run/build-runtime/kconfig/src/core/kconfigini.cpp:503] Couldn't write "/home/doc/.var/app/org.fkoehler.KTailctl/data/fkoehler.org/KTailctl/data" . Disk full?
Jul 14 23:27:46 DellL5400 plasmashell[27708]: [2024-07-14T23:27:46][warning][/run/build-runtime/kconfig/src/core/kconfigini.cpp:503] Couldn't write "/home/doc/.var/app/org.fkoehler.KTailctl/config/KTailctlrc" . Disk full?
Jul 14 23:27:49 DellL5400 plasmashell[27708]: [2024-07-14T23:27:49][warning][/run/build-runtime/kconfig/src/core/kconfigini.cpp:503] Couldn't write "/home/doc/.var/app/org.fkoehler.KTailctl/config/KTailctlrc" . Disk full?
Jul 14 23:27:57 DellL5400 plasmashell[27708]: [2024-07-14T23:27:57][warning][/run/build-runtime/kconfig/src/core/kconfigini.cpp:503] Couldn't write "/home/doc/.var/app/org.fkoehler.KTailctl/data/fkoehler.org/KTailctl/data" . Disk full?

The .../KTailctl/data file:

doc@DellL5400:~/.var/app/org.fkoehler.KTailctl/data/fkoehler.org/KTailctl$ ls -la
total 8
drwxrwxr-x 2 doc doc 4096 Jul 14 23:23 .
drwxrwxr-x 3 doc doc 4096 Jul 14 00:16 ..
-rwxrwxrwx 1 doc doc    0 Jul 14 14:09 data
doc@DellL5400:~/.var/app/org.fkoehler.KTailctl/data/fkoehler.org/KTailctl$

It's got me stumped.

Thanks for your help!

Ah I see, seems like KDE Discover installs the flatpak system-wide. I have never tested this mode, I will try to see what happens on my end...

flatpak install --user org.fkoehler.KTailctl likely fails because you have not set up flathub for your user account (only system-wide, maybe done automatically during Kubuntu installation but probably not since it is a Ubuntu Flavor). You can fix this with flatpak remote-add --user --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo (run as your normal user). Then the install command should succeed.

However, I want KTailctl to also work when install system wide so I will try to reproduce.

mlongval commented 1 month ago

I just checked my work system (Ubuntu 24.04 with Plasma 5.27.11), and the settings are saved just fine.

So it must be something specific with my Kubuntu system that is not properly configured.

I am going to dig around and try to learn more about flatpaks.

Don't waste your time on this because it seems like a one-off.

Cheers!

mlongval commented 1 month ago

The only other thing it could be is that one system (the one with the problem) is Kubuntu 24.04, while the other (the one where the settings are saved just fine) is Ubuntu 22.04 with Plasma desktop installed.

So maybe a Flatpak version issue..., better security... ?? More a feature than a bug?

f-koehler commented 1 month ago

So I was able to reproduce the bug in a clean Kubuntu 24.04 VM using the following steps:

  1. Open Discover
  2. Install flatpak backend for Discover from insider Discover
  3. Reopen Discover.
  4. Under settings, click on "Add Flathub" to add the flathub remote for flatpak
  5. Search for KTailctl and click install
  6. Launch application
  7. Change some setting

So I will definitely label this a bug since I would expect this to work. Does not seem to be a broken install on your end.

f-koehler commented 1 month ago

Interestingly, it works on my Plasma 6 NixOS machine when installed system wide...

mlongval commented 1 month ago

Ok. Thanks for checking. I don't have my Kubuntu 24.04 machine with me at work. However I checked on my Ubuntu 22.04 work machine (with Plasma 5) and Flatpak is installed via 'apt'

❯ apt list --installed | grep flatpak
flatpak/jammy,jammy,jammy,jammy,jammy,jammy,jammy,jammy,jammy,jammy,now 1.12.7-1 amd64 [installed]
gnome-software-plugin-flatpak/jammy-updates,now 41.5-2ubuntu2 amd64 [installed]
libflatpak0/jammy,jammy,jammy,jammy,jammy,jammy,jammy,jammy,jammy,jammy,now 1.12.7-1 amd64 [installed,automatic]

I thought perhaps it could be a "sandbox-Inception", ie that Flatpak would have been installed as a Snap and then it could be either system that could be messing things up.

I will check on my Kubuntu 24.04 machine to see if Flatpak is installed as a Snap.

Thanks again!

mlongval commented 1 month ago

I think it may be an Apparmor + Flatpak issue. See:

https://www.omgubuntu.co.uk/2024/07/ubuntu-apparmor-fix-for-telegram-flatpak#comments

Anyway, I found a cudgel of a workaround.

I changed ownership of $HOME/.var/app/org.fkoehler.KTailctl/config/KTailctrlrc to root:root and then I did a chmod 666 on it.

Not elegant at all, but at least now it saves as it should.

Cheers!

f-koehler commented 1 month ago

@mlongval Thanks for the follow-up, this a very helpful resource! That looks like it and a fix seems to be on its way! Let's see if this resolves this issue or if there is work to do on my end!