Repository navigation
Install the workspace policy at ug configure - #1259
billiam-wang wants to merge 6 commits into
Conversation
Explicit ug configure now installs the workspace policy at /etc/unitygateway/managed-settings.json on Linux and macOS, using a non-interactive-sudo-capable writer. Unchanged policy writes nothing, and no-config or feature-disabled removes the installed file. A failed install raises ManagedPolicyInstallDenied with an actionable message. Launches keep reading the per-user cache and never touch the machine file. Co-authored-by: Isaac <no-reply@databricks.com>
|
/ug-review |
| An explicit ``ug configure`` also installs the workspace policy machine-wide at | ||
| ``/etc/unitygateway/managed-settings.json`` (Linux and macOS) through | ||
| :func:`ucode.managed_files.update_workspace_policy`. Launches never write that file; they read and | ||
| refresh only the per-user cache above. |
There was a problem hiding this comment.
This is intentional. The followup consumes the new file: #1260
| if not config: | ||
| update_workspace_policy(MACHINE_POLICY_PATH, None, interactive=True, allow_sudo=True) | ||
| return |
There was a problem hiding this comment.
We assume single user for ug today, so shared machine issues are not a concern. Since we are explicitly modifying the global files, it is expected that all users use the same workspace.
| "This machine-wide file needs sudo. Rerun `ug configure` from a terminal where you " | ||
| "can use sudo, or ask your IT team or an administrator to run it." | ||
| ) | ||
| raise ManagedPolicyInstallDenied(message) from exc |
There was a problem hiding this comment.
will this break current ug users? on linux/macos every ug configure with a published config now needs sudo, and none of the callers (cli.py:830, 1049) catch this. CI, sudo -n runs, and users without sudo now abort halfway through configure, after the per-user cache is already saved and before any agent setup runs. can we downgrade this to print_warning and keep going?
There was a problem hiding this comment.
Published config already needed sudo since it writes to the global file. This is not a new requirement.
|
|
||
| @pytest.mark.managed_fixture | ||
| @pytest.mark.claude | ||
| def test_ug_configure_installs_workspace_policy_machine_wide(live_session, workspace): |
There was a problem hiding this comment.
Windows is planned as a follow up to prevent scope creep.
`ug revert` deletes /etc/unitygateway/managed-settings.json with sudo; nothing else writes that file. Without sudo it warns and keeps it, and Windows, UG_SKIP_OS_SETTINGS and `--user` leave it alone. Test cleanup keeps a backstop removal in its own finally, so a failed or skipped revert can no longer leave the policy behind for later cases. Co-authored-by: Isaac <no-reply@databricks.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
|
/ug-review |
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Removal hands the replace script the exact bytes of the installed file, so a file with a BOM or CRLF endings still matches its byte-for-byte check. Add a regression test and a comment on why the copy is binary. Co-authored-by: Isaac <no-reply@databricks.com>
Polly AI ReviewBlocking issues
Security vulnerabilitiesNo newly introduced security vulnerability was confirmed. The documented world-readable policy format is intentional; administrators must not place credentials in it. Non-blocking notes
ApproachThe existing managed writer and shell worker are appropriate boundaries. SummaryDiff size (computed): 19 files; +935 / -36 lines (971 changed text lines); 0 binary files.
Shares use additions + deletions, including generated text and lockfiles. Binary files have no line count. Tests include fixtures/helpers under test paths and colocated test/spec files; categories are path-based, not coverage measurements. ChangesThe PR installs a machine-wide workspace-policy envelope during configure, removes it when no policy is published, and adds revert handling. Launches continue using the per-user cache. Supporting changes cover privileged writes, platform and opt-out gates, test isolation, cleanup, and documentation. No dependency or generated-file changes contribute to the diff. Most of the breadth follows from introducing a privileged filesystem boundary. A concrete implementation reduction is sharing the temporary-source, sudo invocation, and error-normalization machinery between TestsTest-by-test assessmentThe frozen diff’s checksum and both trusted review policies were verified. Static parsing confirmed the import failure; the reconstructed file also matches the diff’s post-image blob hash. No tests, lint, or type checks were executed, so the description’s green-gate claims are not independently confirmed. Existing TTL, config-scope, and shell replacement/rollback tests provide relevant coverage. No existing test function was directly removed or weakened; fixture changes alter their execution. The supplied checkout has no
After fixing the import failure, run: uv run pytest tests/test_managed_config.py tests/test_managed_files.py tests/test_integration_runner.py
just lintOn a disposable POSIX host, verify configure creates the documented owner/modes, repeated configure leaves unchanged policy untouched, and denied sudo produces recovery guidance. Also verify installation-only checks preserve a policy that existed before the test run. ScopeNo clearly unrelated changes were found. The implementation, revert behavior, documentation, preflight checks, and cleanup all support the workspace-policy lifecycle. The installation-only teardown defect is an unsafe implementation of that supporting cleanup, not a separate requested outcome. Automated review by Polly · workflow run |
🥞 Stacked PR
Use this link to review incremental changes.
Worktree: unity-gateway | Branch: mdm-policy-write
What did you change, and why?
First of two stacked PRs that replace #1228, porting #1105's machine workspace policy. This one only writes it: on Linux and macOS,
ug configurefor Claude or Codex installs the workspace's managed config as root-owned/etc/unitygateway/managed-settings.json({workspace, config},0644in a root0755folder) using sudo. It rewrites the file only on change and removes it when the workspace publishes none. If sudo is denied, configure fails with steps to fix it.Launches don't change: they still read the per-user cache. Windows,
UG_SKIP_OS_SETTINGSand--userwrite nothing. #1260 makes launches read the file.How do you know it works?
New unit tests cover the writer and the install, replace and remove paths. One integration test checks that configure installs a root-owned file. Lint and ty are clean.
This pull request and its description were written by Isaac.