linux - 有什么方法可以让 System.Diagnostics.Process 尊重 Linux 用户的次要组?
问题描述
帮助!
在Linux上运行 .NET CORE 。
我在打开基于 Linux 中的辅助组具有读取访问权限的文件时遇到问题。为了测试这一点,我只需为当前用户执行 Linux 命令“id”:
var proc = new System.Diagnostics.Process();
proc.StartInfo.UserName = "JohnNonRootUser";
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.FileName = "id";
proc.StartInfo.RedirectStandardOutput = true;
proc.Start();
while (!proc.StandardOutput.EndOfStream)
{
sb.AppendLine(proc.StandardOutput.ReadLine());
}
var resID = sb.ToString();
结果是:
uid=1002(JohnNonRootUser) gid=1002(JohnNonRootUser) groups=1002(JohnNonRootUser)
但如果我从命令行手动执行,它是正确的:
JohnNonRootUser@mybox:/$ id
uid=1002(JohnNonRootUser) gid=1002(JohnNonRootUser) groups=1002(JohnNonRootUser),1003(SomeOtherGroup)
谁能让我知道如何解决这个问题?
解决方案
推荐阅读
- postgresql - 获取在 Db.Query 调用后面使用的实际 sql 语句
- postgresql - Grafana Singlestat 在重复行上显示不同面板的相同值
- php - smt->close(); 之后什么也没有发生
- c++ - C++ 早期动态初始化
- r - 根据行号更改/替换变量值的元素
- javascript - Vue-chat-scroll 不适用于加载程序
- postgresql - 保存实体时出现 Utf 8 问题
- java - 读取多个文本文件并从每个文本文件中查找最长的单词
- sql - 如何使用 ORDS 发出 POST 请求?
- php - 正则表达式选择特定的 html 元素 [Curl / PHP]