Documentation
¶
Overview ¶
Package osfs 提供 XOps v2 句柄安全的三平台本地文件系统、旁路文件锁、空设备、Windows DACL/超长路径 与受控本地 AF_UNIX 套接字及 SCM_RIGHTS 单 FD 传递原语(公开契约 4,ADR-007 / ADR-019 / INV-A1..A5)。
Index ¶
- Constants
- Variables
- func AtomicReplace(r ports.RootHandle, d pathalg.LocalRootedDest, p fs.FileMode, fn WriteFileFunc) error
- func AtomicReplaceWithSidecarLock(ctx context.Context, root ports.RootHandle, dest pathalg.LocalRootedDest, ...) error
- func CreateExclusive(r ports.RootHandle, d pathalg.LocalRootedDest, p fs.FileMode, fn WriteFileFunc) error
- func DialWindowsNamedPipeVerified(ctx context.Context, _ string) (net.Conn, error)
- func EnsureDir(dir pathalg.LocalDir, perm fs.FileMode) error
- func EnsureOwnerOnlyDir(dir pathalg.LocalDir) error
- func EvaluateWindowsObjectACL(in WindowsACLInput) security.Verdict
- func IsExtendedOrDeviceWindowsPath(path string) bool
- func IsPathWithinRoot(targetPath, rootPath string) (bool, error)
- func MaxUnixSocketPathBytes() int
- func NormalizeWin32LongPath(p string) string
- func OpenLockedContext(ctx context.Context, r ports.RootHandle, d pathalg.LocalRootedDest, ...) error
- func OpenNullDevice() (*os.File, error)
- func OpenRegular(r ports.RootHandle, d pathalg.LocalRootedDest, l ports.ReadLimits, ...) error
- func ReadVerifiedPrivateFile(fsPort ports.ScopedRootFS, rootDir pathalg.LocalDir, ...) error
- func ReadVerifiedPrivateFileInRoot(root ports.RootHandle, dest pathalg.LocalRootedDest, limits ports.ReadLimits, ...) error
- func RecvUnixFD(conn *net.UnixConn) (*os.File, error)
- func RemoveLockedFileSafely(root ports.RootHandle, lockDest pathalg.LocalRootedDest) (bool, error)
- func ResolvePhysicalPath(raw string) (string, error)
- func SendUnixFD(conn *net.UnixConn, f *os.File) error
- func SidecarLockDest(dest pathalg.LocalRootedDest) (pathalg.LocalRootedDest, error)
- func TerminalSizeOfFD(f *os.File) (ports.TerminalSize, error)
- func UTF16CodeUnitLen(s string) int
- func WithSidecarLock(ctx context.Context, root ports.RootHandle, target pathalg.LocalRootedDest, ...) error
- func WithSocketSlot(ctx context.Context, path ControlSocketPath, opts SocketSlotOptions, ...) (retErr error)
- type ControlSocketPath
- func BuildManagedMuxSocketPath(dir pathalg.LocalDir, percentC string) (ControlSocketPath, error)
- func ControlSocketPathFromSource(src pathalg.LocalSourcePath) (ControlSocketPath, error)
- func ValidateControlSocketPath(raw string) (ControlSocketPath, error)
- func ValidateUnixControlSocketPath(raw string, maxBytes int) (ControlSocketPath, error)
- func ValidateWindowsControlSocketPath(raw string, maxBytes int) (ControlSocketPath, error)
- func (p ControlSocketPath) Dir() string
- func (p ControlSocketPath) Equal(o ControlSocketPath) bool
- func (p ControlSocketPath) IsValid() bool
- func (p ControlSocketPath) IsZero() bool
- func (p ControlSocketPath) Name() string
- func (p ControlSocketPath) NativePath() string
- func (p ControlSocketPath) String() string
- type LockedFileFunc
- type OpenRegularFunc
- type OperatorFS
- type ParsedWindowsACE
- type PeerCred
- func (c PeerCred) Equal(o PeerCred) bool
- func (c PeerCred) GID() (uint32, bool)
- func (c PeerCred) HasGID() bool
- func (c PeerCred) HasPID() bool
- func (c PeerCred) HasUID() bool
- func (c PeerCred) IsValid() bool
- func (c PeerCred) IsZero() bool
- func (c PeerCred) PID() (uint32, bool)
- func (c PeerCred) UID() (uint32, bool)
- type ScopedFS
- type SocketPeerPolicy
- type SocketProbeStatus
- type SocketSlot
- type SocketSlotOptions
- type WindowsACLInput
- type WindowsACLMode
- type WriteFileFunc
Constants ¶
const (
WinAttrDirectory, WinAttrDevice, WinAttrReparsePoint uint32 = osfsutil.WinAttrDirectory, osfsutil.WinAttrDevice, osfsutil.WinAttrReparsePoint
WinACEFlagInheritOnly, WinACETypeAllow, WinACETypeDeny uint8 = osfsutil.WinACEFlagInheritOnly, osfsutil.WinACETypeAllow, osfsutil.WinACETypeDeny
WinAccessWriteData, WinAccessAppendData, WinAccessWriteEA uint32 = osfsutil.WinAccessWriteData, osfsutil.WinAccessAppendData, osfsutil.WinAccessWriteEA
WinAccessCreatePipeInstance uint32 = osfsutil.WinAccessCreatePipeInstance // WinSDK FILE_CREATE_PIPE_INSTANCE(命名管道抢注权限)
WinAccessDeleteChild uint32 = osfsutil.WinAccessDeleteChild // WinSDK winnt.h FILE_DELETE_CHILD(目录删除子项权限)
WinAccessWriteAttrs, WinAccessDelete, WinAccessWriteDAC, WinAccessWriteOwner uint32 = osfsutil.WinAccessWriteAttrs, osfsutil.WinAccessDelete, osfsutil.WinAccessWriteDAC, osfsutil.WinAccessWriteOwner
WinAccessGenericAll, WinAccessGenericWrite uint32 = osfsutil.WinAccessGenericAll, osfsutil.WinAccessGenericWrite
)
Win32 DACL 与文件属性位常量(跨平台纯数学副本)。
const Win32LongPathThreshold = osfsutil.Win32LongPathThreshold
Win32LongPathThreshold 是触发 Win32 扩展长路径前缀(\\?\ 与 \\?\UNC\)的 UTF-16 码元阈值(INV-A4)。
Variables ¶
var ( ErrSlotOccupied = domi18n.Sentinel(domi18n.KeyOSFSSlotOccupied) ErrNotSocket = domi18n.Sentinel(domi18n.KeyOSFSNotSocket) ErrInvalidControlPath = domi18n.Sentinel(domi18n.KeyOSFSInvalidControlPath) ErrControlPathTooLong = domi18n.Sentinel(domi18n.KeyOSFSControlPathTooLong) ErrUnsupportedPeerCred = domi18n.Sentinel(domi18n.KeyOSFSUnsupportedPeerCred) ErrInsecurePermissions = domi18n.Sentinel(domi18n.KeyOSFSInsecurePermissions) ErrSameFileMismatch = domi18n.Sentinel(domi18n.KeyOSFSSameFileMismatch) )
本包导出的规范化哨兵错误(供调用方以 errors.Is 精确判定)。
Functions ¶
func AtomicReplace ¶
func AtomicReplace(r ports.RootHandle, d pathalg.LocalRootedDest, p fs.FileMode, fn WriteFileFunc) error
func AtomicReplaceWithSidecarLock ¶
func AtomicReplaceWithSidecarLock(ctx context.Context, root ports.RootHandle, dest pathalg.LocalRootedDest, perm fs.FileMode, fn WriteFileFunc) error
AtomicReplaceWithSidecarLock 持有同目录旁路独占锁 <dest>.lock(绝不锁目标文件)并原子替换 dest(ADR-007); 完全通过 ports.RootHandle 接口委派,零具体类型断言,同时兼容真实 osfs、仿真器及包装适配器。
func CreateExclusive ¶
func CreateExclusive(r ports.RootHandle, d pathalg.LocalRootedDest, p fs.FileMode, fn WriteFileFunc) error
func DialWindowsNamedPipeVerified ¶
DialWindowsNamedPipeVerified 在非 Windows 平台上固定返回 ports.ErrUnsupported。
func EnsureDir ¶
EnsureDir 跨平台安全确保本地根目录 dir 存在且末段非符号链接: Unix 逐段使用 Mkdirat + O_DIRECTORY|O_NOFOLLOW 建目录(默认 0700);Windows 当 perm&0o077==0 时附带 Owner-Only DACL。
func EnsureOwnerOnlyDir ¶
EnsureOwnerOnlyDir 跨平台确保目录 dir 存在且仅所有者可访问(Unix 0700 + 非软链;Windows Owner-Only DACL)。
func EvaluateWindowsObjectACL ¶
func EvaluateWindowsObjectACL(in WindowsACLInput) security.Verdict
EvaluateWindowsObjectACL 以失败关闭交半格语义评估 Windows 对象属性与 DACL 安全性(INV-A4 / INV-E1)。
func IsExtendedOrDeviceWindowsPath ¶
IsExtendedOrDeviceWindowsPath 报告路径是否已携带 \\?\、\\.\ 或 \??\ Win32 设备/扩展前缀。
func IsPathWithinRoot ¶ added in v1.3.0
IsPathWithinRoot 先经 ResolvePhysicalPath 规范化双方路径,再按段边界判定目标是否位于根目录内(windows || darwin 折叠大小写)。
func MaxUnixSocketPathBytes ¶
func MaxUnixSocketPathBytes() int
MaxUnixSocketPathBytes 返回当前平台 sockaddr_un.sun_path 最大路径字节数(不含结尾 NUL)。
func NormalizeWin32LongPath ¶
NormalizeWin32LongPath 在有效路径长度 >= 248 UTF-16 码元时补齐 \\?\ 或 \\?\UNC\ 前缀(INV-A4)。
func OpenLockedContext ¶
func OpenLockedContext(ctx context.Context, r ports.RootHandle, d pathalg.LocalRootedDest, m ports.LockMode, c bool, p fs.FileMode, fn LockedFileFunc) error
func OpenNullDevice ¶ added in v1.3.0
OpenNullDevice 以 O_RDWR|O_NOFOLLOW|O_CLOEXEC 打开 /dev/null 并核验字符设备(S_IFCHR), 返回可同时用于 stdin/stdout/stderr 重定向且拥有所有权的 *os.File。
func OpenRegular ¶
func OpenRegular(r ports.RootHandle, d pathalg.LocalRootedDest, l ports.ReadLimits, fn OpenRegularFunc) error
OpenRegular / CreateExclusive / OpenLockedContext / AtomicReplace 为 ports.RootHandle 提供包级显式作用域原语(ADR-007)。
func ReadVerifiedPrivateFile ¶ added in v1.3.0
func ReadVerifiedPrivateFile(fsPort ports.ScopedRootFS, rootDir pathalg.LocalDir, dest pathalg.LocalRootedDest, limits ports.ReadLimits, fn func(box *secret.SecretBox) error) error
ReadVerifiedPrivateFile 是面向 ports.ScopedRootFS 的跨平台原子私密文件读取便捷入口(ADR-018): 打开 rootDir 沙箱并在同步闭包内将通过句柄级权限校验的常规文件 dest 借出为 *secret.SecretBox, 完整兼容生产 *osfs.ScopedFS 与仿真 *sim.SimScopedRootFS。
func ReadVerifiedPrivateFileInRoot ¶ added in v1.3.0
func ReadVerifiedPrivateFileInRoot(root ports.RootHandle, dest pathalg.LocalRootedDest, limits ports.ReadLimits, fn func(box *secret.SecretBox) error) error
ReadVerifiedPrivateFileInRoot 在已借出的 ports.RootHandle 沙箱内通过 ports.PrivateFileReader 窄接口 原子校验并读取私密文件至 *secret.SecretBox;底层 RootHandle 未实现该接口时 fail-closed 返回 ports.ErrUnsupported。
func RecvUnixFD ¶ added in v1.3.0
RecvUnixFD 经本地 AF_UNIX 套接字接收单枚 fd,并返回拥有所有权且已设 FD_CLOEXEC 的 *os.File。
func RemoveLockedFileSafely ¶
func RemoveLockedFileSafely(root ports.RootHandle, lockDest pathalg.LocalRootedDest) (bool, error)
RemoveLockedFileSafely 按三平台安全删锁协议清理已退役的单进程实例锁文件: 持独占锁截断清空刷盘 -> 解锁关句柄 -> Remove(忽略 ErrNotFound),消除 Windows 共享冲突。
func ResolvePhysicalPath ¶ added in v1.3.0
ResolvePhysicalPath 自根向叶逐分量无跟随展开已存在及悬空符号链接/重解析点(上限 40 跳),返回规范物理路径。
func SendUnixFD ¶ added in v1.3.0
SendUnixFD 经本地 AF_UNIX 套接字以 SCM_RIGHTS 发送单枚 fd(强制 SyscallConn().Control,禁 f.Fd())。
func SidecarLockDest ¶
func SidecarLockDest(dest pathalg.LocalRootedDest) (pathalg.LocalRootedDest, error)
SidecarLockDest 为目标文件构造同目录旁路锁路径 <name>.lock(ADR-007)。
func TerminalSizeOfFD ¶ added in v1.3.0
func TerminalSizeOfFD(f *os.File) (ports.TerminalSize, error)
TerminalSizeOfFD 经 f.SyscallConn().Control 借用原始 fd 并调用 TIOCGWINSZ 查询终端尺寸。
func UTF16CodeUnitLen ¶
UTF16CodeUnitLen 计算字符串在 UTF-16 编码下的精确码元数量(辅助平面码点计 2 码元)。
func WithSidecarLock ¶
func WithSidecarLock(ctx context.Context, root ports.RootHandle, target pathalg.LocalRootedDest, mode ports.LockMode, perm fs.FileMode, fn LockedFileFunc) error
WithSidecarLock 锁定 target 同目录旁路锁文件 <target>.lock 并同步执行回调(ADR-007)。
func WithSocketSlot ¶
func WithSocketSlot(ctx context.Context, path ControlSocketPath, opts SocketSlotOptions, fn func(slot *SocketSlot) error) (retErr error)
WithSocketSlot 在目录锁保护下独占绑定本地 AF_UNIX 套接字并在同步闭包内借出 SocketSlot; 退出时无条件按 INV-A3 固定顺序「加目录锁 -> 身份校验 -> unlink -> close -> 解锁」释放。
Types ¶
type ControlSocketPath ¶
type ControlSocketPath struct {
// contains filtered or unexported fields
}
ControlSocketPath 表示经平台安全规则与 sun_path 上限校验的本地 AF_UNIX 套接字路径。 Unix 允许 OpenSSH ControlPath 含 ':'(如 cm-alice@host:22),Windows 除盘符前缀外严禁 ':'。
func BuildManagedMuxSocketPath ¶
func BuildManagedMuxSocketPath(dir pathalg.LocalDir, percentC string) (ControlSocketPath, error)
BuildManagedMuxSocketPath 基于经校验的沙箱目录与 OpenSSH %C 40 位小写十六进制摘要构造自管套接字路径。
func ControlSocketPathFromSource ¶
func ControlSocketPathFromSource(src pathalg.LocalSourcePath) (ControlSocketPath, error)
ControlSocketPathFromSource 将经 pathalg 校验的本地源路径转换为当前平台安全控制套接字路径; 兼容 Unix 下 OpenSSH %r@%h:%p 含 ':' 文件名,并在 Windows 上剥离 \\?\ 前缀后执行 sun_path 校验。
func ValidateControlSocketPath ¶
func ValidateControlSocketPath(raw string) (ControlSocketPath, error)
ValidateControlSocketPath 按当前运行平台规则校验并构造不可变 ControlSocketPath。
func ValidateUnixControlSocketPath ¶
func ValidateUnixControlSocketPath(raw string, maxBytes int) (ControlSocketPath, error)
ValidateUnixControlSocketPath 按 Unix 规则校验套接字路径:允许文件名含 ':',拒绝 '..'、尾随分隔符/'.' 与超长 sun_path。
func ValidateWindowsControlSocketPath ¶
func ValidateWindowsControlSocketPath(raw string, maxBytes int) (ControlSocketPath, error)
ValidateWindowsControlSocketPath 按 Windows/NTFS 规则严格校验套接字路径:除盘符前缀外严禁 ':'、前导分隔符与尾随分隔符/'.'。
func (ControlSocketPath) Dir ¶
func (p ControlSocketPath) Dir() string
func (ControlSocketPath) Equal ¶
func (p ControlSocketPath) Equal(o ControlSocketPath) bool
func (ControlSocketPath) IsValid ¶
func (p ControlSocketPath) IsValid() bool
func (ControlSocketPath) IsZero ¶
func (p ControlSocketPath) IsZero() bool
func (ControlSocketPath) Name ¶
func (p ControlSocketPath) Name() string
func (ControlSocketPath) NativePath ¶
func (p ControlSocketPath) NativePath() string
func (ControlSocketPath) String ¶
func (p ControlSocketPath) String() string
type LockedFileFunc ¶
type LockedFileFunc func(f ports.LockedFile) error
type OpenRegularFunc ¶
type OpenRegularFunc func(r ports.BoundedReadHandle, size int64) error
OpenRegularFunc / WriteFileFunc / LockedFileFunc 定义包级作用域闭包原语的借用回调契约。
type OperatorFS ¶
type OperatorFS struct {
// contains filtered or unexported fields
}
OperatorFS 是面向 CLI/Playbook DirectOperatorProfile 的人工显式本地只读源适配器, 仅实现 ports.OperatorReadFS(物理上绝不注入 mcpruntime,零值失败关闭)。
func NewOperatorReadFS ¶
func NewOperatorReadFS() *OperatorFS
NewOperatorReadFS 构造可用的操作员只读源文件适配器实例(ports.OperatorReadFS 生产实现)。
func (*OperatorFS) WithOperatorRead ¶
func (o *OperatorFS) WithOperatorRead(ctx context.Context, path pathalg.LocalSourcePath, policy pathalg.SymlinkPolicy, fn func(r ports.BoundedReadHandle, size int64) error) error
WithOperatorRead 按 policy 管控符号链接行为打开只读常规文件,并在同步闭包内借出随机只读句柄与字节长度; 回调退出后立即使借出句柄失效并关闭底层文件句柄。
type ParsedWindowsACE ¶
ParsedWindowsACE 表示从 Windows DACL 解码出的单条 ACE 纯数学视图。
type PeerCred ¶
type PeerCred struct {
// contains filtered or unexported fields
}
PeerCred 表示经内核查询到的本地 AF_UNIX 连接对端身份凭据快照;零值恒无效。
func DialUnixVerified ¶
DialUnixVerified 连接至经安全核验的本地 AF_UNIX 控制套接字并强制核验对端用户身份(fail-closed)。
func QueryUnixPeerCred ¶
QueryUnixPeerCred / VerifyUnixPeerCurrentUser 通过内核套接字选项查询或强校验对端身份(fail-closed)。
type ScopedFS ¶
type ScopedFS struct {
// contains filtered or unexported fields
}
ScopedFS 是基于 Go *os.Root 的沙箱本地文件系统适配器,仅实现 ports.ScopedRootFS(零值失败关闭)。
func NewScopedRootFS ¶
func NewScopedRootFS() *ScopedFS
NewScopedRootFS 构造可用的沙箱本地文件系统实例(ports.ScopedRootFS 生产实现)。
func (*ScopedFS) EnsureRoot ¶
EnsureRoot 实现 ports.ScopedRootFS.EnsureRoot,在 WithRoot 前安全引导沙箱根目录存在。
type SocketPeerPolicy ¶ added in v1.3.0
type SocketPeerPolicy uint8
SocketPeerPolicy 声明本地 AF_UNIX 套接字监听器的跨用户对端接入策略。 零值 SocketPeerPolicyUnset 强制归一为最严 SocketPeerOwnerOnly(同 UID/同 SID,INV-A3)。
const ( // SocketPeerPolicyUnset 为零值默认策略,强制归一为最严 SocketPeerOwnerOnly(INV-A3)。 SocketPeerPolicyUnset SocketPeerPolicy = SocketPeerPolicy(osfsutil.SocketPeerPolicyUnsetCode) // SocketPeerOwnerOnly 强制每次 Accept 执行内核级同 UID(Unix)或同 SID(Windows)对端校验, // 且要求套接字文件权限禁止任何非属主位(filePerm & 0o077 == 0)。 SocketPeerOwnerOnly SocketPeerPolicy = SocketPeerPolicy(osfsutil.SocketPeerOwnerOnlyCode) // SocketPeerFilesystemPerm 显式授权在 Unix StreamLocal 本地转发放宽掩码时委托内核 VFS 文件权限裁决; // ControlMaster 管理面与 SocketSlot.AcceptVerified 严禁受其影响,Windows 平台恒拒绝本策略。 SocketPeerFilesystemPerm SocketPeerPolicy = SocketPeerPolicy(osfsutil.SocketPeerFilesystemPermCode) )
func (SocketPeerPolicy) Effective ¶ added in v1.3.0
func (p SocketPeerPolicy) Effective() SocketPeerPolicy
Effective 返回归一后的有效对端策略:零值与未知非法值一律 fail-closed 收敛为 SocketPeerOwnerOnly。
func (SocketPeerPolicy) IsValid ¶ added in v1.3.0
func (p SocketPeerPolicy) IsValid() bool
IsValid 报告 p 是否为已登记的合法策略值(含零值 SocketPeerPolicyUnset)。
func (SocketPeerPolicy) String ¶ added in v1.3.0
func (p SocketPeerPolicy) String() string
String 返回 SocketPeerPolicy 的规范小写名称。
type SocketProbeStatus ¶
type SocketProbeStatus uint8
SocketProbeStatus 描述 ProbeStaleUnixSocket 的探活分类结果;零值 SocketProbeUnknown 严格失败关闭。
const ( SocketProbeUnknown SocketProbeStatus = SocketProbeStatus(osfsutil.SocketProbeUnknownCode) // 探测未完成或异常(零值失败关闭) SocketProbeMissing SocketProbeStatus = SocketProbeStatus(osfsutil.SocketProbeMissingCode) // 目标路径不存在 SocketProbeNotSocket SocketProbeStatus = SocketProbeStatus(osfsutil.SocketProbeNotSocketCode) // 存在但非本地 AF_UNIX 套接字 SocketProbeLive SocketProbeStatus = SocketProbeStatus(osfsutil.SocketProbeLiveCode) // 存在且活跃监听进程响应连接 SocketProbeStale SocketProbeStatus = SocketProbeStatus(osfsutil.SocketProbeStaleCode) // 确认为套接字且连接被明确拒绝(可安全清理) )
func ProbeStaleUnixSocket ¶
func ProbeStaleUnixSocket(ctx context.Context, path ControlSocketPath) (SocketProbeStatus, error)
ProbeStaleUnixSocket 对本地 AF_UNIX 套接字执行 fail-closed 存活/陈旧探测。
func PruneStaleUnixSocket ¶
func PruneStaleUnixSocket(ctx context.Context, path ControlSocketPath) (SocketProbeStatus, error)
PruneStaleUnixSocket 在目录锁内复核并安全清理已确证过期的本地 AF_UNIX 套接字;父目录缺失时零副作用返回 Missing。
func (SocketProbeStatus) IsValid ¶
func (s SocketProbeStatus) IsValid() bool
IsValid 报告 s 是否为已判明的有效探测状态(零值 SocketProbeUnknown 返回 false)。
func (SocketProbeStatus) String ¶
func (s SocketProbeStatus) String() string
String 返回 SocketProbeStatus 的可读名称。
type SocketSlot ¶
type SocketSlot struct {
// contains filtered or unexported fields
}
SocketSlot 表示 WithSocketSlot 在同步作用域内借出的独占本地 AF_UNIX 监听槽位(INV-A3)。
func (*SocketSlot) AcceptVerified ¶
func (s *SocketSlot) AcceptVerified() (*net.UnixConn, PeerCred, error)
AcceptVerified 接受本地 AF_UNIX 连接并强制核验对端用户身份(无视 PeerPolicy,失败立即关连并返回 ErrUnauthorizedPeer)。
func (*SocketSlot) IsActive ¶
func (s *SocketSlot) IsActive() bool
func (*SocketSlot) Listener ¶
func (s *SocketSlot) Listener() net.Listener
func (*SocketSlot) Path ¶
func (s *SocketSlot) Path() ControlSocketPath
type SocketSlotOptions ¶
type SocketSlotOptions struct {
ReplaceStale bool // 在目录锁内确证为 SocketProbeStale 后允许清理接管
FilePerm fs.FileMode // 可选 Unix 套接字权限位(零值默认 0o600;仅允许低 9 位 <= 0o777,拒绝特殊模式位;非属主位须显式配 SocketPeerFilesystemPerm)
PeerPolicy SocketPeerPolicy // 本地对端身份校验策略(零值 SocketPeerPolicyUnset 归一为 SocketPeerOwnerOnly)
ConfineRoot algebraic.Option[pathalg.LocalDir] // 可选:内核级防软链逃逸沙箱根目录(ADR-019 v2.2 S3-Q4b,非空须为非根绝对目录)
}
SocketSlotOptions 控制 WithSocketSlot 绑定本地 AF_UNIX 套接字时的冲突处置、权限位、对端接入策略与可选内核沙箱根。 零值最严:ReplaceStale=false、FilePerm 归一为 0o600、PeerPolicy 归一为 SocketPeerOwnerOnly(INV-A3)。
func DefaultSocketSlotOptions ¶ added in v1.3.0
func DefaultSocketSlotOptions() SocketSlotOptions
DefaultSocketSlotOptions 返回最严默认本地套接字槽位选项(0o600 + SocketPeerOwnerOnly + ReplaceStale=false)。
func (SocketSlotOptions) EffectiveFilePerm ¶ added in v1.3.0
func (o SocketSlotOptions) EffectiveFilePerm() fs.FileMode
EffectiveFilePerm 返回归一后的有效套接字权限位(零值返回 0o600,含非法特殊权限位返回 0)。
func (SocketSlotOptions) EffectivePeerPolicy ¶ added in v1.3.0
func (o SocketSlotOptions) EffectivePeerPolicy() SocketPeerPolicy
EffectivePeerPolicy 返回归一后的有效对端接入策略(零值与未知值一律 fail-closed 收敛为 SocketPeerOwnerOnly)。
type WindowsACLInput ¶
type WindowsACLInput struct {
Mode WindowsACLMode
Attrs uint32
ExpectDir, AllowReparse, OwnerTrusted, HasDACL bool
ACEs []ParsedWindowsACE
}
WindowsACLInput 封装待评估 Windows 对象的属性与解析后 DACL 信息。
type WindowsACLMode ¶
type WindowsACLMode uint8
WindowsACLMode 区分 Windows DACL 安全评估策略;零值 WindowsACLInvalid 严格失败关闭。
const ( WindowsACLInvalid WindowsACLMode = WindowsACLMode(osfsutil.ACLModeInvalid) // 无效评估模式(零值失败关闭) WindowsACLOwnerOnly WindowsACLMode = WindowsACLMode(osfsutil.ACLModeOwnerOnly) // 仅受信任所有者/系统主体可访问 WindowsACLWriteRestricted WindowsACLMode = WindowsACLMode(osfsutil.ACLModeWriteRestricted) // 严禁非受信任主体具备写/删/改权位 WindowsACLPipeServerSafe WindowsACLMode = WindowsACLMode(osfsutil.ACLModePipeServerSafe) // 命名管道服务端:阻断非受信任主体抢注实例/改权限,放行合法双工 FILE_WRITE_DATA )
type WriteFileFunc ¶
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
internal
|
|
|
osfsutil
Package osfsutil 提供 core/osfs 使用的平台无关纯辅助、错误归一化、路径与目录项校验工具。
|
Package osfsutil 提供 core/osfs 使用的平台无关纯辅助、错误归一化、路径与目录项校验工具。 |
|
unixipc
Package unixipc 为 core/osfs 提供私有本地 AF_UNIX 套接字控制、借用监听、SCM_RIGHTS 单 FD 传递与 TIOCGWINSZ 终端尺寸查询原语(ADR-019)。
|
Package unixipc 为 core/osfs 提供私有本地 AF_UNIX 套接字控制、借用监听、SCM_RIGHTS 单 FD 传递与 TIOCGWINSZ 终端尺寸查询原语(ADR-019)。 |
|
winpipe
Package winpipe 为 core/osfs 提供私有 Windows 命名管道全双工重叠 I/O 连接封装(ADR-007 / P4-T4)。
|
Package winpipe 为 core/osfs 提供私有 Windows 命名管道全双工重叠 I/O 连接封装(ADR-007 / P4-T4)。 |