Skip to content

Commit 69e0d38

Browse files
committed
Drop global scripts enabled gate from software uninstalls, script-based lock/unlock/wipe
TODO: * Fix tests * Write scripts to DB as eligible for skipping script disabled, read from DB when scripts disabled
1 parent 2576fe3 commit 69e0d38

File tree

4 files changed

+3
-51
lines changed

4 files changed

+3
-51
lines changed

cmd/fleetctl/mdm.go

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -265,16 +265,6 @@ func mdmWipeCommand() *cli.Command {
265265
return err
266266
}
267267

268-
config, err := client.GetAppConfig()
269-
if err != nil {
270-
return err
271-
}
272-
273-
// linux hosts need scripts to be enabled in the org settings to wipe.
274-
if host.Platform == "linux" && config.ServerSettings.ScriptsDisabled {
275-
return errors.New("Can't wipe host because running scripts is disabled in organization settings.")
276-
}
277-
278268
if err := client.MDMWipeHost(host.ID); err != nil {
279269
return fmt.Errorf("Failed to wipe host: %w", err)
280270
}

ee/server/service/hosts.go

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -91,18 +91,6 @@ func (svc *Service) LockHost(ctx context.Context, hostID uint, viewPIN bool) (un
9191
return "", ctxerr.Wrap(ctx, err, "check windows MDM enabled")
9292
}
9393
}
94-
// on windows and linux, a script is used to lock the host so scripts must
95-
// be enabled
96-
appCfg, err := svc.ds.AppConfig(ctx)
97-
if err != nil {
98-
return "", ctxerr.Wrap(ctx, err, "get app config")
99-
}
100-
if appCfg.ServerSettings.ScriptsDisabled {
101-
return "", ctxerr.Wrap(
102-
ctx,
103-
fleet.NewInvalidArgumentError("host_id", "Can't lock host because running scripts is disabled in organization settings."),
104-
)
105-
}
10694
hostOrbitInfo, err := svc.ds.GetHostOrbitInfo(ctx, host.ID)
10795
switch {
10896
case err != nil:
@@ -182,7 +170,7 @@ func (svc *Service) UnlockHost(ctx context.Context, hostID uint) (string, error)
182170

183171
case "windows", "linux":
184172
// on windows and linux, a script is used to lock the host so scripts must
185-
// be enabled
173+
// be enabled on the host
186174
if host.FleetPlatform() == "windows" {
187175
if err := svc.VerifyMDMWindowsConfigured(ctx); err != nil {
188176
if errors.Is(err, fleet.ErrMDMNotConfigured) {
@@ -191,13 +179,6 @@ func (svc *Service) UnlockHost(ctx context.Context, hostID uint) (string, error)
191179
return "", ctxerr.Wrap(ctx, err, "check windows MDM enabled")
192180
}
193181
}
194-
appCfg, err := svc.ds.AppConfig(ctx)
195-
if err != nil {
196-
return "", ctxerr.Wrap(ctx, err, "get app config")
197-
}
198-
if appCfg.ServerSettings.ScriptsDisabled {
199-
return "", ctxerr.Wrap(ctx, fleet.NewInvalidArgumentError("host_id", "Can't unlock host because running scripts is disabled in organization settings."))
200-
}
201182
hostOrbitInfo, err := svc.ds.GetHostOrbitInfo(ctx, host.ID)
202183
switch {
203184
case err != nil:
@@ -286,14 +267,7 @@ func (svc *Service) WipeHost(ctx context.Context, hostID uint) error {
286267
requireMDM = true
287268

288269
case "linux":
289-
// on linux, a script is used to wipe the host so scripts must be enabled
290-
appCfg, err := svc.ds.AppConfig(ctx)
291-
if err != nil {
292-
return ctxerr.Wrap(ctx, err, "get app config")
293-
}
294-
if appCfg.ServerSettings.ScriptsDisabled {
295-
return ctxerr.Wrap(ctx, fleet.NewInvalidArgumentError("host_id", "Can't wipe host because running scripts is disabled in organization settings."))
296-
}
270+
// on linux, a script is used to wipe the host so scripts must be enabled on the host
297271
hostOrbitInfo, err := svc.ds.GetHostOrbitInfo(ctx, host.ID)
298272
switch {
299273
case err != nil:

ee/server/service/software_installers.go

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -836,18 +836,6 @@ func (svc *Service) installSoftwareTitleUsingInstaller(ctx context.Context, host
836836
}
837837

838838
func (svc *Service) UninstallSoftwareTitle(ctx context.Context, hostID uint, softwareTitleID uint) error {
839-
// First check if scripts are disabled globally. If so, no need for further processing.
840-
cfg, err := svc.ds.AppConfig(ctx)
841-
if err != nil {
842-
svc.authz.SkipAuthorization(ctx)
843-
return err
844-
}
845-
846-
if cfg.ServerSettings.ScriptsDisabled {
847-
svc.authz.SkipAuthorization(ctx)
848-
return fleet.NewUserMessageError(errors.New(fleet.RunScriptScriptsDisabledGloballyErrMsg), http.StatusForbidden)
849-
}
850-
851839
// we need to use ds.Host because ds.HostLite doesn't return the orbit node key
852840
host, err := svc.ds.Host(ctx, hostID)
853841
if err != nil {

server/service/orbit.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ func (svc *Service) GetOrbitConfig(ctx context.Context) (fleet.OrbitConfig, erro
295295
}
296296

297297
// load the pending script executions for that host
298-
if !appConfig.ServerSettings.ScriptsDisabled {
298+
if !appConfig.ServerSettings.ScriptsDisabled { // TODO filter to only "special" scripts rather than skipping entirely when scripts disabled
299299
pending, err := svc.ds.ListPendingHostScriptExecutions(ctx, host.ID)
300300
if err != nil {
301301
return fleet.OrbitConfig{}, err

0 commit comments

Comments
 (0)