Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix USB config sync #890

Merged

Conversation

np5
Copy link
Contributor

@np5 np5 commented Sep 21, 2022

  • get BlockUSBMount and RemountUSBMode from the configState and from the syncState.
  • disable BlockUSBMount if set to false in the preflight response.
  • only set BlockUSBMount in syncState if present in the preflight response.
  • Fix keyPathsForValuesAffecting* for RemountUSBMode, RemountUSBBlockMessage and USBBlockMessage.
  • Add BlockUSBMount and RemountUSBMode to the docs.
  • Fix block_usb_mount docs.

@russellhancox russellhancox self-assigned this Sep 21, 2022
Copy link
Contributor

@russellhancox russellhancox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes under santasyncservice/ should be reverted - the mode is retrieved during preflight but it shouldn't be applied until postflight time as the majority of the other keys do. The changes in SNTConfigurator should be enough to fix the bug, I think

@np5
Copy link
Contributor Author

np5 commented Sep 21, 2022

I think this change is necessary if we want to be able to unblock the USB device mounts and if we want to not update the SNTConfigurator syncState if the server is not sending the key.

@liamn
Copy link
Contributor

liamn commented Oct 14, 2022

Hey folks 👋

We're looking at rolling this out internally and appear to have hit the same issue - is there an update on this, or a workaround? The Santa documentation seems to suggest that it'll work with a sync server. Happy to help get this over the line if you need!

@pmarkowsky
Copy link
Contributor

@liamn the main issue with this PR is that the settings are being changed in the Preflight stage rather than at the end in the Postflight stage. This breaks how the sync protocol is supposed to work.

As @russellhancox calls out reverting the changes in the syncservice should enough to fix this. If the PR can be changed to do that I think it'll good to merge.

@arubdesu
Copy link
Contributor

If @np5 doesn't chime in soon I'll remind him that this is pending his response.

@np5
Copy link
Contributor Author

np5 commented Oct 15, 2022

Sorry for the delay. I made the change in the preflight because it was easier for me to manage the true/false/missing values in the server response. I think that "missing" or "absent" is important, because if a sync server is not yet implementing this, you do not want to overwrite the value set in the config profile. I am not really proficient with objective C, but maybe by setting the value as a pointer to a boolean NSNumber in the preflight, it would be possible to maintain the "absent" state separate from "false" and only apply the change in the postflight if the value was sent by the server?

- get `BlockUSBMount` and `RemountUSBMode` from the `configState` and
  from the `syncState`.
- disable `BlockUSBMount` if set to `false` in the preflight response.
- only set `BlockUSBMount` in `syncState` if present in the preflight
  response.
- Fix `keyPathsForValuesAffecting*` for `RemountUSBMode`,
  `RemountUSBBlockMessage` and `USBBlockMessage`.
- `BlockUSBMount` and `RemountUSBMode` added to the docs.
- Fix `block_usb_mount` docs.
@np5 np5 force-pushed the 20220921_fix_usb_config_sync branch from 8c2191d to f672833 Compare October 17, 2022 10:26
@np5 np5 requested a review from russellhancox October 17, 2022 16:05
@russellhancox russellhancox merged commit 4fe8b79 into google:main Oct 18, 2022
@russellhancox
Copy link
Contributor

I am not really proficient with objective C, but maybe by setting the value as a pointer to a boolean NSNumber in the preflight, it would be possible to maintain the "absent" state separate from "false" and only apply the change in the postflight if the value was sent by the server?

Yes, this will work and what you have now meets our general constraint of receiving new configuration during preflight but applying it during postflight so that syncing acts like a kind of transaction.

Thanks!

@np5 np5 deleted the 20220921_fix_usb_config_sync branch October 18, 2022 14:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants