Skip to content

shared/pager: add support for more(1) pager in secure mode#41503

Merged
poettering merged 3 commits into
systemd:mainfrom
cgoesche:more_pager_secure_env_support
May 6, 2026
Merged

shared/pager: add support for more(1) pager in secure mode#41503
poettering merged 3 commits into
systemd:mainfrom
cgoesche:more_pager_secure_env_support

Conversation

@cgoesche
Copy link
Copy Markdown
Contributor

@cgoesche cgoesche commented Apr 4, 2026

The more(1) pager (part of util-linux) now supports secure mode,
which can be enabled with the MORESECURE environment variable.

Adding support for more(1) in secure mode serves as an alternative
for systems that do not have less installed or for users who prefer
it.

Commit d2fce960f9cac740 introduced secure mode in more(1) and the
new feature is available in version 2.42 of util-linux.

@github-actions github-actions Bot added documentation util-lib please-review PR is ready for (re-)review by a maintainer labels Apr 4, 2026
@keszybz
Copy link
Copy Markdown
Member

keszybz commented Apr 4, 2026

The problem is that we need to support systems with older more. So we somehow need to check that more version that we're about to launch is new enough.

@keszybz keszybz added reviewed/needs-rework 🔨 PR has been reviewed and needs another round of reworks and removed please-review PR is ready for (re-)review by a maintainer labels Apr 4, 2026
@cgoesche
Copy link
Copy Markdown
Contributor Author

cgoesche commented Apr 4, 2026

The problem is that we need to support systems with older more. So we somehow need to check that more version that we're about to launch is new enough.

That makes sense to me.

Now, is there a common way this is done in the systemd code base ?

I was thinking of a helper function in shared/pager.c that checks the --version of more with a combination of popen() and fopen() calls but not sure if thats sensible enough in this context. Any ideas ?

@poettering
Copy link
Copy Markdown
Member

urks, i'd really prefer if we wouldn't have to add support for numerous XYZSECURE env vars for all the pagers around. Can we get util-linux to parse $PAGERSECURE in more in addition to MORESECURE? it would make a ton of set to augment $PAGER wit $PAGERSECURE, and if this indeed is a generic concept now, then the env var should be generic too.

i understand this would not really help with figuring out if a page supports the concept at all, but that's a separate issue.

@poettering
Copy link
Copy Markdown
Member

our current baseline for util-linux is 2.41 right now (see README). 2.42 is not that far off, we might consider just bumping the dep to that whic would solve the MORESECURE feature check issue? that said, not sure how much that'd help if we push for PAGERSECURE instead...

@cgoesche
Copy link
Copy Markdown
Contributor Author

cgoesche commented Apr 7, 2026

@poettering when I added support for secure mode in more I also included PAGERSECURE as env, so yes this should be a good way to go.

@poettering
Copy link
Copy Markdown
Member

btw, here's another issue. not sure how much i care, and i just wanted to mention that this exists, but buybox provides it's own crappy implementation of "more" with a very different feature set.

@poettering
Copy link
Copy Markdown
Member

but hmm, i really don't care about busybox and we official do not offer compat with it anyway, so maybe let's ignore the busybox angle.

if you change the PR to use PAGERSECURE and drop MORESECURE and then bump the baseline i think we should be fine.

@cgoesche
Copy link
Copy Markdown
Contributor Author

cgoesche commented Apr 7, 2026

This sounds plausible! Fixing ...

@cgoesche cgoesche force-pushed the more_pager_secure_env_support branch from e863e6c to 5538d04 Compare April 21, 2026 03:42
@github-actions github-actions Bot added please-review PR is ready for (re-)review by a maintainer and removed reviewed/needs-rework 🔨 PR has been reviewed and needs another round of reworks labels Apr 21, 2026
The more(1) pager (part of util-linux) now supports secure mode,
which can be enabled with the PAGERSECURE environment variable.

Adding support for more(1) in secure mode serves as an alternative
for systems that do not have less installed or for users who prefer
it.

Commit d2fce960f9cac740 introduced secure mode in more(1) and the
new feature is available in version 2.42 of util-linux.

Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
This baseline bump is mainly to support the secure mode feature
in more(1) that has been made available since util-linux v2.42.

Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
@cgoesche cgoesche force-pushed the more_pager_secure_env_support branch from 5538d04 to df87d75 Compare April 27, 2026 17:06
@poettering poettering merged commit e0ea854 into systemd:main May 6, 2026
11 of 15 checks passed
@github-actions github-actions Bot removed the please-review PR is ready for (re-)review by a maintainer label May 6, 2026
@bluca
Copy link
Copy Markdown
Member

