Skip to content

Fix files being created with 000 permissions on Linux - #2199

Open
realchonk wants to merge 1 commit into
OpenXRay:devfrom
realchonk:fix/posix-sopen-file-mode
Open

realchonk wants to merge 1 commit into
OpenXRay:devfrom
realchonk:fix/posix-sopen-file-mode

Conversation

@realchonk

@realchonk realchonk commented Oct 20, 2026 •

Copy link
Copy Markdown

On POSIX _sopen is #defined to open(), and its third argument is the
file creation mode. So SH_DENYWR (which is 0 on POSIX) became the mode,
and everything the engine writes through CFileWriter (saves, configs,
logs) ended up with permissions 000. The engine then can't open its own
files back and dies, e.g. CoC aborts on startup with
can't open file ...\gamedata\configs\axr_options.ltx right after
writing it.

Repro on Linux: start Call of Chernobyl, check the mode of
gamedata/configs/axr_options.ltx — ----------.

Pass the mode explicitly: 4-arg _sopen on Windows, plain mode as the
third argument on POSIX.


Labeling note: should be tagged "AI" and "External (3rd party)" - cannot set labels as an outside contributor.

On POSIX _sopen is open(), so SH_DENYWR (which is 0) ended up as the
file mode. Saves and configs were unreadable after writing them.

@Xottab-DUTY Xottab-DUTY left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Labeling note: should be tagged "AI" and "External (3rd party)" - cannot set labels as an outside contributor.

Should be not. AI label only refers to the in-game AI code, which is inside xrGame/ai and xrAICore, not to AI agentic programming. I've renamed it to Game AI and changed the description accordingly.
External (3rd party) only applies to external dependencies (most of them lie in Externals folder). Since this PR edits engine's filesystem, it's not external at all.

Comment thread src/xrCore/FS_internal.h
const int handle = _sopen(conv_fn, _O_WRONLY | _O_TRUNC | _O_CREAT | _O_BINARY, SH_DENYWR);
#ifdef XR_PLATFORM_WINDOWS
const int handle = _sopen(conv_fn, _O_WRONLY | _O_TRUNC | _O_CREAT | _O_BINARY, SH_DENYWR, _S_IREAD | _S_IWRITE);
#else

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We need to make sure it is safe to set #else here.
Was it checked with other platforms?
I mean at least checking other platforms headers and/or their man documentation, to see if _sopen is a macro everywhere, or it's an actual function on some other non-Windows platforms also.

@Xottab-DUTY Xottab-DUTY moved this to To do in Roadmap Oct 21, 2026

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

Bug The issue in the run-time. Linux Portability

Projects

Status: To do

Development

Successfully merging this pull request may close these issues.

2 participants