You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
funcValidateFilePermissionNotTooOpen(pathstring, fi os.FileInfo) error {
16
+
iffi.IsDir() {
17
+
returnfmt.Errorf("cannot read a directory: %v", path)
18
+
}
19
+
iffi.Mode()&0o037>0 {
20
+
returnfmt.Errorf("permissions %04o for '%v' are too open; requires the file is NOT writable by the same group and NOT accessible by others; suggest 0640 or 0600", fi.Mode()&0o777, path)
21
+
}
22
+
returnnil
23
+
}
24
+
25
+
funcValidateFilePermissionAllowed(pathstring, fi os.FileInfo, allowedModes...os.FileMode) error {
26
+
iffi.IsDir() {
27
+
returnfmt.Errorf("cannot read a directory: %v", path)
28
+
}
29
+
perm:=fi.Mode().Perm()
30
+
for_, mode:=rangeallowedModes {
31
+
ifperm==mode.Perm() {
32
+
returnnil
33
+
}
34
+
}
35
+
iflen(allowedModes) ==0 {
36
+
returnfmt.Errorf("permissions %04o for '%v' are invalid", perm, path)
returnnil, fmt.Errorf("subscription file cannot be a directory: %v", path)
117
-
}
118
-
iffi.Mode()&0037>0 {
119
-
returnnil, fmt.Errorf("permissions %04o for '%v' are too open; requires the file is NOT writable by the same group and NOT accessible by others; suggest 0640 or 0600", fi.Mode()&0777, path)
returnfmt.Errorf("cannot include a directory: %v", entry)
76
-
}
77
-
iffi.Mode()&0037>0 {
78
-
returnfmt.Errorf("permissions %04o for '%v' are too open; requires the file is NOT writable by the same group and NOT accessible by others; suggest 0640 or 0600", fi.Mode()&0777, entry)
0 commit comments