Skip to content

Commit 6447e79

Browse files
leefine02leefine02
authored andcommitted
1 parent 77e2a24 commit 6447e79

File tree

4 files changed

+22
-9
lines changed

4 files changed

+22
-9
lines changed
-909 KB
Binary file not shown.
-34 KB
Binary file not shown.

RemoteFile/RemoteFile.csproj

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,13 @@
2020
</ItemGroup>
2121

2222
<ItemGroup>
23-
<PackageReference Include="BouncyCastle.Cryptography" Version="2.3.0" />
23+
<PackageReference Include="BouncyCastle.Cryptography" Version="2.4.0" />
2424
<PackageReference Include="CliWrap" Version="3.6.6" />
2525
<PackageReference Include="Keyfactor.Logging" Version="1.1.1" />
2626
<PackageReference Include="Keyfactor.Orchestrators.IOrchestratorJobExtensions" Version="0.7.0" />
2727
<PackageReference Include="Keyfactor.PKI" Version="5.0.0" />
2828
<PackageReference Include="Microsoft.PowerShell.SDK" Version="7.2.12" />
29-
</ItemGroup>
30-
31-
<ItemGroup>
32-
<Folder Include="External References\" />
29+
<PackageReference Include="SSH.NET" Version="2024.0.0" />
3330
</ItemGroup>
3431

3532
<ItemGroup>

RemoteFile/RemoteHandlers/SSHHandler.cs

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ public override void Initialize()
7676
{
7777
sshClient = new SshClient(Connection);
7878
sshClient.Connect();
79+
80+
//method call below necessary to check edge condition where password for user id has expired. SCP (and possibly SFTP) download hangs in that scenario
81+
CheckConnection();
7982
}
8083
catch (Exception ex)
8184
{
@@ -146,7 +149,7 @@ public override string RunCommand(string commandText, object[] arguments, bool w
146149
catch (Exception ex)
147150
{
148151
_logger.LogError($"Exception during RunCommand...{RemoteFileException.FlattenExceptionMessages(ex, ex.Message)}");
149-
throw ex;
152+
throw;
150153
}
151154
}
152155

@@ -328,18 +331,18 @@ public override void CreateEmptyStoreFile(string path, string linuxFilePermissio
328331
{
329332
_logger.MethodEntry(LogLevel.Debug);
330333
string[] linuxGroupOwner = linuxFileOwner.Split(":");
331-
string linuxFileGroup = linuxFileOwner;
334+
string linuxFileGroup = String.Empty;
332335

333336
if (linuxGroupOwner.Length == 2)
334337
{
335338
linuxFileOwner = linuxGroupOwner[0];
336-
linuxFileGroup = linuxGroupOwner[1];
339+
linuxFileGroup = $"-g {linuxGroupOwner[1]}";
337340
}
338341

339342
if (IsStoreServerLinux)
340343
{
341344
AreLinuxPermissionsValid(linuxFilePermissions);
342-
RunCommand($"install -m {linuxFilePermissions} -o {linuxFileOwner} -g {linuxFileGroup} /dev/null {path}", null, ApplicationSettings.UseSudo, null);
345+
RunCommand($"install -m {linuxFilePermissions} -o {linuxFileOwner} {linuxFileGroup} /dev/null {path}", null, ApplicationSettings.UseSudo, null);
343346
}
344347
else
345348
RunCommand($@"Out-File -FilePath ""{path}""", null, false, null);
@@ -431,5 +434,18 @@ private string FormatFTPPath(string path, bool addLeadingSlashForWindows)
431434

432435
return rtnPath;
433436
}
437+
438+
private void CheckConnection()
439+
{
440+
try
441+
{
442+
RunCommand("echo", null, ApplicationSettings.UseSudo, null);
443+
}
444+
catch (Exception ex)
445+
{
446+
_logger.LogError(RemoteFileException.FlattenExceptionMessages(ex, "Error validating server connection."));
447+
throw;
448+
}
449+
}
434450
}
435451
}

0 commit comments

Comments
 (0)