bluca commented May 6, 2026

Cutting off anything but util-linux 2.42 cuts off CentOS 9, CentOS 10, Fedora 42, Fedora 43 and the just released Debian 13 and Ubuntu 26.04. I don't think we can't really do this just yet...? It's basically everything but archlinux and rawhide...

@bluca
Copy link
Copy Markdown
Member

bluca commented May 6, 2026

Cutting off anything but util-linux 2.42 cuts off CentOS 9, CentOS 10, Fedora 42, Fedora 43 and the just released Debian 13 and Ubuntu 26.04. I don't think we can't really do this just yet...? It's basically everything but archlinux and rawhide...

ref: https://repology.org/project/util-linux/versions

@bluca
Copy link
Copy Markdown
Member

bluca commented May 6, 2026

I had just seen the doc commit, but looking at the diff it doesn't look like it changes the baseline at all? What is the failure mode if I run this with util-linux 2.41? What breaks precisely?

@cgoesche
Copy link
Copy Markdown
Contributor Author

cgoesche commented May 6, 2026

I had just seen the doc commit, but looking at the diff it doesn't look like it changes the baseline at all? What is the failure mode if I run this with util-linux 2.41? What breaks precisely?

The failure mode is that systemctl will open a version of more(1) that does not support secure mode, which could allow an unprivileged user to execute a shell as the EUID :(

Also, @bluca is there a place other than README where the baseline for runtime requirements is updated, I could not find anything obvious.

Either way, it might be a good idea to backport the secure mode to util-linux 2.41 at least. @karelzak what do you think ?

@bluca
Copy link
Copy Markdown
Member

bluca commented May 6, 2026

The failure mode is that systemctl will open a version of more(1) that does not support secure mode, which could allow an unprivileged user to execute a shell as the EUID :(

When you describe it like that, I really don't think this is a footgun we want to introduce. This needs at the very least to be enabled based on the version of util-linux used at build time, given we use libmount/libblkid there is a strong correlation anyway, so that should suffice.

@cgoesche
Copy link
Copy Markdown
Contributor Author

cgoesche commented May 6, 2026

Ok, so if I understand correctly this implies the introduction of something like HAVE_SECURE_MORE_PAGER or a better name.

more_pager = dependency('more',
                      version : '>= 2.42',
                      required : get_option('more_pager'))
have = more_pager.found()
conf.set10('HAVE_SECURE_MORE_PAGER', have)

Now, do we want to make PAGERSECURE env dependent on more(1)'s availability (probably not) ?

Either way, we can then use a macro to add more(1) to the secure pager list or if that is ugly an inline #ifdef HAVE_SECURE_MORE_PAGER.

#if HAVE_SECURE_MORE_PAGER
#define SECURE_MORE_PAGER "more",
#else
#define SECURE_MORE_PAGER
#endif /* HAVE_SECURE_MORE_PAGER */
...

if (use_secure_mode && !STR_IN_SET(pagers[i], "less", SECURE_MORE_PAGER "(built-in)"))
...

Makes sense ?

@bluca
Copy link
Copy Markdown
Member

bluca commented May 6, 2026

Something like that, can even use the existing libmount or libfdisk checks without checking for more, given it's the same sources

@cgoesche
Copy link
Copy Markdown
Contributor Author

cgoesche commented May 6, 2026

I was thinking of separating the check, because I was not too sure what side effects bumping the baseline for libmount to v2.42 could have.

Also, wouldn't it make sense to implicitly check for secure more(1), simply for HAVE_SECURE_MORE_PAGER and if its not the right version we build regardless just not with more in the list of secure pagers ? That means no need for required: get_option('more_pager').

@bluca
Copy link
Copy Markdown
Member

bluca commented May 6, 2026

sure

@cgoesche
Copy link
Copy Markdown
Contributor Author

cgoesche commented May 6, 2026

Cool! Preparing a new PR then :)

@karelzak
Copy link
Copy Markdown
Contributor

From a long-term point of view, maybe we can add util-linux.pc so we can ask for supported features with pkg-config --variable=<foo>, avoiding a strict dependency on a specific version.

@bluca
Copy link
Copy Markdown
Member

bluca commented May 11, 2026

From a long-term point of view, maybe we can add util-linux.pc so we can ask for supported features with pkg-config --variable=<foo>, avoiding a strict dependency on a specific version.

That would be nice, yes please!

@keszybz
Copy link
Copy Markdown
Member

keszybz commented May 12, 2026

I don't think this should have been merged. That util-linux release is only present in a few places right now, and this means that unless people carefully check, we're opening them up to a vulnerability. This is just the wrong way to approach this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

5 participants