[Pkg-owncloud-commits] [owncloud-client] 02/211: Fix order in which credentials are getting fetched
Sandro Knauß
hefee-guest at moszumanska.debian.org
Sat Oct 25 09:10:20 UTC 2014
This is an automated email from the git hooks/post-receive script.
hefee-guest pushed a commit to branch master
in repository owncloud-client.
commit 1579c23ff13c8901e9cf743955cb5c7eeafe4ba0
Author: Daniel Molkentin <danimo at owncloud.com>
Date: Tue Oct 7 18:21:22 2014 +0200
Fix order in which credentials are getting fetched
---
src/owncloudcmd/owncloudcmd.cpp | 71 +++++++++++++++++++++--------------------
1 file changed, 37 insertions(+), 34 deletions(-)
diff --git a/src/owncloudcmd/owncloudcmd.cpp b/src/owncloudcmd/owncloudcmd.cpp
index cb8665f..c9173ba 100644
--- a/src/owncloudcmd/owncloudcmd.cpp
+++ b/src/owncloudcmd/owncloudcmd.cpp
@@ -209,40 +209,43 @@ int main(int argc, char **argv) {
QUrl url = QUrl::fromUserInput(options.target_url);
- // Fetch username and password. If empty, try to retrieve
- // from URL and strip URL
- QString user;
- QString password;
-
- if (options.useNetrc) {
- NetrcParser parser;
- if (parser.parse()) {
- NetrcParser::LoginPair pair = parser.find(url.host());
- user = pair.first;
- password = pair.second;
- }
- } else {
- user = options.user;
- if (user.isEmpty()) {
- user = url.userName();
- }
- password = options.password;
- if (password.isEmpty()) {
- password = url.password();
- }
-
- if (options.interactive) {
- if (user.isEmpty()) {
- std::cout << "Please enter user name: ";
- std::string s;
- std::getline(std::cin, s);
- user = QString::fromStdString(s);
- }
- if (password.isEmpty()) {
- password = queryPassword(user);
- }
- }
- }
+ // Order of retrieval attempt (later attempts override earlier ones):
+ // 1. From URL
+ // 2. From options
+ // 3. From netrc (if enabled)
+ // 4. From prompt (if interactive)
+
+ QString user = url.userName();
+ QString password = url.password();
+
+ if (!options.user.isEmpty()) {
+ user = options.user;
+ }
+
+ if (!options.password.isEmpty()) {
+ password = options.password;
+ }
+
+ if (options.useNetrc) {
+ NetrcParser parser;
+ if (parser.parse()) {
+ NetrcParser::LoginPair pair = parser.find(url.host());
+ user = pair.first;
+ password = pair.second;
+ }
+ }
+
+ if (options.interactive) {
+ if (user.isEmpty()) {
+ std::cout << "Please enter user name: ";
+ std::string s;
+ std::getline(std::cin, s);
+ user = QString::fromStdString(s);
+ }
+ if (password.isEmpty()) {
+ password = queryPassword(user);
+ }
+ }
// ### ensure URL is free of credentials
if (url.userName().isEmpty()) {
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud-client.git
More information about the Pkg-owncloud-commits
mailing list