]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
shared/pager: add support for more(1) pager in secure mode
authorChristian Goeschel Ndjomouo <cgoesc2@wgu.edu>
Sat, 4 Apr 2026 04:16:41 +0000 (00:16 -0400)
committerChristian Goeschel Ndjomouo <cgoesc2@wgu.edu>
Mon, 27 Apr 2026 17:04:43 +0000 (13:04 -0400)
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>
src/shared/pager.c

index 3c89aacab48d026dbff6f3f0edb9c883cfd23232..61718aeaa6807d2b5799d5acb948f43ee79de683 100644 (file)
@@ -206,6 +206,13 @@ void pager_open(PagerFlags flags) {
                         _exit(EXIT_FAILURE);
                 }
 
+                /* Some pager implementations support the PAGERSECURE environment variable, e.g. more(1) */
+                r = set_unset_env("PAGERSECURE", use_secure_mode ? "1" : NULL, true);
+                if (r < 0) {
+                        log_error_errno(r, "Failed to adjust environment variable PAGERSECURE: %m");
+                        _exit(EXIT_FAILURE);
+                }
+
                 if (trust_pager && pager_args) { /* The pager config might be set globally, and we cannot
                                                   * know if the user adjusted it to be appropriate for the
                                                   * secure mode. Thus, start the pager specified through
@@ -228,8 +235,8 @@ void pager_open(PagerFlags flags) {
                 static const char* pagers[] = { "pager", "less", "more", "(built-in)" };
 
                 for (unsigned i = 0; i < ELEMENTSOF(pagers); i++) {
-                        /* Only less (and our trivial fallback) implement secure mode right now. */
-                        if (use_secure_mode && !STR_IN_SET(pagers[i], "less", "(built-in)"))
+                        /* Only less, more (and our trivial fallback) implement secure mode right now. */
+                        if (use_secure_mode && !STR_IN_SET(pagers[i], "less", "more", "(built-in)"))
                                 continue;
 
                         r = loop_write(exe_name_pipe[1], pagers[i], strlen(pagers[i]) + 1);