desktop icon indicating copy to clipboard operation
desktop copied to clipboard

Nextcloud thinks it is logged out if KWallet is locked

Open phoerious opened this issue 6 years ago • 10 comments

Expected behaviour

When using the Nextcloud client on KDE with a GPG-encrypted KWallet, it should wait for the KWallet to unlock.

Actual behaviour

I have Nextcloud in my autostart. When I start my session, GnuPG asks me to insert my security key to unlock the KWallet which has the Nextcloud password in it. Instead of waiting for the unlock, though, Nextcloud thinks it is logged out and shows the login dialogue (which isn't working anyway, because FIDO does not work with its browser wrapper). So in order to use Nextcloud, I have to restart Nextcloud after unlocking the KWallet, because it does not register me opening it (and it should not have shown the login dialogue in the first place, because it isn't really "logged out").

The issue has existed for quite a while, but wasn't always there (but at least 2.4 had it as well).

Steps to reproduce

  1. Install Nextcloud on KDE and use a password- or PGP-encrypted KWallet to save its password
  2. Add Nextcloud to autostart and start a new KDE session
  3. Decrypt the KWallet

This issue may be related to #912, but I only experience when my KWallet is not open.

Client configuration

Client version: 2.5.1 b37cbe

Operating system: Arch Linux

OS language: en_GB

Qt version used by client package (Linux only, see also Settings dialog): 5.12.0

Client package (From Nextcloud or distro) (Linux only): distro

Installation path of client: /usr/bin/nextcloud

phoerious avatar Jan 11 '19 20:01 phoerious

I experience the same problem with a password-protected KWallet under NixOS, Nextcloud desktop client version is 2.5.1 as well.

blipp avatar Mar 04 '19 11:03 blipp

2.5.2git - the same issue

I've also encounterd a problem with network manager - i've tried the first(commented) version of bash workaround and the problem persisted, despite that nextcloud was started staight after kwallet unlock event. Maybe it is caused by chained NM connections (firstly WiFi connection, then OpenVPN connection). Reaching full global network connectivity takes about 15 seconds.

Workaround:

So, I've found a kludge solution for this problem. Ensure that you have installed dbus-monitor and have nextcloud executable in your $PATH Just place this script to KDE startup:

$ cat nextcloud_runner.sh
#!/bin/bash
# ###############################################################################
# This issue also includes kwallet unlocking problem, 
# but if we can connect to wifi and VPN network - we successfully unlocked the kwallet
# ( IN MY CASE: i'm using NetworkManager)
# ###############################################################################
# If you DO NOT store network credentials in kwallet store 
# (e.g using `systemd-networkd` system wide configuration), monitor should look like that:
#
# dbus-monitor --session "sender='org.kde.kwalletd', path=/modules/kwalletd, member='walletOpened'" |
#   while read x; do
#      echo $x | grep -E '.*string "kdewallet".*' && nohup nextcloud >> /dev/null 2>&1
#   done
#
# ###############################################################################
dbus-monitor --system "sender='org.freedesktop.NetworkManager', path=/org/freedesktop/NetworkManager, member='StateChanged'" |
   while read x; do
      echo $x | grep -E '.*uint32\s+70.*' && nohup nextcloud >> /dev/null 2>&1
   done

BloodyAltair avatar Apr 10 '19 17:04 BloodyAltair

Here is a script that is independent of network manager (inspired by @BloodyAltair). It tries to open the wallet, and only runs the nextcloud-client if the wallet is open.

#!/bin/bash
#
# See https://github.com/nextcloud/desktop/issues/1011
#
############################################
# Adjust the following to suit your needs
WALLET="kdewallet"   # Name of wallet storing nextcloud client password
MAX_TRIES=2          # Max. number of tries to ask for password
############################################
i=0
while [ $i -lt $MAX_TRIES ]; do
  ((i++))
  open=`qdbus org.kde.kwalletd5 /modules/kwalletd5 isOpen "$WALLET"`
  if [ "$open" = "true" ]; then
    break
  fi
  qdbus org.kde.kwalletd5 /modules/kwalletd5 open "$WALLET" 0 "nextcloud-client-starter" > /dev/null
done
nohup nextcloud >> /dev/null 2>&1

PhilippWoelfel avatar Jul 10 '19 17:07 PhilippWoelfel

@PhilippWoelfel Nice script, but it seems to that the line

qdbus org.kde.kwalletd5 /modules/kwalletd5 open kdewallet 0 "nextcloud-client-starter" > /dev/null

have to be replaced by (variable $WALLET missing and hardcoded to kdewallet)

qdbus org.kde.kwalletd5 /modules/kwalletd5 open $WALLET 0 "nextcloud-client-starter" > /dev/null

raabf avatar Oct 22 '19 14:10 raabf

@raabf yes, you are right. I updated the script.

PhilippWoelfel avatar Oct 22 '19 16:10 PhilippWoelfel

Works perfectly, thanks. However, I did replace the last line with

exec nextcloud

and then added this thing as a script to my session startup.

phoerious avatar Oct 26 '19 14:10 phoerious

Yup, I'm still facing this issue. I'm using the flatpak "com.nextcloud.desktopclient.nextcloud"

enygmator avatar May 29 '23 09:05 enygmator

I edited the following script for Flatpak. It is the same script as @PhilippWoelfel, but it calls the desktop file from flatpak with KIOclient instead.

#!/bin/bash
#
# See https://github.com/nextcloud/desktop/issues/1011
#
############################################
# Adjust the following to suit your needs
WALLET="kdewallet"   # Name of wallet storing nextcloud client password
MAX_TRIES=2          # Max. number of tries to ask for password
############################################
i=0
while [ $i -lt $MAX_TRIES ]; do
  ((i++))
  open=`qdbus org.kde.kwalletd5 /modules/kwalletd5 isOpen "$WALLET"`
  if [ "$open" = "true" ]; then
    break
  fi
  qdbus org.kde.kwalletd5 /modules/kwalletd5 open "$WALLET" 0 "nextcloud-client-starter" > /dev/null
done
kioclient exec /var/lib/flatpak/exports/share/applications/com.nextcloud.desktopclient.nextcloud.desktop

TeaDrinkingProgrammer avatar Oct 14 '23 10:10 TeaDrinkingProgrammer

Here is a script that is independent of network manager (inspired by @BloodyAltair). It tries to open the wallet, and only runs the nextcloud-client if the wallet is open.

#!/bin/bash
#
# See https://github.com/nextcloud/desktop/issues/1011
#
############################################
# Adjust the following to suit your needs
WALLET="kdewallet"   # Name of wallet storing nextcloud client password
MAX_TRIES=2          # Max. number of tries to ask for password
############################################
i=0
while [ $i -lt $MAX_TRIES ]; do
  ((i++))
  open=`qdbus org.kde.kwalletd5 /modules/kwalletd5 isOpen "$WALLET"`
  if [ "$open" = "true" ]; then
    break
  fi
  qdbus org.kde.kwalletd5 /modules/kwalletd5 open "$WALLET" 0 "nextcloud-client-starter" > /dev/null
done
nohup nextcloud >> /dev/null 2>&1

The solution works for me, but now everytime that I open the console, Nextcloud client pops up :(

JohannesWiesner avatar Nov 12 '23 12:11 JohannesWiesner

It's 2024 and I still encounter this problem :)

vschwaberow avatar Feb 11 '24 05:02 vschwaberow