Set-DbaPrivilege - Write secedit's working database to temp, not cwd - #58
Set-DbaPrivilege - Write secedit's working database to temp, not cwd#58potatoqualitee wants to merge 1 commit into
Conversation
secedit /configure /db resolves a bare filename against the process's current directory, not $env:TEMP. The relative "secedit.sdb" argument left secedit.sdb and its secedit.jfm journal file behind wherever the caller happened to be running the command. Point /db at an absolute $temp path instead, and clean up the database and journal file alongside the exported cfg. (do Set-DbaPrivilege) Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
ReviewSolid, well-scoped fix — the root cause analysis ( Correctness
Missing version bumpCLAUDE.md is explicit: "Bump the version whenever you change runtime behavior — package upgrades, connection/auth logic, cmdlet behavior, anything beyond docs or tests — in the same PR." This is a cmdlet behavior fix ( Test coverageThe PR is upfront that there's no MSTest coverage for Minor / no action needed
Nice, tightly-scoped fix. Main blocker before merge is the version bump per repo convention. |
Summary
Companion fix to dataplat/dbatools's PR for the same bug report:
Set-DbaPrivilegeleavessecedit.sdb/secedit.jfmbehind in the current working directory.SetDbaPrivilegeCommand.cs'sMainScriptconstant callssecedit /configure /cfg $tempfile /db secedit.sdb /areas USER_RIGHTS /overwrite /quiet- the same relative/dbargument as the PowerShell source it was ported from.secedit.exeresolves a bare filename for/dbagainst the process's current directory, not$env:TEMP, so the working database and its.jfmjournal file leak into whatever directory the caller's shell was running in.MainScript: point/dbat$temp\secedit.sdb($tempis already set earlier in the same scriptblock).CleanupScript: remove$temp\secedit.sdband$temp\secedit.jfmalongside the existingsecpolByDbatools.cfgcleanup.The retired PowerShell source (
dbatools/private/retired/Set-DbaPrivilege.ps1) still carries the original bug, but it's dead code on thelibmigrationbranch, not shipping - not touched here.Verification
dotnet build dbatools.sln -c Debugcompilesdbatools.computercleanly with this change (verified both with and without the patch to confirm a pre-existing, unrelatedXmlDoc2CmdletDocpost-build failure in a fresh worktree - missing SMO assembly resolution on net8.0, across many unrelated projects - is not caused by this change; the actualdbatools.computer.dlloutput for both net472 and net8.0 built successfully).SetDbaPrivilegeCommandcurrently, so none was added here; the behavioral regression test lives in the PowerShell repo'stests/Set-DbaPrivilege.Tests.ps1.secedit.exerequires Administrator rights for a localhost target and my shell isn't elevated.Test plan
dotnet build dbatools.sln -c Debugsucceeds fordbatools.computer(both target frameworks)secedit.sdb/secedit.jfmleak into cwd🤖 Generated with Claude Code