-
Notifications
You must be signed in to change notification settings - Fork 1
Propagate MDM setup failures via exit code across all tools #187
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1252,7 +1252,7 @@ def main(): | |
|
|
||
| if clear_mode: | ||
| clear_setup() | ||
| return | ||
| return True | ||
|
Comment on lines
1254
to
+1255
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When |
||
|
|
||
| print("=" * 60) | ||
| print("Augment Code Hooks - MDM Setup") | ||
|
|
@@ -1266,7 +1266,7 @@ def main(): | |
| ) | ||
| print("This script requires administrator/root privileges") | ||
| print(" Please re-run with sudo.") | ||
| return | ||
| return False | ||
|
|
||
| base_url = "https://backend.getunbound.ai" | ||
| gateway_url = DEFAULT_GATEWAY_URL | ||
|
|
@@ -1301,27 +1301,27 @@ def main(): | |
| print("\nMissing required argument: --api-key") | ||
| print("Usage: sudo python3 setup.py --api-key <api_key> [--backend-url <url>] [--app_name <app_name>] [--debug]") | ||
| print(" Or: sudo python3 setup.py --clear [--debug]") | ||
| return | ||
| return False | ||
|
|
||
| print("\nGetting device identifier...") | ||
| device_id = get_device_identifier() | ||
| if not device_id: | ||
| print("Failed to get device identifier") | ||
| return | ||
| return False | ||
| debug_print(f"Device identifier: {device_id}") | ||
| print("Device identifier retrieved") | ||
|
|
||
| print("\nFetching API key from MDM...") | ||
| api_key = fetch_api_key_from_mdm(base_url, app_name, auth_api_key, device_id) | ||
| if not api_key: | ||
| return | ||
| return False | ||
| print("API key received") | ||
|
|
||
| print("\nSetting environment variables system-wide...") | ||
| success, _ = set_env_var_system_wide("UNBOUND_AUGMENT_API_KEY", api_key) | ||
| if not success: | ||
| print("Failed to set UNBOUND_AUGMENT_API_KEY") | ||
| return | ||
| return False | ||
| debug_print("UNBOUND_AUGMENT_API_KEY set successfully") | ||
|
|
||
| # Write the per-user unbound config now (needed by the managed hook; harmless | ||
|
|
@@ -1336,7 +1336,7 @@ def main(): | |
| print("\nConfiguring Augment managed hooks...") | ||
| if not setup_managed_hooks(gateway_url=gateway_url): | ||
| print("Failed to configure managed hooks") | ||
| return | ||
| return False | ||
| managed_dir = get_managed_settings_dir() | ||
| print(f"Created managed hooks in {managed_dir}") | ||
|
|
||
|
|
@@ -1357,12 +1357,16 @@ def main(): | |
|
|
||
| notify_setup_complete(api_key, "augment_code", backend_url=base_url, install_state=state, serial_number=device_id) | ||
|
|
||
| return True | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| try: | ||
| main() | ||
| ok = main() | ||
| except KeyboardInterrupt: | ||
| print("\n\nSetup cancelled.") | ||
| sys.exit(1) | ||
| except Exception as e: | ||
| print(f"\nError: {e}") | ||
| exit(1) | ||
| sys.exit(1) | ||
| sys.exit(0 if ok else 1) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clear mode false success
High Severity
In
--clearmode,main()always returnsTrueright afterclear_setup(), even whenclear_setup()exits early (for example missing root/admin) without performing cleanup. The new__main__block then exits 0, somdm/onboard.pytreats a failed uninstall as success.Additional Locations (2)
claude-code/gateway/mdm/setup.py#L905-L908cursor/mdm/setup.py#L1044-L1047Reviewed by Cursor Bugbot for commit 98cb63a. Configure here.