Repository navigation
omd: keep the system Apache configuration root-owned, and add a sudo rule to update it - #251
Open
superbot-helper wants to merge 2 commits into
Open
superbot-helper wants to merge 2 commits into
superbot-helper wants to merge 2 commits into
Conversation
added 2 commits
November 24, 2026 13:59
The global Apache runs as root and includes configuration files that belong to each site user. A LoadModule directive in one of those files loads a shared object the site user wrote into the root parent process, so everything the global Apache reads is staged below /omd/apache/<site>.d, written and owned by root. Redirects, rewrite rules and other directives are copied as they are, an Include of another file in the site's own tree is inlined and checked the same way, and a file that names a module the site user owns is refused while the last accepted configuration stays in place. omd update-apache-config <site> rewrites the staged copy after a site user changes a setting.
The system Apache reads a root-owned copy of each site's configuration, so a change below a site's etc/apache directory has to be copied there by root before it becomes live. That is the root step the previous commit introduced for existing sites. Ship /etc/sudoers.d/omd from the package: members of the omd group, which is every site user, may run exactly omd update-apache-config <site> as root without a password. The argument pattern is the site-name syntax omd creates sites with, so the rule admits neither another subcommand nor a second argument. The command itself validates the name again, and when it runs through sudo it refuses any site but the caller's own. WEB_REDIRECT and WEB_ALIAS refresh the copy themselves when a site user sets them, and the site's own apache init script refreshes it on start and reload, so a redirect or maintenance page change is live at once instead of waiting for the next log rotation. Without sudo, or without the packaged rule, the behaviour is the one from before: the change needs a root step, and the command names it. The copy now refuses a site file that a symlink points to outside the site tree, and the maintenance page does the same, because the rule lets a site user start the copy while it runs as root.
sni
reviewed
Nov 24, 2026
sni
left a comment
Contributor
There was a problem hiding this comment.
looks good in general. I've got two questions.
| ! test -x /usr/sbin/a2disconf || a2disconf zzz_omd || /bin/true | ||
| rm -f "$APACHE_OMD_CONF" | ||
| rm -f "$SYSCTL_OMD_CONF" | ||
| rm -f /etc/sudoers.d/omd |
Contributor
There was a problem hiding this comment.
i think we should choose a different filename, maybe omd.pkg or omd.auto. Chances are high that there is a file name omd already and it would be overwritten.
|
|
||
| case "$1" in | ||
| reload|force-reload) | ||
| refresh_system_apache |
Contributor
There was a problem hiding this comment.
i see no reason to unconditionally refresh the system apache? Why not checking for stale files here as well?
Contributor
|
And thanks for this pull request. I think this is a good idea to make root apache things more deterministic. |
Author
|
Thanks for the review.
I'll also rebase onto the current |
Contributor
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this changes
The system-wide Apache runs as root and includes configuration files from each
site's home directory. Those files belong to the site user, so a site user can
write directives into them that make the root Apache load code the next time it
reads its configuration.
This branch keeps everything the system Apache reads in a directory written by
root,
/omd/apache/<site>.d. The site's ownmode.conf,proxy-port.confandetc/apache/system.d/*.confare copied there when the site is created orupdated, with the same content, except that a
LoadModule/LoadFileof a filethe site user owns, or an
Includethat leaves the site tree, is refused andthe last accepted copy stays in place. The hook files in
/omd/apachethen onlyinclude the root-owned copies.
omd update-apache-config <site>refreshes thecopy and reloads the system Apache.
Because that copy is written by root, a change a site user makes under
etc/apachewould need a root step again, where before it was picked up at thenext log rotation. The package now installs
/etc/sudoers.d/omd, which lets amember of the
omdgroup (every site user) run exactlyomd update-apache-config <site>for its own site as root:The regular expression is matched against the whole argument string, so neither
another subcommand nor a second argument can pass it. The command validates the
site name as well and refuses a site other than the caller's own when it is
started through sudo.
omd config set WEB_REDIRECTandWEB_ALIASrefresh thecopy themselves when a site user sets them, and the site's own apache init
script does the same on start and reload. Without sudo, or without the rule,
nothing changes: the change needs a root step, and the command says which one.
Why
A site is meant to need no root permissions after
omd create, and a change inthe system Apache currently becomes active only when the next log rotation
restarts it. The sudo rule for the new command keeps both properties.
How it was tested
On one Debian 12 machine with systemd as pid 1 and omd 5.80-labs-edition from
the stable repository, with both commits applied to the installed package and
the sudo rule installed the way the package installs it:
LoadModuleinetc/apache/system.dwasloaded by the root Apache on a reload (marker written three times, uid 0).
With the patch the same directive is refused in three spellings
(
LoadModule,loadmodule, and a backslash-continuedLoadMod/ule), thesite user cannot make it reach the root Apache through the sudo command, and
no marker is written after a reload, a restart, the distribution's log
rotation or the creation of another site.
first
omd update-apache-config; after that a newLoadModuleis refusedwhile the previously accepted configuration stays in place and the site keeps
serving.
WEB_REDIRECTandWEB_ALIASchanges are live immediatelyafter
omd config set, and a hand-written rewrite rule, a site-ownedInclude, a redirect appended toapache-own.confand the maintenance pageare served through the root-owned copy.
another omd subcommand, a second argument and a different program. A fake
omdin the site user's ownbindirectory is refused as well.omd config setand the site's reload pathprint one line naming the root command to run, and the change stays pending
until root runs it.
t/10-omd_testsite.tpasses before and after the patch(638 tests).
t/11-omd_update.tis an author test and does not run withoutTEST_AUTHOR.Operator-visible change
etc/apacheis live at once when it is madethrough
omd config set WEB_REDIRECT/WEB_ALIAS, or on the site's nextomd start/omd reload apache.omd update-apache-config <site>as root (or by the site user through sudo).sudo omd update-apache-config <site>now works for a site user for its ownsite.
What this does not cover
installed or run here.
LoadModule/LoadFilethat can run code from a sitefile:
RewriteMap ... prg:, a CGI handler, anErrorDocumentpointing at asite CGI.
omdfork: its per-site hook is created in its closed binary.rule does not match, and the change needs root as before.
AI tools were used to write and test this change.