Skip to content

Commit f9cb1f7

Browse files
committed
Fix plugins; updated readme; fix workflow
1 parent a16e650 commit f9cb1f7

File tree

16 files changed

+324
-21
lines changed

16 files changed

+324
-21
lines changed

.github/workflows/dotnet.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
runs-on: ubuntu-latest
1616
strategy:
1717
matrix:
18-
dotnet-version: [ '3.1.x', '5.0.x' ]
18+
dotnet-version: [ '3.1.x', '6.0.x' ]
1919

2020
steps:
2121
- uses: actions/checkout@v2

NyaImageTool.sln

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NyaImageTool", "NyaImageToo
2323
EndProject
2424
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NyaLZO", "NyaLZO\NyaLZO.csproj", "{B47A5DEA-D7A4-4A3D-9735-33D9FAF37D36}"
2525
EndProject
26-
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{7DE93B12-1E74-4204-A550-DDC4F3550AF9}"
26+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Docs", "Docs", "{7DE93B12-1E74-4204-A550-DDC4F3550AF9}"
2727
ProjectSection(SolutionItems) = preProject
2828
readme.md = readme.md
2929
todo.md = todo.md
@@ -42,6 +42,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NyaFsLinux", "Plugins\NyaFs
4242
EndProject
4343
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NyaFsTftp", "Plugins\NyaFsTftp\NyaFsTftp.csproj", "{2FFD947D-8EF4-417A-BE85-CDD8A456BDFD}"
4444
EndProject
45+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Workflow", "Workflow", "{D877671C-2F73-4572-A9C6-8798614526E0}"
46+
ProjectSection(SolutionItems) = preProject
47+
.github\workflows\dotnet.yml = .github\workflows\dotnet.yml
48+
EndProjectSection
49+
EndProject
4550
Global
4651
GlobalSection(SolutionConfigurationPlatforms) = preSolution
4752
Debug|Any CPU = Debug|Any CPU

