@@ -124,7 +124,7 @@ func secureCreateDirectory(path string, sddl string) error {
124
124
// We choose option (b) because it allows us to modify the permissions in the future.
125
125
// We check the owner to ensure it is Administrators or SYSTEM before changing the permissions,
126
126
// as the owner cannot be set to Administrators by a non-privileged user.
127
- err = isDirSecure (path )
127
+ err = IsDirSecure (path )
128
128
if err != nil {
129
129
// The directory owner is not Administrators or SYSTEM, so may have been created
130
130
// by an unknown party. Adjusting the permissions may not be safe, as it won't affect
@@ -152,10 +152,12 @@ func secureCreateDirectory(path string, sddl string) error {
152
152
func IsInstallerDataDirSecure () error {
153
153
targetDir := DatadogInstallerData
154
154
log .Infof ("Checking if installer data directory is secure: %s" , targetDir )
155
- return isDirSecure (targetDir )
155
+ return IsDirSecure (targetDir )
156
156
}
157
157
158
- func isDirSecure (targetDir string ) error {
158
+ // IsDirSecure returns nil if the directory is owned by Administrators or SYSTEM,
159
+ // otherwise an error is returned.
160
+ func IsDirSecure (targetDir string ) error {
159
161
allowedWellKnownSids := []windows.WELL_KNOWN_SID_TYPE {
160
162
windows .WinBuiltinAdministratorsSid ,
161
163
windows .WinLocalSystemSid ,
0 commit comments