desktop icon indicating copy to clipboard operation
desktop copied to clipboard

[Bug]: nextcloud client failed to parse netrc

Open 130e opened this issue 1 year ago • 3 comments

⚠️ Before submitting, please verify the following: ⚠️

Bug description

After upgrading to 3.14.0, nextcloud client commandline (nextcloudcmd) failed to parse netrc credential with -n option. As a result, nextcloud server prompt for credential.
On the other hand, using --user and --password options work.

Steps to reproduce

  1. Create the file ~/.netrc as:
default
login admin
password mypassword
  1. Run nextcloudcmd from bash.
nextcloudcmd -n --path /Documents /home/user/Nextcloud/Documents/ https://myserver.com
  1. nextcloudcmd failed to parse netrc and prompt for credentials.
09-20 17:27:56:193 [ debug default ]	[ OCC::NetrcParser::parse ]:	error fetching value for "default\nlogin admin\npassword mypassword\n"
Please enter username:

Expected behavior

nextcloudcmd should parsed netrc.

Which files are affected by this bug

netrc

Operating system

Linux

Which version of the operating system you are running.

NixOS 24.11.20240919.c04d565 (Vicuna) x86_64

Package

Distro package manager

Nextcloud Server version

29.0.4

Nextcloud Desktop Client version

3.14.0

Is this bug present after an update or on a fresh install?

Fresh desktop client install

Are you using the Nextcloud Server Encryption module?

Encryption is Disabled

Are you using an external user-backend?

  • [X] Default internal user-backend
  • [ ] LDAP/ Active Directory
  • [ ] SSO - SAML
  • [ ] Other

Nextcloud Server logs

No response

Additional info

No response

130e avatar Sep 21 '24 00:09 130e

Same here, on:

  • Linux, Ubuntu 22.04.5 LTS
  • package version including nextcloudcmd is nextcloud-client 3.14.0-20240916.085658.d8fcb9273-1.0~jammy1
  • nextcloud server 29.0.6

I have evidence that it synced normally before the latest update of nextcloudcmd, i.e. before 2024-09-16

freundhein avatar Sep 22 '24 07:09 freundhein

I also had it working before, and now it is throwing an error. I'm using a NixOS package.

Nextcloud version 3.14.0
Git revision d8fcb9273729c0e70f99d6f42ed7185c2bb69779
Using Qt 6.7.2, built against Qt 6.7.2
Using 'OpenSSL 3.0.14 4 Jun 2024'
Running on NixOS 24.11 (Vicuna), x86_64

pfassina avatar Oct 03 '24 17:10 pfassina

same here

Nextcloud version 3.14.1
Git revision 8b92fc33a289bf4fc7bc7cdd68d25a9ed1ae1782
Using Qt 6.7.2, built against Qt 6.7.2
Using 'OpenSSL 3.0.14 4 Jun 2024'
Running on Ubuntu 22.04.5 LTS, x86_64

fatpat avatar Oct 17 '24 07:10 fatpat

Same here, running FreeBSD:

Nextcloud version 3.14.1daily
Git revision 8b92fc33a289bf4fc7bc7cdd68d25a9ed1ae1782
Using Qt 6.7.3, built against Qt 6.7.3
Using 'OpenSSL 3.0.13 30 Jan 2024'
Running on FreeBSD 14.1-RELEASE-p5, x86_6

tarastella avatar Oct 28 '24 09:10 tarastella

I, too, have the same issue on FreeBSD 14.1-RELEASE-p5, following a Nextcloud upgrade.

ncartron avatar Nov 06 '24 16:11 ncartron

Do we have yet a solution for this Problem? Since that day my backup is not working! :-(

Machine is Linux Ubuntu 22.04 - Nextcloud 3.14.3-20241107.180900 Server version 29.08

Rudiberto avatar Nov 08 '24 07:11 Rudiberto

@Rudiberto as temporary workaround, I am using something like "nextcloudcmd -u user -p $(cat $passwordfile)".

tarastella avatar Nov 08 '24 08:11 tarastella

[@Rudiberto] as temporary workaround, I am using something like "nextcloudcmd -u user -p $(cat $passwordfile)".

Thank You, very much. I will test that. I'm passing temporarily user and password inside my script. Guess it makes not that much difference to your solution. Hopefully it will work again soon. It's never a good sign, when something so essential is not working properly.

Rudiberto avatar Nov 08 '24 09:11 Rudiberto

const auto sanitisedTargetUrl = options.target_url.endsWith('/') || options.target_url.endsWith('\\') 
        ? options.target_url.chopped(1) 
        : options.target_url;
    QUrl hostUrl = QUrl::fromUserInput(sanitisedTargetUrl);

This is my main suspect in the Source code. The function seems to catch a misconfiguration, but is probably implemented incorrectly, because when parsing the '.netrc' it becomes an '\n' filled in after the password(s) for each end of line.

Formerly it was done this way: QUrl hostUrl = QUrl::fromUserInput((options.target_url.endsWith(QLatin1Char('/')) || options.target_url.endsWith(QLatin1Char('\\'))) ? options.target_url.chopped(1) : options.target_url);

Rudiberto avatar Nov 08 '24 12:11 Rudiberto

Bump I also encountered the same problem, using nextcloudcmd version : 3.14.3

Vagahbond avatar Dec 23 '24 00:12 Vagahbond

@Rudiberto as temporary workaround, I am using something like "nextcloudcmd -u user -p $(cat $passwordfile)".

Just a note that this will protect the password from being logged in shell history and such, but password will still be visible in clear text for anyone who can list the process tree on the machine (and it might still be logged in some audit logs). Maybe not a problem for everyone, but something to keep in mind.

As noted in my PR I think the problem is the tokenizing of the netrc content where it expects every field to be separated by " \n\t". I haven't tested but a "netrc-file" formated like this might actually work (space before newline and tab after):

machine 
	<host> 
	login 
	<username> 
	password 
	<userpassword>

fredrik-eriksson avatar Dec 28 '24 13:12 fredrik-eriksson

I have tried different variations of my ~/.netrc file with what @fredrik-eriksson suggested, but still no luck so far.

ncartron avatar Dec 30 '24 18:12 ncartron