Repository navigation
Conversation
|
The two failing jobs are network errors: |
|
Nice, this complements #2689 well. Some data points and one suggestion. The domain mapping in
Suggestion: the lint can't tell when the transition has been added. An image that ships a policy module like the one in #2366/#2689 will still warn, and so will every wrapped service once fedora-selinux/selinux-policy#3327 reaches the base policies. Checking the compiled policy is probably too heavy for a lint. Could the help text mention the policy-module workaround next to Two smaller gaps, fine to leave for later:
|
The SELinux policy moves bootc into `install_t` only when systemd executes it directly. A service that starts bootc from a shell command or a `bin_t` script runs it in `initrc_t` or `unconfined_service_t`, and nothing tells the image's author. The `install-t-wrapper` lint reads the `Exec*=` command lines of each service and of its `*.service.d/*.conf` drop-ins, and asks the image's policy for the label of the program that systemd executes. It warns when that label is `bin_t` or `shell_exec_t` and the command line, or a script it names, mentions bootc. A script that a shell runs is read whether or not it has a `#!` line. A wrapper with a type of its own passes, because its policy module owns its transitions. An image without an SELinux policy passes. An image can instead ship a policy module that lets `unconfined_service_t` and `initrc_t` transition to `install_t`. The lint reads only file labels, so its help text tells such an image to pass `--skip install-t-wrapper`. A comment marks the lint for review once fedora-selinux/selinux-policy#3327 adds those transitions to the base policies. The lint covers bootc alone. ostree and rpm-ostree share the `install_exec_t` label, but CentOS Stream 9 ships ostree-readonly-sysroot-migration.service, whose `bin_t` script calls `ostree config`, and a warning there fails every build that runs the lint with `--fatal-warnings`. The lint misses a wrapper that reaches bootc through a second script, and one that builds the command at run time. It reads each unit file and drop-in on its own, so it still warns on a unit whose drop-in replaces the wrapper with a direct call. Tested by linting registry.redhat.io/rhel10/rhel-bootc. The image as shipped draws no warning. Three added wrapper services (`sh -c`, a script, and `bash` with a script argument) each draw one, and a direct `ExecStart=/usr/bin/bootc` draws none. Also tested by linting quay.io/centos-bootc/centos-bootc:stream10, which as shipped draws no warning. A drop-in that runs `sh -c 'bootc upgrade --apply'` and `bash` with a script that has no `#!` line each draw one, and `python3` with that script and a drop-in that runs `/usr/bin/bootc status` draw none. Generated-by: AI Signed-off-by: Varun Iyer <viyer9@uic.edu>
0fa1e7d to
e606bc9
Compare
|
Thanks, all three were real. I pushed:
Tested on centos-bootc stream10: a drop-in running |
cgwalters
left a comment
There was a problem hiding this comment.
Thanks for this contribution, but I think it's taking the scope of the lint tool beyond what I'm comfortable with, and it's too heuristic even then.
I think we just need to recommend people apply the selinux patch if they're affected now.
It's really unfortunate that it hasn't been fixed in base SELinux policy, but if that continues to be the case in say a month, then I would be in favor of encouraging downstreams to apply the patch or ship a custom selinux policy here.
(There is a large cost to custom selinux policy though)
| } | ||
|
|
||
| /// Whether shell text names bootc outside a comment line. | ||
| fn names_bootc(text: &str) -> bool { |
There was a problem hiding this comment.
This seems too likely to result in false positives.
In general, us parsing systemd units seems a bit beyond what I think this tooling should be doing.
|
I cannot think of a way to really lint this in a way that's truly accurate, scraping |
|
The one failure is |
The SELinux policy moves bootc into
install_tonly when systemd executes it directly. A service that starts bootc from a shell or a script leaves it in the wrapper's domain, where it may lack the permission to write labels unknown to the running policy. Nothing reports this at build time, and the failure shows up later, during an update. See #2186 and #2366.This adds an
install-t-wrapperwarning tobootc container lint.What it checks
The lint reads the
Exec*=lines of each service in/usr/lib/systemd/systemand/etc/systemd/system. It warns when both of these hold:bin_torshell_exec_t.bootc.A service that runs
/usr/bin/bootcdirectly fromExecStart=draws no warning.Scope
bootcalone. A version that also matchedostreefailed the CentOS Stream 9 builds under--fatal-warnings, becauseostree-readonly-sysroot-migration.servicethere runs abin_tscript that callsostree config.--skip install-t-wrapperturns it off.It complements #2366 and #2689. Those make a wrapped bootc work, and this tells an image author that their service wraps it.
Testing
registry.redhat.io/rhel10/rhel-bootc, the stock image draws no warning. With test services added, an inlinesh -c "bootc upgrade", a script named inExecStartPre=, and a barebash /path/script.sheach warn, and a directExecStart=/usr/bin/bootc upgradedoes not.Generated-by: AI
I used AI to generate the code. I reviewed its functionality and cleanliness.