Skip to content

fix(python): create user folders with the profile ACL, not a 0o700 DACL (#973) - #985

Closed
asdf80730 wants to merge 3 commits into
EasyIME:masterfrom
asdf80730:fix/973-user-dir-acl
Closed

asdf80730 wants to merge 3 commits into
EasyIME:masterfrom
asdf80730:fix/973-user-dir-acl

Conversation

@asdf80730

Copy link
Copy Markdown
Contributor

Fixes #973

os.makedirs(..., mode=0o700) sets no POSIX bits on Windows: CPython turns the mode into a DACL for the creating token. A launcher that was ever started elevated therefore creates %APPDATA%\PIME\<ime> owned by BUILTIN\Administrators with no ACE for the user, the next non-elevated backend cannot read it, chewing_new2() returns NULL after ~6 s of retries, and every key is swallowed while python_backend.log stays empty.

  • Create the per-user folders through ensure_user_dir(): no mode on Windows, so the directory inherits the profile's user-only ACL; 0o700 on POSIX so other local users still cannot read IME data.
  • Raise from ChewingContext.__init__ when chewing_new2()/chewing_new() return NULL, naming the elevated-install possibility. server.py already logs the traceback and replies {success:false}. chewing_delete is skipped for a context that was never created.
  • Tests: tests/test_pime_dirs.py pins the platform split; tests/test_chewing_context.py fakes libchewing to cover the NULL and delete paths.

Validation:

The two build-time converters under cinbase/tools/ keep 0o700: they write inside the checkout, not the profile, and the launcher never runs them.

Generated with assistance from omp (DeepSeek V4.1 Flash).

…E#973)

On Windows, os.makedirs(..., mode=0o700) does not set POSIX bits: CPython turns
the mode into a DACL for the creating token. A launcher started elevated creates
the directory owned by BUILTIN\Administrators, so the next non-elevated backend
cannot enter it and Chewing stops composing without a log line.

The profile directory already carries a user-only inherited ACL, so create the
PIME directories without a mode on Windows and keep 0o700 on POSIX. The two
build-time converters under cinbase/tools keep their mode: they write inside the
checkout, not the profile, and are not started by the launcher.

Generated with assistance from omp (deepseek-v4.1-flash)
chewing_new2() returning NULL left a context that accepted every call, so
filterKeyDown() took the Chinese branch and onKeyDown() fed a NULL engine: keys
were swallowed and nothing reached the backend log. Raise from
ChewingContext.__init__ instead; server.py already turns that into a logged
traceback and a {success:false} reply, and the message names the likely elevated
install. Skip chewing_delete for a context that was never created.

Generated with assistance from omp (deepseek-v4.1-flash)
…IME#973)

The directory test pins the platform split: no mode on Windows (inherit the
profile ACL), 0o700 on POSIX. The chewing test fakes libchewing so a NULL handle
raises, is never passed to chewing_delete, and a valid handle is deleted once.

Generated with assistance from omp (deepseek-v4.1-flash)
@PCMan

PCMan commented Oct 24, 2026

Copy link
Copy Markdown
Member

Issue #973 has been addressed in #988 by stripping mode=0o700 from os.makedirs across backend files and implementing in-memory database fallback in chewing_ime.py. Closing as resolved by #988.

(Generated with assistance from Antigravity + Gemini 3.8 Flash)

@PCMan PCMan closed this Oct 24, 2026
@asdf80730
asdf80730 deleted the fix/973-user-dir-acl branch October 25, 2026 17:39
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.

Chewing silently stops working (keys swallowed) if the user config folder was created by an elevated PIMELauncher

2 participants