Repository navigation
Install tgz: give the target of a dangling symlink the packaged mode - #112766
Conversation
Follow-up to #111960. When the destination is a symlink whose target does not exist yet, `doinst.sh` wrote through it with a shell redirection, which creates the target with the `umask` of the installation and with no relation to the mode, the ownership or the label of the packaged file - a symlinked binary path would install as a non-executable file owned by the builder. There is no destination inode to preserve in that case, so the packaged file is renamed to where the link points instead: the link keeps its indirection, and the installed file gets the metadata it has in the package, the same way a fresh installation does. A symlink to an existing file is still written through, so its inode, ownership and attributes survive an upgrade. `Install tgz over a dangling symlink` now installs under `umask 077` and asserts the mode and the ownership of the installed target. Verified with a fake-root simulation of the generated `doinst.sh`: before the change the dangling-symlink targets came out `0600` instead of `0644`/`0755`, after it they carry the packaged mode, while the write-through, hard-link and fresh-install paths are unchanged. Related: #111960
|
Workflow [PR], commit [7829d32] Summary: ✅
AI ReviewSummaryThis PR changes the Final VerdictStatus: ✅ Approve |
The dangling-symlink branch of `doinst.sh` resolved a single `readlink` hop, so a destination symlink pointing at another symlink had that second link replaced by a regular file: the installation still destroyed a level of indirection that writing through the destination with `cat` used to keep, because a redirection follows the chain to its end. `resolve_symlink_chain` now follows every hop, resolving a relative hop against the directory of the link it was read from, and only the final referent is created. A chain that never ends - a symlink loop - is reported and fails the installation instead of looping forever, the same way the previous `cat` failed with `ELOOP`. Added `Install tgz over a chain of dangling symlinks` to `ci/jobs/install_check.py`, with relative hops so that a hop resolved against the wrong directory is caught as well. Verified with a fake-root simulation (`tmp/sim3/run.sh`): both links kept, `/real/config.xml` created with the packaged mode, an absolute single-hop link still handled, no leftovers in the unpack tree; `tmp/sim3/run_loop.sh` shows the loop case failing with `Too many levels of symbolic links`.
|
🕵 Merged The AI Review verdict is now ✅ Approve and all jobs are green except Root cause of that red, from the server log: BuzzHouse fuzzed Fixed separately in #113002, which excludes that failpoint (and |
BuzzHouse enables a random failpoint from \`system.fail_points\`. Two of them - \`attach_to_group_failure\` and \`thread_group_switcher_post_attach_failure\` - deliberately break the invariant that a query thread is attached to a thread group. \`ThreadGroupSwitcher\` is \`noexcept\` and only logs the injected failure, so the thread carries on with no group and the next \`executeQuery\` that runs on it fails with the \`No thread group attached to the thread\` logical error, e.g. https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=112766&sha=25a457c530e81c122d764503aa913d2d04eedbb1&name_0=PR&name_1=BuzzHouse%20%28amd_msan%29 (ClickHouse#112766). The same failure hit ClickHouse#110514 in \`BuzzHouse (amd_debug)\` on the same day. Both failpoints exist for the in-process unit test \`gtest_thread_group_switcher\`, which enables them around a single controlled switch; they are not meaningful to inject from SQL. Exclude them from the list the fuzzer picks from, like the other failpoints that legitimately take the server down.
…sing directory Creating the parent directory of the symlink target with `mkdir -p` gave it the `umask` of the installation and no defined ownership, so under a restrictive `umask` the installed file could end up unreachable while `doinst.sh` reported success. Writing through the link failed loudly in that case before, so `doinst.sh` now reports the missing directory and exits instead of materializing a half-usable tree. Added `Install tgz over a symlink into a missing directory` to `ci/jobs/install_check.py`.
|
🕵 Addressed the AI Review Major ( The finding was real: Took the fail-fast option: when the directory a dangling destination points into does not exist, and exits, which is exactly what writing through the link did before this PR. Nothing is created on that path. Added the regression test |
|
🕵 The only red on the previous run, Merged |
Build profile diff (arm_release)No arm_release build profile data for commit 7829d32 - the build was skipped, reused from cache, or predates profile upload. |
|
🕵 The only red, |
…ntf` `resolve_symlink_chain` returned the resolved path with `echo`, but the installer runs under `/bin/sh`, which is `dash` on Debian-based systems, and `dash`'s `echo` expands backslash escapes: a dangling destination whose target contains `\t` or `\n` was resolved to a mangled path, so the installation either failed or created the file at the wrong place. Every `echo` inside the generated script is now `printf '%s\n'` - the `ls -ld` listing fed to `awk` in `keep_destination_inode` carries the file name too, and the diagnostics should print paths byte-for-byte as well. Added `Install tgz over a dangling symlink with a backslash in the target` to `ci/jobs/install_check.py`. #112766
|
🕵 The only red on the last run, Merged |
…ctory test The `Install tgz over a symlink into a missing directory` test failed in the deb image with `grep: /tmp/install.log: No such file or directory`, although the shell redirection had just created that file. The install test images boot systemd as PID 1 and deliberately keep `systemd-tmpfiles-setup` in `sysinit.target.wants`; Ubuntu ships `D /tmp` in `tmpfiles.d/tmp.conf`, so the container "boot" wipes `/tmp` concurrently with the test script that `docker exec` starts right after `docker run --detach`. Write the log to `/root` instead, which the boot-time cleanup never touches. CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=112766&sha=a4bf75a4c431a7eaefeae6afa53ea25bcf997aeb&name_0=PR&name_1=Install%20packages%20%28amd_release%29 PR: #112766
Address review: the `hops > 40` hard-fail branch of `resolve_symlink_chain` in `doinst.sh` was only validated manually. The new `Install tgz over a symlink loop` test points `/etc/clickhouse-client/config.xml` and `/shared/config.xml` at each other, asserts the installation fails with `Too many levels of symbolic links`, and checks that both links survive unchanged. PR: #112766
|
🕵 Both items on
|
Follow-up to #111960, which addresses the remaining unresolved review finding there.
In the
tgzinstaller (doinst.sh), a destination that is a symlink is written through so that an installation keeping its configs or binaries elsewhere keeps the indirection after an upgrade. When the symlink is dangling, however, there is no destination inode to preserve: the shell redirection creates the target with theumaskof the installation, unrelated to the mode, the ownership or the label of the packaged file. A symlinked binary path would install as a non-executable file owned by whoever built the tarball.Such a destination is now handled by renaming the packaged file to where the link points: the link keeps its indirection, and the installed file gets exactly the metadata a fresh installation gives it (
chown -h root:rootandrestorecon), with no extra disk space. The whole chain is followed - a link pointing at another link keeps both, the way a redirection did, and only the final referent is created - and a symlink loop is reported and fails the installation instead of looping forever. A symlink to an existing file is still written through, so its inode, ownership and extended attributes survive an upgrade.The
Install tgz over a dangling symlinktest now runs the installation underumask 077and asserts the mode and the ownership of the installed target, andInstall tgz over a chain of dangling symlinkscovers a destination link pointing at another dangling link through relative hops. Verified additionally with a fake-root simulation of the generateddoinst.sh: before the change the dangling-symlink targets came out0600instead of0644/0755, after it they carry the packaged mode, while the write-through, hard-link and fresh-install paths are unchanged.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Installing a
tgzpackage over a dangling symlink now gives the created target the mode and the ownership from the package instead of aumask-derived mode, and keeps every level of the symlink chain.Documentation entry for user-facing changes
Related: #111960
Version info
26.8.1.1051(included in26.8and later)