Added a FTP_USERNAME environment variable and corresponding --ftp-username option.

Fixed issue #86.
Fixed issue #87.

git-svn-id: https://duplicati.googlecode.com/svn/trunk@225 59da171f-624f-0410-aa54-27559c288bec
This commit is contained in:
kenneth.skovhede@gmail.com
2009-07-16 20:36:49 +00:00
parent f4fe982aef
commit 9b13c60a01
25 changed files with 227 additions and 23 deletions
+4
View File
@@ -91,6 +91,10 @@ namespace Duplicati.CommandLine
if (!string.IsNullOrEmpty(System.Environment.GetEnvironmentVariable("FTP_PASSWORD")))
options["ftp-password"] = System.Environment.GetEnvironmentVariable("FTP_PASSWORD");
if (!options.ContainsKey("ftp-username"))
if (!string.IsNullOrEmpty(System.Environment.GetEnvironmentVariable("FTP_USERNAME")))
options["ftp-username"] = System.Environment.GetEnvironmentVariable("FTP_USERNAME");
if (source.Trim().ToLower() == "list")
Console.WriteLine(string.Join("\r\n", Duplicati.Library.Main.Interface.List(target, options)));
else if (source.Trim().ToLower() == "list-current-files")
+2 -1
View File
@@ -85,11 +85,12 @@ namespace Duplicati.Datamodel.Backends
public string GetDestinationPath()
{
return "ftp://" + this.Username + "@" + this.Host + ":" + this.Port + "/" + this.Folder;
return "ftp://" + this.Host + ":" + this.Port + "/" + this.Folder;
}
public void GetOptions(Dictionary<string, string> options)
{
options["ftp-username"] = this.Username;
options["ftp-password"] = this.Password;
if (this.Passive)
options["ftp-passive"] = "";
+3 -4
View File
@@ -61,14 +61,13 @@ namespace Duplicati.Datamodel.Backends
public string GetDestinationPath()
{
if (!string.IsNullOrEmpty(this.Username))
return "file://" + this.Username + "@" + this.DestinationFolder;
else
return "file://" + this.DestinationFolder;
return "file://" + this.DestinationFolder;
}
public void GetOptions(Dictionary<string, string> options)
{
if (!string.IsNullOrEmpty(this.Username))
options["ftp-username"] = this.Username;
if (!string.IsNullOrEmpty(this.Password))
options["ftp-password"] = this.Password;
}
+4 -1
View File
@@ -95,11 +95,14 @@ namespace Duplicati.Datamodel.Backends
public string GetDestinationPath()
{
return "ssh://" + this.Username + "@" + this.Host + "/" + this.Folder;
return "ssh://" + this.Host + "/" + this.Folder;
}
public void GetOptions(Dictionary<string, string> options)
{
if (!string.IsNullOrEmpty(this.Username))
options["ftp-username"] = this.Username;
if (!this.Passwordless)
options["ftp-password"] = this.Password;
+4 -4
View File
@@ -92,14 +92,14 @@ namespace Duplicati.Datamodel.Backends
public string GetDestinationPath()
{
if (string.IsNullOrEmpty(this.Username))
return "webdav://" + this.Host + ":" + this.Port + "/" + this.Folder;
else
return "webdav://" + this.Username + "@" + this.Host + ":" + this.Port + "/" + this.Folder;
return "webdav://" + this.Host + ":" + this.Port + "/" + this.Folder;
}
public void GetOptions(Dictionary<string, string> options)
{
if (!string.IsNullOrEmpty(this.Username))
options["ftp-username"] = this.Username;
options["ftp-password"] = this.Password;
if (IntegratedAuthentication)
options["integrated-authentication"] = "";
@@ -60,6 +60,11 @@ namespace Duplicati.Library.Backend
}
else
{
if (options.ContainsKey("ftp-username"))
m_username = options["ftp-username"];
if (options.ContainsKey("ftp-password"))
m_password = options["ftp-password"];
if (options.ContainsKey("cloudfiles_username"))
m_username = options["cloudfiles_username"];
if (options.ContainsKey("cloudfiles_accesskey"))
@@ -163,6 +168,7 @@ namespace Duplicati.Library.Backend
{
return new List<ICommandLineArgument>(new ICommandLineArgument[] {
new CommandLineArgument("ftp-password", CommandLineArgument.ArgumentType.String, Strings.CloudFiles.DescriptionFTPPasswordShort, Strings.CloudFiles.DescriptionFTPPasswordLong),
new CommandLineArgument("ftp-username", CommandLineArgument.ArgumentType.String, Strings.CloudFiles.DescriptionFTPUsernameShort, Strings.CloudFiles.DescriptionFTPUsernameLong),
new CommandLineArgument("cloudfiles_username", CommandLineArgument.ArgumentType.String, Strings.CloudFiles.DescriptionUsernameShort, Strings.CloudFiles.DescriptionUsernameLong),
new CommandLineArgument("cloudfiles_accesskey", CommandLineArgument.ArgumentType.String, Strings.CloudFiles.DescriptionPasswordShort, Strings.CloudFiles.DescriptionPasswordLong),
});
@@ -87,6 +87,24 @@ namespace Duplicati.Library.Backend.Strings {
}
}
/// <summary>
/// Looks up a localized string similar to The username used to connect to the server. This may also be supplied as the environment variable &quot;FTP_USERNAME&quot;..
/// </summary>
internal static string DescriptionFTPUsernameLong {
get {
return ResourceManager.GetString("DescriptionFTPUsernameLong", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Supplies the username used to connect to the server.
/// </summary>
internal static string DescriptionFTPUsernameShort {
get {
return ResourceManager.GetString("DescriptionFTPUsernameShort", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Supplies the API Access Key used to authenticate with CloudFiles..
/// </summary>
@@ -126,6 +126,12 @@
<data name="DescriptionFTPPasswordShort" xml:space="preserve">
<value>Supplies the password used to connect to the server</value>
</data>
<data name="DescriptionFTPUsernameLong" xml:space="preserve">
<value>The username used to connect to the server. This may also be supplied as the environment variable "FTP_USERNAME".</value>
</data>
<data name="DescriptionFTPUsernameShort" xml:space="preserve">
<value>Supplies the username used to connect to the server</value>
</data>
<data name="DescriptionPasswordLong" xml:space="preserve">
<value>Supplies the API Access Key used to authenticate with CloudFiles.</value>
</data>
@@ -53,6 +53,16 @@ namespace Duplicati.Library.Backend
m_userInfo.Password = options["ftp-password"];
}
}
else
{
if (options.ContainsKey("ftp-username"))
{
m_userInfo = new System.Net.NetworkCredential();
m_userInfo.UserName = options["ftp-username"];
if (options.ContainsKey("ftp-password"))
m_userInfo.Password = options["ftp-password"];
}
}
m_options = options;
m_url = url;
@@ -195,6 +205,7 @@ namespace Duplicati.Library.Backend
new CommandLineArgument("ftp-passive", CommandLineArgument.ArgumentType.Boolean, Strings.FTPBackend.DescriptionFTPPassiveShort, Strings.FTPBackend.DescriptionFTPPassiveLong, "false"),
new CommandLineArgument("ftp-regular", CommandLineArgument.ArgumentType.Boolean, Strings.FTPBackend.DescriptionFTPActiveShort, Strings.FTPBackend.DescriptionFTPActiveLong, "true"),
new CommandLineArgument("ftp-password", CommandLineArgument.ArgumentType.String, Strings.FTPBackend.DescriptionFTPPasswordShort, Strings.FTPBackend.DescriptionFTPPasswordLong),
new CommandLineArgument("ftp-username", CommandLineArgument.ArgumentType.String, Strings.FTPBackend.DescriptionFTPUsernameShort, Strings.FTPBackend.DescriptionFTPUsernameLong),
new CommandLineArgument("integrated-authentication", CommandLineArgument.ArgumentType.Boolean, Strings.FTPBackend.DescriptionIntegratedAuthenticationShort, Strings.FTPBackend.DescriptionIntegratedAuthenticationLong),
});
}
@@ -123,6 +123,24 @@ namespace Duplicati.Library.Backend.Strings {
}
}
/// <summary>
/// Looks up a localized string similar to The username used to connect to the server. This may also be supplied as the environment variable &quot;FTP_USERNAME&quot;..
/// </summary>
internal static string DescriptionFTPUsernameLong {
get {
return ResourceManager.GetString("DescriptionFTPUsernameLong", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Supplies the username used to connect to the server.
/// </summary>
internal static string DescriptionFTPUsernameShort {
get {
return ResourceManager.GetString("DescriptionFTPUsernameShort", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to If the server and client both supports integrated authentication, this option enables that authentication method. This is likely only avalible with windows servers and clients..
/// </summary>
@@ -138,6 +138,12 @@
<data name="DescriptionFTPPasswordShort" xml:space="preserve">
<value>Supplies the password used to connect to the server</value>
</data>
<data name="DescriptionFTPUsernameLong" xml:space="preserve">
<value>The username used to connect to the server. This may also be supplied as the environment variable "FTP_USERNAME".</value>
</data>
<data name="DescriptionFTPUsernameShort" xml:space="preserve">
<value>Supplies the username used to connect to the server</value>
</data>
<data name="DescriptionIntegratedAuthenticationLong" xml:space="preserve">
<value>If the server and client both supports integrated authentication, this option enables that authentication method. This is likely only avalible with windows servers and clients.</value>
</data>
@@ -55,6 +55,13 @@ namespace Duplicati.Library.Backend
m_password = options["ftp-password"];
}
}
else
{
if (options.ContainsKey("ftp-username"))
m_username = options["ftp-username"];
if (options.ContainsKey("ftp-password"))
m_password = options["ftp-password"];
}
if (!System.IO.Path.IsPathRooted(url))
m_path = System.IO.Path.GetFullPath(m_path);
@@ -141,7 +148,8 @@ namespace Duplicati.Library.Backend
get
{
return new List<ICommandLineArgument>(new ICommandLineArgument[] {
new CommandLineArgument("ftp-password", CommandLineArgument.ArgumentType.String, Strings.FileBackend.DescriptionFTPPasswordShort, Strings.FileBackend.DescriptionFTPPasswordLong)
new CommandLineArgument("ftp-password", CommandLineArgument.ArgumentType.String, Strings.FileBackend.DescriptionFTPPasswordShort, Strings.FileBackend.DescriptionFTPPasswordLong),
new CommandLineArgument("ftp-username", CommandLineArgument.ArgumentType.String, Strings.FileBackend.DescriptionFTPUsernameShort, Strings.FileBackend.DescriptionFTPUsernameLong)
});
}
@@ -87,6 +87,24 @@ namespace Duplicati.Library.Backend.Strings {
}
}
/// <summary>
/// Looks up a localized string similar to The username used to connect to the server. This may also be supplied as the environment variable &quot;FTP_USERNAME&quot;..
/// </summary>
internal static string DescriptionFTPUsernameLong {
get {
return ResourceManager.GetString("DescriptionFTPUsernameLong", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Supplies the username used to connect to the server.
/// </summary>
internal static string DescriptionFTPUsernameShort {
get {
return ResourceManager.GetString("DescriptionFTPUsernameShort", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to File based.
/// </summary>
@@ -126,6 +126,12 @@
<data name="DescriptionFTPPasswordShort" xml:space="preserve">
<value>Supplies the password used to connect to the server</value>
</data>
<data name="DescriptionFTPUsernameLong" xml:space="preserve">
<value>The username used to connect to the server. This may also be supplied as the environment variable "FTP_USERNAME".</value>
</data>
<data name="DescriptionFTPUsernameShort" xml:space="preserve">
<value>Supplies the username used to connect to the server</value>
</data>
<data name="DisplayName" xml:space="preserve">
<value>File based</value>
</data>
+7 -1
View File
@@ -63,6 +63,11 @@ namespace Duplicati.Library.Backend
}
else
{
if (options.ContainsKey("ftp-username"))
m_awsID = options["ftp-username"];
if (options.ContainsKey("ftp-password"))
m_awsKey = options["ftp-password"];
if (options.ContainsKey("aws_access_key_id"))
m_awsID = options["aws_access_key_id"];
if (options.ContainsKey("aws_secret_access_key"))
@@ -259,10 +264,11 @@ namespace Duplicati.Library.Backend
{
return new List<ICommandLineArgument>(new ICommandLineArgument[] {
new CommandLineArgument("aws_secret_access_key", CommandLineArgument.ArgumentType.Path, Strings.S3Backend.AMZKeyDescriptionShort, Strings.S3Backend.AMZKeyDescriptionLong, null, new string[] {"ftp-password"}, null),
new CommandLineArgument("aws_access_key_id", CommandLineArgument.ArgumentType.Path, Strings.S3Backend.AMZUserIDDescriptionShort, Strings.S3Backend.AMZUserIDDescriptionLong),
new CommandLineArgument("aws_access_key_id", CommandLineArgument.ArgumentType.Path, Strings.S3Backend.AMZUserIDDescriptionShort, Strings.S3Backend.AMZUserIDDescriptionLong, null, new string[] {"ftp-username"}, null),
new CommandLineArgument("s3-use-new-style", CommandLineArgument.ArgumentType.Boolean, Strings.S3Backend.S3NewStyleDescriptionShort, Strings.S3Backend.S3NewStyleDescriptionLong, "true"),
new CommandLineArgument("s3-european-buckets", CommandLineArgument.ArgumentType.Boolean, Strings.S3Backend.S3EurobucketDescriptionShort, Strings.S3Backend.S3EurobucketDescriptionLong, "false"),
new CommandLineArgument("ftp-password", CommandLineArgument.ArgumentType.String, Strings.S3Backend.FTPPasswordDescriptionShort, Strings.S3Backend.FTPPasswordDescriptionLong),
new CommandLineArgument("ftp-username", CommandLineArgument.ArgumentType.String, Strings.S3Backend.DescriptionFTPUsernameShort, Strings.S3Backend.DescriptionFTPUsernameLong)
});
}
+19 -1
View File
@@ -79,7 +79,7 @@ namespace Duplicati.Library.Backend.Strings {
}
/// <summary>
/// Looks up a localized string similar to The AWS &quot;Access Key ID&quot; can be obtained after logging into your AWS account..
/// Looks up a localized string similar to The AWS &quot;Access Key ID&quot; can be obtained after logging into your AWS account, this can also be supplied through the &quot;ftp-username&quot; property.
/// </summary>
internal static string AMZUserIDDescriptionLong {
get {
@@ -105,6 +105,24 @@ namespace Duplicati.Library.Backend.Strings {
}
}
/// <summary>
/// Looks up a localized string similar to The username used to connect to the server. This may also be supplied as the environment variable &quot;FTP_USERNAME&quot;..
/// </summary>
internal static string DescriptionFTPUsernameLong {
get {
return ResourceManager.GetString("DescriptionFTPUsernameLong", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Supplies the username used to connect to the server.
/// </summary>
internal static string DescriptionFTPUsernameShort {
get {
return ResourceManager.GetString("DescriptionFTPUsernameShort", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Amazon S3 based.
/// </summary>
@@ -124,7 +124,7 @@
<value>The AWS "Secret Access Key"</value>
</data>
<data name="AMZUserIDDescriptionLong" xml:space="preserve">
<value>The AWS "Access Key ID" can be obtained after logging into your AWS account.</value>
<value>The AWS "Access Key ID" can be obtained after logging into your AWS account, this can also be supplied through the "ftp-username" property</value>
</data>
<data name="AMZUserIDDescriptionShort" xml:space="preserve">
<value>The AWS "Access Key ID"</value>
@@ -141,6 +141,12 @@
<data name="FTPPasswordDescriptionShort" xml:space="preserve">
<value>Supplies the password used to connect to the server</value>
</data>
<data name="DescriptionFTPUsernameLong" xml:space="preserve">
<value>The username used to connect to the server. This may also be supplied as the environment variable "FTP_USERNAME".</value>
</data>
<data name="DescriptionFTPUsernameShort" xml:space="preserve">
<value>Supplies the username used to connect to the server</value>
</data>
<data name="NoAMZKeyError" xml:space="preserve">
<value>No Amazon S3 secret key given</value>
</data>
@@ -71,6 +71,13 @@ namespace Duplicati.Library.Backend
m_password = options["ftp-password"];
}
}
else
{
if (options.ContainsKey("ftp-username"))
m_username = options["ftp-username"];
if (options.ContainsKey("ftp-password"))
m_password = options["ftp-password"];
}
m_path = u.AbsolutePath;
@@ -259,6 +266,7 @@ namespace Duplicati.Library.Backend
new CommandLineArgument("sftp-command", CommandLineArgument.ArgumentType.Path, Strings.SSHBackend.DescriptionSFTPCommandShort, Strings.SSHBackend.DescriptionSFTPCommandLong, (System.Environment.OSVersion.Platform == PlatformID.Unix || System.Environment.OSVersion.Platform == PlatformID.MacOSX) ? "sftp" : "psftp.exe"),
new CommandLineArgument("ssh-options", CommandLineArgument.ArgumentType.String, Strings.SSHBackend.DescriptionSSHOptionsShort, Strings.SSHBackend.DescriptionSSHOptionsLong, "-C"),
new CommandLineArgument("ftp-password", CommandLineArgument.ArgumentType.String, Strings.SSHBackend.DescriptionFTPPasswordShort, Strings.SSHBackend.DescriptionFTPPasswordLong),
new CommandLineArgument("ftp-username", CommandLineArgument.ArgumentType.String, Strings.SSHBackend.DescriptionFTPUsernameShort, Strings.SSHBackend.DescriptionFTPUsernameLong),
new CommandLineArgument("debug-to-console", CommandLineArgument.ArgumentType.Boolean, Strings.SSHBackend.DescriptionDebugToConsoleShort, Strings.SSHBackend.DescriptionDebugToConsoleLong),
new CommandLineArgument("transfer-timeout", CommandLineArgument.ArgumentType.Timespan, Strings.SSHBackend.DescriptionTransferTimeoutShort, Strings.SSHBackend.DescriptionTransferTimeoutLong, "10m"),
});
@@ -222,6 +222,24 @@ namespace Duplicati.Library.Backend.Strings {
}
}
/// <summary>
/// Looks up a localized string similar to The username used to connect to the server. This may also be supplied as the environment variable &quot;FTP_USERNAME&quot;..
/// </summary>
internal static string DescriptionFTPUsernameLong {
get {
return ResourceManager.GetString("DescriptionFTPUsernameLong", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Supplies the username used to connect to the server.
/// </summary>
internal static string DescriptionFTPUsernameShort {
get {
return ResourceManager.GetString("DescriptionFTPUsernameShort", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to The full path to the &quot;sftp&quot; application..
/// </summary>
@@ -171,6 +171,12 @@
<data name="DescriptionFTPPasswordShort" xml:space="preserve">
<value>Supplies the password used to connect to the server</value>
</data>
<data name="DescriptionFTPUsernameLong" xml:space="preserve">
<value>The username used to connect to the server. This may also be supplied as the environment variable "FTP_USERNAME".</value>
</data>
<data name="DescriptionFTPUsernameShort" xml:space="preserve">
<value>Supplies the username used to connect to the server</value>
</data>
<data name="DescriptionSFTPCommandLong" xml:space="preserve">
<value>The full path to the "sftp" application.</value>
</data>
@@ -105,6 +105,24 @@ namespace Duplicati.Library.Backend.Strings {
}
}
/// <summary>
/// Looks up a localized string similar to The username used to connect to the server. This may also be supplied as the environment variable &quot;FTP_USERNAME&quot;..
/// </summary>
internal static string DescriptionFTPUsernameLong {
get {
return ResourceManager.GetString("DescriptionFTPUsernameLong", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Supplies the username used to connect to the server.
/// </summary>
internal static string DescriptionFTPUsernameShort {
get {
return ResourceManager.GetString("DescriptionFTPUsernameShort", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to If the server and client both supports integrated authentication, this option enables that authentication method. This is likely only avalible with windows servers and clients..
/// </summary>
@@ -132,6 +132,12 @@
<data name="DescriptionFTPPasswordShort" xml:space="preserve">
<value>Supplies the password used to connect to the server</value>
</data>
<data name="DescriptionFTPUsernameLong" xml:space="preserve">
<value>The username used to connect to the server. This may also be supplied as the environment variable "FTP_USERNAME".</value>
</data>
<data name="DescriptionFTPUsernameShort" xml:space="preserve">
<value>Supplies the username used to connect to the server</value>
</data>
<data name="DescriptionIntegratedAuthenticationLong" xml:space="preserve">
<value>If the server and client both supports integrated authentication, this option enables that authentication method. This is likely only avalible with windows servers and clients.</value>
</data>
@@ -56,6 +56,16 @@ namespace Duplicati.Library.Backend
m_userInfo.Password = options["ftp-password"];
}
}
else
{
if (options.ContainsKey("ftp-username"))
{
m_userInfo = new System.Net.NetworkCredential();
m_userInfo.UserName = options["ftp-username"];
if (options.ContainsKey("ftp-password"))
m_userInfo.Password = options["ftp-password"];
}
}
m_options = options;
m_useIntegratedAuthentication = m_options.ContainsKey("integrated-authentication");
@@ -166,6 +176,7 @@ namespace Duplicati.Library.Backend
{
return new List<ICommandLineArgument>(new ICommandLineArgument[] {
new CommandLineArgument("ftp-password", CommandLineArgument.ArgumentType.String, Strings.WEBDAV.DescriptionFTPPasswordShort, Strings.WEBDAV.DescriptionFTPPasswordLong),
new CommandLineArgument("ftp-username", CommandLineArgument.ArgumentType.String, Strings.WEBDAV.DescriptionFTPUsernameShort, Strings.WEBDAV.DescriptionFTPUsernameLong),
new CommandLineArgument("integrated-authentication", CommandLineArgument.ArgumentType.Boolean, Strings.WEBDAV.DescriptionIntegratedAuthenticationShort, Strings.WEBDAV.DescriptionIntegratedAuthenticationLong),
new CommandLineArgument("force-digest-authentication", CommandLineArgument.ArgumentType.Boolean, Strings.WEBDAV.DescriptionForceDigestShort, Strings.WEBDAV.DescriptionForceDigestLong),
});
@@ -125,38 +125,38 @@
<value>The full backup duration entered is not valid: {0}</value>
</data>
<data name="OneDay" xml:space="preserve">
<value>One day</value>
<value>En dag</value>
<comment>A string displayed in comboboxes indicating that the duration should be one day</comment>
</data>
<data name="OneMonth" xml:space="preserve">
<value>One month</value>
<value>En måned</value>
<comment>A string displayed in comboboxes indicating that the duration should be one month</comment>
</data>
<data name="OneWeek" xml:space="preserve">
<value>One week</value>
<value>En uge</value>
<comment>A string displayed in comboboxes indicating that the duration should be one week</comment>
</data>
<data name="ThreadPriorityAboveNormal" xml:space="preserve">
<value>Above normal</value>
<value>Over normal</value>
</data>
<data name="ThreadPriorityBelowNormal" xml:space="preserve">
<value>Below normal</value>
<value>Under normal</value>
</data>
<data name="ThreadPriorityHighest" xml:space="preserve">
<value>Highest</value>
<value>Højeste</value>
</data>
<data name="ThreadPriorityNormal" xml:space="preserve">
<value>Normal</value>
</data>
<data name="ThreadPriortyLowest" xml:space="preserve">
<value>Lowest</value>
<value>Laveste</value>
</data>
<data name="ThreeMonths" xml:space="preserve">
<value>Three months</value>
<value>Tre måneder</value>
<comment>A string displayed in comboboxes indicating that the duration should be three months</comment>
</data>
<data name="TwoWeeks" xml:space="preserve">
<value>Two weeks</value>
<value>To uger</value>
<comment>A string displayed in comboboxes indicating that the duration should be two weeks</comment>
</data>
</root>
+3
View File
@@ -1,3 +1,6 @@
trunk
Added a FTP_USERNAME option to solve problems with usernames in urls.
1.0.1 r215 05 jul 2009
Fixes to a restore problem when restoring the setup
Added a debug option for the SSH backend