Skip to content

Commit

Permalink
Limit Cabbie reboot action to Windows updates.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 623640336
  • Loading branch information
jm2 authored and copybara-github committed Apr 10, 2024
1 parent b78ed00 commit 9c7de11
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion cablib/cablib_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,27 @@ func RebootRequired() (bool, error) {
}
defer r.Clear()

return r.Value().(bool), nil
registryReboot := false
k, err := registry.OpenKey(registry.LOCAL_MACHINE, `SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update`, registry.QUERY_VALUE|registry.ENUMERATE_SUB_KEYS)
if err != nil {
return false, err
}
defer k.Close()

names, err := k.ReadSubKeyNames(-1)
if err != nil {
return false, err
}

if StringInSlice(`RebootRequired`, names) {
registryReboot = true
}

if r.Value().(bool) && registryReboot {
return true, nil
}

return false, nil
}

// GetUpdateTitles loops through an update collection and returns a list of titles.
Expand Down

0 comments on commit 9c7de11

Please sign in to comment.