From 8f5658bc0174d867c616c2ecb098b364d9036143 Mon Sep 17 00:00:00 2001 From: Niels van Adrichem Date: Mon, 2 Nov 2015 22:57:17 +0100 Subject: [PATCH] Added Non Shibboleth WebDAV authentication and Dav Path customization to `owncloudcmd` --- src/cmd/cmd.cpp | 18 ++++++++++++++++++ src/libsync/account.cpp | 9 +++++++++ src/libsync/account.h | 1 + src/libsync/theme.cpp | 5 +++++ src/libsync/theme.h | 1 + 5 files changed, 34 insertions(+) diff --git a/src/cmd/cmd.cpp b/src/cmd/cmd.cpp index 11390dbf6..c75335e11 100644 --- a/src/cmd/cmd.cpp +++ b/src/cmd/cmd.cpp @@ -56,8 +56,10 @@ struct CmdOptions { bool useNetrc; bool interactive; bool ignoreHiddenFiles; + bool nonShib; QString exclude; QString unsyncedfolders; + QString davPath; }; // we can't use csync_set_userdata because the SyncEngine sets it already. @@ -155,6 +157,8 @@ void help() 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 << " --nonshib, -ns Use Non Shibboleth WebDAV authentication" << std::endl; + std::cout << " --davpath, -dp [path] Custom themed dav path, overrides --nonshib" << std::endl; std::cout << " -h Sync hidden files,do not ignore them" << std::endl; std::cout << " --version, -v Display version and exit" << std::endl; std::cout << "" << std::endl; @@ -222,6 +226,10 @@ void parseOptions( const QStringList& app_args, CmdOptions *options ) options->exclude = it.next(); } else if( option == "--unsyncedfolders" && !it.peekNext().startsWith("-") ) { options->unsyncedfolders = it.next(); + } else if( option == "--nonshib" || option == "-ns") { + options->nonShib = true; + } else if( (option == "--davpath" || option == "-dp") && !it.peekNext().startsWith("-") ) { + options->davPath = it.next(); } else { help(); } @@ -268,6 +276,7 @@ int main(int argc, char **argv) { options.useNetrc = false; options.interactive = true; options.ignoreHiddenFiles = true; + options.nonShib = false; ClientProxy clientProxy; parseOptions( app.arguments(), &options ); @@ -282,6 +291,15 @@ int main(int argc, char **argv) { if(!options.target_url.endsWith("/")) { options.target_url.append("/"); } + + if( options.nonShib ) { + account->setNonShib(true); + } + + if(!options.davPath.isEmpty()) { + account->setDavPath( options.davPath ); + } + if( !options.target_url.contains( account->davPath() )) { options.target_url.append(account->davPath()); } diff --git a/src/libsync/account.cpp b/src/libsync/account.cpp index 73a68872c..6c5450e59 100644 --- a/src/libsync/account.cpp +++ b/src/libsync/account.cpp @@ -497,6 +497,15 @@ bool Account::rootEtagChangesNotOnlySubFolderEtags() return (serverVersionInt() >= 0x080100); } +void Account::setNonShib(bool nonShib) +{ + if( nonShib ) { + _davPath = Theme::instance()->webDavPathNonShib(); + } else { + _davPath = Theme::instance()->webDavPath(); + } +} + } // namespace OCC diff --git a/src/libsync/account.h b/src/libsync/account.h index cb706c42b..4a4014dab 100644 --- a/src/libsync/account.h +++ b/src/libsync/account.h @@ -67,6 +67,7 @@ public: */ QString davPath() const; void setDavPath(const QString&s) { _davPath = s; } + void setNonShib(bool nonShib); static AccountPtr create(); ~Account(); diff --git a/src/libsync/theme.cpp b/src/libsync/theme.cpp index 709d4c386..6fbe05f0b 100644 --- a/src/libsync/theme.cpp +++ b/src/libsync/theme.cpp @@ -412,5 +412,10 @@ QString Theme::webDavPath() const return QLatin1String("remote.php/webdav/"); } +QString Theme::webDavPathNonShib() const +{ + return QLatin1String("remote.php/nonshib-webdav/"); +} + } // end namespace client diff --git a/src/libsync/theme.h b/src/libsync/theme.h index d3062449c..7cd6e7baa 100644 --- a/src/libsync/theme.h +++ b/src/libsync/theme.h @@ -227,6 +227,7 @@ public: * it has a trailing slash, for example "remote.php/webdav/". */ virtual QString webDavPath() const; + virtual QString webDavPathNonShib() const; protected: #ifndef TOKEN_AUTH_ONLY