Plugins/NyaFsLinux/Commands/FindPasswd.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ public override ScriptStepResult Exec(ImageProcessor Processor)
6060
{
6161
if(U.NoPassword)
6262
return new ScriptStepResult(ScriptStepStatus.Error, $"User '{User}' has no password.");
63+
else if (U.Hash == "")
64+
{
65+
NyaFs.Log.Ok(0, $"Password for '{User}' is '' (empty string)");
66+
return new ScriptStepResult(ScriptStepStatus.Ok, null);
67+
}
6368
else if (U.Hash != null)
6469
{
6570
var Passwords = System.IO.File.ReadAllLines(PasswordsFile);

Plugins/NyaFsLinux/Commands/LsHashes.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ public override ScriptStepResult Exec(ImageProcessor Processor)
5050
{
5151
var UidGid = $"{U.UID}:{U.GID}";
5252

53-
if ((U.Hash != null) && !U.NoPassword)
53+
if((U.Hash == ""))
54+
NyaFs.Log.Write(0, $"{U.Name.PadRight(12)} {"no".PadRight(8)} {"-".PadRight(18)} {"no password".PadRight(25)}");
55+
else if ((U.Hash != null) && !U.NoPassword)
5456
NyaFs.Log.Write(0, $"{U.Name.PadRight(12)} {U.HashType.PadRight(8)} {U.Salt.PadRight(18)} {U.HashValue.PadRight(25)}");
5557
}
5658

Plugins/NyaFsLinux/Commands/LsUsers.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,14 @@ public override ScriptStepResult Exec(ImageProcessor Processor)
5454
if (U.Hash != null)
5555
{
5656
if (U.NoPassword)
57-
Info += "no password";
57+
NyaFs.Log.Ok(0, Info + "no password enabled");
58+
else if (U.Hash == "")
59+
NyaFs.Log.Warning(0, Info + "no password (unrestricted access)");
5860
else
59-
Info += $"hash {U.HashType} with salt '{U.Salt}'";
61+
NyaFs.Log.Ok(0, Info + $"hash {U.HashType} with salt '{U.Salt}'");
6062
}
61-
62-
NyaFs.Log.Write(0, Info);
63+
else
64+
NyaFs.Log.Warning(0, Info + "no hash info!");
6365
}
6466

6567
return new ScriptStepResult(ScriptStepStatus.Ok, null);

Plugins/NyaFsLinux/Commands/Passwd.cs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,21 @@ class Passwd : ScriptStepGenerator
1111

1212
public Passwd() : base("passwd")
1313
{
14-
AddConfig(new ScriptArgsConfig(0, new ScriptArgsParam[] {
14+
AddConfig(new ScriptArgsConfig(1, new ScriptArgsParam[] {
1515
new NyaFs.Processor.Scripting.Params.StringScriptArgsParam("user"),
1616
new NyaFs.Processor.Scripting.Params.StringScriptArgsParam("password")
1717
}));
18+
AddConfig(new ScriptArgsConfig(0, new ScriptArgsParam[] {
19+
new NyaFs.Processor.Scripting.Params.StringScriptArgsParam("user")
20+
}));
1821
}
1922

2023
public override ScriptStep Get(ScriptArgs Args)
2124
{
22-
return new PasswdScriptStep(Args.RawArgs[0], Args.RawArgs[1]);
25+
if(Args.ArgConfig == 1)
26+
return new PasswdScriptStep(Args.RawArgs[0], Args.RawArgs[1]);
27+
else
28+
return new PasswdScriptStep(Args.RawArgs[0], "");
2329
}
2430

2531
public class PasswdScriptStep : ScriptStep
@@ -57,6 +63,14 @@ public override ScriptStepResult Exec(ImageProcessor Processor)
5763
{
5864
if(U.NoPassword)
5965
return new ScriptStepResult(ScriptStepStatus.Error, $"User '{User}' has no password.");
66+
else if (U.Hash == "")
67+
{
68+
if (Password == "")
69+
{
70+
NyaFs.Log.Ok(0, $"Password is correct");
71+
return new ScriptStepResult(ScriptStepStatus.Ok, null);
72+
}
73+
}
6074
else if (U.Hash != null)
6175
{
6276
if (U.CheckPassword(Password))

Plugins/NyaFsSftp/FreeSFtpSharp/SftpSubsystem.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public class SftpSubsystem
3232

3333
private string ActivePath = "/";
3434

35-
private uint channel;
35+
private readonly uint channel;
3636
internal EventHandler<ICollection<byte>> OnOutput;
3737

3838
Dictionary<string, string> HandleToPathDictionary;
@@ -489,7 +489,7 @@ private void HandleWriteFile(SshDataWorker reader)
489489
else
490490
SendStatus(requestId, SftpStatusType.SSH_FX_OP_UNSUPPORTED);
491491
}
492-
catch(Exception E)
492+
catch(Exception)
493493
{
494494
SendStatus(requestId, SftpStatusType.SSH_FX_BAD_MESSAGE);
495495
}

Plugins/NyaFsSftp/FxSsh/Session.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,15 @@ public Session(Socket socket, Dictionary<string, string> hostKeys, string server
114114
public event EventHandler<SshService> ServiceRegistered;
115115

116116
public event EventHandler<KeyExchangeArgs> KeysExchanged;
117-
117+
118+
public event EventHandler<SshService> Check;
119+
120+
internal void CheckService()
121+
{
122+
if(_socket.Connected)
123+
SendMessage(new Messages.Connection.ShouldIgnoreMessage());
124+
}
125+
118126
internal void EstablishConnection()
119127
{
120128
if (!_socket.Connected)
@@ -218,7 +226,7 @@ private string SocketReadProtocolVersion()
218226

219227
if (len == 0)
220228
{
221-
throw new SshConnectionException("Could't read the protocal version", DisconnectReason.ProtocolError);
229+
throw new SshConnectionException("Could't read the protocol version", DisconnectReason.ProtocolError);
222230
}
223231

224232
for (var i = 0; i < len; i++, pos++)

Plugins/NyaFsSftp/FxSsh/SshServer.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ public class SshServer : IDisposable
1515
private bool _isDisposed;
1616
private bool _started;
1717
private TcpListener _listener = null;
18+
private System.Timers.Timer checkTimer = new System.Timers.Timer(5000);
1819

1920
public SshServer()
2021
: this(new SshServerSettings())
@@ -49,10 +50,34 @@ public void Start()
4950
_listener.Start();
5051
BeginAcceptSocket();
5152

53+
checkTimer.Elapsed += CheckTimer_Elapsed;
54+
checkTimer.Start();
55+
5256
_started = true;
5357
}
5458
}
5559

60+
private void CheckTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
61+
{
62+
try
63+
{
64+
foreach (var session in sessions)
65+
{
66+
try
67+
{
68+
session.CheckService();
69+
}
70+
catch
71+
{
72+
}
73+
}
74+
}
75+
catch
76+
{
77+
}
78+
}
79+
80+
5681
public void Stop()
5782
{
5883
lock (_lock)
@@ -63,6 +88,7 @@ public void Stop()
6388

6489
_listener.Stop();
6590

91+
checkTimer.Stop();
6692
_isDisposed = true;
6793
_started = false;
6894

Plugins/NyaFsSftp/SftpPlugin.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,16 @@
33

44
namespace NyaFsSftp
55
{
6-
76
public class SftpPlugin : NyaFs.ImageFormat.Plugins.Base.ServicePlugin
87
{
9-
private int Port = 1234;
8+
/// <summary>
9+
/// SSH port. Default is 22
10+
/// </summary>
11+
private int Port = 22;
1012

13+
/// <summary>
14+
/// SSH server class
15+
/// </summary>
1116
NyaSshService ssh;
1217

1318
public SftpPlugin() : base("sftp", "SFTP service")
@@ -27,7 +32,7 @@ protected override void OnStop()
2732
{
2833
ssh.Stop();
2934
ssh = null;
30-
NyaFs.Log.Ok(0, $"Sftp is stopped");
35+
NyaFs.Log.Ok(0, $"SFTP server is stopped");
3136
}
3237

3338
/// <summary>

0 commit comments

Comments
 (0)