MCPcopy Index your code
hub / github.com/1Panel-dev/1Panel / secureMasterSocket

Function secureMasterSocket

agent/server/server.go:69–91  ·  view source on GitHub ↗
(sockPath string)

Source from the content-addressed store, hash-verified

67}
68
69func secureMasterSocket(sockPath string) error {
70 if err := os.Chmod(sockPath, masterSocketFilePerm); err != nil {
71 return fmt.Errorf("chmod master socket %s failed: %w", sockPath, err)
72 }
73 info, err := os.Stat(sockPath)
74 if err != nil {
75 return fmt.Errorf("stat master socket %s failed: %w", sockPath, err)
76 }
77 if info.Mode().Perm()&masterSocketFilePermMask != 0 {
78 return fmt.Errorf("master socket %s permission %#o is too permissive", sockPath, info.Mode().Perm())
79 }
80 stat, ok := info.Sys().(*syscall.Stat_t)
81 if !ok {
82 return nil
83 }
84 if int(stat.Uid) != os.Geteuid() {
85 return fmt.Errorf(
86 "master socket %s owner uid %d does not match current process uid %d",
87 sockPath, stat.Uid, os.Geteuid(),
88 )
89 }
90 return nil
91}
92
93func Start() {
94 re.Init()

Callers 1

StartFunction · 0.85

Calls 3

ModeMethod · 0.80
SysMethod · 0.80
StatMethod · 0.45

Tested by

no test coverage detected