在Windows上转到(golang),文件uid [英] Go (golang), file uid on windows

查看:141
本文介绍了在Windows上转到(golang),文件uid的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在Windows上获取文件的UID(所有者)?我尝试使用FileInfo.Sys(),但是它仅适用于Linux.我真的很为难,无法弄清楚如何获取UID.

Is it possible to get a file's UID (owner) on Windows? I tried to use FileInfo.Sys(), but it only works on Linux. I'm really stumped on this one and can't figure out how to get the UID.

推荐答案

第一个问题是Windows本身支持文件/目录所有权的文件系统不具有所有者UID"的概念,仅仅是因为Windows用户没有UID要么.

The first problem is that file systems native to Windows which supports file/directory ownership do not have the concept of "owner UID" simply because Windows users have no UIDs either.

使用所谓的访问控制列表"(ACL)实现Windows NT产品线或内核的安全性,并使用所谓的安全标识符"(SID)标识安全主体(例如用户). . SID是可变长度的多字段数据结构,通常会传递给它作为字节数组.

The security of the Windows NT line or kernels is implemented using the so-called "access control lists" (ACLs), and security principals (such as users) are identified using the so-called "security identifiers" (SIDs). A SID is a variable-length multi-field data structure usually passed around as a byte array.

另一个麻烦是,启用ACL的Windows文件系统上的文件可能根本没有所有者(也没有附加ACL);这很少见,但有可能.

Another complication is that a file on an ACL-enabled Windows file system might have no owner at all (and no ACL attached to it as well); this is rare but possible.

所以...如果说在Windows文件系统上没有条目所有者的UID之类的东西"的解释部分对您来说是可以的,那么便足够了.

So... If the part of explanation stating "there's no such thing as the entry owner's UID on Windows filesystem" is OK for you, this is all there is to it.

如果不是,并且您实际上想问如何获取Windows文件系统上条目的安全性信息?",问题变得更加复杂. AFAIK Go随附的库存标准库在Win32 API的相关位周围没有必要的包装.因此,要实现此目的,您需要自己包装它们(毕竟并不难)或尝试找到一个帮助程序包.

If not, and you actually wanted to ask "how do I get security information for an entry on a Windows filesystem?", the question gets more complicated. AFAIK the stock standard library shipped with Go does not have the necessary wrappers around the relevant bits of the Win32 API. So to implement this, you'll need to either wrap them yourself (it's not that hard, after all) or try to find a helper package.

这篇关于在Windows上转到(golang),文件uid的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