From 4d02d0b3accf954d446ebe844bd7730f534b0e2c Mon Sep 17 00:00:00 2001 From: bonni Date: Wed, 16 Aug 2023 21:36:18 +0200 Subject: [PATCH 1/3] reads env vars in --non-interactive Signed-off-by: bonni Signed-off-by: internet-memme <142409719+internet-memme@users.noreply.github.com> Co-authored-by: Claudio Cambra --- src/cmd/cmd.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/cmd/cmd.cpp b/src/cmd/cmd.cpp index c4589307a082e..bb5b87482e380 100644 --- a/src/cmd/cmd.cpp +++ b/src/cmd/cmd.cpp @@ -4,6 +4,7 @@ * SPDX-License-Identifier: GPL-2.0-or-later */ +#include #include #include #include @@ -174,7 +175,7 @@ void help() std::cout << " --user, -u [name] Use [name] as the login name" << std::endl; std::cout << " --password, -p [pass] Use [pass] as password" << std::endl; std::cout << " -n Use netrc (5) for login" << std::endl; - std::cout << " --non-interactive Do not block execution with interaction" << std::endl; + std::cout << " --non-interactive Do not block execution with interaction and tries to read $NC_USER and $NC_PASSWORD if not set by other means" << std::endl; std::cout << " --max-sync-retries [n] Retries maximum n times (default to 3)" << std::endl; std::cout << " --uplimit [n] Limit the upload speed of files to n KB/s" << std::endl; std::cout << " --downlimit [n] Limit the download speed of files to n KB/s" << std::endl; @@ -351,6 +352,7 @@ int main(int argc, char **argv) // 2. From options // 3. From netrc (if enabled) // 4. From prompt (if interactive) + // 5. From environment (if non-interactive) QString user = hostUrl.userName(); QString password = hostUrl.password(); @@ -382,6 +384,13 @@ int main(int argc, char **argv) if (password.isEmpty()) { password = queryPassword(user); } + } else { + if (user.isEmpty()) { + user = std::getenv("NC_USER"); + } + if (password.isEmpty()) { + password = std::getenv("NC_PASSWORD"); + } } // Find the folder and the original owncloud url From 6abd4c70c418864b77b3d587907e9f66a75da702 Mon Sep 17 00:00:00 2001 From: bonni Date: Wed, 23 Aug 2023 20:53:53 +0200 Subject: [PATCH 2/3] Revert "Merge branch 'cmd-env-vars' of github.com:internet-memme/nc-desktop into cmd-env-vars" This reverts commit e2e3c92bc3fa9a9a4e9b0fec6954f4aec7e418e7, reversing changes made to def7b65d122f93d58d1f41268247d2de8206f27f. --- src/cmd/cmd.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cmd/cmd.cpp b/src/cmd/cmd.cpp index bb5b87482e380..eee47b8d6dac2 100644 --- a/src/cmd/cmd.cpp +++ b/src/cmd/cmd.cpp @@ -392,6 +392,7 @@ int main(int argc, char **argv) password = std::getenv("NC_PASSWORD"); } } + // Find the folder and the original owncloud url From c7689e754578fe37496a2aaaf1e4721acc149166 Mon Sep 17 00:00:00 2001 From: Camila Ayres Date: Tue, 29 Jul 2025 08:39:28 +0200 Subject: [PATCH 3/3] fix(cmd): use qgetenv. Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Camila Ayres --- src/cmd/cmd.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cmd/cmd.cpp b/src/cmd/cmd.cpp index eee47b8d6dac2..8cf86773fb43f 100644 --- a/src/cmd/cmd.cpp +++ b/src/cmd/cmd.cpp @@ -386,10 +386,10 @@ int main(int argc, char **argv) } } else { if (user.isEmpty()) { - user = std::getenv("NC_USER"); + user = QString::fromUtf8(qgetenv("NC_USER")); } if (password.isEmpty()) { - password = std::getenv("NC_PASSWORD"); + password = QString::fromUtf8(qgetenv("NC_PASSWORD")); } }