mirror of
https://github.com/Leonmmcoset/CMLeonOS.git
synced 2026-03-03 15:30:27 +00:00
Compare commits
2 Commits
b80c5b45a3
...
f19cad7f3a
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f19cad7f3a | ||
|
|
269c61ffdb |
3
BuildTime.ps1
Normal file
3
BuildTime.ps1
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
$buildTime = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
|
||||||
|
$buildTime | Out-File -FilePath "BuildTime.txt" -Encoding UTF8
|
||||||
|
Write-Host "Build time written to BuildTime.txt: $buildTime"
|
||||||
1
BuildTime.txt
Normal file
1
BuildTime.txt
Normal file
@@ -0,0 +1 @@
|
|||||||
|
2026-02-12 00:49:53
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
@@ -70,6 +70,7 @@
|
|||||||
<EmbeddedResource Include="font.psf" />
|
<EmbeddedResource Include="font.psf" />
|
||||||
<EmbeddedResource Include="Wallpapers\wallpaper.bmp" />
|
<EmbeddedResource Include="Wallpapers\wallpaper.bmp" />
|
||||||
<EmbeddedResource Include="GitCommit.txt" />
|
<EmbeddedResource Include="GitCommit.txt" />
|
||||||
|
<EmbeddedResource Include="BuildTime.txt" />
|
||||||
<EmbeddedResource Include="LuaApps\*.lua" />
|
<EmbeddedResource Include="LuaApps\*.lua" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
@@ -93,6 +94,7 @@
|
|||||||
|
|
||||||
<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
|
<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
|
||||||
<Exec Command="powershell -ExecutionPolicy Bypass -File GenerateGitCommit.ps1" WorkingDirectory="$(MSBuildProjectDirectory)" />
|
<Exec Command="powershell -ExecutionPolicy Bypass -File GenerateGitCommit.ps1" WorkingDirectory="$(MSBuildProjectDirectory)" />
|
||||||
|
<Exec Command="powershell -ExecutionPolicy Bypass -File BuildTime.ps1" WorkingDirectory="$(MSBuildProjectDirectory)" />
|
||||||
</Target>
|
</Target>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
b36e3ba
|
269c61f
|
||||||
21
Kernel.cs
21
Kernel.cs
@@ -43,6 +43,9 @@ namespace CMLeonOS
|
|||||||
[IL2CPU.API.Attribs.ManifestResourceStream(ResourceName = "CMLeonOS.GitCommit.txt")]
|
[IL2CPU.API.Attribs.ManifestResourceStream(ResourceName = "CMLeonOS.GitCommit.txt")]
|
||||||
public static readonly byte[] gitCommitFile;
|
public static readonly byte[] gitCommitFile;
|
||||||
|
|
||||||
|
[IL2CPU.API.Attribs.ManifestResourceStream(ResourceName = "CMLeonOS.BuildTime.txt")]
|
||||||
|
public static readonly byte[] buildTimeFile;
|
||||||
|
|
||||||
public static void ShowError(string message)
|
public static void ShowError(string message)
|
||||||
{
|
{
|
||||||
Console.ForegroundColor = ConsoleColor.Red;
|
Console.ForegroundColor = ConsoleColor.Red;
|
||||||
@@ -142,6 +145,24 @@ namespace CMLeonOS
|
|||||||
_logger.Warning("Kernel", "Git Commit file not found, using 'unknown'");
|
_logger.Warning("Kernel", "Git Commit file not found, using 'unknown'");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 读取 Build Time
|
||||||
|
if (buildTimeFile != null && buildTimeFile.Length > 0)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string buildTime = System.Text.Encoding.UTF8.GetString(buildTimeFile);
|
||||||
|
_logger.Info("Kernel", $"Build Time: {buildTime}");
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
_logger.Warning("Kernel", "Failed to read Build Time");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_logger.Warning("Kernel", "Build Time file not found");
|
||||||
|
}
|
||||||
|
|
||||||
// 检查env.dat文件是否存在,如果不存在则创建并设置Test环境变量
|
// 检查env.dat文件是否存在,如果不存在则创建并设置Test环境变量
|
||||||
string envFilePath = @"0:\system\env.dat";
|
string envFilePath = @"0:\system\env.dat";
|
||||||
if (!System.IO.File.Exists(envFilePath))
|
if (!System.IO.File.Exists(envFilePath))
|
||||||
|
|||||||
@@ -14,6 +14,19 @@ namespace CMLeonOS
|
|||||||
currentDirectory = @"0:\";
|
currentDirectory = @"0:\";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static bool ContainsInvalidChars(string input)
|
||||||
|
{
|
||||||
|
char[] invalidChars = { '<', '>', ':', '"', '|', '?', '*' };
|
||||||
|
foreach (char c in invalidChars)
|
||||||
|
{
|
||||||
|
if (input.Contains(c.ToString()))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public FileSystem(string initialPath)
|
public FileSystem(string initialPath)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(initialPath))
|
if (string.IsNullOrEmpty(initialPath))
|
||||||
@@ -67,6 +80,12 @@ namespace CMLeonOS
|
|||||||
|
|
||||||
public void MakeDirectory(string path)
|
public void MakeDirectory(string path)
|
||||||
{
|
{
|
||||||
|
if (ContainsInvalidChars(path))
|
||||||
|
{
|
||||||
|
Console.WriteLine("Error: Directory name contains invalid characters: < > : \" | ?");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
string fullPath = GetFullPath(path);
|
string fullPath = GetFullPath(path);
|
||||||
|
|
||||||
try
|
try
|
||||||
@@ -363,6 +382,28 @@ namespace CMLeonOS
|
|||||||
return currentDirectory;
|
return currentDirectory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (path.Length > 255)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Error: Path too long (maximum 255 characters)");
|
||||||
|
return currentDirectory;
|
||||||
|
}
|
||||||
|
|
||||||
|
char[] invalidChars = { '<', '>', ':', '"', '|', '?', '*' };
|
||||||
|
foreach (char c in invalidChars)
|
||||||
|
{
|
||||||
|
if (path.Contains(c.ToString()))
|
||||||
|
{
|
||||||
|
Console.WriteLine($"Error: Invalid character in path: '{c}'");
|
||||||
|
return currentDirectory;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (path.Contains("//") || path.Contains("\\\\"))
|
||||||
|
{
|
||||||
|
Console.WriteLine("Error: Path contains consecutive slashes");
|
||||||
|
return currentDirectory;
|
||||||
|
}
|
||||||
|
|
||||||
if (path.StartsWith(@"0:\"))
|
if (path.StartsWith(@"0:\"))
|
||||||
{
|
{
|
||||||
return path;
|
return path;
|
||||||
@@ -467,6 +508,16 @@ namespace CMLeonOS
|
|||||||
|
|
||||||
string normalizedPath = path;
|
string normalizedPath = path;
|
||||||
|
|
||||||
|
while (normalizedPath.Contains("//"))
|
||||||
|
{
|
||||||
|
normalizedPath = normalizedPath.Replace("//", "/");
|
||||||
|
}
|
||||||
|
|
||||||
|
while (normalizedPath.Contains("\\\\"))
|
||||||
|
{
|
||||||
|
normalizedPath = normalizedPath.Replace("\\\\", "\\");
|
||||||
|
}
|
||||||
|
|
||||||
if (normalizedPath.StartsWith("/"))
|
if (normalizedPath.StartsWith("/"))
|
||||||
{
|
{
|
||||||
normalizedPath = normalizedPath.Substring(1);
|
normalizedPath = normalizedPath.Substring(1);
|
||||||
|
|||||||
@@ -53,6 +53,19 @@ namespace CMLeonOS
|
|||||||
return Convert.ToBase64String(sha256.GetHash());
|
return Convert.ToBase64String(sha256.GetHash());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static bool ContainsInvalidChars(string input)
|
||||||
|
{
|
||||||
|
char[] invalidChars = { '<', '>', ':', '"', '|', '?', '*', '/', '\\' };
|
||||||
|
foreach (char c in invalidChars)
|
||||||
|
{
|
||||||
|
if (input.Contains(c.ToString()))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public UserSystem()
|
public UserSystem()
|
||||||
{
|
{
|
||||||
EnsureSysDirectoryExists();
|
EnsureSysDirectoryExists();
|
||||||
@@ -388,6 +401,17 @@ namespace CMLeonOS
|
|||||||
username = global::System.Console.ReadLine();
|
username = global::System.Console.ReadLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
while (ContainsInvalidChars(username))
|
||||||
|
{
|
||||||
|
CMLeonOS.UI.TUIHelper.SetColors(global::System.ConsoleColor.Red, global::System.ConsoleColor.Black);
|
||||||
|
global::System.Console.SetCursorPosition(7, 24);
|
||||||
|
global::System.Console.Write("Username contains invalid characters: < > : \" | ? / \\ ");
|
||||||
|
CMLeonOS.UI.TUIHelper.SetColors(global::System.ConsoleColor.White, global::System.ConsoleColor.Black);
|
||||||
|
global::System.Console.SetCursorPosition(7, 7);
|
||||||
|
global::System.Console.Write("Username: ");
|
||||||
|
username = global::System.Console.ReadLine();
|
||||||
|
}
|
||||||
|
|
||||||
CMLeonOS.UI.TUIHelper.SetColors(global::System.ConsoleColor.White, global::System.ConsoleColor.Black);
|
CMLeonOS.UI.TUIHelper.SetColors(global::System.ConsoleColor.White, global::System.ConsoleColor.Black);
|
||||||
global::System.Console.SetCursorPosition(7, 8);
|
global::System.Console.SetCursorPosition(7, 8);
|
||||||
global::System.Console.Write("Password: ");
|
global::System.Console.Write("Password: ");
|
||||||
|
|||||||
@@ -691,6 +691,18 @@ unalias ll
|
|||||||
version
|
version
|
||||||
```
|
```
|
||||||
|
|
||||||
|
**输出:**
|
||||||
|
```
|
||||||
|
CMLeonOS v1.0.0 (PreRelease 2) - Git: b80c5b4
|
||||||
|
Major: 1
|
||||||
|
Minor: 0
|
||||||
|
Patch: 0
|
||||||
|
Type: PreRelease 2
|
||||||
|
Full Version: 1.0.0-PreRelease 2
|
||||||
|
Git Commit: b80c5b4
|
||||||
|
Build Time: 2026-02-12 15:30:45
|
||||||
|
```
|
||||||
|
|
||||||
### settings
|
### settings
|
||||||
查看或修改系统设置。
|
查看或修改系统设置。
|
||||||
|
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ namespace UniLua
|
|||||||
new NameFuncPair("base64decrypt", OS_Base64Decrypt),
|
new NameFuncPair("base64decrypt", OS_Base64Decrypt),
|
||||||
new NameFuncPair("timerstart", OS_TimerStart),
|
new NameFuncPair("timerstart", OS_TimerStart),
|
||||||
new NameFuncPair("timerstop", OS_TimerStop),
|
new NameFuncPair("timerstop", OS_TimerStop),
|
||||||
|
new NameFuncPair("osversion", OS_Osversion),
|
||||||
new NameFuncPair("tui_drawbox", OS_TUIDrawBox),
|
new NameFuncPair("tui_drawbox", OS_TUIDrawBox),
|
||||||
new NameFuncPair("tui_drawtext", OS_TUIDrawText),
|
new NameFuncPair("tui_drawtext", OS_TUIDrawText),
|
||||||
new NameFuncPair("tui_setcolor", OS_TUISetColor),
|
new NameFuncPair("tui_setcolor", OS_TUISetColor),
|
||||||
@@ -240,6 +241,13 @@ namespace UniLua
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static int OS_Osversion(ILuaState lua)
|
||||||
|
{
|
||||||
|
string version = CMLeonOS.Version.FullVersion;
|
||||||
|
lua.PushString(version);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
private static int OS_TUIDrawBox(ILuaState lua)
|
private static int OS_TUIDrawBox(ILuaState lua)
|
||||||
{
|
{
|
||||||
int x = (int)lua.L_CheckNumber(1);
|
int x = (int)lua.L_CheckNumber(1);
|
||||||
|
|||||||
@@ -1,11 +1,16 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using IL2CPU.API.Attribs;
|
||||||
|
|
||||||
namespace CMLeonOS.Commands
|
namespace CMLeonOS.Commands
|
||||||
{
|
{
|
||||||
public static class VersionCommand
|
public static class VersionCommand
|
||||||
{
|
{
|
||||||
|
[ManifestResourceStream(ResourceName = "CMLeonOS.BuildTime.txt")]
|
||||||
|
private static byte[] buildTimeResource;
|
||||||
|
|
||||||
public static void ProcessVersion()
|
public static void ProcessVersion()
|
||||||
{
|
{
|
||||||
|
string buildTime = global::System.Text.Encoding.UTF8.GetString(buildTimeResource);
|
||||||
Console.WriteLine(Version.DisplayVersionWithGit);
|
Console.WriteLine(Version.DisplayVersionWithGit);
|
||||||
Console.WriteLine($"Major: {Version.Major}");
|
Console.WriteLine($"Major: {Version.Major}");
|
||||||
Console.WriteLine($"Minor: {Version.Minor}");
|
Console.WriteLine($"Minor: {Version.Minor}");
|
||||||
@@ -13,6 +18,7 @@ namespace CMLeonOS.Commands
|
|||||||
Console.WriteLine($"Type: {Version.VersionType}");
|
Console.WriteLine($"Type: {Version.VersionType}");
|
||||||
Console.WriteLine($"Full Version: {Version.FullVersion}");
|
Console.WriteLine($"Full Version: {Version.FullVersion}");
|
||||||
Console.WriteLine($"Git Commit: {Version.GitCommit}");
|
Console.WriteLine($"Git Commit: {Version.GitCommit}");
|
||||||
|
Console.WriteLine($"Build Time: {buildTime}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,19 @@ namespace CMLeonOS.Commands.User
|
|||||||
{
|
{
|
||||||
private static CMLeonOS.UserSystem userSystem;
|
private static CMLeonOS.UserSystem userSystem;
|
||||||
|
|
||||||
|
private static bool ContainsInvalidChars(string input)
|
||||||
|
{
|
||||||
|
char[] invalidChars = { '<', '>', ':', '"', '|', '?', '*', '/', '\\' };
|
||||||
|
foreach (char c in invalidChars)
|
||||||
|
{
|
||||||
|
if (input.Contains(c.ToString()))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public static void SetUserSystem(CMLeonOS.UserSystem system)
|
public static void SetUserSystem(CMLeonOS.UserSystem system)
|
||||||
{
|
{
|
||||||
userSystem = system;
|
userSystem = system;
|
||||||
@@ -80,6 +93,12 @@ namespace CMLeonOS.Commands.User
|
|||||||
string password = parts[3];
|
string password = parts[3];
|
||||||
bool isAdmin = userType == "admin";
|
bool isAdmin = userType == "admin";
|
||||||
|
|
||||||
|
if (ContainsInvalidChars(username))
|
||||||
|
{
|
||||||
|
showError("Error: Username contains invalid characters: < > : \" | ? / \\");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
userSystem.AddUser($"{username} {password}", isAdmin);
|
userSystem.AddUser($"{username} {password}", isAdmin);
|
||||||
}
|
}
|
||||||
else if (subCommand == "delete")
|
else if (subCommand == "delete")
|
||||||
|
|||||||
Reference in New Issue
Block a user