Skip to content

🐛 device/windows: restore disk read-only state, not online state#8664

Open
tas50 wants to merge 1 commit into
mainfrom
claude/fix-device-readonly-restore
Open

🐛 device/windows: restore disk read-only state, not online state#8664
tas50 wants to merge 1 commit into
mainfrom
claude/fix-device-readonly-restore

Conversation

@tas50

@tas50 tas50 commented Jun 23, 2026

Copy link
Copy Markdown
Member

Bug

connection/device/windows/device_manager.go:

if diskStatus.Readonly {
    err = d.setDiskReadonlyState(targetDrive.Index, false)
    if err != nil {
        return nil, err
    }
    d.diskSetToOnline = true   // BUG: should be d.diskSetToReadonly = true
    d.diskIndex = targetDrive.Index
}

The read-only branch records its action in diskSetToOnline instead of diskSetToReadonly. diskSetToReadonly is therefore never set to true anywhere, so UnmountAndClose never restores the disk's read-only protection — the disk is left writable after the scan. Worse, the spurious diskSetToOnline = true makes cleanup flip the online/offline state that was never changed.

Fix

Record the read-only change in diskSetToReadonly so cleanup re-applies it. (Windows-only code path; verified by build — no mock harness exists for the disk-management PowerShell calls.)

🤖 Generated with Claude Code

https://claude.ai/code/session_015U1ocAxfcBhVYi3f9JnyZZ


Generated by Claude Code

@github-actions

github-actions Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@mondoo-code-review mondoo-code-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Fixes incorrect flag tracking so disk read-only state is properly restored on cleanup.

@tas50 tas50 force-pushed the claude/fix-device-readonly-restore branch from 1ece206 to b5c988f Compare June 23, 2026 17:50
@github-actions

github-actions Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Test Results

11 153 tests  ±0   11 146 ✅ ±0   3m 24s ⏱️ - 1m 56s
   545 suites ±0        7 💤 ±0 
    40 files   ±0        0 ❌ ±0 

Results for commit 2d62edf. ± Comparison against base commit a92a575.

♻️ This comment has been updated with latest results.

@tas50 tas50 force-pushed the claude/fix-device-readonly-restore branch 3 times, most recently from c1c8f89 to d343c28 Compare June 24, 2026 18:02
When a target disk was read-only, the manager cleared the read-only
flag for scanning but recorded the action in diskSetToOnline instead of
diskSetToReadonly. diskSetToReadonly was therefore never set, so
UnmountAndClose never re-applied the disk's read-only protection — the
disk was left writable after the scan — and the spurious diskSetToOnline
caused cleanup to also flip the online/offline state that was never
changed.

Record the read-only change in diskSetToReadonly.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015U1ocAxfcBhVYi3f9JnyZZ
@tas50 tas50 force-pushed the claude/fix-device-readonly-restore branch from d343c28 to 2d62edf Compare June 29, 2026 17:23
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.

1 participant