From eafcae4b59c7e77ff0ec554d6553f51960229b4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=80=81=E4=B9=9D?= <366193849@qq.com> Date: Sun, 14 Nov 2021 00:14:19 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A3=80=E6=B5=8Buid?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FastGithub.HttpServer/CaCertInstallerOfLinux.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/FastGithub.HttpServer/CaCertInstallerOfLinux.cs b/FastGithub.HttpServer/CaCertInstallerOfLinux.cs index ae7eba0..51f1d4a 100644 --- a/FastGithub.HttpServer/CaCertInstallerOfLinux.cs +++ b/FastGithub.HttpServer/CaCertInstallerOfLinux.cs @@ -3,6 +3,7 @@ using System; using System.Diagnostics; using System.IO; using System.Linq; +using System.Runtime.InteropServices; namespace FastGithub.HttpServer { @@ -20,6 +21,8 @@ namespace FastGithub.HttpServer /// protected abstract string CaCertStorePath { get; } + [DllImport("libc", SetLastError = true)] + private static extern uint geteuid(); public CaCertInstallerOfLinux(ILogger logger) { @@ -47,7 +50,7 @@ namespace FastGithub.HttpServer return; } - if (Environment.UserName != "root") + if (geteuid() != 0) { this.logger.LogWarning($"无法自动安装CA证书{caCertFilePath},因为没有root权限"); return;