Add support for custom temporary directories in image creation scripts #26
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
gh-drakmor/ShadowMountPlus!26
Loading…
Reference in a new issue
No description provided.
Delete branch "ali-ghanati/main"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
note: because of my poor english, I've wrote description using ai, and did some refactor in code using ai, I just wanted to help and improve this awesome project from my own point of view, thank you everyone who helped this project
Summary
Adds an optional temp/work directory flag across all exFAT image creation paths so large builds can use a fast or spacious disk (e.g.
/mnt/hdd,D:\temp) instead of default system temp or fixed mount paths.mkexfat.sh):-t/--tmp-dir/--temp-dirmay appear anywhere in the command line. Creates a unique mount dir under the chosen base (mkexfat.XXXXXX). Mount prefers directexfat-fusefile access and falls back to-o loopwhen needed (fixes loop setup failures on some removable exFAT targets).mkexfat_macos.sh): Same flag parsing; when omitted, behavior is unchanged (mktempdefaults). When set, sizing scratch file and mount staging dir are created under the given path.New-OsfExfatImage.ps1,make_image.bat):-TempDir/-t(PowerShell) and-t/--tmp-dir/--temp-dir(batch). Sets%TEMP%/%TMP%for format redirect files and related scratch work.Motivation
Large game/app images (~80GB+) can fail or run slowly when temp/mount work uses root-owned paths, small system partitions, or loop mounts on USB exFAT volumes. Letting users point temp work at another drive avoids those issues without changing default behavior for existing scripts.
Behavior
-t/--tmp-dir/tmp/mkexfat.*<dir>/mkexfat.*mktemp<dir>/mkexfat.*and<dir>/mkexfat_sizes.*%TEMP%Output image path is always the positional/output argument you pass; only intermediate work moves to the temp directory.
Linux —
mkexfat.shRequires:
exfatprogs,exfat-fuse,fuse3,rsync(often run with
sudofor mount operations)ℹ️ Recent review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID:
92284f79-afba-42c4-8713-d31e05e94403📥 Commits
Reviewing files that changed from the base of the PR and between
9d6505d5d3andb45396c134.📒 Files selected for processing (4)
New-OsfExfatImage.ps1make_image.batmkexfat.shmkexfat_macos.sh📝 Walkthrough
Walkthrough
Adds an optional temp-directory option across PowerShell, Batch, Linux, and macOS scripts to control where temporary files and mount points are created during exFAT image building; includes CLI parsing, validation, dynamic mounts, and a PowerShell temp-file helper.
Changes
Temporary Directory Control Across Platforms
New-OsfExfatImage.ps1-TempDirparameter (alias-t) with documentation, implementsInitialize-ScriptTempDirto validate and configure environment variables, andNew-ScriptTempFileto create temp files within the specified directory.New-OsfExfatImage.ps1Invoke-FormatVolumeuses the new temp-file helper for format.com stdout/stderr redirection instead of direct system temp names, and the main script flow initializes the temp directory before image creation.make_image.bat-t,--tmp-dir, and--temp-dirflags; validation confirms directory existence and passes it to PowerShell conditionally; usage documentation includes new examples.mkexfat.sh-t/--tmp-dir/--temp-diralongside-h/--helpand--positional separation; newcleanup()trap handler unmounts and removes dynamically created mount directories; mounting attempts unwrapped exfat-fuse before falling back to loop device and usesrsyncinto the dynamic mount.mkexfat_macos.sh-t/--tmp-dir/--temp-dirwith--separation and expands validation; intermediate sizes file and mount-point directory are conditionally placed under the user-specified temp base when provided.Estimated code review effort
🎯 3 (Moderate) | ⏱️ ~25 minutes
🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings.
✨ Finishing Touches
🧪 Generate unit tests (beta)
Comment
@coderabbitai helpto get the list of available commands and usage tips.Actionable comments posted: 4
🤖 Prompt for all review comments with AI agents
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID:
c0061dd0-8ac7-44cf-9c95-cd3cc12002a5📥 Commits
Reviewing files that changed from the base of the PR and between
8622d8757fand9d6505d5d3.📒 Files selected for processing (4)
New-OsfExfatImage.ps1make_image.batmkexfat.shmkexfat_macos.sh⚠️ Potential issue | 🟡 Minor | ⚡ Quick win
Fail fast when
-TempDiris not writable.The current check only verifies directory existence. If the directory exists but isn’t writable, the script fails later during formatting/log redirection with a less actionable error.
💡 Proposed fix
📝 Committable suggestion
🤖 Prompt for AI Agents
✅ Addressed in commit
b45396c@ -29,10 +61,21 @@ if not exist "%SRCDIR%\eboot.bin" (exit /b 4⚠️ Potential issue | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🌐 Web query:
Is usingpowershell.exe -ExecutionPolicy Bypassrecommended for automation scripts, and what safer alternatives does Microsoft recommend?💡 Result:
Using powershell.exe -ExecutionPolicy Bypass is generally not recommended as a standard practice for automation scripts because it explicitly instructs PowerShell to ignore all security policies, including signature verification [1][2]. While it is a common method to resolve script execution errors, it should be used with caution and only when you fully trust the script being executed [1][2]. It is important to understand that PowerShell execution policies are not a security boundary; they are safety features designed to prevent accidental execution of scripts [3][2]. They do not prevent a determined user or attacker from running malicious code, as there are many ways to circumvent these policies [3][4]. Microsoft and security professionals recommend the following safer alternatives for automation: 1. Use RemoteSigned: This is the recommended policy for most environments [5]. It allows scripts created on the local machine to run without restriction, while requiring that scripts downloaded from the internet (or other remote locations) be digitally signed by a trusted publisher [3][5]. 2. Digitally Sign Your Scripts: For production, enterprise, or CI/CD environments, the most secure approach is to sign your automation scripts with a code-signing certificate [5]. This allows you to enforce a stricter policy, such as AllSigned, ensuring that only verified, trusted code can execute [5]. 3. Use the Process Scope: If you must bypass the policy for a specific, trusted automation task, you can set the execution policy for the current process only, rather than globally [6][7]. This limits the exposure to the duration of that specific script execution [8][7]. You can do this by using: powershell.exe -ExecutionPolicy RemoteSigned -Scope Process -File script.ps1 4. Implement Defense-in-Depth: Because execution policies are not a security boundary, rely on broader security controls such as AppLocker, Windows Defender Application Control (WDAC), and monitoring tools (e.g., AMSI, logging) to detect and block malicious activity, rather than relying on the execution policy alone [9][10]. In summary, while -ExecutionPolicy Bypass is a functional way to run scripts, it removes a layer of safety. Prioritize signing your scripts and using the RemoteSigned policy to maintain a balance between security and operational requirements [5][2].
Citations:
🏁 Script executed:
Repository: drakmor/ShadowMountPlus
Length of output: 82
🏁 Script executed:
Repository: drakmor/ShadowMountPlus
Length of output: 3173
🏁 Script executed:
Repository: drakmor/ShadowMountPlus
Length of output: 378
🏁 Script executed:
Repository: drakmor/ShadowMountPlus
Length of output: 89
🏁 Script executed:
Repository: drakmor/ShadowMountPlus
Length of output: 294
🏁 Script executed:
Repository: drakmor/ShadowMountPlus
Length of output: 77
🏁 Script executed:
Repository: drakmor/ShadowMountPlus
Length of output: 1154
Use script signing and
RemoteSignedpolicy instead of hardcoding-ExecutionPolicy Bypass.Microsoft guidance confirms that
-ExecutionPolicy Bypassshould not be standard practice. However, simply removing it would break the documented usage pattern. The recommended approach is to digitally signNew-OsfExfatImage.ps1with a code-signing certificate and use-ExecutionPolicy RemoteSignedinstead, which maintains security while allowing locally-created scripts to run. If signing is not feasible, document the security implications of the Bypass decision.🧰 Tools
🪛 Blinter (1.0.112)
[error] 75-75: PowerShell execution policy bypass. Explanation: Bypassing PowerShell execution policy can allow malicious scripts to run. Recommendation: Avoid using -ExecutionPolicy Bypass unless absolutely necessary. Context: PowerShell execution policy bypass detected
(SEC009)
🤖 Prompt for AI Agents
✅ Addressed in commit
b45396c@ -95,0 +165,4 @@}trap cleanup EXIT INT TERM⚠️ Potential issue | 🟡 Minor | ⚡ Quick win
Validate temp-directory permissions, not just existence.
A directory can exist but still be unusable for
mktemp(missing write/execute perms), which leads to a later opaque failure.💡 Proposed fix
📝 Committable suggestion
🤖 Prompt for AI Agents
✅ Addressed in commit
b45396c⚠️ Potential issue | 🟡 Minor | ⚡ Quick win
Add explicit output-directory validation before path normalization.
With
set -e, a missing parent directory causes an abruptcdfailure. Emit a clear error before converting to absolute path.💡 Proposed fix
📝 Committable suggestion
🤖 Prompt for AI Agents
✅ Addressed in commit
b45396cView command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.