Skip to content

mktemp: strip permission denied system error code - #13849

Open
Devel08 wants to merge 1 commit into
uutils:mainfrom
Devel08:fix-issue-13720
Open

Devel08 wants to merge 1 commit into
uutils:mainfrom
Devel08:fix-issue-13720

Conversation

@Devel08

@Devel08 Devel08 commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

closes #13720, pr #13815 seems to be abondoned

@github-actions

github-actions Bot commented Aug 10, 2026 •

Copy link
Copy Markdown

GNU testsuite comparison:

Skip an intermittent issue tests/date/resolution (fails in this run but passes in the 'main' branch)
Skip an intermittent issue tests/tail/retry (fails in this run but passes in the 'main' branch)
Skipping an intermittent issue tests/cut/bounded-memory (passes in this run but fails in the 'main' branch)
Skipping an intermittent issue tests/pr/bounded-memory (passes in this run but fails in the 'main' branch)
Note: The gnu test tests/basenc/bounded-memory is now being skipped but was previously passing.
Note: The gnu test tests/cp/link-heap is now being skipped but was previously passing.

@Devel08
Devel08 marked this pull request as draft August 10, 2026 18:56
@Devel08

Devel08 commented Aug 10, 2026

Copy link
Copy Markdown
Contributor Author

well, -p / wouldn't work on some runners as its read-only fs

@Devel08

Devel08 commented Aug 10, 2026

Copy link
Copy Markdown
Contributor Author

read-only fs error would contain an os error too, we can just check if it doesnt

@codspeed

codspeed Bot commented Aug 10, 2026

Copy link
Copy Markdown

Merging this PR will degrade performance by 3.17%

❌ 1 regressed benchmark
✅ 284 untouched benchmarks
⏩ 108 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
❌ Simulation numfmt_to_si_precision[10000] 92.5 ms 95.5 ms -3.17%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing Devel08:fix-issue-13720 (32d48f7) with main (acf5747)2

Open in CodSpeed

Footnotes

  1. 108 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

  2. No successful run was found on main (8ba86de) during the generation of this report, so acf5747 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

@Devel08
Devel08 marked this pull request as ready for review August 10, 2026 20:42
Comment thread src/uu/mktemp/locales/en-US.ftl Outdated
mktemp-error-too-many-templates = too many templates
mktemp-error-not-found = failed to create { $template_type } via template { $template }: No such file or directory
mktemp-error-failed-print = failed to print directory name
mktemp-error-failed-to-create-file-via-template = failed to create file via template '{ $path }': { $error }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

please use .quote() on the path instead of hardcoded quotes

Err(MkTempError::NotFound(translate!("mktemp-template-type-file"), path).into())
}
Err(e) => Err(e.into()),
Err(e) => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

what about make_temp_dir? mktemp -d -p /ro will still show the os error

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I'll even add this to the test

}
Err(e) => Err(e.into()),
Err(e) => {
let filename = format!("{prefix}{}{suffix}", "X".repeat(rand));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

same two lines as the NotFound arm just above, could be dedup, no?

Comment thread src/uu/mktemp/src/mktemp.rs Outdated
Err(e) => {
let filename = format!("{prefix}{}{suffix}", "X".repeat(rand));
let path = Path::new(dir).join(filename);
Err(uucore::error::USimpleError::new(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

please add a variant to MkTempError instead of a USimpleError, like NotFound

Comment thread tests/by-util/test_mktemp.rs Outdated
fn test_permission_denied_no_os_error() {
let scene = TestScenario::new(util_name!());

let result = scene.ucmd().arg("-p").arg("/").run();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

as root this passes the permission check and creates a file in /
please create a dir with no write permission in the fixture instead

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

True, my bad

Comment thread tests/by-util/test_mktemp.rs Outdated

assert!(!result.succeeded());

assert!(!result.stderr_str().contains("os error"));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

please check the full message with stderr_is / stderr_contains("Permission denied")

@Devel08
Devel08 force-pushed the fix-issue-13720 branch 2 times, most recently from fc5b6a4 to 44e4cf4 Compare October 12, 2026 12:31
@Devel08
Devel08 marked this pull request as draft October 12, 2026 12:52
@Devel08

Devel08 commented Oct 12, 2026

Copy link
Copy Markdown
Contributor Author

Locales do use .quote() now instead of hardcoded quotes, the error code is stripped in make_temp_dir too now, the error is wrapped with thiserror, in the test we now use a real read-only dir and check the full error message.

@Devel08
Devel08 marked this pull request as ready for review October 12, 2026 13:40

This branch has not been deployed

No deployments
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.

mktemp: permission denied error strip

2 participants