Let the shell user install packages with pacman
The root user now owns the whole MSYS2 installation and can run pacman. The login path the journey depends on - the sshd, the login shell zsh and cat - is kept as a protected copy in C:\msys2\opt\kik that only SYSTEM and the administrators may write, and the sshd runs as SYSTEM from there (the new KiK sshd task; the msys2-sshd service is disabled). Replacing the user's own /usr/bin/sshd therefore cannot touch the running server. opt/kik is two levels below C:\msys2, so its runtime resolves the same installation root and the login shell and the user's tools share one cygwin runtime. A separate second installation does not work: two runtimes in one process tree corrupt each other's file descriptors and pacman cannot lock its database. /etc/passwd and /etc/ssh are read-only to the user, /opt/kik is first on PATH so cat README survives even if the user deletes their own /usr/bin/cat, and the restore task rebuilds the protected copy and re-applies the permissions every 30 minutes. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
ea0d6a85fd
commit
b228fec07e
1 changed files with 244 additions and 52 deletions
|
|
@ -32,14 +32,32 @@ Anything thats not specified above (like the content of README for example) is N
|
|||
|
||||
As long as the user story above does not break, we do not guarantee the functionality of anything else on the server. However the cleanup task should still try to best-effort restore everything to a working condition.
|
||||
|
||||
## The cleanup task
|
||||
## Packages
|
||||
|
||||
The scheduled task `KiK restore shell files` runs every 30 minutes and at every startup, as SYSTEM. The user cannot stop it. Cleanup has two jobs:
|
||||
The root user owns the whole MSYS2 installation and can install packages with pacman. That means they can also
|
||||
replace or delete the very programs the login needs. So the sshd, the login shell `zsh` and `cat` are kept as a
|
||||
second, protected copy in `C:\msys2\opt\kik`, which only SYSTEM and the administrators may write. The sshd runs as
|
||||
SYSTEM from that copy and the login shell is that copy's `zsh`, with `/opt/kik` first on the path, so the journey
|
||||
keeps working no matter what the user does to their own `/usr/bin`. Replacing `/usr/bin/sshd` cannot touch the
|
||||
running server, so the key on the website still never grants administrator access.
|
||||
|
||||
1. Act as a secondary safeguard to restore the essential files for the user journey above.
|
||||
2. Revert any other mockery the user did that might affect the system.
|
||||
The copy has to be the *same* MSYS2 installation, not a second one: `C:\msys2\opt\kik` is two levels below
|
||||
`C:\msys2`, so its runtime resolves the same root and the login shell and the user's own tools share one cygwin
|
||||
runtime. A separate installation does not work - two runtimes in one process tree corrupt each other's file
|
||||
descriptors and pacman cannot even lock its database.
|
||||
|
||||
The second job should also be able to restore a new server to the expected state.
|
||||
`/etc/passwd` (the login shell and home directory) and `/etc/ssh` (the host keys and config) are read-only to the
|
||||
user as well; everything else in the installation is theirs.
|
||||
|
||||
## The cleanup tasks
|
||||
|
||||
Two scheduled tasks run as SYSTEM, both at startup, and the user cannot stop either:
|
||||
|
||||
- `KiK sshd` runs the sshd from `C:\msys2\opt\kik`. It replaces the installation's own `msys2-sshd` service, which
|
||||
is disabled.
|
||||
- `KiK restore shell files` runs every 30 minutes and rebuilds the protected copy from its trusted originals,
|
||||
re-applies the permissions, and puts the home directory, the shell configuration, the website's key and the four
|
||||
texts back. Its second job is to best-effort revert other mockery and bring a fresh server to the expected state.
|
||||
|
||||
The files that have to stay belong to the administrators, so the user cannot delete them, and they cannot change the
|
||||
shell configuration or the key the website logs in with either. The shell reads its configuration from `~/.zsh`, so
|
||||
|
|
|
|||
Loading…
Reference in a new issue