检测uid
This commit is contained in:
parent
30d5fa064e
commit
eafcae4b59
@ -3,6 +3,7 @@ using System;
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
namespace FastGithub.HttpServer
|
namespace FastGithub.HttpServer
|
||||||
{
|
{
|
||||||
@ -20,6 +21,8 @@ namespace FastGithub.HttpServer
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
protected abstract string CaCertStorePath { get; }
|
protected abstract string CaCertStorePath { get; }
|
||||||
|
|
||||||
|
[DllImport("libc", SetLastError = true)]
|
||||||
|
private static extern uint geteuid();
|
||||||
|
|
||||||
public CaCertInstallerOfLinux(ILogger logger)
|
public CaCertInstallerOfLinux(ILogger logger)
|
||||||
{
|
{
|
||||||
@ -47,7 +50,7 @@ namespace FastGithub.HttpServer
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Environment.UserName != "root")
|
if (geteuid() != 0)
|
||||||
{
|
{
|
||||||
this.logger.LogWarning($"无法自动安装CA证书{caCertFilePath},因为没有root权限");
|
this.logger.LogWarning($"无法自动安装CA证书{caCertFilePath},因为没有root权限");
|
||||||
return;
|
return;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user